Annotation of /mambo/branches/4.6/administrator/includes/admin.php
Parent Directory
|
Revision Log
Revision 446 - (view) (download)
| 1 : | mambo | 117 | <?php |
| 2 : | /** | ||
| 3 : | csouza | 297 | * @package Mambo Open Source |
| 4 : | * @copyright (C) 2005 - 2006 Mambo Foundation Inc. | ||
| 5 : | mambo | 117 | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
| 6 : | csouza | 297 | * |
| 7 : | * Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure | ||
| 8 : | * that Mambo remained free Open Source software owned and managed by the community. | ||
| 9 : | mambo | 117 | * Mambo is Free Software |
| 10 : | csouza | 297 | */ |
| 11 : | mambo | 117 | |
| 12 : | /** ensure this file is being included by a parent file */ | ||
| 13 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 14 : | |||
| 15 : | /** | ||
| 16 : | csouza | 129 | * Basic XML parsing of installation files |
| 17 : | ***/ | ||
| 18 : | |||
| 19 : | class mosBasicXML { | ||
| 20 : | csouza | 149 | var $xmlfile = ''; |
| 21 : | csouza | 129 | var $opentags = array(); |
| 22 : | var $accept = array(); | ||
| 23 : | var $mosinstall = false; | ||
| 24 : | counterpoi | 272 | t var $chardata = ''; |
| 25 : | csouza | 129 | var $type; |
| 26 : | counterpoi | 206 | t var $errors = ''; |
| 27 : | csouza | 138 | var $mosParameter = null; |
| 28 : | var $name = ''; | ||
| 29 : | csouza | 129 | |
| 30 : | csouza | 138 | function mosBasicXML ($file, $mosParameter=null, $name='params') { |
| 31 : | csouza | 149 | $this->xmlfile = $file; |
| 32 : | $this->mosParameter = $mosParameter; | ||
| 33 : | csouza | 138 | $this->name = $name; |
| 34 : | counterpoi | 206 | t $this->errors = new mosErrorSet(); |
| 35 : | csouza | 129 | $this->setTree(); |
| 36 : | $parser = xml_parser_create(); | ||
| 37 : | csouza | 149 | $startfunc = array (&$this, 'start_element'); |
| 38 : | $endfunc = array (&$this, 'end_element'); | ||
| 39 : | $charfunc = array (&$this, 'character_data'); | ||
| 40 : | xml_set_element_handler ($parser, $startfunc, $endfunc); | ||
| 41 : | xml_set_character_data_handler ($parser, $charfunc); | ||
| 42 : | counterpoi | 206 | t if ($fp = fopen($this->xmlfile, 'rb')) { |
| 43 : | t while ($data = fread($fp, 4096) AND $this->errors->getMaxLevel() < _MOS_ERROR_FATAL) { | ||
| 44 : | csouza | 151 | $data = str_replace('&', ' ampersand ', $data); |
| 45 : | counterpoi | 206 | t $ret = xml_parse($parser, $data, feof($fp)) or $this->errors->addErrorDetails(sprintf(T_('XML ERROR in %s: %s at line %d'), |
| 46 : | t $this->xmlfile, | ||
| 47 : | csouza | 151 | xml_error_string(xml_get_error_code($parser)), |
| 48 : | counterpoi | 206 | t xml_get_current_line_number($parser)), _MOS_ERROR_FATAL); |
| 49 : | csouza | 151 | } |
| 50 : | csouza | 129 | } |
| 51 : | counterpoi | 206 | t else $this->errors->addErrorDetails(sprintf(T_('Unable to open XML file %s'),$this->xmlfile), _MOS_ERROR_FATAL); |
| 52 : | csouza | 129 | if (count($this->opentags) != 0) { |
| 53 : | $tags = implode (', ', $this->opentags); | ||
| 54 : | counterpoi | 206 | t $this->errors->addErrorDetails(sprintf(T_('XML error in %s - unclosed tag(s) (%s) at end of file'),$this->xmlfile, $tags), _MOS_ERROR_SEVERE); |
| 55 : | csouza | 129 | } |
| 56 : | xml_parser_free($parser); | ||
| 57 : | } | ||
| 58 : | csouza | 149 | |
| 59 : | csouza | 129 | function setTree () { |
| 60 : | $this->accept['MOSINSTALL'] = array ('NAME', 'CREATIONDATE', 'AUTHOR', 'COPYRIGHT', | ||
| 61 : | csouza | 149 | 'LICENSE', 'AUTHOREMAIL', 'AUTHORURL', 'VERSION', 'DESCRIPTION', 'FILES', 'MEDIA', |
| 62 : | csouza | 129 | 'PARAMS', 'INSTALL', 'UNINSTALL', 'INSTALLFILE', 'UNINSTALLFILE', 'ADMINISTRATION', |
| 63 : | csouza | 151 | 'IMAGES', 'CSS', 'GROUP'); |
| 64 : | csouza | 129 | $this->accept['PARAMS'] = array ('PARAM'); |
| 65 : | $this->accept['PARAM'] = array ('OPTION'); | ||
| 66 : | $this->accept['FILES'] = array ('FILENAME'); | ||
| 67 : | $this->accept['INSTALL'] = array ('QUERIES'); | ||
| 68 : | $this->accept['UNINSTALL'] = array ('QUERIES'); | ||
| 69 : | $this->accept['QUERIES'] = array ('QUERY'); | ||
| 70 : | csouza | 149 | $this->accept['ADMINISTRATION'] = array ('FILES', 'IMAGES', 'MENU', 'SUBMENU'); |
| 71 : | csouza | 129 | $this->accept['IMAGES'] = array ('FILENAME'); |
| 72 : | $this->accept['SUBMENU'] = array('MENU'); | ||
| 73 : | csouza | 149 | $this->accept['MEDIA'] = array('FILENAME'); |
| 74 : | csouza | 129 | $this->accept['CSS'] = array('FILENAME'); |
| 75 : | } | ||
| 76 : | |||
| 77 : | function start_element ($parser, $element_name, $element_attrs) { | ||
| 78 : | counterpoi | 206 | t if ($this->errors->getMaxLevel() >= _MOS_ERROR_FATAL) return; |
| 79 : | csouza | 129 | if ($this->mosinstall) { |
| 80 : | $container = $this->opentags[0]; | ||
| 81 : | counterpoi | 206 | t if (!isset($this->accept[$container]) OR !is_array($this->accept[$container])) $this->errors->addErrorDetails(sprintf(T_('XML error in %s: %s is not a valid containing element'), $this->xmlfile, $container), _MOS_ERROR_WARN); |
| 82 : | t elseif (!in_array($element_name, $this->accept[$container])) $this->errors->addErrorDetails(sprintf(T_('XML error in %s: %s not permitted within %s'), $this->xmlfile, $element_name, $container), _MOS_ERROR_WARN); | ||
| 83 : | csouza | 129 | } |
| 84 : | if ($this->mosinstall OR $element_name == 'MOSINSTALL') { | ||
| 85 : | $this->opencount = array_unshift ($this->opentags, $element_name); | ||
| 86 : | $this->mosinstall = true; | ||
| 87 : | csouza | 149 | $method = 'element_'.$element_name; |
| 88 : | $specific = array (&$this, $method); | ||
| 89 : | counterpoi | 425 | t foreach ($element_attrs as $key=>$attr) $element_attrs[$key] = str_replace(' ampersand ', '&', $attr); |
| 90 : | csouza | 149 | if (is_callable($specific)) $this->$method($element_attrs); |
| 91 : | csouza | 129 | } |
| 92 : | counterpoi | 206 | t else $this->errors->addErrorDetails(sprintf(T_('XML error in %s: expected MOSINSTALL but found %s'), $this->xmlfile, $element_name), _MOS_ERROR_SEVERE); |
| 93 : | csouza | 129 | } |
| 94 : | |||
| 95 : | function end_element ($parser, $element_name) { | ||
| 96 : | counterpoi | 206 | t if ($this->errors->getMaxLevel() >= _MOS_ERROR_FATAL) return; |
| 97 : | csouza | 149 | if ($this->opentags[0] != $element_name) { |
| 98 : | counterpoi | 206 | t $this->errors->addErrorDetails(sprintf(T_('XML error in %s: last open tag was %s, but found end of %s'), $this->xmlfile, $check, $element_name), _MOS_ERROR_SEVERE); |
| 99 : | csouza | 149 | return; |
| 100 : | csouza | 129 | } |
| 101 : | counterpoi | 425 | t $this->chardata = str_replace(' ampersand ', '&', $this->chardata); |
| 102 : | counterpoi | 272 | t if (isset($this->opentags[1]) AND $this->opentags[1] == 'MOSINSTALL') $this->values[$this->opentags[0]] = $this->chardata; |
| 103 : | csouza | 138 | $method = 'end_element_'.$element_name; |
| 104 : | csouza | 149 | $specific = array (&$this, $method); |
| 105 : | csouza | 138 | if (is_callable($specific)) $this->$method(); |
| 106 : | csouza | 149 | array_shift ($this->opentags); |
| 107 : | $this->opencount--; | ||
| 108 : | counterpoi | 272 | t $this->chardata = ''; |
| 109 : | csouza | 129 | } |
| 110 : | |||
| 111 : | function character_data ($parser, $data) { | ||
| 112 : | counterpoi | 272 | t if ($this->errors->getMaxLevel() >= _MOS_ERROR_FATAL) return; |
| 113 : | t $this->chardata .= trim($data); | ||
| 114 : | csouza | 129 | } |
| 115 : | csouza | 149 | |
| 116 : | csouza | 129 | function element_mosinstall ($attrs) { |
| 117 : | if (isset($attrs['TYPE'])) $this->type = $attrs['TYPE']; | ||
| 118 : | counterpoi | 206 | t else $this->errors->addErrorDetails(sprintf(T_('XML error in %s: mosinstall does not have type attribute'), $this->xmlfile), _MOS_ERROR_FATAL); |
| 119 : | csouza | 129 | } |
| 120 : | |||
| 121 : | function getType () { | ||
| 122 : | return $this->type; | ||
| 123 : | } | ||
| 124 : | counterpoi | 206 | t |
| 125 : | t function &getErrors () { | ||
| 126 : | t $errors =& $this->errors->getErrors(); | ||
| 127 : | t return $errors; | ||
| 128 : | t } | ||
| 129 : | csouza | 129 | |
| 130 : | } | ||
| 131 : | |||
| 132 : | /** | ||
| 133 : | * Extend basic parser to extract the description for a type of install file | ||
| 134 : | **/ | ||
| 135 : | |||
| 136 : | class mosXMLDescription extends mosBasicXML { | ||
| 137 : | var $values = array(); | ||
| 138 : | |||
| 139 : | function getDescription ($type) { | ||
| 140 : | if ($type == $this->type AND isset($this->values['DESCRIPTION'])) return $this->values['DESCRIPTION']; | ||
| 141 : | else return ''; | ||
| 142 : | } | ||
| 143 : | |||
| 144 : | function getName ($type) { | ||
| 145 : | if ($type == $this->type AND isset($this->values['NAME'])) return $this->values['NAME']; | ||
| 146 : | else return ''; | ||
| 147 : | } | ||
| 148 : | |||
| 149 : | function getGroup ($type) { | ||
| 150 : | if ($type == $this->type AND isset($this->values['GROUP'])) return $this->values['GROUP']; | ||
| 151 : | else return ''; | ||
| 152 : | } | ||
| 153 : | |||
| 154 : | function getCreationDate ($type) { | ||
| 155 : | if ($type == $this->type AND isset($this->values['CREATIONDATE'])) return $this->values['CREATIONDATE']; | ||
| 156 : | else return ''; | ||
| 157 : | } | ||
| 158 : | |||
| 159 : | function getAuthor ($type) { | ||
| 160 : | if ($type == $this->type AND isset($this->values['AUTHOR'])) return $this->values['AUTHOR']; | ||
| 161 : | else return ''; | ||
| 162 : | } | ||
| 163 : | |||
| 164 : | function getCopyright ($type) { | ||
| 165 : | if ($type == $this->type AND isset($this->values['COPYRIGHT'])) return $this->values['COPYRIGHT']; | ||
| 166 : | else return ''; | ||
| 167 : | } | ||
| 168 : | |||
| 169 : | function getAuthorEmail ($type) { | ||
| 170 : | if ($type == $this->type AND isset($this->values['AUTHOREMAIL'])) return $this->values['AUTHOREMAIL']; | ||
| 171 : | else return ''; | ||
| 172 : | } | ||
| 173 : | |||
| 174 : | function getAuthorUrl ($type) { | ||
| 175 : | if ($type == $this->type AND isset($this->values['AUTHORURL'])) return $this->values['AUTHORURL']; | ||
| 176 : | else return ''; | ||
| 177 : | } | ||
| 178 : | |||
| 179 : | function getVersion ($type) { | ||
| 180 : | if ($type == $this->type AND isset($this->values['VERSION'])) return $this->values['VERSION']; | ||
| 181 : | else return ''; | ||
| 182 : | } | ||
| 183 : | |||
| 184 : | } | ||
| 185 : | |||
| 186 : | csouza | 138 | class mosXMLParams extends mosXMLDescription { |
| 187 : | var $options = array(); | ||
| 188 : | var $optvalue = ''; | ||
| 189 : | var $paramattrs = array(); | ||
| 190 : | var $paramcount = 0; | ||
| 191 : | var $html = array(); | ||
| 192 : | |||
| 193 : | function element_params ($attrs) { | ||
| 194 : | $this->html[] = '<table class="paramlist">'; | ||
| 195 : | if (isset($attrs['NAME'])) { | ||
| 196 : | $pname = $attrs['NAME']; | ||
| 197 : | $this->html[] = "<tr><td colspan='3'>$pname</td></tr>"; | ||
| 198 : | } | ||
| 199 : | } | ||
| 200 : | |||
| 201 : | function element_param ($attrs) { | ||
| 202 : | $this->paramattrs = $attrs; | ||
| 203 : | } | ||
| 204 : | |||
| 205 : | function element_option ($attrs) { | ||
| 206 : | csouza | 151 | if (isset($attrs['VALUE'])) $this->optvalue = $attrs['VALUE']; |
| 207 : | csouza | 138 | } |
| 208 : | |||
| 209 : | function end_element_option () { | ||
| 210 : | counterpoi | 272 | t $this->options[] = mosHTML::makeOption($this->optvalue, $this->chardata); |
| 211 : | csouza | 138 | $this->optvalue = ''; |
| 212 : | } | ||
| 213 : | |||
| 214 : | function end_element_param () { | ||
| 215 : | $type = mosGetParam ($this->paramattrs, 'TYPE', ''); | ||
| 216 : | $name = mosGetParam ($this->paramattrs, 'NAME', ''); | ||
| 217 : | $label = mosGetParam ($this->paramattrs, 'LABEL', $name); | ||
| 218 : | $default = mosGetParam ($this->paramattrs, 'DEFAULT', ''); | ||
| 219 : | if ($description = mosGetParam ($this->paramattrs, 'DESCRIPTION', '')) $tooltip = mosToolTip($description, $name); | ||
| 220 : | else $tooltip = ''; | ||
| 221 : | csouza | 151 | if (is_object($this->mosParameter)) { |
| 222 : | $mp = $this->mosParameter; | ||
| 223 : | $value = $mp->get($name, $default); | ||
| 224 : | } | ||
| 225 : | csouza | 138 | else $value = $default; |
| 226 : | $this->html[] = '<tr>'; | ||
| 227 : | if ($label == '@spacer') $label = '<hr />'; | ||
| 228 : | elseif ($label) $label .= ':'; | ||
| 229 : | $this->html[] = '<td width="35%" align="right" valign="top">'.$label.'</td>'; | ||
| 230 : | $controlname = $this->name; | ||
| 231 : | switch ($type) { | ||
| 232 : | case 'text': | ||
| 233 : | $size = mosGetParam ($this->paramattrs, 'SIZE', 0); | ||
| 234 : | $controlstring = '<input type="text" name="'.$this->name.'['.$name.']" value="'.$value.'" class="text_area" size="'.$size.'" />'; | ||
| 235 : | break; | ||
| 236 : | case 'list': | ||
| 237 : | csouza | 151 | $controlstring = mosHTML::selectList($this->options, $controlname.'['.$name.']', 'class="inputbox"', 'value', 'text', $value); |
| 238 : | csouza | 138 | break; |
| 239 : | case 'radio': | ||
| 240 : | csouza | 151 | $controlstring = mosHTML::radioList($this->options, $controlname.'['.$name.']', '', $value); |
| 241 : | csouza | 138 | break; |
| 242 : | case 'imagelist': | ||
| 243 : | $directory = new mosDirectory (mamboCore::get('mosConfig_absolute_path').mosGetParam($this->paramattrs, 'DIRECTORY', '')); | ||
| 244 : | $files = $directory->listFiles ('\.png$|\.gif$|\.jpg$|\.bmp$|\.ico$'); | ||
| 245 : | $options = array(); | ||
| 246 : | foreach ($files as $file) $options[] = mosHTML::makeOption($file, $file); | ||
| 247 : | if (!isset($this->paramattrs['HIDE_NONE'])) array_unshift($options, mosHTML::makeOption('-1', '- Do not use an image -' )); | ||
| 248 : | if (!isset($this->paramattrs['HIDE_DEFAULT'])) array_unshift($options, mosHTML::makeOption('', '- Use Default image -')); | ||
| 249 : | counterpoi | 283 | t $controlstring = mosHTML::selectList ($options, $controlname.'['.$name.']', 'class="inputbox"', 'value', 'text', $value); |
| 250 : | csouza | 138 | break; |
| 251 : | case 'textarea': | ||
| 252 : | $rows = mosGetParam ($this->paramattrs, 'ROWS', 0); | ||
| 253 : | $cols = mosGetParam ($this->paramattrs, 'COLS', 0); | ||
| 254 : | $value = str_replace ('<br /', "\n", $value); | ||
| 255 : | $controlstring = "<textarea name='params[$name]' cols='$cols' rows='$rows' class='text_area'>$value</textarea>"; | ||
| 256 : | break; | ||
| 257 : | case 'spacer': | ||
| 258 : | $controlstring = $value ? $value : '<hr />'; | ||
| 259 : | break; | ||
| 260 : | case 'mos_section': | ||
| 261 : | counterpoi | 283 | t $controlstring = $this->_form_mos_section($name, $value, $controlname); |
| 262 : | csouza | 138 | break; |
| 263 : | case 'mos_category': | ||
| 264 : | counterpoi | 283 | t $controlstring = $this->_form_mos_category($name, $value, $controlname); |
| 265 : | csouza | 138 | break; |
| 266 : | case 'mos_menu': | ||
| 267 : | counterpoi | 283 | t $controlstring = $this->_form_mos_menu($name, $value, $controlname); |
| 268 : | t break; | ||
| 269 : | csouza | 138 | default: |
| 270 : | csouza | 194 | $controlstring = T_('Handler not defined for type').'='.$type; |
| 271 : | csouza | 138 | } |
| 272 : | // $this->html[] = "<td>$type</td>"; | ||
| 273 : | $this->html[] = "<td>$controlstring</td>"; | ||
| 274 : | $this->html[] = "<td width='10%' align='left' valign='top'>$tooltip</td>"; | ||
| 275 : | $this->html[] = '</tr>'; | ||
| 276 : | $this->options = array(); | ||
| 277 : | $this->paramattrs = array(); | ||
| 278 : | $this->paramcount++; | ||
| 279 : | } | ||
| 280 : | |||
| 281 : | function end_element_params () { | ||
| 282 : | $this->html[] = '</table>'; | ||
| 283 : | csouza | 194 | if ($this->paramcount == 0) $this->html[] = '<tr><td colspan="2"><i>'.T_('There are no Parameters for this item').'</i></td></tr>'; |
| 284 : | csouza | 138 | $this->paramcount = 0; |
| 285 : | } | ||
| 286 : | /** | ||
| 287 : | * @param string The name of the form element | ||
| 288 : | * @param string The value of the element | ||
| 289 : | * @param object The xml element for the parameter | ||
| 290 : | * @param string The control name | ||
| 291 : | * @return string The html for the element | ||
| 292 : | */ | ||
| 293 : | function _form_mos_section( $name, $value, $control_name ) { | ||
| 294 : | counterpoi | 238 | t $database =& mamboDatabase::getInstance(); |
| 295 : | csouza | 138 | $query = "SELECT id AS value, title AS text" |
| 296 : | . "\n FROM #__sections" | ||
| 297 : | . "\n WHERE published='1' AND scope='content'" | ||
| 298 : | . "\n ORDER BY title" | ||
| 299 : | ; | ||
| 300 : | $database->setQuery( $query ); | ||
| 301 : | $options = $database->loadObjectList(); | ||
| 302 : | array_unshift($options, mosHTML::makeOption( '0', '- Select Content Section -' )); | ||
| 303 : | counterpoi | 360 | t return mosHTML::selectList( $options, $control_name.'['.$name.']', 'class="inputbox"', 'value', 'text', $value ); |
| 304 : | csouza | 138 | } |
| 305 : | /** | ||
| 306 : | * @param string The name of the form element | ||
| 307 : | * @param string The value of the element | ||
| 308 : | * @param object The xml element for the parameter | ||
| 309 : | * @param string The control name | ||
| 310 : | * @return string The html for the element | ||
| 311 : | */ | ||
| 312 : | function _form_mos_category( $name, $value, $control_name ) { | ||
| 313 : | counterpoi | 238 | t $database =& mamboDatabase::getInstance(); |
| 314 : | csouza | 138 | $query = "SELECT c.id AS value, CONCAT_WS( '/',s.title, c.title ) AS text" |
| 315 : | . "\n FROM #__categories AS c" | ||
| 316 : | . "\n LEFT JOIN #__sections AS s ON s.id=c.section" | ||
| 317 : | . "\n WHERE c.published='1' AND s.scope='content'" | ||
| 318 : | . "\n ORDER BY c.title" | ||
| 319 : | ; | ||
| 320 : | $database->setQuery( $query ); | ||
| 321 : | $options = $database->loadObjectList(); | ||
| 322 : | array_unshift($options, mosHTML::makeOption('0', '- Select Content Category -')); | ||
| 323 : | counterpoi | 360 | t return mosHTML::selectList( $options, $control_name.'['.$name.']', 'class="inputbox"', 'value', 'text', $value ); |
| 324 : | csouza | 138 | } |
| 325 : | /** | ||
| 326 : | * @param string The name of the form element | ||
| 327 : | * @param string The value of the element | ||
| 328 : | * @param object The xml element for the parameter | ||
| 329 : | * @param string The control name | ||
| 330 : | * @return string The html for the element | ||
| 331 : | */ | ||
| 332 : | counterpoi | 283 | t function _form_mos_menu( $name, $value, $control_name ) { |
| 333 : | t $menuTypes = mosAdminMenus::menutypes(); | ||
| 334 : | t foreach($menuTypes as $menutype ) $options[] = mosHTML::makeOption( $menutype, $menutype ); | ||
| 335 : | t array_unshift( $options, mosHTML::makeOption( '', '- Select Menu -' ) ); | ||
| 336 : | t return mosHTML::selectList( $options, ''. $control_name .'['. $name .']', 'class="inputbox"', 'value', 'text', $value ); | ||
| 337 : | t } | ||
| 338 : | csouza | 138 | } |
| 339 : | |||
| 340 : | csouza | 129 | /** |
| 341 : | csouza | 138 | * Parameters handler |
| 342 : | * @package Mambo | ||
| 343 : | */ | ||
| 344 : | class mosAdminParameters extends mosParameters { | ||
| 345 : | /** @var string Path to the xml setup file */ | ||
| 346 : | var $_path = null; | ||
| 347 : | /** @var string The type of setup file */ | ||
| 348 : | var $_type = null; | ||
| 349 : | /** @var object The xml params element */ | ||
| 350 : | var $_xmlElem = null; | ||
| 351 : | /** | ||
| 352 : | * Constructor | ||
| 353 : | * @param string The raw parms text | ||
| 354 : | * @param string Path to the xml setup file | ||
| 355 : | * @var string The type of setup file | ||
| 356 : | */ | ||
| 357 : | function mosAdminParameters( $text, $path='', $type='component' ) { | ||
| 358 : | $this->_params = $this->parse( $text ); | ||
| 359 : | $this->_raw = $text; | ||
| 360 : | $this->_path = $path; | ||
| 361 : | $this->_type = $type; | ||
| 362 : | } | ||
| 363 : | |||
| 364 : | } | ||
| 365 : | /** | ||
| 366 : | counterpoi | 212 | t * Generally available parameter object |
| 367 : | t * @package Mambo | ||
| 368 : | t */ | ||
| 369 : | t class mosSpecialAdminParameters extends mosAdminParameters { | ||
| 370 : | t | ||
| 371 : | t function mosSpecialAdminParameters ($name, $version='') { | ||
| 372 : | counterpoi | 238 | t $database =& mamboDatabase::getInstance(); |
| 373 : | counterpoi | 212 | t $sql = "SELECT * FROM #__parameters WHERE param_name='$name'"; |
| 374 : | t if ($version) $sql .= " AND param_version='$version'"; | ||
| 375 : | t $database->setQuery($sql); | ||
| 376 : | t $parameters = $database->loadObjectList(); | ||
| 377 : | t if ($parameters) $parameters = $parameters[0]; | ||
| 378 : | t parent::mosAdminParameters($parameters->params, mamboCore::get('mosConfig_absolute_path').'/parameters/'.$parameters->param_file); | ||
| 379 : | t } | ||
| 380 : | t } | ||
| 381 : | t | ||
| 382 : | t /** | ||
| 383 : | counterpoi | 446 | t * Useful HTML class for admin side components |
| 384 : | t * @package Mambo | ||
| 385 : | t */ | ||
| 386 : | t class basicAdminHTML { | ||
| 387 : | t var $pageNav = ''; | ||
| 388 : | t var $option = ''; | ||
| 389 : | t var $act = ''; | ||
| 390 : | t var $limit = 10; | ||
| 391 : | t | ||
| 392 : | t function basicAdminHTML (&$controller, $limit) { | ||
| 393 : | t $this->act = $controller->admin->act; | ||
| 394 : | t $this->limit = $limit; | ||
| 395 : | t $this->pageNav = $controller->pageNav; | ||
| 396 : | t $this->option = strtolower(mosGetParam($_REQUEST,'option','com_admin')); | ||
| 397 : | t } | ||
| 398 : | t | ||
| 399 : | t function tickBox ($object, $property) { | ||
| 400 : | t if (is_object($object) AND $object->$property) $checked = "checked='checked'"; | ||
| 401 : | t else $checked = ''; | ||
| 402 : | t echo "<td><input type='checkbox' name='$property' value='1' $checked /></td>"; | ||
| 403 : | t } | ||
| 404 : | t | ||
| 405 : | t function yesNoList ($object, $property) { | ||
| 406 : | t $yesno[] = mosHTML::makeOption( 0, _NO ); | ||
| 407 : | t $yesno[] = mosHTML::makeOption( 1, _YES ); | ||
| 408 : | t if ($object) $default = $object->$property; | ||
| 409 : | t else $default = 0; | ||
| 410 : | t echo '<td valign="top">'; | ||
| 411 : | t echo mosHTML::selectList($yesno, $property, 'class="inputbox" size="1"', 'value', 'text', $default);; | ||
| 412 : | t echo '</td></tr>'; | ||
| 413 : | t } | ||
| 414 : | t | ||
| 415 : | t function inputTop ($title, $redstar=false, $maxsize=0) { | ||
| 416 : | t ?> | ||
| 417 : | t <tr> | ||
| 418 : | t <td width="30%" valign="top" align="right"> | ||
| 419 : | t <b><?php if ($redstar) echo '<font color="red">*</font>'; echo $title; if ($maxsize) echo "</b> <br /><i>$maxsize</i> "; ?></b> | ||
| 420 : | t </td> | ||
| 421 : | t <?php | ||
| 422 : | t } | ||
| 423 : | t | ||
| 424 : | t function blankRow () { | ||
| 425 : | t ?> | ||
| 426 : | t <tr><td> </td></tr> | ||
| 427 : | t <?php | ||
| 428 : | t } | ||
| 429 : | t | ||
| 430 : | t function fileInputBox ($title, $name, $value, $width, $tooltip=null) { | ||
| 431 : | t $this->inputTop($title); | ||
| 432 : | t ?> | ||
| 433 : | t <td align="left" valign="top"> | ||
| 434 : | t <input class="inputbox" type="text" name="<?php echo $name; ?>" size="<?php echo $width; ?>" value="<?php echo $value; ?>" /> | ||
| 435 : | t <?php if ($tooltip) echo tooltip($tooltip); ?> | ||
| 436 : | t </td> | ||
| 437 : | t </tr> | ||
| 438 : | t <?php | ||
| 439 : | t } | ||
| 440 : | t | ||
| 441 : | t function fileInputArea ($title, $maxsize, $name, $value, $rows, $cols, $editor=false, $tooltip=null) { | ||
| 442 : | t $this->inputTop ($title, false, $maxsize); | ||
| 443 : | t echo '<td valign="top">'; | ||
| 444 : | t if ($editor) { | ||
| 445 : | t $box = "editorArea( 'description', '$value', '$name', 500, 200, $rows, $cols );"; | ||
| 446 : | t eval($box); | ||
| 447 : | t } | ||
| 448 : | t else echo "<textarea class='inputbox' name='$name' rows='$rows' cols='$cols'>$value</textarea>"; | ||
| 449 : | t if ($tooltip) echo tooltip($tooltip); | ||
| 450 : | t echo '</td></tr>'; | ||
| 451 : | t } | ||
| 452 : | t | ||
| 453 : | t function tickBoxField ($object, $property, $title) { | ||
| 454 : | t ?> | ||
| 455 : | t <tr> | ||
| 456 : | t <td width="30%" valign="top" align="right"> | ||
| 457 : | t <b><?php echo $title; ?></b> | ||
| 458 : | t </td> | ||
| 459 : | t <?php | ||
| 460 : | t $this->tickBox($object,$property); | ||
| 461 : | t echo '</tr>'; | ||
| 462 : | t } | ||
| 463 : | t | ||
| 464 : | t function simpleTickBox ($title, $name, $checked=false) { | ||
| 465 : | t $this->inputTop($title); | ||
| 466 : | t if ($checked) $check = 'checked="checked"'; | ||
| 467 : | t else $check = ''; | ||
| 468 : | t ?> | ||
| 469 : | t <td> | ||
| 470 : | t <input type="checkbox" name="<?php echo $name; ?>" value="1" <?php echo $check; ?> /> | ||
| 471 : | t </td> | ||
| 472 : | t </tr> | ||
| 473 : | t <?php | ||
| 474 : | t } | ||
| 475 : | t function formStart ($title, $imagepath) { | ||
| 476 : | t ?> | ||
| 477 : | t <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div> | ||
| 478 : | t <script language="Javascript" src="../includes/js/overlib_mini.js"></script> | ||
| 479 : | t <form action="index2.php" method="post" name="adminForm"> | ||
| 480 : | t <table cellpadding="4" cellspacing="0" border="0" width="100%"> | ||
| 481 : | t <tr> | ||
| 482 : | t <td width="100%" colspan="4"> | ||
| 483 : | t <div class="title"> | ||
| 484 : | t <img src="<?php echo $imagepath; ?>" alt="<?php echo $title; ?>" /> | ||
| 485 : | t <span class="sectionname"> <?php echo T_('Mambo '); echo $title; ?></span> | ||
| 486 : | t </div> | ||
| 487 : | t </td> | ||
| 488 : | t </tr> | ||
| 489 : | t <?php | ||
| 490 : | t } | ||
| 491 : | t | ||
| 492 : | t function listHeadingStart ($count) { | ||
| 493 : | t ?> | ||
| 494 : | t <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist"> | ||
| 495 : | t <tr> | ||
| 496 : | t <th width="5" align="left"> | ||
| 497 : | t <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo $count; ?>);" /> | ||
| 498 : | t </th> | ||
| 499 : | t <?php | ||
| 500 : | t } | ||
| 501 : | t | ||
| 502 : | t function headingItem ($width, $title, $colspan=1) { | ||
| 503 : | t if ($colspan > 1) $colcode = " colspan=\"$colspan\""; | ||
| 504 : | t else $colcode = ''; | ||
| 505 : | t echo "<th width=\"$width\" align=\"left\"$colcode>$title</th>"; | ||
| 506 : | t } | ||
| 507 : | t | ||
| 508 : | t function commonScripts ($edit_fields) { | ||
| 509 : | t ?> | ||
| 510 : | t <script type="text/javascript"> | ||
| 511 : | t function submitbutton(pressbutton) { | ||
| 512 : | t <?php | ||
| 513 : | t if (is_array($edit_fields)) foreach ($edit_fields as $field) getEditorContents( $field, $field ); | ||
| 514 : | t else getEditorContents ($edit_fields, $edit_fields); | ||
| 515 : | t ?> | ||
| 516 : | t submitform( pressbutton ); | ||
| 517 : | t } | ||
| 518 : | t </script> | ||
| 519 : | t <?php | ||
| 520 : | t } | ||
| 521 : | t | ||
| 522 : | t function listFormEnd ($pagecontrol=true) { | ||
| 523 : | t if ($pagecontrol) { | ||
| 524 : | t ?> | ||
| 525 : | t <tr> | ||
| 526 : | t <th align="center" colspan="10"> <?php echo $this->pageNav->writePagesLinks(); ?></th> | ||
| 527 : | t </tr> | ||
| 528 : | t <tr> | ||
| 529 : | t <td align="center" colspan="10"> <?php echo $this->pageNav->writePagesCounter(); ?></td> | ||
| 530 : | t </tr> | ||
| 531 : | t <?php | ||
| 532 : | t } | ||
| 533 : | t ?> | ||
| 534 : | t <input type="hidden" name="option" value="<?php echo $this->option; ?>" /> | ||
| 535 : | t <input type="hidden" name="task" value="" /> | ||
| 536 : | t <input type="hidden" name="act" value="<?php echo $this->act; ?>" /> | ||
| 537 : | t <input type="hidden" name="boxchecked" value="0" /> | ||
| 538 : | t </table> | ||
| 539 : | t </form> | ||
| 540 : | t <?php | ||
| 541 : | t } | ||
| 542 : | t | ||
| 543 : | t function editFormEnd ($id) { | ||
| 544 : | t ?> | ||
| 545 : | t <input type="hidden" name="cfid" value="<?php echo $id; ?>" /> | ||
| 546 : | t <input type="hidden" name="limit" value="<?php echo $this->limit; ?>" /> | ||
| 547 : | t <input type="hidden" name="option" value="<?php echo $this->option; ?>" /> | ||
| 548 : | t <input type="hidden" name="task" value="" /> | ||
| 549 : | t <input type="hidden" name="act" value="<?php echo $this->act; ?>" /> | ||
| 550 : | t </table> | ||
| 551 : | t </form> | ||
| 552 : | t <?php | ||
| 553 : | t } | ||
| 554 : | t | ||
| 555 : | t function multiOptionList ($name, $title, $options, $current, $tooltip=null) { | ||
| 556 : | t $alternatives = explode(',',$options); | ||
| 557 : | t $already = explode(',', $current); | ||
| 558 : | t ?> | ||
| 559 : | t <tr> | ||
| 560 : | t <td width="30%" valign="top" align="right"> | ||
| 561 : | t <b><?php echo $title; ?></b> | ||
| 562 : | t </td> | ||
| 563 : | t <td valign="top"> | ||
| 564 : | t <?php | ||
| 565 : | t foreach ($alternatives as $one) { | ||
| 566 : | t if (in_array($one,$already)) $mark = 'checked="checked"'; | ||
| 567 : | t else $mark = ''; | ||
| 568 : | t $value = $name.'_'.$one; | ||
| 569 : | t echo "<input type=\"checkbox\" name=\"$value\" $mark />$one"; | ||
| 570 : | t } | ||
| 571 : | t if ($tooltip) echo ' '.tooltip($tooltip); | ||
| 572 : | t echo '</td></tr>'; | ||
| 573 : | t } | ||
| 574 : | t | ||
| 575 : | t function tooltip ($text) { | ||
| 576 : | t return '<a href="javascript:void(0)" onmouseover="return escape('."'".$text."'".')">'.mamboCore::get('mosConfig_live_site').'/includes/js/ThemeOffice/tooltip.png</a>'; | ||
| 577 : | t } | ||
| 578 : | t | ||
| 579 : | t } | ||
| 580 : | t | ||
| 581 : | t /** | ||
| 582 : | mambo | 117 | * @param string THe template position |
| 583 : | */ | ||
| 584 : | function mosCountAdminModules( $position='left' ) { | ||
| 585 : | counterpoi | 238 | t $handler =& mosModuleHandler::getInstance(); |
| 586 : | csouza | 149 | return $handler->mosCountModules($position, true); |
| 587 : | mambo | 117 | } |
| 588 : | /** | ||
| 589 : | * Loads admin modules via module position | ||
| 590 : | * @param string The position | ||
| 591 : | * @param int 0 = no style, 1 = tabbed | ||
| 592 : | */ | ||
| 593 : | function mosLoadAdminModules( $position='left', $style=0 ) { | ||
| 594 : | counterpoi | 238 | t $handler =& mosModuleHandler::getInstance(); |
| 595 : | csouza | 149 | return $handler->mosLoadAdminModules($position, $style); |
| 596 : | mambo | 117 | } |
| 597 : | /** | ||
| 598 : | * Loads an admin module | ||
| 599 : | */ | ||
| 600 : | function mosLoadAdminModule( $name, $params=NULL ) { | ||
| 601 : | global $mosConfig_absolute_path, $mosConfig_live_site; | ||
| 602 : | csouza | 149 | global $database, $acl, $my, $mainframe, $option; |
| 603 : | global $task, $act; | ||
| 604 : | |||
| 605 : | mambo | 117 | $name = str_replace( '/', '', $name ); |
| 606 : | $name = str_replace( '\\', '', $name ); | ||
| 607 : | csouza | 149 | $path = mamboCore::get('mosConfig_absolute_path')."/administrator/modules/mod_$name.php"; |
| 608 : | if (file_exists($path)) require $path; | ||
| 609 : | mambo | 117 | } |
| 610 : | |||
| 611 : | function mosLoadCustomModule( &$module, &$params ) { | ||
| 612 : | csouza | 151 | die ("The function mosLoadCustomModule has had its code removed as it appears unused"); |
| 613 : | mambo | 117 | } |
| 614 : | |||
| 615 : | function mosShowSource( $filename, $withLineNums=false ) { | ||
| 616 : | ini_set('highlight.html', '000000'); | ||
| 617 : | ini_set('highlight.default', '#800000'); | ||
| 618 : | ini_set('highlight.keyword','#0000ff'); | ||
| 619 : | ini_set('highlight.string', '#ff00ff'); | ||
| 620 : | ini_set('highlight.comment','#008000'); | ||
| 621 : | |||
| 622 : | if (!($source = @highlight_file( $filename, true ))) { | ||
| 623 : | return 'Operation Failed'; | ||
| 624 : | } | ||
| 625 : | $source = explode("<br />", $source); | ||
| 626 : | |||
| 627 : | $ln = 1; | ||
| 628 : | |||
| 629 : | $txt = ''; | ||
| 630 : | foreach( $source as $line ) { | ||
| 631 : | $txt .= "<code>"; | ||
| 632 : | if ($withLineNums) { | ||
| 633 : | $txt .= "<font color=\"#aaaaaa\">"; | ||
| 634 : | $txt .= str_replace( ' ', ' ', sprintf( "%4d:", $ln ) ); | ||
| 635 : | $txt .= "</font>"; | ||
| 636 : | } | ||
| 637 : | $txt .= "$line<br /><code>"; | ||
| 638 : | $ln++; | ||
| 639 : | } | ||
| 640 : | return $txt; | ||
| 641 : | } | ||
| 642 : | |||
| 643 : | function mosIsChmodable($file) | ||
| 644 : | { | ||
| 645 : | $perms = fileperms($file); | ||
| 646 : | if ($perms !== FALSE) | ||
| 647 : | if (@chmod($file, $perms ^ 0001)) { | ||
| 648 : | @chmod($file, $perms); | ||
| 649 : | return TRUE; | ||
| 650 : | } // if | ||
| 651 : | return FALSE; | ||
| 652 : | } // mosIsChmodable | ||
| 653 : | |||
| 654 : | /** | ||
| 655 : | * @param string An existing base path | ||
| 656 : | * @param string A path to create from the base path | ||
| 657 : | * @param int Directory permissions | ||
| 658 : | * @return boolean True if successful | ||
| 659 : | */ | ||
| 660 : | function mosMakePath($base, $path='', $mode = NULL) | ||
| 661 : | { | ||
| 662 : | global $mosConfig_dirperms; | ||
| 663 : | |||
| 664 : | // convert windows paths | ||
| 665 : | $path = str_replace( '\\', '/', $path ); | ||
| 666 : | $path = str_replace( '//', '/', $path ); | ||
| 667 : | |||
| 668 : | // check if dir exists | ||
| 669 : | if (file_exists( $base . $path )) return true; | ||
| 670 : | |||
| 671 : | // set mode | ||
| 672 : | $origmask = NULL; | ||
| 673 : | if (isset($mode)) { | ||
| 674 : | $origmask = @umask(0); | ||
| 675 : | } else { | ||
| 676 : | if ($mosConfig_dirperms=='') { | ||
| 677 : | // rely on umask | ||
| 678 : | $mode = 0777; | ||
| 679 : | } else { | ||
| 680 : | $origmask = @umask(0); | ||
| 681 : | $mode = octdec($mosConfig_dirperms); | ||
| 682 : | } // if | ||
| 683 : | } // if | ||
| 684 : | |||
| 685 : | $parts = explode( '/', $path ); | ||
| 686 : | $n = count( $parts ); | ||
| 687 : | $ret = true; | ||
| 688 : | if ($n < 1) { | ||
| 689 : | $ret = @mkdir($base, $mode); | ||
| 690 : | } else { | ||
| 691 : | $path = $base; | ||
| 692 : | for ($i = 0; $i < $n; $i++) { | ||
| 693 : | $path .= $parts[$i] . '/'; | ||
| 694 : | if (!file_exists( $path )) { | ||
| 695 : | if (!@mkdir( $path, $mode )) { | ||
| 696 : | $ret = false; | ||
| 697 : | break; | ||
| 698 : | } | ||
| 699 : | } | ||
| 700 : | } | ||
| 701 : | } | ||
| 702 : | if (isset($origmask)) @umask($origmask); | ||
| 703 : | return $ret; | ||
| 704 : | } | ||
| 705 : | |||
| 706 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

