basicAdminHTML.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class basicAdminHTML extends aliroBasicHTML  {
00007     protected $core = '';
00008     protected $act = '';
00009 
00010     function __construct ($controller) {
00011         parent::__construct($controller);
00012         $this->act = $controller->act;
00013         if ($this->core = strtolower($this->getParam($_REQUEST,'core'))) {
00014             $this->optionline = "<input type='hidden' name='core' value='$this->core' />";
00015             $this->optionurl = 'index.php?core='.$this->core;
00016         }
00017         $this->optionurl .= '&amp;act='.$this->act;
00018     }
00019 
00020 }
00021 
00022 class advancedAdminHTML extends basicAdminHTML {
00023 
00024     protected function listHTML ($tablename, $title, $rows, $keyname, $needlink=true) {
00025 
00026         $rowcount = count($rows);
00027         if (isset($this->controller->list_exclude)) $excludes = $this->controller->list_exclude;
00028         else $excludes = array();
00029 
00030         $html = <<<END_OF_HEADER_HTML1
00031 
00032         <form action="index.php" method="post" name="adminForm">
00033 
00034         <table class="adminheading">
00035         <thead>
00036         <tr>
00037             <th class="user">
00038             $title
00039             </th>
00040         </tr>
00041         </thead>
00042         <tbody><tr><td></td></tr></tbody>
00043         </table>
00044         
00045         <table class="adminlist">
00046         <thead>
00047         <tr>
00048             <th width="3%" class="title">
00049             <input type="checkbox" name="toggle" value="" onclick="checkAll($rowcount);" />
00050             </th>
00051 END_OF_HEADER_HTML1;
00052 
00053         $fields = $this->getTableInfo($tablename);
00054         foreach ($fields as $field) {
00055             if (in_array($field->Field, $excludes)) continue;
00056             $fieldname = strtoupper($field->Field[0]).substr($field->Field,1);
00057             $html .= <<<HEADING_ITEM
00058 
00059             <th class="title">
00060             $fieldname
00061             </th>
00062 
00063 HEADING_ITEM;
00064 
00065         }
00066 
00067         $html .= <<<END_OF_HEADER_HTML2
00068 
00069         </tr>
00070         </thead>
00071         <tbody>
00072 
00073 END_OF_HEADER_HTML2;
00074 
00075         $k = 0;
00076         foreach ($rows as $i=>$row) {
00077 
00078             $html .= <<<END_OF_BODY_HTML
00079 
00080             <tr class="row$k">
00081                 <td>
00082                     {$this->html('idBox', $i, $row->$keyname)}
00083                 </td>
00084 
00085 END_OF_BODY_HTML;
00086 
00087             foreach ($fields as $field) {
00088             if (in_array($field->Field, $excludes)) continue;
00089                 $fieldname = $field->Field;
00090                 $method = 'list_'.$fieldname;
00091                 if (method_exists($this, $method)) $fieldvalue = $this->$method($row->$fieldname, $row->$keyname);
00092                 else $fieldvalue = strip_tags($row->$fieldname);
00093                 if ($needlink AND $fieldname != $keyname) {
00094                     $fieldvalue = "<a href='$this->optionurl&task=edit&id={$row->$keyname}'>$fieldvalue</a>";
00095                     $needlink = false;
00096                 }
00097                 $html .= "\n\t\t\t<td>$fieldvalue</td>";
00098             }
00099             $html .= "\n\t\t</tr>";
00100 
00101             $k = 1 - $k;
00102         }
00103         $pagenavtext = $this->pageNav->getListFooter();
00104 
00105         $html .= <<<END_OF_FINAL_HTML
00106 
00107         </tbody>
00108         </table>
00109         $pagenavtext
00110         $this->optionline
00111         $this->formstamp
00112         <input type="hidden" name="task" value="" />
00113         <input type="hidden" name="boxchecked" value="0" />
00114         <input type="hidden" name="hidemainmenu" value="0" />
00115         </form>
00116 END_OF_FINAL_HTML;
00117 
00118         return $html;
00119 
00120     }
00121 
00122     protected function editornewHeader ($title) {
00123         return <<<HTML
00124 
00125         <table class="adminheading">
00126         <tr>
00127             <th>
00128                 $title
00129             </th>
00130         </tr>
00131         </table>
00132 
00133         <table width="100%">
00134         <tr valign="top">
00135             <td width="60%">
00136                 <table class="adminform">
00137 
00138 HTML;
00139     }
00140 
00141     protected function editornewFooter () {
00142         return <<<HTML
00143 
00144         </table>
00145         $this->optionline
00146         $this->formstamp
00147         <input type="hidden" name="task" value="" />
00148         <input type="hidden" name="hidemainmenu" value="1" />
00149         <script type="text/javascript" src="{$this->getCfg('live_site')}/includes/js/overlib_mini.js"></script>
00150 
00151 HTML;
00152 
00153     }
00154 
00155     protected function newHTML ($tablename, $title, $keyname) {
00156 
00157         $html = $this->editornewHeader($title);
00158         $editor = aliroEditor::getInstance();
00159 
00160         $fields = $this->getTableInfo($tablename);
00161         /*
00162         <script type="text/javascript">
00163         function submitbutton(pressbutton) {
00164                 <?php getEditorContents( 'description', 'description' ); ?>
00165                 submitform( pressbutton );
00166         }
00167         </script>
00168         */
00169         foreach ($fields as $field) if ($field->Field != $keyname) {
00170             $field->Field[0] = strtoupper($field->Field[0]);
00171 
00172             if (false === strpos($field->Type, 'text')) $html .= <<<ITEM_HTML
00173 
00174                 <tr>
00175                     <td width="10%" align="right"><label for="field_$field->Field">$field->Field</label></td>
00176                     <td width="80%">
00177                     <input id="field_$field->Field" class="inputbox" type="text" name="$field->Field" size="60" maxlength="255" />
00178                     </td>
00179                 </tr>
00180 
00181 ITEM_HTML;
00182 
00183             else {
00184                 $editor->getEditorContents( $fieldname, $fieldname );
00185                 $html .= <<<TEXT_HTML
00186 
00187                 <tr>
00188                     <td width="10%" align="right"><label for="field_$field->Field">$field->Field</label></td>
00189                     <td width="80%">
00190                     {$editor->editorAreaText('$fieldname', '', '$fieldname', 500, 300, 100, 8)}
00191                     </td>
00192                 </tr>
00193 
00194 TEXT_HTML;
00195 
00196             }
00197                 //  <textarea id="field_$field->Field" class="inputbox" name="$field->Field" rows="10" cols="60"></textarea>
00198         }
00199 
00200         $html .= $this->editornewFooter();
00201 
00202         return $html;
00203     }
00204 
00205     protected function editHTML ($tablename, $title, $keyname, $row) {
00206 
00207         $html = $this->editornewHeader($title);
00208         $editor = aliroEditor::getInstance();
00209         $fields = $this->getTableInfo($tablename);
00210         foreach ($fields as $field) if ($field->Field != $keyname) {
00211             $fieldname = $field->Field;
00212             $field->Field[0] = strtoupper($field->Field[0]);
00213             if (false === strpos($field->Type, 'text')) $html .= <<<ITEM_HTML
00214 
00215                 <tr>
00216                     <td width="10%" align="right"><label for="field_$field->Field">$field->Field</label></td>
00217                     <td width="80%">
00218                     <input id="field_$field->Field" class="inputbox" type="text" name="$field->Field" value="{$row->$fieldname}" size="60" maxlength="255" />
00219                     </td>
00220                 </tr>
00221 
00222 ITEM_HTML;
00223 
00224             else {
00225                 $editor->getEditorContents( $fieldname, $fieldname );
00226                 $html .= <<<TEXT_HTML
00227 
00228                 <tr>
00229                     <td width="10%" align="right"><label for="field_$field->Field">$field->Field</label></td>
00230                     <td width="80%">
00231                     {$editor->editorAreaText('$fieldname', '', '$fieldname', 500, 300, 80, 8)}
00232                     </td>
00233                 </tr>
00234 
00235 TEXT_HTML;
00236 
00237             }
00238                 //  <textarea id="field_$field->Field" class="inputbox" name="$field->Field" rows="10" cols="60">{$row->$fieldname}</textarea>
00239         }
00240 
00241         $html .= $this->editornewFooter();
00242 
00243         return $html;
00244     }
00245 
00246 }
00247 
00248 class widgetAdminHTML extends advancedAdminHTML {
00249 
00250     function tickBox ($object, $property) {
00251         if (is_object($object) AND $object->$property) $checked = "checked='checked'";
00252         else $checked = '';
00253         echo "<td><input type='checkbox' name='$property' value='1' $checked /></td>";
00254     }
00255 
00256     function yesNoList ($object, $property) {
00257         $yesno[] = mosHTML::makeOption( 0, _NO );
00258         $yesno[] = mosHTML::makeOption( 1, _YES );
00259         if ($object) $default = $object->$property;
00260         else $default = 0;
00261         echo '<td valign="top">';
00262         echo mosHTML::selectList($yesno, $property, 'class="inputbox" size="1"', 'value', 'text', $default);;
00263         echo '</td></tr>';
00264     }
00265 
00266     function inputTop ($title, $redstar=false, $maxsize=0) {
00267         ?>
00268         <tr>
00269             <td width="30%" valign="top" align="right">
00270                 <b><?php if ($redstar) echo '<font color="red">*</font>'; echo $title; if ($maxsize) echo "</b>&nbsp;<br /><i>$maxsize</i>&nbsp;"; ?></b>&nbsp;
00271             </td>
00272         <?php
00273     }
00274 
00275     function blankRow () {
00276         ?>
00277             <tr><td>&nbsp;</td></tr>
00278         <?php
00279     }
00280 
00281     function fileInputBox ($title, $name, $value, $width, $tooltip=null) {
00282         $this->inputTop($title);
00283         ?>
00284             <td align="left" valign="top">
00285                 <input class="inputbox" type="text" name="<?php echo $name; ?>" size="<?php echo $width; ?>" value="<?php echo $value; ?>" />
00286                 <?php if ($tooltip) echo tooltip($tooltip); ?>
00287             </td>
00288         </tr>
00289         <?php
00290     }
00291 
00292     function fileInputArea ($title, $maxsize, $name, $value, $rows, $cols, $editor=false, $tooltip=null) {
00293         $this->inputTop ($title, false, $maxsize);
00294         echo '<td valign="top">';
00295         if ($editor) {
00296             $editorclass = aliroEditor::getInstance();
00297             $editorclass->editorArea( 'description', $value, $name, 500, 200, $rows, $cols );
00298         }
00299         else echo "<textarea class='inputbox' name='$name' rows='$rows' cols='$cols'>$value</textarea>";
00300         if ($tooltip) echo tooltip($tooltip);
00301         echo '</td></tr>';
00302     }
00303 
00304     function tickBoxField ($object, $property, $title) {
00305         ?>
00306         <tr>
00307             <td width="30%" valign="top" align="right">
00308                 <b><?php echo $title; ?></b>&nbsp;
00309             </td>
00310         <?php
00311         $this->tickBox($object,$property);
00312         echo '</tr>';
00313     }
00314 
00315     function simpleTickBox ($title, $name, $checked=false) {
00316         $this->inputTop($title);
00317         if ($checked) $check = 'checked="checked"';
00318         else $check = '';
00319         ?>
00320             <td>
00321                 <input type="checkbox" name="<?php echo $name; ?>" value="1" <?php echo $check; ?> />
00322             </td>
00323         </tr>
00324         <?php
00325     }
00326     function formStart ($title, $imagepath) {
00327         ?>
00328         <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
00329         <script type="text/javascript" src="../includes/js/overlib_mini.js"></script>
00330         <form action="index2.php" method="post" name="adminForm">
00331         <table cellpadding="4" cellspacing="0" border="0" width="100%">
00332         <tr>
00333             <td width="100%" colspan="4">
00334             <div class="title">
00335             <img src="<?php echo $imagepath; ?>" alt="<?php echo $title; ?>" />
00336             <span class="sectionname">&nbsp;<?php echo $title; ?></span>
00337             </div>
00338             </td>
00339         </tr>
00340         <?php
00341     }
00342 
00343     function listHeadingStart ($count) {
00344         ?>
00345         <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
00346             <tr>
00347                 <th width="5" align="left">
00348                     <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo $count; ?>);" />
00349                 </th>
00350         <?php
00351     }
00352 
00353     function headingItem ($width, $title, $colspan=1) {
00354         if ($colspan > 1) $colcode = " colspan=\"$colspan\"";
00355         else $colcode = '';
00356         echo "<th width=\"$width\" align=\"left\"$colcode>$title</th>";
00357     }
00358 
00359     function commonScripts ($edit_fields) {
00360         ?>
00361         <script type="text/javascript">
00362         function submitbutton(pressbutton) {
00363                 <?php
00364                 $editor = aliroEditor::getInstance();
00365                 if (is_array($edit_fields)) foreach ($edit_fields as $field) $editor->getEditorContents( $field, $field );
00366                 else $editor->getEditorContents ($edit_fields, $edit_fields);
00367                 ?>
00368                 submitform( pressbutton );
00369         }
00370         </script>
00371         <?php
00372     }
00373 
00374     function listFormEnd ($pagecontrol=true) {
00375         if ($pagecontrol) {
00376             ?>
00377             <tr>
00378                 <th align="center" colspan="10"> <?php echo $this->pageNav->writePagesLinks(); ?></th>
00379             </tr>
00380             <tr>
00381                 <td align="center" colspan="10"> <?php echo $this->pageNav->writePagesCounter(); ?></td>
00382             </tr>
00383             <?php
00384         }
00385         ?>
00386         </table>
00387         <div>
00388         <?php echo $this->optionline; ?>
00389         <input type="hidden" name="task" value="" />
00390         <input type="hidden" name="act" value="<?php echo $this->act; ?>" />
00391         <input type="hidden" name="boxchecked" value="0" />
00392         </div>
00393         </form>
00394         <?php
00395     }
00396 
00397     function editFormEnd ($id) {
00398         echo $this->optionline;
00399         ?>
00400         </table>
00401         <div>
00402         <input type="hidden" name="cid" value="<?php echo $id; ?>" />
00403         <input type="hidden" name="task" value="" />
00404         <input type="hidden" name="act" value="<?php echo $this->act; ?>" />
00405         </div>
00406         </form>
00407         <?php
00408     }
00409 
00410     function multiOptionList ($name, $title, $options, $current, $tooltip=null) {
00411         $alternatives = explode(',',$options);
00412         $already = explode(',', $current);
00413         ?>
00414         <tr>
00415         <td width="30%" valign="top" align="right">
00416         <b><?php echo $title; ?></b>&nbsp;
00417         </td>
00418         <td valign="top">
00419         <?php
00420         foreach ($alternatives as $one) {
00421             if (in_array($one,$already)) $mark = 'checked="checked"';
00422             else $mark = '';
00423             $value = $name.'_'.$one;
00424             echo "<input type=\"checkbox\" name=\"$value\" $mark />$one";
00425         }
00426         if ($tooltip) echo '&nbsp;'.tooltip($tooltip);
00427         echo '</td></tr>';
00428     }
00429 
00430     function tooltip ($text) {
00431         return '<a href="javascript:void(0)"  onmouseover="return escape('."'".$text."'".')">'.aliroCore::get('mosConfig_live_site').'/includes/js/ThemeOffice/tooltip.png</a>';
00432     }
00433 
00434 }
00435 
00436 ?>

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