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