--- mambo/branches/4.5.4/includes/mamboHTML.php 2005/12/29 17:26:37 83 +++ mambo/branches/4.6/includes/mamboHTML.php 2007/04/13 06:01:44 1037 @@ -1,670 +1,735 @@ -value = $value; - $obj->text = trim( $text ) ? $text : $value; - return $obj; - } - - function writableCell( $folder ) { - echo ''; - echo '' . $folder . '/'; - echo ''; - echo is_writable( "../$folder" ) ? 'Writeable' : 'Unwriteable' . ''; - echo ''; - } - - /** - * Generates an HTML select list - * @param array An array of objects - * @param string The value of the HTML name attribute - * @param string Additional HTML attributes for the "; - for ($i=0, $n=count( $arr ); $i < $n; $i++ ) { - $k = $arr[$i]->$key; - $t = $arr[$i]->$text; - $id = @$arr[$i]->id; - - $extra = ''; - $extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : ''; - if (is_array( $selected )) { - foreach ($selected as $obj) { - $k2 = $obj->$key; - if ($k == $k2) { - $extra .= " selected=\"selected\""; - break; - } - } - } else { - $extra .= ($k == $selected ? " selected=\"selected\"" : ''); - } - $html .= "\n\t"; - } - $html .= "\n\n"; - return $html; - } - - /** - * Writes a select list of integers - * @param int The start integer - * @param int The end integer - * @param int The increment - * @param string The value of the HTML name attribute - * @param string Additional HTML attributes for the tag - * @param mixed The key that is selected - * @returns string HTML for the select list values - */ - function monthSelectList( $tag_name, $tag_attribs, $selected ) { - $arr = array( - mosHTML::makeOption( '01', _JAN ), - mosHTML::makeOption( '02', _FEB ), - mosHTML::makeOption( '03', _MAR ), - mosHTML::makeOption( '04', _APR ), - mosHTML::makeOption( '05', _MAY ), - mosHTML::makeOption( '06', _JUN ), - mosHTML::makeOption( '07', _JUL ), - mosHTML::makeOption( '08', _AUG ), - mosHTML::makeOption( '09', _SEP ), - mosHTML::makeOption( '10', _OCT ), - mosHTML::makeOption( '11', _NOV ), - mosHTML::makeOption( '12', _DEC ) - ); - - return mosHTML::selectList( $arr, $tag_name, $tag_attribs, 'value', 'text', $selected ); - } - - /** - * Writes a yes/no select list - * @param string The value of the HTML name attribute - * @param string Additional HTML attributes for the tag - * @param mixed The key that is selected - * @param string The name of the object variable for the option value - * @param string The name of the object variable for the option text - * @returns string HTML for the select list - */ - function radioList( &$arr, $tag_name, $tag_attribs, $selected=null, $key='value', $text='text' ) { - reset( $arr ); - $html = ""; - for ($i=0, $n=count( $arr ); $i < $n; $i++ ) { - $k = $arr[$i]->$key; - $t = $arr[$i]->$text; - $id = @$arr[$i]->id; - - $extra = ''; - $extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : ''; - if (is_array( $selected )) { - foreach ($selected as $obj) { - $k2 = $obj->$key; - if ($k == $k2) { - $extra .= " selected=\"selected\""; - break; - } - } - } else { - $extra .= ($k == $selected ? " checked=\"checked\"" : ''); - } - $html .= "\n\t" . $t; - } - $html .= "\n"; - return $html; - } - - /** - * Writes a yes/no radio list - * @param string The value of the HTML name attribute - * @param string Additional HTML attributes for the '; - } - } - - function sortIcon( $base_href, $field, $state='none' ) { - global $mosConfig_live_site; - - $alts = array( - 'none' => _CMN_SORT_NONE, - 'asc' => _CMN_SORT_ASC, - 'desc' => _CMN_SORT_DESC, - ); - $next_state = 'asc'; - if ($state == 'asc') { - $next_state = 'desc'; - } else if ($state == 'desc') { - $next_state = 'none'; - } - - $html = "" - . "\"{$alts[$next_state]}\"" - . ""; - return $html; - } - - /** - * Writes Close Button - */ - function CloseButton ( &$params, $hide_js=NULL ) { - // displays close button in Pop-up window - if ( $params->get( 'popup' ) && !$hide_js ) { - ?> -
- - - - - -
- get( 'back_button' ) && !$params->get( 'popup' ) && !$hide_js) { - ?> -
- - - -
- ]*>.*?'si", '', $text ); - $text = preg_replace( '/]*>([^<]+)<\/a>/is', '\2 (\1)', $text ); - $text = preg_replace( '//', '', $text ); - $text = preg_replace( '/{.+?}/', '', $text ); - $text = preg_replace( '/ /', ' ', $text ); - $text = preg_replace( '/&/', ' ', $text ); - $text = preg_replace( '/"/', ' ', $text ); - $text = strip_tags( $text ); - $text = htmlspecialchars( $text ); - return $text; - } - - /** - * Writes Print icon - */ - function PrintIcon( &$row, &$params, $hide_js, $link, $status=NULL ) { - global $mosConfig_live_site, $mosConfig_absolute_path, $cur_template, $Itemid; - if ( $params->get( 'print' ) && !$hide_js ) { - // use default settings if none declared - if ( !$status ) { - $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no'; - } - - // checks template image directory for image, if non found default are loaded - if ( $params->get( 'icons' ) ) { - $mainframe = mosMainFrame::getInstance(); - $image = $mainframe->ImageCheck( 'printButton.png', '/images/M_images/', NULL, NULL, _CMN_PRINT ); - } else { - $image = _ICON_SEP .' '. _CMN_PRINT. ' '. _ICON_SEP; - } - - if ( $params->get( 'popup' ) && !$hide_js ) { - // Print Preview button - used when viewing page - ?> - - - - - - - - - - - - \n"; - $replacement .= " \n"; - $replacement .= " \n"; - $replacement .= " \n"; - - return $replacement; - } - - function encoding_converter( $text ) { - // replace vowels with character encoding - $text = str_replace( 'a', 'a', $text ); - $text = str_replace( 'e', 'e', $text ); - $text = str_replace( 'i', 'i', $text ); - $text = str_replace( 'o', 'o', $text ); - $text = str_replace( 'u', 'u', $text ); - - return $text; - } -} - -class mosCommonHTML { - - function ContentLegend( ) { - ?> - - - - - - - - - - - - - - -
- Pending - - Published, but is Pending | - - Visible - - Published and is Current | - - Finished - - Published, but has Expired | - - Finished - - Not Published -
- Click on icon to toggle state. -
- - - - - -
- - - - - Menu - - - - menutype; ?> - - - - - - Link Name - - - - - name; ?> - - - - - - - State - - - published ) { - case -2: - echo 'Trashed'; - break; - case 0: - echo 'UnPublished'; - break; - case 1: - default: - echo 'Published'; - break; - } - ?> - - - - - - - - - - -
- - - - - Menu - - - - menutype; ?> - - - - - - Type - - - type; ?> - - - - - Item Name - - - - - name; ?> - - - - - - - State - - - published ) { - case -2: - echo 'Trashed'; - break; - case 0: - echo 'UnPublished'; - break; - case 1: - default: - echo 'Published'; - break; - } - ?> - - - - - - checked_out_time, '%A, %d %B %Y' ); - $time = mosFormatDate( $row->checked_out_time, '%H:%M' ); - $checked_out_text = ''; - $checked_out_text .= ''; - $checked_out_text .= ''; - $checked_out_text .= ''; - $checked_out_text .= '
'. $row->editor .'
'. $date .'
'. $time .'
'; - $hover = 'onMouseOver="return overlib(\''. $checked_out_text .'\', CAPTION, \'Checked Out\', BELOW, RIGHT);" onMouseOut="return nd();"'; - } - $checked = ''; - - return $checked; - } - - /* - * Loads all necessary files for JS Overlib tooltips - */ - function loadOverlib() { - global $mosConfig_live_site; - ?> - - - - - - - - - access ) { - $color_access = 'style="color: green;"'; - $task_access = 'accessregistered'; - } else if ( $row->access == 1 ) { - $color_access = 'style="color: red;"'; - $task_access = 'accessspecial'; - } else { - $color_access = 'style="color: black;"'; - $task_access = 'accesspublic'; - } - - $href = ' - - '. $row->groupname .' - ' - ; - - return $href; - } - - function CheckedOutProcessing( &$row, $i ) { - global $my; - - if ( $row->checked_out ) { - $checked = mosCommonHTML::checkedOut( $row ); - } else { - $checked = mosHTML::idBox( $i, $row->id, ($row->checked_out && $row->checked_out != $my->id ) ); - } - - return $checked; - } - - function PublishedProcessing( &$row, $i ) { - $img = $row->published ? 'publish_g.png' : 'publish_x.png'; - $task = $row->published ? 'unpublish' : 'publish'; - $alt = $row->published ? 'Published' : 'Unpublished'; - $action = $row->published ? 'Unpublish Item' : 'Publish item'; - - $href = ' - - '. $alt .' - ' - ; - - return $href; - } -} - -?> +value = $value; + $obj->text = trim( $text ) ? $text : $value; + return $obj; + } + + function writableCell( $folder ) { + echo ''; + echo '' . $folder . '/'; + echo ''; + echo is_writable( "../$folder" ) ? ''.T_('Writeable').'' : ''.T_('Unwriteable').'' . ''; + echo ''; + } + + /** + * Generates an HTML select list + * @param array An array of objects + * @param string The value of the HTML name attribute + * @param string Additional HTML attributes for the "; + for ($i=0, $n=count( $arr ); $i < $n; $i++ ) { + $k = $arr[$i]->$key; + $t = $arr[$i]->$text; + $id = isset($arr[$i]->id) ? $arr[$i]->id : null; + + $extra = ''; + $extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : ''; + if (is_array( $selected )) { + foreach ($selected as $obj) { + $k2 = $obj->$key; + if ($k == $k2) { + $extra .= " selected=\"selected\""; + break; + } + } + } else { + $extra .= ($k == $selected ? " selected=\"selected\"" : ''); + } + $html .= "\n\t"; + } + $html .= "\n\n"; + return $html; + } + + /** + * Writes a select list of integers + * @param int The start integer + * @param int The end integer + * @param int The increment + * @param string The value of the HTML name attribute + * @param string Additional HTML attributes for the tag + * @param mixed The key that is selected + * @returns string HTML for the select list values + */ + function monthSelectList( $tag_name, $tag_attribs, $selected ) { + $arr = array( + mosHTML::makeOption( '01', T_('January') ), + mosHTML::makeOption( '02', T_('February') ), + mosHTML::makeOption( '03', T_('March') ), + mosHTML::makeOption( '04', T_('April') ), + mosHTML::makeOption( '05', T_('May') ), + mosHTML::makeOption( '06', T_('June') ), + mosHTML::makeOption( '07', T_('July') ), + mosHTML::makeOption( '08', T_('August') ), + mosHTML::makeOption( '09', T_('September') ), + mosHTML::makeOption( '10', T_('October') ), + mosHTML::makeOption( '11', T_('November') ), + mosHTML::makeOption( '12', T_('December') ) + ); + + return mosHTML::selectList( $arr, $tag_name, $tag_attribs, 'value', 'text', $selected ); + } + + /** + * Writes a yes/no select list + * @param string The value of the HTML name attribute + * @param string Additional HTML attributes for the tag + * @param mixed The key that is selected + * @param string The name of the object variable for the option value + * @param string The name of the object variable for the option text + * @returns string HTML for the select list + */ + function radioList( &$arr, $tag_name, $tag_attribs, $selected=null, $key='value', $text='text' ) { + reset( $arr ); + $html = ""; + foreach ($arr as $choice) { + $id = @$choice->id; + $extra = $id ? " id=\"" . $choice->id . "\"" : ''; + if (is_array( $selected )) { + foreach ($selected as $obj) { + if ($choice->$key == $obj->$key) { + $extra .= ' selected="selected"'; + break; + } + } + } else { + $extra .= ($choice->$key == $selected ? " checked=\"checked\"" : ''); + } + $html .= "\n\t$key."\"$extra $tag_attribs />" . $choice->$text; + } + $html .= "\n"; + return $html; + } + + /** + * Writes a yes/no radio list + * @param string The value of the HTML name attribute + * @param string Additional HTML attributes for the '; + } + } + + function sortIcon( $base_href, $field, $state='none' ) { + $mosConfig_live_site = mamboCore::get('mosConfig_live_site'); + $alts = array( + 'none' => T_('No Sorting'), + 'asc' => T_('Sort Ascending'), + 'desc' => T_('Sort Descending'), + ); + $next_state = 'asc'; + if ($state == 'asc') { + $next_state = 'desc'; + } else if ($state == 'desc') { + $next_state = 'none'; + } + + $html = "" + . "\"{$alts[$next_state]}\"" + . ""; + return $html; + } + + /** + * Writes Close Button + */ + function CloseButton ( &$params, $hide_js=NULL ) { + // displays close button in Pop-up window + if ( $params->get( 'popup' ) && !$hide_js ) { + ?> +
+ + + + + +
+ get( 'back_button' ) && !$params->get( 'popup' ) && !$hide_js) { + ?> +
+ + + +
+ ]*>.*?'si", '', $text ); + $text = preg_replace( '/]*>([^<]+)<\/a>/is', '\2 (\1)', $text ); + $text = preg_replace( '//', '', $text ); + $text = preg_replace( '/{.+?}/', '', $text ); + $text = preg_replace( '/ /', ' ', $text ); + $text = preg_replace( '/&/', ' ', $text ); + $text = preg_replace( '/"/', ' ', $text ); + $text = strip_tags( $text ); + $text = htmlspecialchars( $text ); + return $text; + } + + /** + * Writes Print icon + */ + function PrintIcon( &$row, &$params, $hide_js, $link, $status=NULL ) { + if ( $params->get( 'print' ) && !$hide_js ) { + // use default settings if none declared + if ( !$status ) { + $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no'; + } + + // checks template image directory for image, if non found default are loaded + if ( $params->get( 'icons' ) ) { + $mainframe =& mosMainFrame::getInstance(); + $image = $mainframe->ImageCheck( 'printButton.png', '/images/M_images/', NULL, NULL, T_('Print')); + } else { + $image = _ICON_SEP .' '. T_('Print'). ' '. _ICON_SEP; + } + + if ( $params->get( 'popup' ) && !$hide_js ) { + // Print Preview button - used when viewing page + ?> + + + + + + + + + + + + \n"; + $replacement .= " \n"; + $replacement .= " \n"; + $replacement .= " \n"; + + return $replacement; + } + + function encoding_converter( $text ) { + // replace vowels with character encoding + $text = str_replace( 'a', 'a', $text ); + $text = str_replace( 'e', 'e', $text ); + $text = str_replace( 'i', 'i', $text ); + $text = str_replace( 'o', 'o', $text ); + $text = str_replace( 'u', 'u', $text ); + + return $text; + } +} + +class mosCommonHTML { + + function ContentLegend( ) { + ?> + + + + + + + + + + + + + + +
+ <?php echo T_('Pending') ?> + + Pending') ?> | + + <?php echo T_('Visible') ?> + + Current') ?> | + + <?php echo T_('Finished') ?> + + Expired') ?> | + + <?php echo T_('Finished') ?> + + +
+ +
+ + + + + +
+ + + + + + + + + menutype; ?> + + + + + + + + + + + name; ?> + + + + + + + + + + published ) { + case -2: + echo ''.T_('Trashed').''; + break; + case 0: + echo T_('UnPublished') ; + break; + case 1: + default: + echo ''.T_('Published').''; + break; + } + ?> + + + + + + + + + + +
+ + + + + + + + + menutype; ?> + + + + + + + + + type; ?> + + + + + + + + + + name; ?> + + + + + + + + + + published ) { + case -2: + echo ''.T_('Trashed').''; + break; + case 0: + echo T_('UnPublished'); + break; + case 1: + default: + echo ''.T_('Published').''; + break; + } + ?> + + + + + + checked_out_time, '%A, %d %B %Y' ); + $time = mosFormatDate( $row->checked_out_time, '%H:%M' ); + $checked_out_text = ''; + $checked_out_text .= ''; + $checked_out_text .= ''; + $checked_out_text .= ''; + $checked_out_text .= '
'. $row->editor .'
'. $date .'
'. $time .'
'; + $hover = 'onMouseOver="return overlib(\''. $checked_out_text .'\', CAPTION, \''.T_('Checked Out') .'\', BELOW, RIGHT);" onMouseOut="return nd();"'; + } + $checked = ''; + + return $checked; + } + + /* + * Loads all necessary files for JS Overlib tooltips + */ + function loadOverlib() { + ?> + + + + + + + + + access ) { + $color_access = 'style="color: green;"'; + $task_access = 'accessregistered'; + } else if ( $row->access == 1 ) { + $color_access = 'style="color: red;"'; + $task_access = 'accessspecial'; + } else { + $color_access = 'style="color: black;"'; + $task_access = 'accesspublic'; + } + + $href = ' + + '. $row->groupname .' + ' + ; + + return $href; + } + + function CheckedOutProcessing( &$row, $i ) { + $my = mamboCore::get('currentUser'); + if ( $row->checked_out ) { + $checked = mosCommonHTML::checkedOut( $row ); + } else { + $checked = mosHTML::idBox( $i, $row->id, ($row->checked_out && $row->checked_out != $my->id ) ); + } + + return $checked; + } + + function PublishedProcessing( &$row, $i ) { + $img = $row->published ? 'publish_g.png' : 'publish_x.png'; + $task = $row->published ? 'unpublish' : 'publish'; + $alt = $row->published ? T_('Published') : T_('Unpublished'); + $action = $row->published ? T_('Unpublish Item') : T_('Publish item'); + + $href = ' + + '. $alt .' + ' + ; + + return $href; + } +} + +/** +* Tab Creation handler +* @package Mambo +* @author Phil Taylor +*/ +class mosTabs { + /** @var int Use cookies */ + var $useCookies = 0; + + /** + * Constructor + * Includes files needed for displaying tabs and sets cookie options + * @param int useCookies, if set to 1 cookie will hold last used tab between page refreshes + */ + function mosTabs($useCookies) { + $mosConfig_live_site = mamboCore::get('mosConfig_live_site'); + echo ""; + echo ""; + $this->useCookies = $useCookies; + } + + /** + * creates a tab pane and creates JS obj + * @param string The Tab Pane Name + */ + function startPane($id){ + echo "
"; + echo "\n"; + } + + /** + * Ends Tab Pane + */ + function endPane() { + echo "
"; + } + + /* + * Creates a tab with title text and starts that tabs page + * @param tabText - This is what is displayed on the tab + * @param paneid - This is the parent pane to build this tab on + */ + function startTab( $tabText, $paneid ) { + echo "
"; + echo "

".$tabText."

"; + echo ""; + } + + /* + * Ends a tab page + */ + function endTab() { + echo "
"; + } +} + +?>