Source for file admin.php

Documentation is available at admin.php

  1. <?php
  2. /**
  3. @package Mambo
  4. @author Mambo Foundation Inc see README.php
  5. @copyright Mambo Foundation Inc.
  6. *  See COPYRIGHT.php for copyright notices and details.
  7. @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see
  8. *  LICENSE.php
  9. *  Mambo is free software; you can redistribute it and/or
  10. *  modify it under the terms of the GNU General Public License
  11. *  as published by the Free Software Foundation; version 2 of the
  12. *  License.
  13. */ 
  14.  
  15. /** ensure this file is being included by a parent file */
  16. defined'_VALID_MOS' or die'Direct Access to this location is not allowed.' );
  17.  
  18. /**
  19. * Basic XML parsing of installation files
  20. ***/
  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($fp4096AND $this->errors->getMaxLevel(_MOS_ERROR_FATAL{
  48.                 $data str_replace('&'' ampersand '$data);
  49.                 $ret xml_parse($parser$datafeof($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_FATALreturn;
  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[$keystr_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_FATALreturn;
  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 = 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_FATALreturn;
  120.         $this->chardata .= trim($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.  
  144. class mosXMLDescription extends mosBasicXML {
  145.     var $values = array();
  146.  
  147.     function getDescription ($type{
  148.         if ($type == $this->type AND isset($this->values['DESCRIPTION'])) return $this->values['DESCRIPTION'];
  149.         else return '';
  150.     }
  151.  
  152.     function getName ($type{
  153.         if ($type == $this->type AND isset($this->values['NAME'])) return $this->values['NAME'];
  154.         else return '';
  155.     }
  156.  
  157.     function getGroup ($type{
  158.         if ($type == $this->type AND isset($this->values['GROUP'])) return $this->values['GROUP'];
  159.         else return '';
  160.     }
  161.  
  162.     function getCreationDate ($type{
  163.         if ($type == $this->type AND isset($this->values['CREATIONDATE'])) return $this->values['CREATIONDATE'];
  164.         else return '';
  165.     }
  166.  
  167.     function getAuthor ($type{
  168.         if ($type == $this->type AND isset($this->values['AUTHOR'])) return $this->values['AUTHOR'];
  169.         else return '';
  170.     }
  171.  
  172.     function getCopyright ($type{
  173.         if ($type == $this->type AND isset($this->values['COPYRIGHT'])) return $this->values['COPYRIGHT'];
  174.         else return '';
  175.     }
  176.  
  177.     function getAuthorEmail ($type{
  178.         if ($type == $this->type AND isset($this->values['AUTHOREMAIL'])) return $this->values['AUTHOREMAIL'];
  179.         else return '';
  180.     }
  181.  
  182.     function getAuthorUrl ($type{
  183.         if ($type == $this->type AND isset($this->values['AUTHORURL'])) return $this->values['AUTHORURL'];
  184.         else return '';
  185.     }
  186.  
  187.     function getVersion ($type{
  188.         if ($type == $this->type AND isset($this->values['VERSION'])) return $this->values['VERSION'];
  189.         else return '';
  190.     }
  191.  
  192. }
  193.  
  194. class mosXMLParams extends mosXMLDescription {
  195.     var $options = array();
  196.     var $optvalue = '';
  197.     var $paramattrs = array();
  198.     var $paramcount = 0;
  199.     var $html = array();
  200.  
  201.     function element_params ($attrs{
  202.         $this->html['<table class="paramlist">';
  203.         if (isset($attrs['NAME'])) {
  204.             $pname $attrs['NAME'];
  205.             $this->html["<tr><td colspan='3'>$pname</td></tr>";
  206.         }
  207.     }
  208.  
  209.     function element_param ($attrs{
  210.         $this->paramattrs = $attrs;
  211.     }
  212.  
  213.     function element_option ($attrs{
  214.         if (isset($attrs['VALUE'])) $this->optvalue = $attrs['VALUE'];
  215.     }
  216.  
  217.     function end_element_option ({
  218.         $this->options[mosHTML::makeOption($this->optvalueT_($this->chardata));
  219.         $this->optvalue = '';
  220.     }
  221.  
  222.     function end_element_param ({
  223.         $type mosGetParam ($this->paramattrs'TYPE''');
  224.         $name mosGetParam ($this->paramattrs'NAME''');
  225.         $label T_(mosGetParam ($this->paramattrs'LABEL'$name));
  226.         $default T_(mosGetParam ($this->paramattrs'DEFAULT'''));
  227.         if ($description mosGetParam ($this->paramattrs'DESCRIPTION''')) $tooltip mosToolTip(T_($description)$name);
  228.         else $tooltip '';
  229.         if (is_object($this->mosParameter)) {
  230.             $mp $this->mosParameter;
  231.             $value $mp->get($name$default);
  232.         }
  233.         else $value $default;
  234.         $this->html['<tr>';
  235.         if ($label == '@spacer'$label '<hr />';
  236.         elseif ($label$label .= ':';
  237.         $this->html['<td width="35%" align="right" valign="top">'.$label.'</td>';
  238.         $controlname $this->name;
  239.         switch ($type{
  240.             case 'text':
  241.                 $size mosGetParam ($this->paramattrs'SIZE'0);
  242.                 $controlstring '<input type="text" name="'.$this->name.'['.$name.']" value="'.$value.'" class="text_area" size="'.$size.'" />';
  243.                 break;
  244.             case 'list':
  245.                 $controlstring mosHTML::selectList($this->options$controlname.'['.$name.']''class="inputbox"''value''text'$value);
  246.                 break;
  247.             case 'radio':
  248.                 $controlstring mosHTML::radioList($this->options$controlname.'['.$name.']'''$value);
  249.                 break;
  250.             case 'imagelist':
  251.                 $directory new mosDirectory (mamboCore::get('mosConfig_absolute_path').mosGetParam($this->paramattrs'DIRECTORY'''));
  252.                 $files $directory->listFiles ('\.png$|\.gif$|\.jpg$|\.bmp$|\.ico$');
  253.                 $options array();
  254.                 foreach ($files as $file$options[mosHTML::makeOption($file$file);
  255.                 if (!isset($this->paramattrs['HIDE_NONE'])) array_unshift($optionsmosHTML::makeOption('-1''- Do not use an image -' ));
  256.                 if (!isset($this->paramattrs['HIDE_DEFAULT'])) array_unshift($optionsmosHTML::makeOption('''- Use Default image -'));
  257.                 $controlstring mosHTML::selectList ($options$controlname.'['.$name.']''class="inputbox"''value''text'$value);
  258.                 break;
  259.             case 'textarea':
  260.                 $rows mosGetParam ($this->paramattrs'ROWS'0);
  261.                 $cols mosGetParam ($this->paramattrs'COLS'0);
  262.                 $value str_replace ('<br />'"\n"$value);
  263.                 $controlstring "<textarea name='params[$name]' cols='$cols' rows='$rows' class='text_area'>$value</textarea>";
  264.                 break;
  265.             case 'spacer':
  266.                 $controlstring $value $value '<hr />';
  267.                 break;
  268.             case 'mos_section':
  269.                 $controlstring $this->_form_mos_section($name$value$controlname);
  270.                 break;
  271.             case 'mos_category':
  272.                 $controlstring $this->_form_mos_category($name$value$controlname);
  273.                 break;
  274.             case 'mos_menu':
  275.                 $controlstring $this->_form_mos_menu($name$value$controlname);
  276.                 break;
  277.             default:
  278.                 $controlstring T_('Handler not defined for type').'='.$type;
  279.         }
  280.         //        $this->html[] = "<td>$type</td>";
  281.         $this->html["<td>$controlstring</td>";
  282.         $this->html["<td width='10%' align='left' valign='top'>$tooltip</td>";
  283.         $this->html['</tr>';
  284.         $this->options = array();
  285.         $this->paramattrs = array();
  286.         $this->paramcount++;
  287.     }
  288.  
  289.     function end_element_params ({
  290.         $this->html['</table>';
  291.         if ($this->paramcount == 0$this->html['<tr><td colspan="2"><i>'.T_('There are no Parameters for this item').'</i></td></tr>';
  292.         $this->paramcount = 0;
  293.     }
  294.     /**
  295.     * @param string The name of the form element
  296.     * @param string The value of the element
  297.     * @param object The xml element for the parameter
  298.     * @param string The control name
  299.     * @return string The html for the element
  300.     */
  301.     function _form_mos_section$name$value$control_name {
  302.         $database =mamboDatabase::getInstance();
  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($optionsmosHTML::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($optionsmosHTML::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$optionsmosHTML::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.  
  378.     function mosSpecialAdminParameters ($name$version=''{
  379.         $database =mamboDatabase::getInstance();
  380.         $sql "SELECT * FROM #__parameters WHERE param_name='$name'";
  381.         if ($version$sql .= " AND param_version='$version'";
  382.         $database->setQuery($sql);
  383.         $parameters $database->loadObjectList();
  384.         if ($parameters$parameters $parameters[0];
  385.         parent::mosAdminParameters($parameters->paramsmamboCore::get('mosConfig_absolute_path').'/parameters/'.$parameters->param_file);
  386.     }
  387. }
  388.  
  389. /**
  390. * Useful HTML class for admin side components
  391. @package Mambo
  392. */
  393. class basicAdminHTML {
  394.     var $pageNav = '';
  395.     var $option = '';
  396.     var $act = '';
  397.     var $limit = 10;
  398.  
  399.     function basicAdminHTML (&$controller$limit{
  400.         $this->act = $controller->admin->act;
  401.         $this->limit = $limit;
  402.         $this->pageNav = $controller->pageNav;
  403.         $this->option = strtolower(mosGetParam($_REQUEST,'option','com_admin'));
  404.     }
  405.  
  406.     function tickBox ($object$property{
  407.         if (is_object($objectAND $object->$property$checked "checked='checked'";
  408.         else $checked '';
  409.         echo "<td><input type='checkbox' name='$property' value='1' $checked /></td>";
  410.     }
  411.  
  412.     function yesNoList ($object$property{
  413.         $yesno[mosHTML::makeOption0_NO );
  414.         $yesno[mosHTML::makeOption1_YES );
  415.         if ($object$default $object->$property;
  416.         else $default 0;
  417.         echo '<td valign="top">';
  418.         echo mosHTML::selectList($yesno$property'class="inputbox" size="1"''value''text'$default);;
  419.         echo '</td></tr>';
  420.     }
  421.  
  422.     function inputTop ($title$redstar=false$maxsize=0{
  423.         ?>
  424.         <tr>
  425.               <td width="30%" valign="top" align="right">
  426.                 <b><?php if ($redstarecho '<font color="red">*</font>'echo $titleif ($maxsizeecho "</b>&nbsp;<br /><i>$maxsize</i>&nbsp;"?></b>&nbsp;
  427.             </td>
  428.         <?php
  429.     }
  430.  
  431.     function blankRow ({
  432.         ?>
  433.             <tr><td>&nbsp;</td></tr>
  434.         <?php
  435.     }
  436.  
  437.     function fileInputBox ($title$name$value$width$tooltip=null{
  438.         $this->inputTop($title);
  439.         ?>
  440.             <td align="left" valign="top">
  441.                 <input class="inputbox" type="text" name="<?php echo $name?>" size="<?php echo $width?>" value="<?php echo $value?>" />
  442.                 <?php if ($tooltipecho tooltip($tooltip)?>
  443.             </td>
  444.         </tr>
  445.         <?php
  446.     }
  447.  
  448.     function fileInputArea ($title$maxsize$name$value$rows$cols$editor=false$tooltip=null{
  449.         $this->inputTop ($titlefalse$maxsize);
  450.         echo '<td valign="top">';
  451.         if ($editor{
  452.             $box "editorArea( 'description', '$value', '$name', 500, 200, $rows$cols );";
  453.             eval($box);
  454.         }
  455.         else echo "<textarea class='inputbox' name='$name' rows='$rows' cols='$cols'>$value</textarea>";
  456.         if ($tooltipecho tooltip($tooltip);
  457.         echo '</td></tr>';
  458.     }
  459.  
  460.     function tickBoxField ($object$property$title{
  461.         ?>
  462.         <tr>
  463.             <td width="30%" valign="top" align="right">
  464.                 <b><?php echo $title?></b>&nbsp;
  465.             </td>
  466.         <?php
  467.         $this->tickBox($object,$property);
  468.         echo '</tr>';
  469.     }
  470.  
  471.     function simpleTickBox ($title$name$checked=false{
  472.         $this->inputTop($title);
  473.         if ($checked$check 'checked="checked"';
  474.         else $check '';
  475.         ?>
  476.             <td>
  477.                 <input type="checkbox" name="<?php echo $name?>" value="1" <?php echo $check?> />
  478.             </td>
  479.         </tr>
  480.         <?php
  481.     }
  482.     function formStart ($title$imagepath{
  483.         ?>
  484.         <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
  485.         <script language="Javascript" src="../includes/js/overlib_mini.js"></script>
  486.         <form action="index2.php" method="post" name="adminForm">
  487.         <table cellpadding="4" cellspacing="0" border="0" width="100%">
  488.            <tr>
  489.             <td width="100%" colspan="4">
  490.             <div class="title">
  491.             <img src="<?php echo $imagepath?>" alt="<?php echo $title?>" />
  492.             <span class="sectionname">&nbsp;<?php echo $title?></span>
  493.             </div>
  494.             </td>
  495.         </tr>
  496.         <?php
  497.     }
  498.  
  499.     function listHeadingStart ($count{
  500.         ?>
  501.         <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
  502.             <tr>
  503.                 <th width="5" align="left">
  504.                     <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo $count?>);" />
  505.                 </th>
  506.         <?php
  507.     }
  508.  
  509.     function headingItem ($width$title$colspan=1{
  510.         if ($colspan 1$colcode " colspan=\"$colspan\"";
  511.         else $colcode '';
  512.         echo "<th width=\"$width\" align=\"left\"$colcode>$title</th>";
  513.     }
  514.  
  515.     function commonScripts ($edit_fields{
  516.         ?>
  517.         <script type="text/javascript">
  518.         function submitbutton(pressbutton) {
  519.             <?php
  520.             if (is_array($edit_fields)) foreach ($edit_fields as $fieldgetEditorContents$field$field );
  521.             else getEditorContents ($edit_fields$edit_fields);
  522.             ?>
  523.             submitform( pressbutton );
  524.         }
  525.         </script>
  526.         <?php
  527.     }
  528.  
  529.     function listFormEnd ($pagecontrol=true{
  530.         if ($pagecontrol{
  531.             ?>
  532.             <tr>
  533.                 <th align="center" colspan="10"> <?php echo $this->pageNav->writePagesLinks()?></th>
  534.             </tr>
  535.             <tr>
  536.                 <td align="center" colspan="10"> <?php echo $this->pageNav->writePagesCounter()?></td>
  537.             </tr>
  538.             <?php
  539.         }
  540.         ?>
  541.         <input type="hidden" name="option" value="<?php echo $this->option?>" />
  542.         <input type="hidden" name="task" value="" />
  543.         <input type="hidden" name="act" value="<?php echo $this->act?>" />
  544.         <input type="hidden" name="boxchecked" value="0" />
  545.         </table>
  546.         </form>
  547.         <?php
  548.     }
  549.  
  550.     function editFormEnd ($id{
  551.         ?>
  552.         <input type="hidden" name="cfid" value="<?php echo $id?>" />
  553.         <input type="hidden" name="limit" value="<?php echo $this->limit?>" />
  554.         <input type="hidden" name="option" value="<?php echo $this->option?>" />
  555.         <input type="hidden" name="task" value="" />
  556.         <input type="hidden" name="act" value="<?php echo $this->act?>" />
  557.         </table>
  558.         </form>
  559.         <?php
  560.     }
  561.  
  562.     function multiOptionList ($name$title$options$current$tooltip=null{
  563.         $alternatives explode(',',$options);
  564.         $already explode(','$current);
  565.         ?>
  566.         <tr>
  567.         <td width="30%" valign="top" align="right">
  568.           <b><?php echo $title?></b>&nbsp;
  569.         </td>
  570.         <td valign="top">
  571.         <?php
  572.         foreach ($alternatives as $one{
  573.             if (in_array($one,$already)) $mark 'checked="checked"';
  574.             else $mark '';
  575.             $value $name.'_'.$one;
  576.             echo "<input type=\"checkbox\" name=\"$value\" $mark />$one";
  577.         }
  578.         if ($tooltipecho '&nbsp;'.tooltip($tooltip);
  579.         echo '</td></tr>';
  580.     }
  581.  
  582.     function tooltip ($text{
  583.         return '<a href="javascript:void(0)"  onmouseover="return escape('."'".$text."'".')">'.mamboCore::get('mosConfig_live_site').'/includes/js/ThemeOffice/tooltip.png</a>';
  584.     }
  585.  
  586. }
  587.  
  588. /**
  589. @param string THe template position
  590. */
  591. function mosCountAdminModules(  $position='left' {
  592.     $handler =mosModuleHandler::getInstance();
  593.     return $handler->mosCountModules($positiontrue);
  594. }
  595. /**
  596. * Loads admin modules via module position
  597. @param string The position
  598. @param int 0 = no style, 1 = tabbed
  599. */
  600. function mosLoadAdminModules$position='left'$style={
  601.     $handler =mosModuleHandler::getInstance();
  602.     return $handler->mosLoadAdminModules($position$style);
  603. }
  604. /**
  605. * Loads an admin module
  606. */
  607. function mosLoadAdminModule$name$params=NULL {
  608.     global $mosConfig_absolute_path$mosConfig_live_site;
  609.     global $database$acl$my$mainframe$option;
  610.     global $task$act;
  611.  
  612.     $name str_replace'/'''$name );
  613.     $name str_replace'\\'''$name );
  614.     $path mamboCore::get('mosConfig_absolute_path')."/administrator/modules/mod_$name.php";
  615.     if (file_exists($path)) require $path;
  616. }
  617.  
  618. function mosLoadCustomModule&$module&$params {
  619.     // custom module params
  620.     $rssurl             $params->get'rssurl' );
  621.     $rssitems             $params->get'rssitems');
  622.     $rssdesc             $params->get'rssdesc');
  623.     $rssimage             $params->get'rssimage');
  624.     $rssitemdesc        $params->get'rssitemdesc');
  625.     $moduleclass_sfx     $params->get'moduleclass_sfx' );
  626.     $words                 $params->def'word_count');
  627.     // feed output
  628.     if $rssurl {
  629.         if (!defined('MAGPIE_CACHE_DIR')) define ('MAGPIE_CACHE_DIR'mamboCore::get('mosConfig_absolute_path').'/includes/magpie_cache');
  630.         require_once (mamboCore::get('mosConfig_absolute_path').'/includes/magpierss/rss_fetch.php');
  631.         $rss fetch_rss($rssurl);
  632.         if (isset($rss->image['title'])) $iTitle $rss->image['title'];
  633.         if (isset($rss->image['url'])) $iUrl $rss->image['url'];
  634.         // feed title
  635.             ?>
  636.             <table cellpadding="0" cellspacing="0" class="moduletable<?php echo $moduleclass_sfx?>">
  637.                 <?php
  638.                 // feed description
  639.                 if $rssdesc {
  640.                     ?>
  641.                     <tr>
  642.                         <td>
  643.                         <?php echo $rss->channel['description']?>
  644.                         </td>
  645.                     </tr>
  646.                     <?php
  647.                 }
  648.                 // feed image
  649.                 if $rssimage AND isset($iUrl) ) {
  650.                     ?>
  651.                     <tr>
  652.                         <td align="center">
  653.                         <image src="<?php echo $iUrl?>" alt="<?php echo $iTitle?>"/>
  654.                         </td>
  655.                     </tr>
  656.                     <?php
  657.                 }
  658.                 $itemnumber 1;
  659.                 ?>
  660.                 <tr>
  661.                     <td>
  662.                     <ul class="newsfeed<?php echo $moduleclass_sfx?>">
  663.                 <?php
  664.                 if(is_object($rss)){
  665.                     foreach ($rss->items as $item{
  666.                         if ($itemnumber $rssitemsbreak;
  667.                         $itemnumber++;
  668.                         // item title
  669.                         ?>
  670.                         <li class="newsfeed<?php echo $moduleclass_sfx?>">
  671.                         <strong>
  672.                         <a href="<?php echo $item['link']?>" target="_blank">
  673.                         <?php echo $item['title']?>
  674.                         </a>
  675.                         </strong>
  676.                         <?php
  677.                         // item description
  678.                         if $rssitemdesc {
  679.                             // item description
  680.                             $text html_entity_decode$item['description');
  681.                             // word limit check
  682.                             if $words {
  683.                                 $texts explode' '$text );
  684.                                 $count count$texts );
  685.                                 if $count $words {
  686.                                     $text '';
  687.                                     for$i=0$i $words$i++ {
  688.                                         $text .= ' '$texts[$i];
  689.                                     }
  690.                                     $text .= '...';
  691.                                 }
  692.                             }
  693.                             ?>
  694.                             <div>
  695.                             <?php echo $text?>
  696.                             </div>
  697.                             <?php
  698.                         }
  699.                         ?>
  700.                         </li>
  701.                         <?php
  702.                     }
  703.                 }
  704.                 ?>
  705.                 </ul>
  706.                 </td>
  707.             </tr>
  708.         </table>
  709.         <?php
  710.     }else{
  711.         if ($module->content{
  712.             $moduleclass_sfx $params->get'moduleclass_sfx''' );
  713.             echo '<table cellpadding="0" cellspacing="0" class="moduletable' $moduleclass_sfx '">';
  714.             echo '<tr>';
  715.             echo '<td>' $module->content '</td>';
  716.             echo '</tr>';
  717.             echo '</table>';
  718.         }
  719.     }
  720. }
  721.  
  722. function mosShowSource$filename$withLineNums=false {
  723.     ini_set('highlight.html''000000');
  724.     ini_set('highlight.default''#800000');
  725.     ini_set('highlight.keyword','#0000ff');
  726.     ini_set('highlight.string''#ff00ff');
  727.     ini_set('highlight.comment','#008000');
  728.  
  729.     if (!($source @highlight_file$filenametrue ))) {
  730.         return 'Operation Failed';
  731.     }
  732.     $source explode("<br />"$source);
  733.  
  734.     $ln 1;
  735.  
  736.     $txt '';
  737.     foreach$source as $line {
  738.         $txt .= "<code>";
  739.         if ($withLineNums{
  740.             $txt .= "<font color=\"#aaaaaa\">";
  741.             $txt .= str_replace' ''&nbsp;'sprintf"%4d:"$ln ) );
  742.             $txt .= "</font>";
  743.         }
  744.         $txt .= "$line<br /><code>";
  745.         $ln++;
  746.     }
  747.     return $txt;
  748. }
  749.  
  750. function mosIsChmodable($file)
  751. {
  752.     $perms fileperms($file);
  753.     if ($perms !== FALSE)
  754.     if (@chmod($file$perms 0001)) {
  755.         @chmod($file$perms);
  756.         return TRUE;
  757.     // if
  758.     return FALSE;
  759. // mosIsChmodable
  760.  
  761. /**
  762. @param string An existing base path
  763. @param string A path to create from the base path
  764. @param int Directory permissions
  765. @return boolean True if successful
  766. */
  767. function mosMakePath($base$path=''$mode NULL)
  768. {
  769.     global $mosConfig_dirperms;
  770.  
  771.     // convert windows paths
  772.     $path str_replace'\\''/'$path );
  773.     $path str_replace'//''/'$path );
  774.  
  775.     // check if dir exists
  776.     if (file_exists$base $path )) return true;
  777.  
  778.     // set mode
  779.     $origmask NULL;
  780.     if (isset($mode)) {
  781.         $origmask @umask(0);
  782.     else {
  783.         if ($mosConfig_dirperms==''{
  784.             // rely on umask
  785.             $mode 0777;
  786.         else {
  787.             $origmask @umask(0);
  788.             $mode octdec($mosConfig_dirperms);
  789.         // if
  790.     // if
  791.  
  792.     $parts explode'/'$path );
  793.     $n count$parts );
  794.     $ret true;
  795.     if ($n 1{
  796.         $ret @mkdir($base$mode);
  797.     else {
  798.         $path $base;
  799.         for ($i 0$i $n$i++{
  800.             $path .= $parts[$i'/';
  801.             if (!file_exists$path )) {
  802.                 if (!@mkdir$path$mode )) {
  803.                     $ret false;
  804.                     break;
  805.                 }
  806.             }
  807.         }
  808.     }
  809.     if (isset($origmask)) @umask($origmask);
  810.     return $ret;
  811. }
  812.  
  813. ?>

Documentation generated on Mon, 05 May 2008 16:16:00 +0400 by phpDocumentor 1.4.0