Cheetah
ChSitesFormAdd.php
Go to the documentation of this file.
1 <?php
2 
8 require_once(CH_DIRECTORY_PATH_CLASSES . 'ChWsbProfileFields.php');
9 
11 {
12  var $_oModule;
13  var $_aParam;
15 
16  function __construct($oModule, $aParam = array())
17  {
18  $this->_oModule = $oModule;
19  $this->_aParam = $aParam;
20 
21  $this->_aCustomForm = count($this->_aParam) > 0 ? $this->getFullForm() : $this->getUrlForm();
22 
23  $aFormInputsSubmit = array(
24  'Submit' => array(
25  'type' => 'submit',
26  'name' => 'submit_form',
27  'value' => _t('_Submit'),
28  'colspan' => false,
29  ),
30  );
31 
32  $this->_aCustomForm['inputs'] = array_merge($this->_aCustomForm['inputs'], $aFormInputsSubmit);
33 
34  parent::__construct($this->_aCustomForm);
35  }
36 
37  function getUrlForm()
38  {
39  return array(
40 
41  'form_attrs' => array(
42  'name' => 'form_site',
43  'action' => CH_WSB_URL_ROOT . $this->_oModule->_oConfig->getBaseUri() . 'browse/my/add',
44  'method' => 'post',
45  'enctype' => 'multipart/form-data',
46  ),
47 
48  'params' => array(
49  'db' => array(
50  'table' => 'ch_sites_main',
51  'key' => 'id',
52  'submit_name' => 'submit_form',
53  ),
54  ),
55 
56  'inputs' => array(
57  'url' => array(
58  'type' => 'text',
59  'name' => 'url',
60  'caption' => _t('_ch_sites_form_url'),
61  'required' => true,
62  'checker' => array(
63  'func' => 'length',
64  'params' => array(1, 255),
65  'error' => _t('_ch_sites_form_field_err'),
66  ),
67  'db' => array(
68  'pass' => 'Xss'
69  ),
70  'display' => true,
71  )
72  )
73  );
74  }
75 
76  function getFullForm()
77  {
78  ch_import('ChWsbCategories');
79  $oCategories = new ChWsbCategories();
80  $oCategories->getTagObjectConfig();
81 
82  $aForm = array(
83  'form_attrs' => array(
84  'name' => 'form_site',
85  'action' => CH_WSB_URL_ROOT . $this->_oModule->_oConfig->getBaseUri() . 'browse/my/add',
86  'method' => 'post',
87  'enctype' => 'multipart/form-data',
88  ),
89 
90  'params' => array(
91  'db' => array(
92  'table' => 'ch_sites_main',
93  'key' => 'id',
94  'uri' => 'entryUri',
95  'uri_title' => 'title',
96  'submit_name' => 'submit_form',
97  ),
98  ),
99 
100  'inputs' => array(
101  'url' => array(
102  'type' => 'text',
103  'name' => 'url',
104  'value' => isset($this->_aParam['url']) ? $this->_aParam['url'] : '',
105  'caption' => _t('_ch_sites_form_url'),
106  'required' => true,
107  'checker' => array(
108  'func' => 'length',
109  'params' => array(1, 255),
110  'error' => _t('_ch_sites_form_field_err'),
111  ),
112  'db' => array(
113  'pass' => 'Xss'
114  ),
115  'display' => true,
116  ),
117  'title' => array(
118  'type' => 'text',
119  'name' => 'title',
120  'value' => isset($this->_aParam['title']) ? $this->_aParam['title'] : '',
121  'caption' => _t('_ch_sites_form_title'),
122  'required' => true,
123  'checker' => array(
124  'func' => 'length',
125  'params' => array(1, 100),
126  'error' => _t('_ch_sites_form_field_err'),
127  ),
128  'db' => array(
129  'pass' => 'Xss'
130  ),
131  'display' => true,
132  ),
133  'description' => array(
134  'type' => 'textarea',
135  'name' => 'description',
136  'value' => isset($this->_aParam['description']) ? $this->_aParam['description'] : '',
137  'caption' => _t('_ch_sites_form_description'),
138  'required' => true,
139  'html' => 1,
140  'checker' => array(
141  'func' => 'length',
142  'params' => array(1, 64000),
143  'error' => _t('_ch_sites_form_field_err'),
144  ),
145  'db' => array(
146  'pass' => 'XssHtml'
147  )
148  ),
149  'thumbnail' => array(
150  'type' => 'custom',
151  'name' => 'thumbnail',
152  'content' => '',
153  'caption' => 'Thumbnail'
154  ),
155  'photo' => array(
156  'type' => 'file',
157  'name' => 'photo',
158  'caption' => _t('_ch_sites_form_photo'),
159  'info' => _t('_ch_sites_form_photo_inf')
160  ),
161  'tags' => array(
162  'type' => 'text',
163  'name' => 'tags',
164  'caption' => _t('_Tags'),
165  'required' => true,
166  'checker' => array(
167  'func' => 'avail',
168  'error' => _t('_ch_sites_form_field_err'),
169  ),
170  'db' => array(
171  'pass' => 'Tags',
172  ),
173  'info' => _t('_sys_tags_note')
174  ),
175  'categories' => $oCategories->getGroupChooser('ch_sites', (int)$this->_oModule->iOwnerId, true),
176  'allowView' => $this->_oModule->oPrivacy->getGroupChooser($this->_oModule->iOwnerId,
177  'ch_sites', 'view', array(), _t('_ch_sites_caption_allow_view')),
178  'allowComments' => $this->_oModule->oPrivacy->getGroupChooser($this->_oModule->iOwnerId,
179  'ch_sites', 'comments', array(), _t('_ch_sites_caption_allow_comments')),
180  'allowRate' => $this->_oModule->oPrivacy->getGroupChooser($this->_oModule->iOwnerId,
181  'ch_sites', 'rate', array(), _t('_ch_sites_caption_allow_rate')),
182  ),
183  );
184 
185  if (isset($this->_aParam['thumbnail']) && getParam('ch_sites_account_type') != 'No Automated Screenshots') {
186  $aForm['inputs']['thumbnail']['content'] = $this->_aParam['thumbnail'];
187  $aForm['inputs']['photo']['caption'] = _t('_ch_sites_form_other_thumbnail');
188 
189  if (isset($this->_aParam['thumbnail_html'])) {
190  $aForm['inputs'] = array_merge($aForm['inputs'], array(
191  'thumbnail_html' => array(
192  'type' => 'hidden',
193  'name' => 'thumbnail_html',
194  'value' => $this->_aParam['thumbnail_html'],
195  )
196  ));
197  }
198  } else {
199  unset($aForm['inputs']['thumbnail']);
200  }
201 
202  return $aForm;
203  }
204 
205  function uploadPhoto($sPath, $isRemote = false)
206  {
207  $aFileInfo = array(
208  'medTitle' => stripslashes($this->getCleanValue('title')),
209  'medDesc' => stripslashes($this->getCleanValue('title')),
210  'medTags' => 'sites',
211  'Categories' => array('Sites'),
212  );
213  $sTmpFile = CH_DIRECTORY_PATH_ROOT . 'tmp/' . time() . (isset($_COOKIE['memberID']) ? (int)$_COOKIE['memberID'] : '');
214  $bResult = $isRemote ? copy($sPath, $sTmpFile) : move_uploaded_file($_FILES['photo']['tmp_name'], $sTmpFile);
215  if ($bResult) {
216  $iRet = ChWsbService::call('photos', 'perform_photo_upload', array($sTmpFile, $aFileInfo, false),
217  'Uploader');
218  if (!$iRet) {
219  @unlink($sTmpFile);
220  } else {
221  return $iRet;
222  }
223  }
224 
225  return 0;
226  }
227 }
ChSitesFormAdd\$_aParam
$_aParam
Definition: ChSitesFormAdd.php:13
$oModule
if(! @isAdmin()) $oModule
Definition: admin.php:25
ChTemplFormView
Definition: ChTemplFormView.php:11
ChWsbForm\getCleanValue
getCleanValue($sName)
Definition: ChWsbForm.php:232
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
php
ChWsbCategories
Definition: ChWsbCategories.php:13
copy
and that you are informed that you can do these things To protect your we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it For if you distribute copies of the whether gratis or for a you must give the recipients all the rights that we gave you You must make sure that receive or can get the source code If you link other code with the you must provide complete object files to the so that they can relink them with the library after making changes to the library and recompiling it And you must show them these terms so they know their rights We protect your rights with a two step which gives you legal permission to copy
Definition: license.txt:50
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
ChSitesFormAdd
Definition: ChSitesFormAdd.php:11
ChSitesFormAdd\$_aCustomForm
$_aCustomForm
Definition: ChSitesFormAdd.php:14
$bResult
$bResult
Definition: get_file.php:11
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
time
that in the case of a Adaptation or at a minimum such credit will if a credit for all contributing authors of the Adaptation or Collection then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors For the avoidance of You may only use the credit required by this Section for the purpose of attribution in the manner set out above by exercising Your rights under this You may not implicitly or explicitly assert or imply any connection sponsorship or endorsement by the Original Licensor and or Attribution as of You or Your use of the without the express prior written permission of the Original Licensor and or Attribution Parties Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable if You Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or You must not modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author s honor or reputation Licensor agrees that in those in which any exercise of the right granted in modification or other derogatory action prejudicial to the Original Author s honor and the Licensor will waive or not as this to the fullest extent permitted by the applicable national to enable You to reasonably exercise Your right under Warranties and Disclaimer UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN LICENSOR OFFERS THE WORK AS IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE STATUTORY OR WITHOUT WARRANTIES OF FITNESS FOR A PARTICULAR OR THE ABSENCE OF LATENT OR OTHER OR THE PRESENCE OF ABSENCE OF WHETHER OR NOT DISCOVERABLE SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED SO SUCH EXCLUSION MAY NOT APPLY TO YOU Limitation on Liability EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES Termination This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License Individuals or entities who have received Adaptations or Collections from You under this will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses and will survive any termination of this License Subject to the above terms and the license granted here is Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time
Definition: license.txt:56
ChSitesFormAdd\uploadPhoto
uploadPhoto($sPath, $isRemote=false)
Definition: ChSitesFormAdd.php:205
ChSitesFormAdd\getFullForm
getFullForm()
Definition: ChSitesFormAdd.php:76
ChSitesFormAdd\$_oModule
$_oModule
Definition: ChSitesFormAdd.php:12
$aForm
$aForm
Definition: forgot.php:43
ChSitesFormAdd\getUrlForm
getUrlForm()
Definition: ChSitesFormAdd.php:37
ChWsbService\call
static call($mixed, $sMethod, $aParams=array(), $sClass='Module')
Definition: ChWsbService.php:32
ChSitesFormAdd\__construct
__construct($oModule, $aParam=array())
Definition: ChSitesFormAdd.php:16