Conditions | 54 |
Paths | > 20000 |
Total Lines | 318 |
Code Lines | 232 |
Lines | 25 |
Ratio | 7.86 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
19 | function edit( $lid = 0 ) |
||
20 | { |
||
21 | global $xoopsDB, $wfmyts, $mytree, $imagearray, $xoopsConfig, $xoopsModuleConfig, $xoopsModule, $xoopsUser; |
||
22 | |||
23 | $sql = "SELECT * FROM " . $xoopsDB -> prefix( 'wflinks_links' ) . " WHERE lid=" . $lid; |
||
24 | if ( !$result = $xoopsDB -> query( $sql ) ) { |
||
25 | XoopsErrorHandler_HandleError( E_USER_WARNING, $sql, __FILE__, __LINE__ ); |
||
26 | |||
27 | return false; |
||
28 | } |
||
29 | $link_array = $xoopsDB -> fetchArray( $xoopsDB -> query( $sql ) ); |
||
30 | |||
31 | $directory = $xoopsModuleConfig['screenshots']; |
||
32 | $lid = $link_array['lid'] ? $link_array['lid'] : 0; |
||
33 | $cid = $link_array['cid'] ? $link_array['cid'] : 0; |
||
34 | $title = $link_array['title'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['title'] ) : ''; |
||
35 | $url = $link_array['url'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['url'] ) : 'http://'; |
||
36 | $publisher = $link_array['publisher'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['publisher'] ) : ''; |
||
37 | $submitter = $link_array['submitter'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['submitter'] ) : ''; |
||
38 | $screenshot = $link_array['screenshot'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['screenshot'] ) : ''; |
||
39 | $descriptionb = $link_array['description'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['description'] ) : ''; |
||
40 | $published = $link_array['published'] ? $link_array['published'] : time(); |
||
41 | $expired = $link_array['expired'] ? $link_array['expired'] : 0; |
||
42 | $updated = $link_array['updated'] ? $link_array['updated'] : 0; |
||
43 | $offline = $link_array['offline'] ? $link_array['offline'] : 0; |
||
44 | $forumid = $link_array['forumid'] ? $link_array['forumid'] : 0; |
||
45 | $ipaddress = $link_array['ipaddress'] ? $link_array['ipaddress'] : 0; |
||
46 | $notifypub = $link_array['notifypub'] ? $link_array['notifypub'] : 0; |
||
47 | $country = $link_array['country'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['country'] ) : '-'; |
||
48 | $keywords = $link_array['keywords'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['keywords'] ) : ''; |
||
49 | $item_tag = $link_array['item_tag'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['item_tag'] ) : ''; |
||
50 | $googlemap = $link_array['googlemap'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['googlemap'] ) : 'http://maps.google.com'; |
||
51 | $yahoomap = $link_array['yahoomap'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['yahoomap'] ) : 'http://maps.yahoo.com'; |
||
52 | $multimap = $link_array['multimap'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['multimap'] ) : 'http://www.multimap.com'; |
||
53 | $street1 = $link_array['street1'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['street1'] ) : ''; |
||
54 | $street2 = $link_array['street2'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['street2'] ) : ''; |
||
55 | $town = $link_array['town'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['town'] ) : ''; |
||
56 | $state = $link_array['state'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['state'] ) : ''; |
||
57 | $zip = $link_array['zip'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['zip'] ) : ''; |
||
58 | $tel = $link_array['tel'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['tel'] ) : ''; |
||
59 | $mobile = $link_array['mobile'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['mobile'] ) : ''; |
||
60 | $voip = $link_array['voip'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['voip'] ) : ''; |
||
61 | $fax = $link_array['fax'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['fax'] ) : ''; |
||
62 | $email = $link_array['email'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['email'] ) : ''; |
||
63 | $vat = $link_array['vat'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['vat'] ) : ''; |
||
64 | |||
65 | include 'admin_header.php'; |
||
66 | xoops_cp_header(); |
||
67 | xoops_load('XoopsUserUtility'); |
||
68 | //wfl_adminmenu( _AM_WFL_MLINKS ); |
||
69 | |||
70 | if ($lid > 0) { |
||
71 | $_vote_data = wfl_getVoteDetails( $lid ); |
||
72 | $text_info = "<table width='100%'> |
||
73 | <tr> |
||
74 | <td width='33%' valign='top'> |
||
75 | <div><b>" . _AM_WFL_LINK_ID . " </b>" . $lid . "</div> |
||
76 | <div><b>" . _AM_WFL_MINDEX_SUBMITTED . ": </b>" . formatTimestamp( $link_array['date'], $xoopsModuleConfig['dateformat'] ) . "</div> |
||
77 | <div><b>" . _AM_WFL_LINK_SUBMITTER . " </b>" . XoopsUserUtility::getUnameFromId( $submitter ) . "</div> |
||
78 | <div><b>" . _AM_WFL_LINK_IP . " </b>" . $ipaddress . "</div> |
||
79 | <div><b>" . _AM_WFL_PAGERANK . " </b>" . pagerank($link_array['url']) . "</div> |
||
80 | <div><b>" . _AM_WFL_HITS . " </b>" . $link_array['hits'] . "</div> |
||
81 | |||
82 | </td> |
||
83 | <td valign='top'> |
||
84 | <div><b>" . _AM_WFL_VOTE_TOTALRATE . ": </b>" . intval( $_vote_data['rate'] ) . "</div> |
||
85 | <div><b>" . _AM_WFL_VOTE_USERAVG . ": </b>" . intval( round( $_vote_data['avg_rate'], 2 ) ) . "</div> |
||
86 | <div><b>" . _AM_WFL_VOTE_MAXRATE . ": </b>" . intval( $_vote_data['min_rate'] ) . "</div> |
||
87 | <div><b>" . _AM_WFL_VOTE_MINRATE . ": </b>" . intval( $_vote_data['max_rate'] ) . "</div> |
||
88 | </td> |
||
89 | <td valign='top'> |
||
90 | <div><b>" . _AM_WFL_VOTE_MOSTVOTEDTITLE . ": </b>" . intval( $_vote_data['max_title'] ) . "</div> |
||
91 | <div><b>" . _AM_WFL_VOTE_LEASTVOTEDTITLE . ": </b>" . intval( $_vote_data['min_title'] ) . "</div> |
||
92 | <div><b>" . _AM_WFL_VOTE_REGISTERED . ": </b>" . ( intval( $_vote_data['rate'] - $_vote_data['null_ratinguser'] ) ) . "</div> |
||
93 | <div><b>" . _AM_WFL_VOTE_NONREGISTERED . ": </b>" . intval( $_vote_data['null_ratinguser'] ) . "</div> |
||
94 | </td> |
||
95 | </tr> |
||
96 | </table>"; |
||
97 | echo "<fieldset style='border: #e8e8e8 1px solid;'><legend style='display: inline; font-weight: bold; color: #0A3760;'>" . _AM_WFL_INFORMATION . "</legend>\n |
||
98 | <div style='padding: 8px;'>" . $text_info . "</div>\n |
||
99 | <!-- <div style='padding: 8px;'><li>" . $imagearray['deleteimg'] . " " . _AM_WFL_VOTE_DELETEDSC . "</li></div>\n --> |
||
100 | </fieldset>\n |
||
101 | <br />\n"; |
||
102 | } |
||
103 | unset( $_vote_data ); |
||
104 | |||
105 | $caption = ( $lid ) ? _AM_WFL_LINK_MODIFYFILE : _AM_WFL_LINK_CREATENEWFILE; |
||
106 | $sform = new XoopsThemeForm( $caption, "storyform", xoops_getenv( 'PHP_SELF' ) ); |
||
107 | $sform -> setExtra( 'enctype="multipart / form - data"' ); |
||
108 | |||
109 | if ($submitter == '') { |
||
110 | $sform -> addElement( new XoopsFormHidden( 'submitter', $submitter ) ); |
||
111 | } |
||
112 | |||
113 | // Link publisher form |
||
114 | if ($publisher) { |
||
115 | $sform -> addElement( new XoopsFormText( _AM_WFL_LINK_PUBLISHER, 'publisher', 70, 255, $publisher ) ); |
||
116 | //$sform -> addElement( new XoopsFormHidden( 'publisher', $publisher ) ) ; |
||
117 | } else { |
||
118 | $publisher = $xoopsUser -> uname(); |
||
119 | $sform -> addElement( new XoopsFormHidden( 'publisher', $publisher ) ); |
||
120 | } |
||
121 | |||
122 | // Link title form |
||
123 | $sform -> addElement( new XoopsFormText( _AM_WFL_LINK_TITLE, 'title', 70, 255, $title ), true ); |
||
124 | |||
125 | // Link url form |
||
126 | $url_text = new XoopsFormText('', 'url', 70, 255, $url); |
||
127 | $url_tray = new XoopsFormElementTray(_AM_WFL_LINK_DLURL, ''); |
||
128 | $url_tray -> addElement( $url_text, true) ; |
||
129 | $url_tray -> addElement( new XoopsFormLabel( " <img src='../assets/images/icon/world.png' onClick=\"window.open(document.storyform.url.value,'','');return(false);\" alt='Check URL' />" )); |
||
130 | $sform -> addElement( $url_tray ); |
||
131 | |||
132 | // Category form |
||
133 | ob_start(); |
||
134 | $mytree -> makeMySelBox( 'title', 'title', $cid, 0 ); |
||
135 | $sform -> addElement( new XoopsFormLabel( _AM_WFL_LINK_CATEGORY, ob_get_contents() ) ); |
||
136 | ob_end_clean(); |
||
137 | |||
138 | // Link description form |
||
139 | // $editor = wfl_getWysiwygForm( _AM_WFL_LINK_DESCRIPTION, 'descriptionb', $descriptionb, 15, 60 ); |
||
140 | // $sform -> addElement($editor, false); |
||
141 | $optionsTrayNote = new XoopsFormElementTray(_AM_WFL_LINK_DESCRIPTION, '<br />'); |
||
142 | View Code Duplication | if (class_exists('XoopsFormEditor')) { |
|
143 | $options['name'] = 'descriptionb'; |
||
144 | $options['value'] = $descriptionb; |
||
145 | $options['rows'] = 5; |
||
146 | $options['cols'] = '100%'; |
||
147 | $options['width'] = '100%'; |
||
148 | $options['height'] = '200px'; |
||
149 | $descriptionb = new XoopsFormEditor('', $xoopsModuleConfig['form_options'], $options, $nohtml = FALSE, $onfailure = 'textarea'); |
||
150 | $optionsTrayNote->addElement($descriptionb); |
||
151 | } else { |
||
152 | $descriptionb = new XoopsFormDhtmlTextArea('', 'descriptionb', $item->getVar('descriptionb', 'e'), '100%', '100%'); |
||
153 | $optionsTrayNote->addElement($descriptionb); |
||
154 | } |
||
155 | |||
156 | $sform->addElement($optionsTrayNote, FALSE); |
||
157 | |||
158 | // Meta keywords form |
||
159 | $keywords = new XoopsFormTextArea( _AM_WFL_KEYWORDS, 'keywords', $keywords, 7, 60, false ); |
||
160 | $keywords -> setDescription( "<small>" . _AM_WFL_KEYWORDS_NOTE . "</small>"); |
||
161 | $sform -> addElement($keywords); |
||
162 | |||
163 | // Insert tags if Tag-module is installed |
||
164 | View Code Duplication | if (wfl_tag_module_included()) { |
|
165 | include_once XOOPS_ROOT_PATH . "/modules/tag/include/formtag.php"; |
||
166 | $text_tags = new XoopsFormTag("item_tag", 70, 255, $link_array['item_tag'], 0); |
||
167 | $sform -> addElement( $text_tags ); |
||
168 | } else { |
||
169 | $sform -> addElement( new XoopsFormHidden( 'item_tag', $link_array['item_tag'] ) ); |
||
170 | } |
||
171 | |||
172 | // Screenshot |
||
173 | $graph_array = &wflLists :: getListTypeAsArray( XOOPS_ROOT_PATH . "/" . $xoopsModuleConfig['screenshots'], $type = "images" ); |
||
174 | $indeximage_select = new XoopsFormSelect( '', 'screenshot', $screenshot ); |
||
175 | $indeximage_select -> addOptionArray( $graph_array ); |
||
176 | $indeximage_select -> setExtra( "onchange = 'showImgSelected(\"image\", \"screenshot\", \"" . $xoopsModuleConfig['screenshots'] . "\", \"\", \"" . XOOPS_URL . "\")'" ); |
||
177 | $indeximage_tray = new XoopsFormElementTray( _AM_WFL_LINK_SHOTIMAGE, ' ' ); |
||
178 | $indeximage_tray -> setDescription( sprintf( _AM_WFL_LINK_MUSTBEVALID, "<b>" . $directory . "</b>" )); |
||
179 | $indeximage_tray -> addElement( $indeximage_select ); |
||
180 | View Code Duplication | if ( !empty( $imgurl ) ) { |
|
181 | $indeximage_tray -> addElement( new XoopsFormLabel( '', " <br /><br />< img src='" . XOOPS_URL . "/" . $xoopsModuleConfig['screenshots'] . "/" . $screenshot . "' name = 'image' id = 'image' alt = '' / > " ) ); |
||
182 | } else { |
||
183 | $indeximage_tray -> addElement( new XoopsFormLabel( '', " <br /><br /><img src='" . XOOPS_URL . "/uploads/blank.gif' name='image' id='image' alt='' / > " ) ); |
||
184 | } |
||
185 | $sform -> addElement( $indeximage_tray ); |
||
186 | |||
187 | if ($xoopsModuleConfig['useaddress']) { |
||
188 | $sform -> insertBreak( _AM_WFL_LINK_CREATEADDRESS, "bg3" ); |
||
189 | // Google Maps |
||
190 | $googlemap_text = new XoopsFormText( '', 'googlemap', 70, 1024, $googlemap ); |
||
191 | $googlemap_tray = new XoopsFormElementTray( _AM_WFL_LINK_GOOGLEMAP, '' ); |
||
192 | $googlemap_tray -> addElement( $googlemap_text , false ) ; |
||
193 | $googlemap_tray -> addElement( new XoopsFormLabel( " <img src='../assets/images/icon/google_map.png' onClick=\"window.open(document.storyform.googlemap.value,'','');return(false);\" alt='"._AM_WFL_LINK_CHECKMAP."' />" ) ); |
||
194 | $sform -> addElement( $googlemap_tray ); |
||
195 | // Yahoo Maps |
||
196 | $yahoomap_text = new XoopsFormText( '', 'yahoomap', 70, 1024, $yahoomap ); |
||
197 | $yahoomap_tray = new XoopsFormElementTray( _AM_WFL_LINK_YAHOOMAP, '' ); |
||
198 | $yahoomap_tray -> addElement( $yahoomap_text , false ) ; |
||
199 | $yahoomap_tray -> addElement( new XoopsFormLabel( " <img src='../assets/images/icon/yahoo_map.png' onClick=\"window.open(document.storyform.yahoomap.value,'','');return(false);\" alt='"._AM_WFL_LINK_CHECKMAP."' />" ) ); |
||
200 | $sform -> addElement( $yahoomap_tray ); |
||
201 | // MS Live Maps |
||
202 | $multimap_text = new XoopsFormText( '', 'multimap', 70, 1024, $multimap ); |
||
203 | $multimap_tray = new XoopsFormElementTray( _AM_WFL_LINK_MULTIMAP, '' ); |
||
204 | $multimap_tray -> addElement( $multimap_text , false ) ; |
||
205 | $multimap_tray -> addElement( new XoopsFormLabel( " <img src='../assets/images/icon/multimap.png' onClick=\"window.open(document.storyform.multimap.value,'','');return(false);\" alt='"._AM_WFL_LINK_CHECKMAP."' />" ) ); |
||
206 | $sform -> addElement( $multimap_tray ); |
||
207 | |||
208 | // Address |
||
209 | $street1 = new XoopsFormText( _AM_WFL_STREET1, 'street1', 70, 255, $street1 ); |
||
210 | $sform -> addElement( $street1, false ); |
||
211 | $street2 = new XoopsFormText( _AM_WFL_STREET2, 'street2', 70, 255, $street2 ); |
||
212 | $sform -> addElement( $street2, false ); |
||
213 | $town = new XoopsFormText( _AM_WFL_TOWN, 'town', 70, 255, $town ); |
||
214 | $sform -> addElement( $town, false ); |
||
215 | $state = new XoopsFormText( _AM_WFL_STATE, 'state', 70, 255, $state ); |
||
216 | $sform -> addElement( $state, false ); |
||
217 | $zip = new XoopsFormText( _AM_WFL_ZIPCODE, 'zip', 25, 25, $zip ); |
||
218 | $sform -> addElement( $zip, false ); |
||
219 | $tel = new XoopsFormText( _AM_WFL_TELEPHONE, 'tel', 25, 25, $tel ); |
||
220 | $sform -> addElement( $tel, false ); |
||
221 | $mobile = new XoopsFormText( _AM_WFL_MOBILE, 'mobile', 25, 25, $mobile ); |
||
222 | $sform -> addElement( $mobile, false ); |
||
223 | $voip = new XoopsFormText( _AM_WFL_VOIP, 'voip', 25, 25, $voip ); |
||
224 | $sform -> addElement( $voip, false ); |
||
225 | $fax = new XoopsFormText( _AM_WFL_FAX, 'fax', 25, 25, $fax ); |
||
226 | $sform -> addElement( $fax, false ); |
||
227 | $email = new XoopsFormText( _AM_WFL_EMAIL, 'email', 25, 60, $email ); |
||
228 | $sform -> addElement( $email, false ); |
||
229 | $vat = new XoopsFormText( _AM_WFL_VAT, 'vat', 25, 25, $vat ); |
||
230 | $vat -> setDescription( _AM_WFL_VATWIKI ); |
||
231 | $sform -> addElement( $vat, false ); |
||
232 | // $sform -> addElement( new XoopsFormHidden( 'vat', $link_array['vat'] ) ); /* If you don't want to use the VAT form, */ |
||
233 | /* use this line and comment-out the 3 lines above */ |
||
234 | } |
||
235 | |||
236 | // Country form |
||
237 | $country_select = new XoopsFormSelectCountry( _AM_WFL_COUNTRY, 'country', $country ); |
||
238 | $sform -> addElement( $country_select, false ); |
||
239 | |||
240 | // Miscellaneous Link settings |
||
241 | $sform -> insertBreak( _AM_WFL_LINK_MISCLINKSETTINGS, 'bg3' ); |
||
242 | |||
243 | // Set Publish date |
||
244 | $sform -> addElement( new XoopsFormDateTime( _AM_WFL_LINK_SETPUBLISHDATE, 'published', $size = 15, $published )); |
||
245 | |||
246 | if ($lid) { |
||
247 | $sform -> addElement( new XoopsFormHidden( 'was_published', $published ) ); |
||
248 | $sform -> addElement( new XoopsFormHidden( 'was_expired', $expired ) ); |
||
249 | } |
||
250 | |||
251 | // Set Expire date |
||
252 | $isexpired = ( $expired > time() ) ? 1: 0 ; |
||
253 | $expiredates = ( $expired > time() ) ? _AM_WFL_LINK_EXPIREDATESET . formatTimestamp( $expired, $xoopsModuleConfig['dateformat'] ) : _AM_WFL_LINK_SETDATETIMEEXPIRE; |
||
254 | $warning = ( $published > $expired && $expired > time() ) ? _AM_WFL_LINK_EXPIREWARNING : ''; |
||
255 | $expiredate_checkbox = new XoopsFormCheckBox( '', 'expiredateactivate', $isexpired ); |
||
256 | $expiredate_checkbox -> addOption( 1, $expiredates . " <br /> <br /> " ); |
||
257 | |||
258 | $expiredate_tray = new XoopsFormElementTray( _AM_WFL_LINK_EXPIREDATE . $warning, '' ); |
||
259 | $expiredate_tray -> addElement( $expiredate_checkbox ); |
||
260 | $expiredate_tray -> addElement( new XoopsFormDateTime( _AM_WFL_LINK_SETEXPIREDATE . " <br /> ", 'expired', 15, $expired ) ); |
||
261 | $expiredate_tray -> addElement( new XoopsFormRadioYN( _AM_WFL_LINK_CLEAREXPIREDATE, 'clearexpire', 0, ' ' . _YES . '', ' ' . _NO . '' ) ); |
||
262 | $sform -> addElement( $expiredate_tray ); |
||
263 | |||
264 | // Set Link offline |
||
265 | $linkstatus_radio = new XoopsFormRadioYN( _AM_WFL_LINK_FILESSTATUS, 'offline', $offline, ' ' . _YES . '', ' ' . _NO . '' ); |
||
266 | $sform -> addElement( $linkstatus_radio ); |
||
267 | |||
268 | // Set Link updated |
||
269 | $up_dated = ( $updated == 0 ) ? 0 : 1; |
||
270 | $link_updated_radio = new XoopsFormRadioYN( _AM_WFL_LINK_SETASUPDATED, 'up_dated', $up_dated, ' ' . _YES . '', ' ' . _NO . '' ); |
||
271 | $sform -> addElement( $link_updated_radio ); |
||
272 | |||
273 | $result = $xoopsDB -> query( "SELECT COUNT( * ) FROM " . $xoopsDB -> prefix( 'wflinks_broken' ) . " WHERE lid = " . $lid ); |
||
274 | list ( $broken_count ) = $xoopsDB -> fetchRow( $result ); |
||
275 | if ($broken_count > 0) { |
||
276 | $link_updated_radio = new XoopsFormRadioYN( _AM_WFL_LINK_DELEDITMESS, 'delbroken', 1, ' ' . _YES . '', ' ' . _NO . '' ); |
||
277 | $sform -> addElement( $editmess_radio ); |
||
278 | } |
||
279 | |||
280 | // Select forum |
||
281 | ob_start(); |
||
282 | wflLists :: getforum( $xoopsModuleConfig['selectforum'], $forumid ); |
||
283 | $sform -> addElement( new XoopsFormLabel( _AM_WFL_LINK_DISCUSSINFORUM, ob_get_contents() ) ); |
||
284 | ob_end_clean(); |
||
285 | |||
286 | //Create News Story |
||
287 | if (wfl_news_module_included()) { |
||
288 | $sform -> insertBreak( _AM_WFL_LINK_CREATENEWSSTORY, "bg3" ); |
||
289 | $submitNews_radio = new XoopsFormRadioYN( _AM_WFL_LINK_SUBMITNEWS, 'submitnews', 0, ' ' . _YES . '', ' ' . _NO . '' ); |
||
290 | $sform -> addElement( $submitNews_radio ); |
||
291 | |||
292 | include_once XOOPS_ROOT_PATH . '/class/xoopstopic.php'; |
||
293 | $xt = new XoopsTopic( $xoopsDB -> prefix( 'topics' ) ); |
||
294 | ob_start(); |
||
295 | $xt -> makeTopicSelBox( 1, 0, "newstopicid" ); |
||
296 | $sform -> addElement( new XoopsFormLabel( _AM_WFL_LINK_NEWSCATEGORY, ob_get_contents() ) ); |
||
297 | ob_end_clean(); |
||
298 | $sform -> addElement( new XoopsFormText( _AM_WFL_LINK_NEWSTITLE, 'newsTitle', 70, 255, '' ), false ); |
||
299 | } |
||
300 | |||
301 | if ($lid && $published == 0) { |
||
302 | $approved = ( $published == 0 ) ? 0 : 1; |
||
303 | $approve_checkbox = new XoopsFormCheckBox( _AM_WFL_LINK_EDITAPPROVE, "approved", 1 ); |
||
304 | $approve_checkbox -> addOption( 1, " " ); |
||
305 | $sform -> addElement( $approve_checkbox ); |
||
306 | } |
||
307 | |||
308 | if (!$lid) { |
||
309 | $button_tray = new XoopsFormElementTray( '', '' ); |
||
310 | $button_tray -> addElement( new XoopsFormHidden( 'status', 1 ) ); |
||
311 | $button_tray -> addElement( new XoopsFormHidden( 'notifypub', $notifypub ) ); |
||
312 | $button_tray -> addElement( new XoopsFormHidden( 'op', 'save' ) ); |
||
313 | $button_tray -> addElement( new XoopsFormButton( '', '', _AM_WFL_BSAVE, 'submit' ) ); |
||
314 | $sform -> addElement( $button_tray ); |
||
315 | } else { |
||
316 | $button_tray = new XoopsFormElementTray( '', '' ); |
||
317 | $button_tray -> addElement( new XoopsFormHidden( 'lid', $lid ) ); |
||
318 | $button_tray -> addElement( new XoopsFormHidden( 'status', 2 ) ); |
||
319 | $hidden = new XoopsFormHidden( 'op', 'save' ); |
||
320 | $button_tray -> addElement( $hidden ); |
||
321 | |||
322 | $butt_dup = new XoopsFormButton( '', '', _AM_WFL_BMODIFY, 'submit' ); |
||
323 | $butt_dup -> setExtra( 'onclick="this . form . elements . op . value = \'save\'"' ); |
||
324 | $button_tray -> addElement( $butt_dup ); |
||
325 | $butt_dupct = new XoopsFormButton( '', '', _AM_WFL_BDELETE, 'submit' ); |
||
326 | $butt_dupct -> setExtra( 'onclick="this.form.elements.op.value=\'delete\'"' ); |
||
327 | $button_tray -> addElement( $butt_dupct ); |
||
328 | $butt_dupct2 = new XoopsFormButton( '', '', _AM_WFL_BCANCEL, 'submit' ); |
||
329 | $butt_dupct2 -> setExtra( 'onclick="this.form.elements.op.value=\'linksConfigMenu\'"' ); |
||
330 | $button_tray -> addElement( $butt_dupct2 ); |
||
331 | $sform -> addElement( $button_tray ); |
||
332 | } |
||
333 | $sform -> display(); |
||
334 | unset( $hidden ); |
||
335 | include_once 'admin_footer.php'; |
||
336 | } |
||
337 | |||
735 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.