Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /joomla/html/html.php

Documentation is available at html.php

  1. <?php
  2. /**
  3. @version        $Id: html.php 6749 2007-03-01 22:54:50Z hackwar $
  4. @package        Joomla.Framework
  5. @subpackage    HTML
  6. @copyright    Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
  7. @license        GNU/GPL, see LICENSE.php
  8. *  Joomla! is free software. This version may have been modified pursuant
  9. *  to the GNU General Public License, and as distributed it includes or
  10. *  is derivative of works licensed under the GNU General Public License or
  11. *  other free or open source software licenses.
  12. *  See COPYRIGHT.php for copyright notices and details.
  13. */
  14.  
  15. /**
  16.  * Utility class for all HTML drawing classes
  17.  *
  18.  * @static
  19.  * @package     Joomla.Framework
  20.  * @subpackage    HTML
  21.  * @since        1.5
  22.  */
  23. class JHTML
  24. {
  25.     /**
  26.      * Write a <a></a> element
  27.      *
  28.      *  @access public
  29.      * @param string     The relative URL to use for the href attribute
  30.      * @param string    The target attribute to use
  31.      * @param array        An associative array of attributes to add
  32.      * @param integer    Set the SSL functionality
  33.      * @since 1.5
  34.      */
  35.  
  36.     function Link($url$text$attribs null$ssl 0)
  37.     {
  38.         $href JRoute::_($url$ssl);
  39.  
  40.         if (is_array($attribs)) {
  41.             $attribs JHTML::_implode_assoc('='' '$attribs);
  42.          }
  43.  
  44.         return '<a href="'.$href.'" '.$attribs.'>'.$text.'</a>';
  45.     }
  46.  
  47.     /**
  48.      * Write a <img></amg> element
  49.      *
  50.      * @access public
  51.      * @param string     The relative URL to use for the src attribute
  52.      * @param string    The target attribute to use
  53.      * @param array        An associative array of attributes to add
  54.      * @since 1.5
  55.      */
  56.     function Image($url$alt$attribs null)
  57.     {
  58.         global $mainframe;
  59.  
  60.         $src substr$url0!= 'http' $mainframe->getCfg('live_site'$url $url;
  61.  
  62.          if (is_array($attribs)) {
  63.             $attribs JHTML::_implode_assoc('='' '$attribs);
  64.          }
  65.  
  66.         return '<img src="'.$src.'" alt="'.$alt.'" '.$attribs.' />';
  67.  
  68.     }
  69.  
  70.     /**
  71.      * Write a <script></script> element
  72.      *
  73.      * @access public
  74.      * @param string     The relative URL to use for the src attribute
  75.      * @param string    The target attribute to use
  76.      * @param array        An associative array of attributes to add
  77.      * @since 1.5
  78.      */
  79.     function Script($url$attribs null)
  80.     {
  81.         global $mainframe;
  82.  
  83.         $src $mainframe->getCfg('live_site'$url;
  84.  
  85.          if (is_array($attribs)) {
  86.             $attribs JHTML::_implode_assoc('='' '$attribs);
  87.          }
  88.  
  89.         return '<script type="text/javascript" src="'.$src.'" '.$attribs.'></script>';
  90.     }
  91.  
  92.     /**
  93.      * Write a <iframe></iframe> element
  94.      *
  95.      * @access public
  96.      * @param string     The relative URL to use for the src attribute
  97.      * @param string    The target attribute to use
  98.      * @param array        An associative array of attributes to add
  99.      * @param integer    Set the SSL functionality
  100.      * @since 1.5
  101.      */
  102.     function Iframe($url$name$attribs null$ssl 0)
  103.     {
  104.         $src JRoute::_($url$ssl);
  105.  
  106.          if (is_array($attribs)) {
  107.             $attribs JHTML::_implode_assoc('='' '$attribs);
  108.          }
  109.  
  110.         return '<iframe src="'.$src.'" '.$attribs.' />';
  111.  
  112.     }
  113.  
  114.     /**
  115.      * Returns formated date according to current local and adds time offset
  116.      *
  117.      * @access public
  118.      * @param string date in an US English date format
  119.      * @param string format optional format for strftime
  120.      * @returns formated date
  121.      * @see strftime
  122.      * @since 1.5
  123.      */
  124.     function Date($date$format DATE_FORMAT_LC$offset NULL)
  125.     {
  126.         jimport('joomla.utilities.date');
  127.  
  128.         if(is_null($offset))
  129.         {
  130.             $config =JFactory::getConfig();
  131.             $offset $config->getValue('config.offset');
  132.         }
  133.         $instance new JDate($date);
  134.         $instance->setOffset($offset);
  135.  
  136.         return $instance->toFormat($format);
  137.     }
  138.  
  139.  
  140.  
  141.     /**
  142.     * @param int The row index
  143.     * @param int The record id
  144.     * @param boolean 
  145.     * @param string The name of the form element
  146.     * @return string 
  147.     */
  148.     function idBox$rowNum$recId$checkedOut=false$name='cid' )
  149.     {
  150.         if $checkedOut {
  151.             return '';
  152.         else {
  153.             return '<input type="checkbox" id="cb'.$rowNum.'" name="'.$name.'[]" value="'.$recId.'" onclick="isChecked(this.checked);" />';
  154.         }
  155.     }
  156.  
  157.     /**
  158.     * simple Javascript Cloaking
  159.     * email cloacking
  160.      * by default replaces an email with a mailto link with email cloacked
  161.     */
  162.     function emailCloaking$mail$mailto=1$text=''$email=)
  163.     {
  164.         // convert text
  165.         $mail             JHTML::_encoding_converter$mail );
  166.         // split email by @ symbol
  167.         $mail            explode'@'$mail );
  168.         $mail_parts        explode'.'$mail[1);
  169.         // random number
  170.         $rand            rand1100000 );
  171.  
  172.         $replacement     "\n <script language='JavaScript' type='text/javascript'>";
  173.         $replacement     .= "\n <!--";
  174.         $replacement     .= "\n var prefix = '&#109;a' + 'i&#108;' + '&#116;o';";
  175.         $replacement     .= "\n var path = 'hr' + 'ef' + '=';";
  176.         $replacement     .= "\n var addy"$rand ." = '"@$mail[0."' + '&#64;';";
  177.         $replacement     .= "\n addy"$rand ." = addy"$rand ." + '"implode"' + '&#46;' + '"$mail_parts ."';";
  178.  
  179.         if $mailto {
  180.             // special handling when mail text is different from mail addy
  181.             if $text {
  182.                 if $email {
  183.                     // convert text
  184.                     $text             JHTML::_encoding_converter$text );
  185.                     // split email by @ symbol
  186.                     $text             explode'@'$text );
  187.                     $text_parts        explode'.'$text[1);
  188.                     $replacement     .= "\n var addy_text"$rand ." = '"@$text[0."' + '&#64;' + '"implode"' + '&#46;' + '"@$text_parts ."';";
  189.                 else {
  190.                     $replacement     .= "\n var addy_text"$rand ." = '"$text ."';";
  191.                 }
  192.                 $replacement     .= "\n document.write( '<a ' + path + '\'' + prefix + ':' + addy"$rand ." + '\'>' );";
  193.                 $replacement     .= "\n document.write( addy_text"$rand ." );";
  194.                 $replacement     .= "\n document.write( '<\/a>' );";
  195.             else {
  196.                 $replacement     .= "\n document.write( '<a ' + path + '\'' + prefix + ':' + addy"$rand ." + '\'>' );";
  197.                 $replacement     .= "\n document.write( addy"$rand ." );";
  198.                 $replacement     .= "\n document.write( '<\/a>' );";
  199.             }
  200.         else {
  201.             $replacement     .= "\n document.write( addy"$rand ." );";
  202.         }
  203.         $replacement     .= "\n //-->";
  204.         $replacement     .= '\n </script>';
  205.  
  206.         // XHTML compliance `No Javascript` text handling
  207.         $replacement     .= "<script language='JavaScript' type='text/javascript'>";
  208.         $replacement     .= "\n <!--";
  209.         $replacement     .= "\n document.write( '<span style=\'display: none;\'>' );";
  210.         $replacement     .= "\n //-->";
  211.         $replacement     .= "\n </script>";
  212.         $replacement     .= JText::_('CLOAKING');
  213.         $replacement     .= "\n <script language='JavaScript' type='text/javascript'>";
  214.         $replacement     .= "\n <!--";
  215.         $replacement     .= "\n document.write( '</' );";
  216.         $replacement     .= "\n document.write( 'span>' );";
  217.         $replacement     .= "\n //-->";
  218.         $replacement     .= "\n </script>";
  219.  
  220.         return $replacement;
  221.     }
  222.  
  223.     /**
  224.      * Keep session alive, for example, while editing or creating an article.
  225.      */
  226.     function keepAlive()
  227.     {
  228.         $js "
  229.                 function keepAlive() {
  230.                     setTimeout('frames[\'keepAliveFrame\'].location.href=\'index.php?option=com_admin&tmpl=component&task=keepalive\';', 60000);
  231.                 }";
  232.  
  233.         $html "<iframe id=\"keepAliveFrame\" name=\"keepAliveFrame\" " .
  234.                 "style=\"width:0px; height:0px; border: 0px\" " .
  235.                 "src=\"index.php?option=com_admin&tmpl=component&task=keepalive\" " .
  236.                 "onload=\"keepAlive();\"></iframe>";
  237.  
  238.         $doc =JFactory::getDocument();
  239.         $doc->addScriptDeclaration($js);
  240.         echo $html;
  241.     }
  242.  
  243.     function _encoding_converter$text )
  244.     {
  245.         // replace vowels with character encoding
  246.         $text     str_replace'a''&#97;'$text );
  247.         $text     str_replace'e''&#101;'$text );
  248.         $text     str_replace'i''&#105;'$text );
  249.         $text     str_replace'o''&#111;'$text );
  250.         $text    str_replace'u''&#117;'$text );
  251.  
  252.         return $text;
  253.     }
  254.  
  255.     function _implode_assoc($inner_glue "="$outer_glue "\n"$array null$keepOuterKey false)
  256.     {
  257.         $output array();
  258.  
  259.         foreach($array as $key => $item)
  260.         if (is_array ($item)) {
  261.             if ($keepOuterKey)
  262.                 $output[$key;
  263.             // This is value is an array, go and do it again!
  264.             $output[JHTML::_implode_assoc($inner_glue$outer_glue$item$keepOuterKey);
  265.         else
  266.             $output[$key $inner_glue $item;
  267.  
  268.         return implode($outer_glue$output);
  269.     }
  270. }
  271.  
  272. /**
  273.  * Utility class for creating HTML select lists
  274.  *
  275.  * @static
  276.  * @package     Joomla.Framework
  277.  * @subpackage    HTML
  278.  * @since        1.5
  279.  */
  280. {
  281.     function option$value$text=''$value_name='value'$text_name='text' )
  282.     {
  283.         $obj new stdClass;
  284.         $obj->$value_name $value;
  285.         $obj->$text_name trim$text $text $value;
  286.         return $obj;
  287.     }
  288.  
  289.     /**
  290.     * Generates an HTML select list
  291.     *
  292.     * @param array An array of objects
  293.     * @param string The value of the HTML name attribute
  294.     * @param string Additional HTML attributes for the <select> tag
  295.     * @param string The name of the object variable for the option value
  296.     * @param string The name of the object variable for the option text
  297.     * @param mixed The key that is selected (accepts an array or a string)
  298.     * @returns string HTML for the select list
  299.     */
  300.     function genericList$arr$tag_name$tag_attribs$key$text$selected=NULL$idtag=false$flag=false )
  301.     {
  302.         // check if array
  303.         if is_array$arr ) ) {
  304.             reset$arr );
  305.         }
  306.  
  307.         $id $tag_name;
  308.         if $idtag {
  309.             $id $idtag;
  310.         }
  311.         $id str_replace('[','',$id);
  312.         $id str_replace(']','',$id);
  313.  
  314.         $html '<select name="'$tag_name .'" id="'$id .'" '$tag_attribs .'>';
  315. //        for ($i=0, $n=count( $arr ); $i < $n; $i++ ) {
  316.         while(current($arr!== FALSE{
  317.             $element =$arr[key($arr)]// since current doesn't return a reference, need to do this
  318.  
  319.             $isArray is_array$element );
  320.             if ($isArray{
  321.                 $k         $element[$key];
  322.                 $t         $element[$text];
  323.                 $id     isset$element['id'$element['id'null );
  324.             else {
  325.                 $k         $element->$key;
  326.                 $t         $element->$text;
  327.                 $id     isset$element->id $element->id null );
  328.             }
  329.  
  330.             // This is real dirty, open to suggestions,
  331.             // barring doing a propper object to handle it
  332.             if ($k === '<OPTGROUP>'{
  333.                 $html .= '<optgroup label="' $t '">';
  334.             else if ($k === '</OPTGROUP>'{
  335.                 $html .= '</optgroup>';
  336.             else {
  337.                 //if no string after hypen - take hypen out
  338.                 $splitText explode" - "$t);
  339.                 $t $splitText[0];
  340.                 if(isset($splitText[1]))$t .= " - "$splitText[1]}
  341.  
  342.                 $extra '';
  343.                 //$extra .= $id ? ' id="' . $arr[$i]->id . '"' : '';
  344.                 if (is_array$selected )) {
  345.                     foreach ($selected as $obj{
  346.                         $k2 $obj->$key;
  347.                         if ($k == $k2{
  348.                             $extra .= ' selected="selected"';
  349.                             break;
  350.                         }
  351.                     }
  352.                 else {
  353.                     $extra .= $k == $selected ' selected="selected"' '' );
  354.                 }
  355.                 //if flag translate text
  356.                 if ($flag{
  357.                     $t JText::_$t );
  358.                 }
  359.  
  360.                 $html .= '<option value="'$k .'" '$extra .'>' $t '</option>';
  361.             }
  362.             next($arr);
  363.         }
  364.         $html .= '</select>';
  365.  
  366.         return $html;
  367.     }
  368.  
  369.     /**
  370.     * Generates a select list of integers
  371.     *
  372.     * @param int The start integer
  373.     * @param int The end integer
  374.     * @param int The increment
  375.     * @param string The value of the HTML name attribute
  376.     * @param string Additional HTML attributes for the <select> tag
  377.     * @param mixed The key that is selected
  378.     * @param string The printf format to be applied to the number
  379.     * @returns string HTML for the select list
  380.     */
  381.     function integerList$start$end$inc$tag_name$tag_attribs$selected$format="" )
  382.     {
  383.         $start     intval$start );
  384.         $end     intval$end );
  385.         $inc     intval$inc );
  386.         $arr     array();
  387.  
  388.         for ($i=$start$i <= $end$i+=$inc{
  389.             $fi $format sprintf"$format"$i "$i";
  390.             $arr[JHTMLSelect::option$fi$fi );
  391.         }
  392.  
  393.         return JHTMLSelect::genericList$arr$tag_name$tag_attribs'value''text'$selected );
  394.     }
  395.  
  396.     /**
  397.     * Generates an HTML radio list
  398.     *
  399.     * @param array An array of objects
  400.     * @param string The value of the HTML name attribute
  401.     * @param string Additional HTML attributes for the <select> tag
  402.     * @param mixed The key that is selected
  403.     * @param string The name of the object variable for the option value
  404.     * @param string The name of the object variable for the option text
  405.     * @returns string HTML for the select list
  406.     */
  407.     function radioList$arr$tag_name$tag_attribs$selected=null$key='value'$text='text'$idtag=false )
  408.     {
  409.         reset$arr );
  410.         $html '';
  411.  
  412.         $id_text $tag_name;
  413.         if $idtag {
  414.             $id_text $idtag;
  415.         }
  416.  
  417.         for ($i=0$n=count$arr )$i $n$i++ {
  418.             $k $arr[$i]->$key;
  419.             $t $arr[$i]->$text;
  420.             $id isset($arr[$i]->id@$arr[$i]->id null);
  421.  
  422.             $extra '';
  423.             $extra .= $id " id=\"" $arr[$i]->id "\"" '';
  424.             if (is_array$selected )) {
  425.                 foreach ($selected as $obj{
  426.                     $k2 $obj->$key;
  427.                     if ($k == $k2{
  428.                         $extra .= " selected=\"selected\"";
  429.                         break;
  430.                     }
  431.                 }
  432.             else {
  433.                 $extra .= ($k == $selected " checked=\"checked\"" '');
  434.             }
  435.             $html .= "\n\t<input type=\"radio\" name=\"$tag_name\" id=\"$id_text$k\" value=\"".$k."\"$extra $tag_attribs />";
  436.             $html .= "\n\t<label for=\"$id_text$k\">$t</label>";
  437.         }
  438.         $html .= "\n";
  439.         return $html;
  440.     }
  441.  
  442.     /**
  443.     * Generates a yes/no radio list
  444.     *
  445.     * @param string The value of the HTML name attribute
  446.     * @param string Additional HTML attributes for the <select> tag
  447.     * @param mixed The key that is selected
  448.     * @returns string HTML for the radio list
  449.     */
  450.     function yesnoList$tag_name$tag_attribs$selected$yes='yes'$no='no'$id=false {
  451.  
  452.         $arr array(
  453.             JHTMLSelect::Option'0'JText::_$no ) ),
  454.             JHTMLSelect::Option'1'JText::_$yes ) )
  455.         );
  456.         return JHTMLSelect::radioList$arr$tag_name$tag_attribs(int) $selected'value''text'$id );
  457.     }
  458. }
  459.  
  460. /**
  461.  * Utility class for drawing common HTML elements
  462.  *
  463.  * @static
  464.  * @package     Joomla.Framework
  465.  * @subpackage    HTML
  466.  * @since        1.5
  467.  */
  468. {
  469.     /*
  470.      * Function is only used in the administrator
  471.      */
  472.     function ContentLegend)
  473.     {
  474.         ?>
  475.         <table cellspacing="0" cellpadding="4" border="0" align="center">
  476.         <tr align="center">
  477.             <td>
  478.             <img src="images/publish_y.png" width="16" height="16" border="0" alt="<?php echo JText::_'Pending' )?>" />
  479.             </td>
  480.             <td>
  481.             <?php echo JText::_'Published, but is' )?> <u><?php echo JText::_'Pending' )?></u> |
  482.             </td>
  483.             <td>
  484.             <img src="images/publish_g.png" width="16" height="16" border="0" alt="<?php echo JText::_'Visible' )?>" />
  485.             </td>
  486.             <td>
  487.             <?php echo JText::_'Published and is' )?> <u><?php echo JText::_'Current' )?></u> |
  488.             </td>
  489.             <td>
  490.             <img src="images/publish_r.png" width="16" height="16" border="0" alt="<?php echo JText::_'Finished' )?>" />
  491.             </td>
  492.             <td>
  493.             <?php echo JText::_'Published, but has' )?> <u><?php echo JText::_'Expired' )?></u> |
  494.             </td>
  495.             <td>
  496.             <img src="images/publish_x.png" width="16" height="16" border="0" alt="<?php echo JText::_'Finished' )?>" />
  497.             </td>
  498.             <td>
  499.             <?php echo JText::_'Not Published' )?>
  500.             </td>
  501.         </tr>
  502.         <tr>
  503.             <td colspan="8" align="center">
  504.             <?php echo JText::_'Click on icon to toggle state.' )?>
  505.             </td>
  506.         </tr>
  507.         </table>
  508.         <?php
  509.     }
  510.  
  511.     /*
  512.      * Function is only used in the administrator
  513.      */
  514.     function checkedOut&$row$overlib=)
  515.     {
  516.         $hover '';
  517.         if $overlib {
  518.  
  519.             $text addslashes(htmlspecialchars($row->editor));
  520.  
  521.             $date                 JHTML::Date$row->checked_out_time'%A, %d %B %Y' );
  522.             $time                JHTML::Date$row->checked_out_time'%H:%M' );
  523.  
  524.             $hover '<span class="editlinktip hasTip" title="'JText::_'Checked Out' .'::'$text .'<br />'$date .'<br />'$time .'">';
  525.         }
  526.         $checked $hover .'<img src="images/checked_out.png"/></span>';
  527.  
  528.         return $checked;
  529.     }
  530.  
  531.     /*
  532.      * Creates a tooltip with an image as button
  533.      */
  534.     function ToolTip($tooltip$title=''$image='tooltip.png'$text=''$href=''$link=1)
  535.     {
  536.         global $mainframe;
  537.  
  538.         $tooltip    addslashes(htmlspecialchars($tooltip));
  539.         $title        addslashes(htmlspecialchars($title));
  540.  
  541.         $url $mainframe->isAdmin($mainframe->getSiteURL(JURI::base();
  542.  
  543.         if !$text {
  544.             $image     $url 'includes/js/ThemeOffice/'$image;
  545.             $text     '<img src="'$image .'" border="0" alt="'JText::_'Tooltip' .'"/>';
  546.         else {
  547.             $text     JText::_$texttrue );
  548.         }
  549.  
  550.         if($title{
  551.             $title $title.'::';
  552.         }
  553.  
  554.         $style 'style="text-decoration: none; color: #333;"';
  555.  
  556.         if $href {
  557.             $href ampReplace$href );
  558.             $style '';
  559.         }
  560.         if $link {
  561.             $tip '<span class="editlinktip hasTip" title="'.$title.$tooltip.'" '$style .'><a href="'$href .'">'$text .'</a></span>';
  562.         else {
  563.             $tip '<span class="editlinktip hasTip" title="'.$title.$tooltip.'" '$style .'>'$text .'</span>';
  564.         }
  565.  
  566.         return $tip;
  567.     }
  568.  
  569.     /*
  570.     * Loads all necessary files for JS Calendar
  571.     */
  572.     /*
  573.      * Function is used in the administrator/site : move into JCalendar
  574.      */
  575.     function loadCalendar()
  576.     {
  577.         global $mainframe;
  578.  
  579.         $doc =JFactory::getDocument();
  580.         $lang =JFactory::getLanguage();
  581.         $url $mainframe->isAdmin($mainframe->getSiteURL(JURI::base();
  582.  
  583.         $doc->addStyleSheet$url'includes/js/calendar/calendar-mos.css''text/css'nullarray(' title' => JText::_'green' ,' media' => 'all' ));
  584.         $doc->addScript$url'includes/js/calendar/calendar_mini.js' );
  585.         $langScript JPATH_SITE.DS.'includes'.DS.'js'.DS.'calendar'.DS.'lang'.DS.'calendar-'.$lang->getTag().'.js';
  586.         iffile_exists$langScript ) ){
  587.             $doc->addScript$url'includes/js/calendar/lang/calendar-'.$lang->getTag().'.js' );
  588.         else {
  589.             $doc->addScript$url'includes/js/calendar/lang/calendar-en-GB.js' );
  590.         }
  591.     }
  592.  
  593.     /*
  594.      * Function is used only in the administrator : move to JHTMLGrid
  595.      */
  596.     function AccessProcessing&$row$i$archived=NULL )
  597.     {
  598.         if !$row->access {
  599.             $color_access 'style="color: green;"';
  600.             $task_access 'accessregistered';
  601.         else if $row->access == {
  602.             $color_access 'style="color: red;"';
  603.             $task_access 'accessspecial';
  604.         else {
  605.             $color_access 'style="color: black;"';
  606.             $task_access 'accesspublic';
  607.         }
  608.  
  609.         if ($archived == -1{
  610.             $href JText::_$row->groupname );
  611.         else {
  612.             $href '
  613.             <a href="javascript:void(0);" onclick="return listItemTask(\'cb'$i .'\',\''$task_access .'\')" '$color_access .'>
  614.             'JText::_$row->groupname .'
  615.             </a>'
  616.             ;
  617.         }
  618.  
  619.         return $href;
  620.     }
  621.  
  622.     /*
  623.      * Function is used only in the administrator : move to JHTMLGrid
  624.      */
  625.     function CheckedOutProcessing&$row$i$identifier 'id' )
  626.     {
  627.         $user   =JFactory::getUser();
  628.         $userid $user->get('id');
  629.  
  630.         $result false;
  631.         if(is_a($row'JTable')) {
  632.             $result $row->isCheckedOut($userid);
  633.         else {
  634.             $result JTable::isCheckedOut($userid$row->checked_out);
  635.         }
  636.  
  637.         $checked '';
  638.         if $result {
  639.             $checked JCommonHTML::checkedOut$row );
  640.         else {
  641.             $checked JHTML::idBox$i$row->$identifier );
  642.         }
  643.  
  644.         return $checked;
  645.     }
  646.  
  647.     /*
  648.      * Function is used only in the administrator : move to JHTMLGrid
  649.      */
  650.     function PublishedProcessing&$row$i$imgY='tick.png'$imgX='publish_x.png'$prefix='' )
  651.     {
  652.         $img     $row->published $imgY $imgX;
  653.         $task     $row->published 'unpublish' 'publish';
  654.         $alt     $row->published JText::_'Published' JText::_'Unpublished' );
  655.         $action $row->published JText::_'Unpublish Item' JText::_'Publish item' );
  656.  
  657.         $href '
  658.         <a href="javascript:void(0);" onclick="return listItemTask(\'cb'$i .'\',\''$prefix.$task .'\')" title="'$action .'">
  659.         <img src="images/'$img .'" border="0" alt="'$alt .'" />
  660.         </a>'
  661.         ;
  662.  
  663.         return $href;
  664.     }
  665.  
  666.     /*
  667.      * Function is used only in the administrator : move to JHTMLGrid
  668.      */
  669.     function selectState$filter_state='*'$published='Published'$unpublished='Unpublished'$archived=NULL )
  670.     {
  671.         $state[JHTMLSelect::option'''- 'JText::_'Select State' .' -' );
  672.         $state[JHTMLSelect::option'*'JText::_'Any' ) );
  673.         $state[JHTMLSelect::option'P'JText::_$published ) );
  674.         $state[JHTMLSelect::option'U'JText::_$unpublished ) );
  675.  
  676.         if ($archived{
  677.             $state[JHTMLSelect::option'A'JText::_$archived ) );
  678.         }
  679.  
  680.         return JHTMLSelect::genericList$state'filter_state''class="inputbox" size="1" onchange="submitform( );"''value''text'$filter_state );
  681.     }
  682.  
  683.     /*
  684.      * Function is used only in the administrator : move to JHTMLGrid
  685.      */
  686.     function saveorderButton$rows$image='filesave.png'$task="saveorder" )
  687.     {
  688.         $image JAdminMenus::ImageCheckAdmin$image'/images/'NULLNULLJText::_'Save Order' )'');
  689.         ?>
  690.         <a href="javascript:saveorder(<?php echo count$rows )-1?>, '<?php echo $task?>')" title="<?php echo JText::_'Save Order' )?>">
  691.             <?php echo $image?></a>
  692.         <?php
  693.     }
  694.  
  695.     /*
  696.      * Function is used only in the administrator : move to JHTMLGrid
  697.      */
  698.     function tableOrdering$text$ordering&$lists$task=NULL )
  699.     {
  700.         ?>
  701.         <a href="javascript:tableOrdering('<?php echo $ordering?>','<?php echo $lists['order_Dir']?>','<?php echo $task?>');" title="<?php echo JText::_'Order by' )?> <?php echo JText::_$text )?>">
  702.             <?php echo JText::_$text )?>
  703.             <?php JCommonHTML::tableOrdering_img$ordering$lists )?></a>
  704.         <?php
  705.     }
  706.  
  707.     /*
  708.      * Function is used only in the administrator : move to JHTMLGrid
  709.      */
  710.     function tableOrdering_img$current&$lists )
  711.     {
  712.         if $current == $lists['order']{
  713.             if $lists['order_Dir'== 'ASC' {
  714.                 $image 'sort_desc.png';
  715.             else {
  716.                 $image 'sort_asc.png';
  717.             }
  718.             echo JAdminMenus::ImageCheckAdmin$image'/images/'NULLNULL'''');
  719.         }
  720.     }
  721. }
  722.  
  723. /**
  724.  * Utility class for drawing admin menu HTML elements
  725.  *
  726.  * @static
  727.  * @package     Joomla.Framework
  728.  * @subpackage    HTML
  729.  * @since        1.0
  730.  */
  731. {
  732.     /**
  733.     * build the select list for Menu Ordering
  734.     */
  735.     /*
  736.      * Function is only used in administrator/component/com_menus/views/item/tmpl/form.php
  737.      */
  738.     function Ordering&$row$id )
  739.     {
  740.         $db =JFactory::getDBO();
  741.  
  742.         if $id {
  743.             $query 'SELECT ordering AS value, name AS text'
  744.             . ' FROM #__menu'
  745.             . ' WHERE menutype = \''.$row->menutype
  746.             . '\' AND parent = '.$row->parent
  747.             . ' AND published != -2'
  748.             . ' ORDER BY ordering';
  749.             $order JAdminMenus::GenericOrdering$query );
  750.             $ordering JHTMLSelect::genericList$order'ordering''class="inputbox" size="1"''value''text'intval$row->ordering ) );
  751.         else {
  752.             $ordering '<input type="hidden" name="ordering" value="'$row->ordering .'" />'JText::_'DESCNEWITEMSLAST' );
  753.         }
  754.         return $ordering;
  755.     }
  756.  
  757.     /**
  758.     * build the select list for access level
  759.     */
  760.     /*
  761.      * Function is used in administrator/site (com_content) : move into parameters
  762.      */
  763.     function Access&$row )
  764.     {
  765.         $db =JFactory::getDBO();
  766.  
  767.         $query 'SELECT id AS value, name AS text'
  768.         . ' FROM #__groups'
  769.         . ' ORDER BY id'
  770.         ;
  771.         $db->setQuery$query );
  772.         $groups $db->loadObjectList();
  773.         $access JHTMLSelect::genericList$groups'access''class="inputbox" size="3"''value''text'intval$row->access )'');
  774.  
  775.         return $access;
  776.     }
  777.  
  778.     /**
  779.     * build the multiple select list for Menu Links/Pages
  780.     */
  781.     /*
  782.      * Function is only used in the administrator (multiple components)
  783.      */
  784.     function MenuLinkOptions$all=false$unassigned=false )
  785.     {
  786.         $db =JFactory::getDBO();
  787.  
  788.         // get a list of the menu items
  789.         $query 'SELECT m.id, m.parent, m.name, m.menutype'
  790.         . ' FROM #__menu AS m'
  791.         . ' WHERE m.published = 1'
  792.         . ' ORDER BY m.menutype, m.parent, m.ordering'
  793.         ;
  794.         $db->setQuery$query );
  795.         $mitems $db->loadObjectList();
  796.         $mitems_temp $mitems;
  797.  
  798.         // establish the hierarchy of the menu
  799.         $children array();
  800.         // first pass - collect children
  801.         foreach $mitems as $v )
  802.         {
  803.             $id $v->id;
  804.             $pt $v->parent;
  805.             $list @$children[$pt$children[$ptarray();
  806.             array_push$list$v );
  807.             $children[$pt$list;
  808.         }
  809.         // second pass - get an indent list of the items
  810.         $list mosTreeRecurseintval$mitems[0]->parent )''array()$children99990);
  811.  
  812.         // Code that adds menu name to Display of Page(s)
  813.         $mitems_spacer     $mitems_temp[0]->menutype;
  814.  
  815.         $mitems array();
  816.         if ($all $unassigned{
  817.             $mitems[JHTMLSelect::option'<OPTGROUP>'JText::_'Menus' ) );
  818.  
  819.             if $all {
  820.                 $mitems[JHTMLSelect::option0JText::_'All' ) );
  821.             }
  822.             if $unassigned {
  823.                 $mitems[JHTMLSelect::option-1JText::_'Unassigned' ) );
  824.             }
  825.  
  826.             $mitems[JHTMLSelect::option'</OPTGROUP>' );
  827.         }
  828.  
  829.         $lastMenuType    null;
  830.         $tmpMenuType    null;
  831.         foreach ($list as $list_a)
  832.         {
  833.             if ($list_a->menutype != $lastMenuType)
  834.             {
  835.                 if ($tmpMenuType{
  836.                     $mitems[JHTMLSelect::option'</OPTGROUP>' );
  837.                 }
  838.                 $mitems[JHTMLSelect::option'<OPTGROUP>'$list_a->menutype );
  839.                 $lastMenuType $list_a->menutype;
  840.                 $tmpMenuType  $list_a->menutype;
  841.             }
  842.  
  843.             $mitems[JHTMLSelect::option$list_a->id$list_a->treename );
  844.         }
  845.         if ($lastMenuType !== null{
  846.             $mitems[JHTMLSelect::option'</OPTGROUP>' );
  847.         }
  848.  
  849.         return $mitems;
  850.     }
  851.  
  852.     /**
  853.     * build the select list to choose an image
  854.     */
  855.     /*
  856.      * Function is only used in the administrator (multiple components) : duplicate with JElementImagelist
  857.      */
  858.     function Images$name&$active$javascript=NULL$directory=NULL )
  859.     {
  860.         if !$directory {
  861.             $directory '/images/stories/';
  862.         }
  863.  
  864.         if !$javascript {
  865.             $javascript "onchange=\"javascript:if (document.forms[0]." $name ".options[selectedIndex].value!='') {document.imagelib.src='..$directory' + document.forms[0].$name ".options[selectedIndex].value} else {document.imagelib.src='../images/blank.png'}\"";
  866.         }
  867.  
  868.         jimport'joomla.filesystem.folder' );
  869.         $imageFiles JFolder::filesJPATH_SITE.DS.$directory );
  870.         $images     array(  JHTMLSelect::option'''- 'JText::_'Select Image' .' -' ) );
  871.         foreach $imageFiles as $file {
  872.             if eregi"bmp|gif|jpg|png"$file ) ) {
  873.                 $images[JHTMLSelect::option$file );
  874.             }
  875.         }
  876.         $images JHTMLSelect::genericList$images$name'class="inputbox" size="1" '$javascript'value''text'$active );
  877.  
  878.         return $images;
  879.     }
  880.  
  881.     /**
  882.      * Description
  883.      *
  884.       * @param string SQL with ordering As value and 'name field' AS text
  885.       * @param integer The length of the truncated headline
  886.       * @since 1.5
  887.       */
  888.       /*
  889.      * Function is only used in the administrator (com_plugins)
  890.      */
  891.     function GenericOrdering$sql$chop='30' )
  892.     {
  893.         $db =JFactory::getDBO();
  894.         $order array();
  895.         $db->setQuery$sql );
  896.         if (!($orders $db->loadObjectList())) {
  897.             if ($db->getErrorNum()) {
  898.                 echo $db->stderr();
  899.                 return false;
  900.             else {
  901.                 $order[JHTMLSelect::option1JText::_'first' ) );
  902.                 return $order;
  903.             }
  904.         }
  905.         $order[JHTMLSelect::option0'0 'JText::_'first' ) );
  906.         for ($i=0$n=count$orders )$i $n$i++{
  907.  
  908.             if (JString::strlen($orders[$i]->text$chop{
  909.                 $text JString::substr($orders[$i]->text,0,$chop)."...";
  910.             else {
  911.                 $text $orders[$i]->text;
  912.             }
  913.  
  914.             $order[JHTMLSelect::option$orders[$i]->value$orders[$i]->value.' ('.$text.')' );
  915.         }
  916.         $order[JHTMLSelect::option$orders[$i-1]->value+1($orders[$i-1]->value+1).' 'JText::_'last' ) );
  917.  
  918.         return $order;
  919.     }
  920.  
  921.     /**
  922.     * build the select list for Ordering of a specified Table
  923.     */
  924.     /*
  925.      * Function is only used in the administrator (multiple components)
  926.      */
  927.     function SpecificOrdering&$row$id$query$neworder=)
  928.     {
  929.         $db =JFactory::getDBO();
  930.  
  931.         if $id {
  932.             $order JAdminMenus::GenericOrdering$query );
  933.             $ordering JHTMLSelect::genericList$order'ordering''class="inputbox" size="1"''value''text'intval$row->ordering ) );
  934.         else {
  935.             if $neworder {
  936.                 $text JText::_'descNewItemsFirst' );
  937.             else {
  938.                 $text JText::_'descNewItemsLast' );
  939.             }
  940.             $ordering '<input type="hidden" name="ordering" value="'$row->ordering .'" />'$text;
  941.         }
  942.         return $ordering;
  943.     }
  944.  
  945.     /**
  946.     * Select list of active users
  947.     */
  948.     /*
  949.      * Function is only used in the administrator (multiple components) : function could create preformance issues
  950.      */
  951.     function UserSelect$name$active$nouser=0$javascript=NULL$order='name'$reg=)
  952.     {
  953.         $db =JFactory::getDBO();
  954.  
  955.         $and '';
  956.         if $reg {
  957.         // does not include registered users in the list
  958.             $and ' AND gid > 18';
  959.         }
  960.  
  961.         $query 'SELECT id AS value, name AS text'
  962.         . ' FROM #__users'
  963.         . ' WHERE block = 0'
  964.         . $and
  965.         . ' ORDER BY '$order
  966.         ;
  967.         $db->setQuery$query );
  968.         if $nouser {
  969.             $users[JHTMLSelect::option'0''- 'JText::_'No User' .' -' );
  970.             $users array_merge$users$db->loadObjectList() );
  971.         else {
  972.             $users $db->loadObjectList();
  973.         }
  974.  
  975.         $users JHTMLSelect::genericList$users$name'class="inputbox" size="1" '$javascript'value''text'$active );
  976.  
  977.         return $users;
  978.     }
  979.  
  980.     /**
  981.     * Select list of positions - generally used for location of images
  982.     */
  983.     /*
  984.      * Function is only used in the administrator (com_categories, com_sections)
  985.      */
  986.     function Positions$name$active=NULL$javascript=NULL$none=1$center=1$left=1$right=1$id=false )
  987.     {
  988.         if $none {
  989.             $pos[JHTMLSelect::option''JText::_'None' ) );
  990.         }
  991.         if $center {
  992.             $pos[JHTMLSelect::option'center'JText::_'Center' ) );
  993.         }
  994.         if $left {
  995.             $pos[JHTMLSelect::option'left'JText::_'Left' ) );
  996.         }
  997.         if $right {
  998.             $pos[JHTMLSelect::option'right'JText::_'Right' ) );
  999.         }
  1000.  
  1001.         $positions JHTMLSelect::genericList$pos$name'class="inputbox" size="1"'$javascript'value''text'$active$id );
  1002.  
  1003.         return $positions;
  1004.     }
  1005.  
  1006.     /**
  1007.     * Select list of active categories for components
  1008.     */
  1009.     /*
  1010.      * Function is used in the site/administrator : duplicate in JElementCategory
  1011.      */
  1012.     function ComponentCategory$name$section$active=NULL$javascript=NULL$order='ordering'$size=1$sel_cat=)
  1013.     {
  1014.         global $mainframe;
  1015.  
  1016.         $db =JFactory::getDBO();
  1017.  
  1018.         $query 'SELECT id AS value, name AS text'
  1019.         . ' FROM #__categories'
  1020.         . ' WHERE section = "'$section '"'
  1021.         . ' AND published = 1'
  1022.         . ' ORDER BY '$order
  1023.         ;
  1024.         $db->setQuery$query );
  1025.         if $sel_cat {
  1026.             $categories[JHTMLSelect::option'0''- 'JText::_'Select a Category' .' -' );
  1027.             $categories array_merge$categories$db->loadObjectList() );
  1028.         else {
  1029.             $categories $db->loadObjectList();
  1030.         }
  1031.  
  1032.         if count$categories {
  1033.             $mainframe->redirect'index.php?option=com_categories&section='$sectionJText::_'You must create a category first.' ) );
  1034.         }
  1035.  
  1036.         $category JHTMLSelect::genericList$categories$name'class="inputbox" size="'$size .'" '$javascript'value''text'$active );
  1037.  
  1038.         return $category;
  1039.     }
  1040.  
  1041.     /**
  1042.     * Select list of active sections
  1043.     */
  1044.     /*
  1045.      * Function is only used in the administrator : duplicate in JElementSection
  1046.      */
  1047.     function SelectSection$name$active=NULL$javascript=NULL$order='ordering' )
  1048.     {
  1049.         $db =JFactory::getDBO();
  1050.  
  1051.         $categories[JHTMLSelect::option'-1''- 'JText::_'Select Section' .' -' );
  1052.         $categories[JHTMLSelect::option'0'JText::_'Uncategorized' ) );
  1053.         $query 'SELECT id AS value, title AS text'
  1054.         . ' FROM #__sections'
  1055.         . ' WHERE published = 1'
  1056.         . ' ORDER BY ' $order
  1057.         ;
  1058.         $db->setQuery$query );
  1059.         $sections array_merge$categories$db->loadObjectList() );
  1060.  
  1061.         $category JHTMLSelect::genericList$sections$name'class="inputbox" size="1" '$javascript'value''text'$active );
  1062.  
  1063.         return $category;
  1064.     }
  1065.  
  1066.     /**
  1067.     * Checks to see if an image exists in the current templates image directory
  1068.      * if it does it loads this image.  Otherwise the default image is loaded.
  1069.     * Also can be used in conjunction with the menulist param to create the chosen image
  1070.     * load the default or use no image
  1071.     */
  1072.     /*
  1073.      * Function is only used in the site/administrator : move to JHTML::Image
  1074.      */
  1075.     function ImageCheck$file$directory='/images/M_images/'$param=NULL$param_directory='/images/M_images/'$alt=NULL$name='image'$type=1$align='top' )
  1076.     {
  1077.         static $paths;
  1078.         global $mainframe;
  1079.  
  1080.         if (!$paths)
  1081.         {
  1082.             $paths array();
  1083.         }
  1084.  
  1085.         $cur_template $mainframe->getTemplate();
  1086.  
  1087.         // strip html
  1088.         $alt    html_entity_decode$alt );
  1089.  
  1090.         if $param {
  1091.             $image $param_directory $param;
  1092.             if $type {
  1093.                 $image '<img src="'$image .'" align="'$align .'" alt="'$alt .'" border="0" />';
  1094.             }
  1095.         else if $param == -{
  1096.             $image '';
  1097.         else {
  1098.             $path JPATH_SITE .'/templates/'$cur_template .'/images/'$file;
  1099.             if (!isset$paths[$path))
  1100.             {
  1101.                 if file_existsJPATH_SITE .'/templates/'$cur_template .'/images/'$file ) ) {
  1102.                     $paths[$path'templates/'$cur_template .'/images/'$file;
  1103.                 else {
  1104.                     // outputs only path to image
  1105.                     $paths[$path$directory $file;
  1106.                 }
  1107.             }
  1108.             $image $paths[$path];
  1109.         }
  1110.  
  1111.         if (substr($image0== "/"{
  1112.             $image substr_replace($image''01);
  1113.         }
  1114.  
  1115.         // outputs actual html <img> tag
  1116.         if $type {
  1117.             $image '<img src="'$image .'" alt="'$alt .'" align="'$align .'" border="0" />';
  1118.         }
  1119.  
  1120.         return $image;
  1121.     }
  1122.  
  1123.     /**
  1124.     * Checks to see if an image exists in the current templates image directory
  1125.     * if it does it loads this image.  Otherwise the default image is loaded.
  1126.     * Also can be used in conjunction with the menulist param to create the chosen image
  1127.     * load the default or use no image
  1128.     */
  1129.     /*
  1130.      * Function is only used in the site/administrator : move to JHTML::Image (combine with ImageCheck)
  1131.      */
  1132.     function ImageCheckAdmin$file$directory='/images/'$param=NULL$param_directory='/images/'$alt=NULL$name=NULL$type=1$align='middle' )
  1133.     {
  1134.         global $mainframe;
  1135.  
  1136.         $cur_template $mainframe->getTemplate();
  1137.  
  1138.         // strip html
  1139.         $alt    html_entity_decode$alt );
  1140.  
  1141.         if $param {
  1142.             $image $param_directory $param;
  1143.         else if $param == -{
  1144.             $image '';
  1145.         else {
  1146.             if file_existsJPATH_ADMINISTRATOR .'/templates/'$cur_template .'/images/'$file ) ) {
  1147.                 $image 'templates/'$cur_template .'/images/'$file;
  1148.             else {
  1149.                 // compability with previous versions
  1150.                 if substr($directory014 )== "/administrator" {
  1151.                     $image substr($directory,15$file;
  1152.                 else {
  1153.                     $image $directory $file;
  1154.                 }
  1155.             }
  1156.         }
  1157.  
  1158.         if (substr($image0== "/"{
  1159.             $image substr_replace($image''01);
  1160.         }
  1161.  
  1162.         // outputs actual html <img> tag
  1163.         if $type {
  1164.             $image '<img src="'$image .'" alt="'$alt .'" align="'$align .'" border="0" />';
  1165.         }
  1166.  
  1167.         return $image;
  1168.     }
  1169. }
  1170. ?>

Documentation generated on Mon, 05 Mar 2007 21:06:34 +0000 by phpDocumentor 1.3.1