00001 <?php
00002
00007 class mosHTML {
00008
00009 static function makeOption( $value, $text='' ) {
00010 return aliroHTML::getInstance()->makeOption ($value, $text);
00011 }
00012
00013 static function writableCell( $folder ) {
00014 echo '<tr>';
00015 echo '<td class="item">' . $folder . '/</td>';
00016 echo '<td align="left">';
00017 echo is_writable( "../$folder" ) ? '<b><span class="green">'.T_('Writeable').'</span></b>' : '<b><span class="red">'.T_('Unwriteable').'</span></b>' . '</td>';
00018 echo '</tr>';
00019 }
00020
00031 static function selectList ( $arr, $tag_name, $tag_attribs, $key, $text, $selected=NULL ) {
00032 return aliroHTML::getInstance()->selectList($arr, $tag_name, $tag_attribs, $key, $text, $selected);
00033 }
00034
00046 static function integerSelectList( $start, $end, $inc, $tag_name, $tag_attribs, $selected, $format="" ) {
00047 $start = intval( $start );
00048 $end = intval( $end );
00049 $inc = intval( $inc );
00050 $arr = array();
00051 for ($i=$start; $i <= $end; $i+=$inc) {
00052 $fi = $format ? sprintf( "$format", $i ) : "$i";
00053 $arr[] = mosHTML::makeOption( $fi, $fi );
00054 }
00055
00056 return mosHTML::selectList( $arr, $tag_name, $tag_attribs, 'value', 'text', $selected );
00057 }
00058
00066 static function monthSelectList( $tag_name, $tag_attribs, $selected ) {
00067 $arr = array(
00068 mosHTML::makeOption( '01', _JAN ),
00069 mosHTML::makeOption( '02', _FEB ),
00070 mosHTML::makeOption( '03', _MAR ),
00071 mosHTML::makeOption( '04', _APR ),
00072 mosHTML::makeOption( '05', _MAY ),
00073 mosHTML::makeOption( '06', _JUN ),
00074 mosHTML::makeOption( '07', _JUL ),
00075 mosHTML::makeOption( '08', _AUG ),
00076 mosHTML::makeOption( '09', _SEP ),
00077 mosHTML::makeOption( '10', _OCT ),
00078 mosHTML::makeOption( '11', _NOV ),
00079 mosHTML::makeOption( '12', _DEC )
00080 );
00081
00082 return mosHTML::selectList( $arr, $tag_name, $tag_attribs, 'value', 'text', $selected );
00083 }
00084
00092 static function yesnoSelectList( $tag_name, $tag_attribs, $selected, $yes=_CMN_YES, $no=_CMN_NO ) {
00093 $arr = array(
00094 mosHTML::makeOption( '0', $no ),
00095 mosHTML::makeOption( '1', $yes ),
00096 );
00097
00098 return mosHTML::selectList( $arr, $tag_name, $tag_attribs, 'value', 'text', $selected );
00099 }
00100
00111 static function radioList( $arr, $tag_name, $tag_attribs, $selected=null, $key='value', $text='text' ) {
00112 return aliroHTML::getInstance()->radioList($arr, $tag_name, $tag_attribs, $selected, $key, $text);
00113 }
00114
00122 static function yesnoRadioList( $tag_name, $tag_attribs, $selected, $yes=_CMN_YES, $no=_CMN_NO ) {
00123 return aliroHTML::getInstance()->yesnoRadioList($tag_name, $tag_attribs, $selected, $yes, $no);
00124 }
00125
00133 static function idBox( $rowNum, $recId, $checkedOut=false, $name='cid' ) {
00134 return aliroHTML::getInstance()->idBox($rowNum, $recId, $checkedOut, $name);
00135 }
00136
00137 static function sortIcon( $base_href, $field, $state='none' ) {
00138 $config = aliroCore::getInstance();
00139 $alts = array(
00140 'none' => _CMN_SORT_NONE,
00141 'asc' => _CMN_SORT_ASC,
00142 'desc' => _CMN_SORT_DESC,
00143 );
00144 $next_state = 'asc';
00145 if ($state == 'asc') {
00146 $next_state = 'desc';
00147 } else if ($state == 'desc') {
00148 $next_state = 'none';
00149 }
00150
00151 $html = "<a href=\"$base_href&field=$field&order=$next_state\">"
00152 . "<img src=\"{$config->getCfg('live_site')}/images/M_images/sort_$state.png\" width=\"12\" height=\"12\" border=\"0\" alt=\"{$alts[$next_state]}\" />"
00153 . "</a>";
00154 return $html;
00155 }
00156
00160 static function CloseButton ( &$params, $hide_js=NULL ) {
00161
00162 if ( $params->get( 'popup' ) && !$hide_js ) {
00163 ?>
00164 <div align="center" style="margin-top: 30px; margin-bottom: 30px;">
00165 <a href='javascript:window.close();'>
00166 <span class="small">
00167 <?php echo _PROMPT_CLOSE;?>
00168 </span>
00169 </a>
00170 </div>
00171 <?php
00172 }
00173 }
00174
00178 static function BackButton ( &$params, $hide_js=NULL ) {
00179
00180 if ( $params->get( 'back_button' ) && !$params->get( 'popup' ) && !$hide_js) {
00181 ?>
00182 <div class="back_button">
00183 <a href='javascript:history.go(-1)'>
00184 <?php echo _BACK; ?>
00185 </a>
00186 </div>
00187 <?php
00188 }
00189 }
00190
00194 static function cleanText ( &$text ) {
00195 $text = preg_replace( "'<script[^>]*>.*?</script>'si", '', $text );
00196 $text = preg_replace( '/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is', '\2 (\1)', $text );
00197 $text = preg_replace( '/<!--.+?-->/', '', $text );
00198 $text = preg_replace( '/{.+?}/', '', $text );
00199 $text = preg_replace( '/ /', ' ', $text );
00200 $text = preg_replace( '/&/', ' ', $text );
00201 $text = preg_replace( '/"/', ' ', $text );
00202 $text = strip_tags( $text );
00203 $text = htmlspecialchars( $text );
00204 return $text;
00205 }
00206
00210 static function PrintIcon( &$row, &$params, $hide_js, $link, $status=NULL ) {
00211 if ( $params->get( 'print' ) && !$hide_js ) {
00212
00213 if ( !$status ) {
00214 $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';
00215 }
00216
00217
00218 if ( $params->get( 'icons' ) ) {
00219 $mainframe = mosMainFrame::getInstance();
00220 $image = $mainframe->ImageCheck( 'printButton.png', '/images/M_images/', NULL, NULL, _CMN_PRINT );
00221 } else {
00222 $image = _ICON_SEP .' '. _CMN_PRINT. ' '. _ICON_SEP;
00223 }
00224
00225 if ( $params->get( 'popup' ) && !$hide_js ) {
00226
00227 ?>
00228 <td align="right" width="100%" class="buttonheading">
00229 <a href="#" onclick="javascript:window.print(); return false" title="<?php echo _CMN_PRINT;?>">
00230 <?php echo $image;?>
00231 </a>
00232 </td>
00233 <?php
00234 } else {
00235
00236 ?>
00237 <td align="right" width="100%" class="buttonheading">
00238 <a href="javascript:void window.open('<?php echo $link; ?>', 'win2', '<?php echo $status; ?>');" title="<?php echo _CMN_PRINT;?>">
00239 <?php echo $image;?>
00240 </a>
00241 </td>
00242 <?php
00243 }
00244 }
00245 }
00246
00252 static function emailCloaking( $mail, $mailto=1, $text='', $email=1 ) {
00253
00254 $mail = mosHTML::encoding_converter( $mail );
00255
00256 $mail = explode( '@', $mail );
00257 $mail_parts = explode( '.', $mail[1] );
00258
00259 $rand = rand( 1, 100000 );
00260
00261 $replacement = "\n<script language='JavaScript' type='text/javascript'> \n";
00262 $replacement .= "<!-- \n";
00263 $replacement .= "var prefix = 'ma' + 'il' + 'to'; \n";
00264 $replacement .= "var path = 'hr' + 'ef' + '='; \n";
00265 $replacement .= "var addy". $rand ." = '". @$mail[0] ."' + '@' + '". implode( "' + '.' + '", $mail_parts ) ."'; \n";
00266 if ( $mailto ) {
00267
00268 if ( $text ) {
00269 if ( $email ) {
00270
00271 $text = mosHTML::encoding_converter( $text );
00272
00273 $text = explode( '@', $text );
00274 $text_parts = explode( '.', $text[1] );
00275 $replacement .= "var addy_text". $rand ." = '". @$text[0] ."' + '@' + '". implode( "' + '.' + '", @$text_parts ) ."'; \n";
00276 } else {
00277 $text = mosHTML::encoding_converter( $text );
00278 $replacement .= "var addy_text". $rand ." = '". $text ."';\n";
00279 }
00280 $replacement .= "document.write( '<a ' + path + '\'' + prefix + ':' + addy". $rand ." + '\'>' ); \n";
00281 $replacement .= "document.write( addy_text". $rand ." ); \n";
00282 $replacement .= "document.write( '<\/a>' ); \n";
00283 } else {
00284 $replacement .= "document.write( '<a ' + path + '\'' + prefix + ':' + addy". $rand ." + '\'>' ); \n";
00285 $replacement .= "document.write( addy". $rand ." ); \n";
00286 $replacement .= "document.write( '<\/a>' ); \n";
00287 }
00288 } else {
00289 $replacement .= "document.write( addy". $rand ." ); \n";
00290 }
00291 $replacement .= "//--> \n";
00292 $replacement .= "</script> \n";
00293 $replacement .= "<noscript> \n";
00294 $replacement .= _CLOAKING;
00295 $replacement .= "\n</noscript> \n";
00296
00297 return $replacement;
00298 }
00299
00300 static function encoding_converter( $text ) {
00301
00302 $text = str_replace( 'a', 'a', $text );
00303 $text = str_replace( 'e', 'e', $text );
00304 $text = str_replace( 'i', 'i', $text );
00305 $text = str_replace( 'o', 'o', $text );
00306 $text = str_replace( 'u', 'u', $text );
00307
00308 return $text;
00309 }
00310
00317 public static function mosToolTip( $tooltip, $title='', $width='', $image='tooltip.png', $text='', $href='#' ) {
00318 return aliroHTML::getInstance()->toolTip ($tooltip, $title, $width, $image, $text, $href);
00319 }
00320
00321 }