aliroXMLParams Class Reference

List of all members.

Public Member Functions

 __construct ()
 paramsFromFile ($xmlfile, $pobject, $controlname)
 paramsFromString ($xmlstring, $xmlfile, $pobject, $controlname)
 _form_mos_menu ($name, $value, $control_name)

Public Attributes

 $html = array()

Protected Member Functions

 T_ ($string)
 _form_mos_section ($name, $value, $control_name)
 _form_mos_category ($name, $value, $control_name)

Protected Attributes

 $xmlobject = null
 $paramcount = 0
 $translations = array()

Private Member Functions

 helpXgettext ()
 analyseXML ($pobject, $controlname)
 processParam ($param, $pobject, $controlname)


Detailed Description

Definition at line 46 of file aliroXMLParams.php.


Constructor & Destructor Documentation

aliroXMLParams::__construct (  ) 

Definition at line 52 of file aliroXMLParams.php.

00052                                    {
00053         $this->xmlobject = new aliroXML;
00054     }


Member Function Documentation

aliroXMLParams::helpXgettext (  )  [private]

Definition at line 56 of file aliroXMLParams.php.

References T_().

00056                                      {
00057         T_('There are no Parameters for this item');
00058     }

aliroXMLParams::paramsFromFile ( xmlfile,
pobject,
controlname 
)

Definition at line 60 of file aliroXMLParams.php.

References analyseXML(), and aliroRequest::getInstance().

00060                                                                       {
00061         try {
00062             $this->xmlobject->loadFile($xmlfile);
00063             return $this->analyseXML($pobject, $controlname);
00064         } catch (aliroXMLException $exception) {
00065                 aliroRequest::getInstance()->setErrorMessage ($exception->getMessage(), _ALIRO_ERROR_FATAL);
00066                 $this->xmlobject = null;
00067         }
00068     }

aliroXMLParams::paramsFromString ( xmlstring,
xmlfile,
pobject,
controlname 
)

Definition at line 70 of file aliroXMLParams.php.

References analyseXML(), and aliroRequest::getInstance().

00070                                                                                     {
00071         try {
00072             $this->xmlobject->loadString($xmlstring);
00073             return $this->analyseXML($pobject, $controlname);
00074         } catch (aliroXMLException $exception) {
00075                 aliroRequest::getInstance()->setErrorMessage ($exception->getMessage(), _ALIRO_ERROR_FATAL);
00076                 $this->xmlobject = null;
00077         }
00078     }

aliroXMLParams::analyseXML ( pobject,
controlname 
) [private]

Definition at line 80 of file aliroXMLParams.php.

References processParam(), and T_().

Referenced by paramsFromFile(), and paramsFromString().

00080                                                          {
00081         $this->html[] = '<table class="paramlist">';
00082         $params = $this->xmlobject->getXML('params->param');
00083         if ($params) foreach ($params as $aparam) {
00084             $this->processParam($aparam, $pobject, $controlname);
00085         }
00086         if ($this->paramcount == 0) {
00087             return <<<NULL_HTML
00088 
00089                 <table class="paramlist">
00090                     <tr>
00091                         <td colspan="2">
00092                             <i>{$this->T_('There are no Parameters for this item')}</i>
00093                         </td>
00094                     </tr>
00095                 </table>
00096 
00097 NULL_HTML;
00098 
00099         }
00100         $this->html[] = '</table>';
00101         $this->paramcount = 0;
00102         return implode("\n", $this->html);
00103     }

aliroXMLParams::T_ ( string  )  [protected]

Definition at line 105 of file aliroXMLParams.php.

Referenced by analyseXML(), helpXgettext(), and processParam().

00105                                     {
00106         return T_($string);
00107     }

aliroXMLParams::processParam ( param,
pobject,
controlname 
) [private]

Definition at line 109 of file aliroXMLParams.php.

References _form_mos_category(), _form_mos_menu(), _form_mos_section(), aliroEditor::getInstance(), aliroHTML::getInstance(), and T_().

Referenced by analyseXML().

00109                                                                    {
00110         $alirohtml = aliroHTML::getInstance();
00111 
00112         $type = (string) $param['type'];
00113         $name = (string) $param['name'];
00114         // if ($name) $this->html[] = "<tr><td colspan='3'>$name</td></tr>";
00115         $label = (string) $param['label'];
00116         $default = (string) $param['default'];
00117         if ($description = (string) $param['description']) $tooltip = $alirohtml->toolTip($description, $name);
00118         else $tooltip = '';
00119 
00120         if (is_object($pobject)) $value = $pobject->get($name, $default);
00121         else $value = $default;
00122 
00123         $this->html[] = '<tr>';
00124         if ($label == '@spacer') $label = '<hr />';
00125         elseif ($label) $label .= ':';
00126         $this->html[] = '<td width="35%" align="right" valign="top">'.$label.'</td>';
00127         switch ($type) {
00128             case 'text':
00129                 $size = (string) $param['size'];
00130                 $controlstring = '<input type="text" name="'.$controlname.'['.$name.']" value="'.$value.'" class="text_area" size="'.$size.'" />';
00131                 break;
00132             case 'list':
00133                 $options = array();
00134                 foreach ($param->option as $option) $options[] = $alirohtml->makeOption((string) $option['value'], (string) $option);
00135                 $controlstring = $alirohtml->selectList($options, $controlname.'['.$name.']', 'class="inputbox"', 'value', 'text', $value);
00136                 break;
00137             case 'radio':
00138                 $options = array();
00139                 foreach ($param->option as $option) $options[] = $alirohtml->makeOption((string) $option['value'], (string) $option);
00140                 $controlstring = $alirohtml->radioList($options, $controlname.'['.$name.']', '', $value);
00141                 break;
00142             case 'imagelist':
00143                 $directory = new aliroDirectory (_ALIRO_ABSOLUTE_PATH.(string) $param['directory']);
00144                 $files = $directory->listFiles ('\.png$|\.gif$|\.jpg$|\.bmp$|\.ico$');
00145                 $options = array();
00146                 foreach ($files as $file) $options[] = $alirohtml->makeOption($file, $file);
00147                 if (!isset($param['hide_none'])) array_unshift($options, $alirohtml->makeOption('-1', '- Do not use an image -' ));
00148                 if (!isset($param['hide_default'])) array_unshift($options, $alirohtml->makeOption('', '- Use Default image -'));
00149                 $controlstring = $alirohtml->selectList ($options, "$controlname[$name]", 'class="inputbox"', 'value', 'text', $value);
00150                 break;
00151             case 'textarea':
00152                 $rows = (string) $param['rows'];
00153                 $cols = (string) $param['cols'];
00154                 $value = str_replace ('<br /', "\n", $value);
00155                 $controlstring = "<textarea name='params[$name]' cols='$cols' rows='$rows' class='text_area'>$value</textarea>";
00156                 break;
00157             case 'editarea':
00158                 $editor = aliroEditor::getInstance();
00159                 $controlstring = $editor->editorAreaText( $controlname.'['.$name.']',  $value , $controlname.'['.$name.']', '700', '350', '95', '30' ) ;
00160                 break;
00161             case 'dynamic':
00162                 $class = (string) $param['class'];
00163                 $method = (string) $param['method'];
00164                 if ($class) $object = call_user_func($class, 'getInstance');
00165                 if (is_object($object) AND $method) {
00166                     $controlstring = $object->$method($name, $value, $controlname, $param);
00167                     break;
00168                 }
00169                 $controlstring = sprintf(T_('Dynamic parameter class: %s, method: %s failed'), $class, $method);
00170                 break;
00171             case 'spacer':
00172                 $controlstring = $value ? $value : '<hr />';
00173                 break;
00174             case 'mos_section':
00175                 $controlstring = _form_mos_section($name, $value, $controlname);
00176                 break;
00177             case 'mos_category':
00178                 $controlstring = _form_mos_category($name, $value, $controlname);
00179                 break;
00180             case 'mos_menu':
00181                 $controlstring = $this->_form_mos_menu($name, $value, $controlname);
00182                 break;
00183             default:
00184                 $controlstring = T_('Handler not defined for type').'='.$type;
00185         }
00186         $this->html[] = "<td>$controlstring</td>";
00187         $this->html[] = "<td width='10%' align='left' valign='top'>$tooltip</td>";
00188         $this->html[] = '</tr>';
00189         $this->paramcount++;
00190     }

aliroXMLParams::_form_mos_section ( name,
value,
control_name 
) [protected]

Parameters:
string The name of the form element
string The value of the element
object The xml element for the parameter
string The control name
Returns:
string The html for the element

Definition at line 199 of file aliroXMLParams.php.

References aliroHTML::getInstance(), and aliroDatabase::getInstance().

Referenced by processParam().

00199                                                                          {
00200         $database = mamboDatabase::getInstance();
00201         $query = "SELECT id AS value, title AS text"
00202         . "\n FROM #__sections"
00203         . "\n WHERE published='1' AND scope='content'"
00204         . "\n ORDER BY title"
00205         ;
00206         $database->setQuery( $query );
00207         $options = $database->loadObjectList();
00208         array_unshift($options, aliroHTML::getInstance()->makeOption( '0', '- Select Content Section -' ));
00209         return aliroHTML::getInstance()->selectList( $options, "$control_name[$name]", 'class="inputbox"', 'value', 'text', $value );
00210     }

aliroXMLParams::_form_mos_category ( name,
value,
control_name 
) [protected]

Parameters:
string The name of the form element
string The value of the element
object The xml element for the parameter
string The control name
Returns:
string The html for the element

Definition at line 218 of file aliroXMLParams.php.

References aliroDatabase::getInstance(), and aliroHTML::getInstance().

Referenced by processParam().

00218                                                                           {
00219         $firstoption = aliroHTML::getInstance()->makeOption('0', '- Select Content Category -');
00220         $database = mamboDatabase::getInstance();
00221         $query  = "SELECT c.id AS value, CONCAT_WS( '/',s.title, c.title ) AS text"
00222         . "\n FROM #__categories AS c"
00223         . "\n LEFT JOIN #__sections AS s ON s.id=c.section"
00224         . "\n WHERE c.published='1' AND s.scope='content'"
00225         . "\n ORDER BY c.title"
00226         ;
00227         $database->setQuery( $query );
00228         $options = $database->loadObjectList();
00229         if ($options) array_unshift($options, $firstoption);
00230         else $options = array($firstoption);
00231         return aliroHTML::getInstance()->selectList( $options, "$control_name[$name]", 'class="inputbox"', 'value', 'text', $value );
00232     }

aliroXMLParams::_form_mos_menu ( name,
value,
control_name 
)

Definition at line 234 of file aliroXMLParams.php.

References aliroHTML::getInstance(), and aliroMenuHandler::getInstance().

Referenced by processParam().

00234                                                             {
00235         $handler = aliroMenuHandler::getInstance();
00236         $menuTypes = $handler->getMenutypes();
00237         $alirohtml = aliroHTML::getInstance();
00238         $options[] = $alirohtml->makeOption( '', '- Select Menu -' );
00239         foreach($menuTypes as $menutype ) $options[] = $alirohtml->makeOption( $menutype, $menutype );
00240         return $alirohtml->selectList( $options, ''. $control_name .'['. $name .']', 'class="inputbox"', 'value', 'text', $value );
00241     }


Member Data Documentation

aliroXMLParams::$xmlobject = null [protected]

Definition at line 47 of file aliroXMLParams.php.

aliroXMLParams::$paramcount = 0 [protected]

Definition at line 48 of file aliroXMLParams.php.

aliroXMLParams::$html = array()

Definition at line 49 of file aliroXMLParams.php.

aliroXMLParams::$translations = array() [protected]

Definition at line 50 of file aliroXMLParams.php.


The documentation for this class was generated from the following file:

Generated on Thu Apr 17 13:03:31 2008 for ALIRO by  doxygen 1.5.5