00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 class aliroHTML {
00044 private static $instance = __CLASS__;
00045
00046 public static function getInstance () {
00047 return is_object(self::$instance) ? self::$instance : (self::$instance = new self::$instance());
00048 }
00049
00050 public function makeOption ($value, $text='', $selected=false, $valuename='value', $textname='text') {
00051 $obj = new stdClass;
00052 $obj->$valuename = $value;
00053 $obj->$textname = trim($text) ? $text : $value;
00054 $obj->selected = $selected;
00055 return $obj;
00056 }
00057
00058
00059 public function selectList ($selections, $tag_name, $tag_attribs='', $key='value', $text='text', $selected=NULL ) {
00060 if (!is_array($selections)) return '';
00061 $selectproperties = array();
00062 if (is_array($selected)) foreach ($selected as $select) {
00063 if (is_object($select)) $selectproperties[] = $select->$key;
00064 else $selectproperties[] = $select;
00065 }
00066 else $selectproperties = array($selected);
00067 $selecthtml = '';
00068 foreach ($selections as $selection) {
00069 $select = ((isset($selection->selected) AND $selection->selected) OR in_array($selection->$key, $selectproperties, true)) ? 'selected="selected"' : '';
00070 $selecthtml .= <<<AN_OPTION
00071 <option value="{$selection->$key}" $select>
00072 {$selection->$text}
00073 </option>
00074 AN_OPTION;
00075 }
00076 return <<<THE_SELECT
00077 <select name="$tag_name" $tag_attribs>
00078 $selecthtml
00079 </select>
00080 THE_SELECT;
00081 }
00082
00083 public function radioList ($arr, $tag_name, $tag_attribs, $selected=null, $key='value', $text='text') {
00084 $html = '';
00085 foreach ($arr as $choice) {
00086 $extra = @$choice->id ? " id=\"$choice->id\"" : '';
00087 if (is_array($selected)) foreach ($selected as $obj) {
00088 if ($choice->$key == $obj->$key) {
00089 $extra .= ' selected="selected"';
00090 break;
00091 }
00092 }
00093 else $extra .= ($choice->$key == $selected ? " checked=\"checked\"" : '');
00094 $html .= <<<RADIO
00095 <input type="radio" name="$tag_name" value="{$choice->$key}" $extra $tag_attribs />
00096 {$choice->$text}
00097 RADIO;
00098 }
00099 return $html;
00100 }
00101
00102 public function yesnoRadioList ($tag_name, $tag_attribs, $selected, $yes=_CMN_YES, $no=_CMN_NO ) {
00103 $arr = array(
00104 $this->makeOption( '0', $no, true ),
00105 $this->makeOption( '1', $yes, true )
00106 );
00107 return $this->radioList ($arr, $tag_name, $tag_attribs, $selected);
00108 }
00109
00110 public function idBox ($rowNum, $recId, $checkedOut=false, $name='cid') {
00111 return $checkedOut ? '' : <<<IDBOX
00112 <input type="checkbox" id="cb$rowNum" name="{$name}[]" value="$recId" onclick="isChecked(this.checked);" />
00113 IDBOX;
00114 }
00115
00116 public function toolTip ($tooltip, $title='', $width='', $image='tooltip.png', $text='', $href='#') {
00117 if ($width) $width = ', WIDTH, \''.$width .'\'';
00118 if ($title) $title = ', CAPTION, \''.$title .'\'';
00119 if (!$text) {
00120 $image = aliroCore::getInstance()->getCfg('live_site').'/includes/js/ThemeOffice/'.$image;
00121 $text = '<img src="'.$image.'" alt="Tool Tip" />';
00122 }
00123
00124 return <<<CTOOLTIP
00125 <a href="$href"> $text <span class="tooltip">$tooltip</span></a>
00126 CTOOLTIP;
00127 return <<<TOOLTIP
00128 <a href="$href" onmouseover="return overlib('$tooltip' $title, BELOW, RIGHT $width );" onmouseout="return nd();" $style > $text </a>
00129 TOOLTIP;
00130 }
00131
00132 private function checkedOut($row, $overlib=1) {
00133 if ($overlib) {
00134 if (!isset($row->editor)) {
00135 $user = new mosUser();
00136 $user->load($row->checked_out);
00137 $row->editor = $user->name;
00138 }
00139 $date = $this->formatDate( $row->checked_out_time, '%A, %d %B %Y' );
00140 $time = $this->formatDate( $row->checked_out_time, '%H:%M' );
00141 $checked_out_text = <<<CHECKED_OUT
00142 <table><tr><td>$row->editor</td></tr><tr><td>$date</td></tr><tr><td>$time</td></tr></table>
00143 CHECKED_OUT;
00144 $hover = 'onmouseover="return overlib(\''. $checked_out_text .'\', CAPTION, \'Checked Out\', BELOW, RIGHT);" onMouseOut="return nd();"';
00145 }
00146 else $hover = '';
00147 return '<img src="images/checked_out.png" '. $hover .' alt="Checked Out"/>';
00148 }
00149
00150 public function formatDate ($date, $format='', $offset=''){
00151 $core = aliroCore::getInstance();
00152
00153 if (!$offset) $offset = $core->getCfg('offset');
00154 if ($date AND ereg( "([0-9]{4})-([0-9]{2})-([0-9]{2})[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})", $date, $regs ) ) {
00155 $date = mktime( $regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1] );
00156 $date = $date > -1 ? aliroLanguage::getInstance()->getDate($format, $date + ($offset*60*60)) : '-';
00157 }
00158 return $date;
00159 }
00160
00161 public function checkedOutProcessing ($row, $i) {
00162 if ($row->checked_out) $checked = $this->checkedOut ($row);
00163 else $checked = $this->idBox ($i, $row->id, ($row->checked_out AND $row->checked_out != aliroUser::getInstance()->id));
00164 return $checked;
00165 }
00166
00167 public function publishedProcessing ($row, $i) {
00168 $img = $row->published ? 'publish_g.png' : 'publish_x.png';
00169 $task = $row->published ? 'unpublish' : 'publish';
00170 $alt = $row->published ? T_('Published') : T_('Unpublished');
00171 $action = $row->published ? T_('Unpublish Item') : T_('Publish item');
00172 return <<<PUBLISH_LINK
00173 <a href="javascript: void(0);" onclick="return listItemTask('cb$i','$task')" title="$action">
00174 <img src="images/$img" border="0" alt="$alt" />
00175 </a>
00176 PUBLISH_LINK;
00177
00178 }
00179
00180 public function loadCalendar() {
00181 $live_site = aliroCore::getInstance()->getCfg('live_site');
00182 $tags = <<<END_TAGS
00183 <link rel="stylesheet" type="text/css" media="all" href="$live_site/extclasses/js/calendar/calendar-mos.css" title="green" />
00184 <!-- import the calendar script -->
00185 <script type="text/javascript" src="$live_site/extclasses/js/calendar/calendar.js"></script>
00186 <!-- import the language module -->
00187 <script type="text/javascript" src="$live_site/extclasses/js/calendar/lang/calendar-en.js"></script>
00188 END_TAGS;
00189 aliroRequest::getInstance()->addCustomHeadTag ($tags);
00190 }
00191
00192 }