Changeset 12222

Show
Ignore:
Timestamp:
06/09/11 03:36:14 (2 years ago)
Author:
mbrevda
Message:

add options array + option to set form action, hide section; add buttons to show/hide any given section; use fpbx_label for labels for easier future updates

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/trunk/amp_conf/htdocs/admin/libraries/components.class.php

    r12212 r12222  
    2323   
    2424  var $_lists; // Array of lists 
     25   
     26  var $_opts; //array of configurable options 
    2527 
    2628  function component($compname, $type = 'setup') { 
     
    283285 
    284286    // Start of form 
    285     $htmlout .= "<form name=\"$formname\" action=\"".$_SERVER['PHP_SELF']."\" method=\"post\" onsubmit=\"return ".$formname."_onsubmit();\">\n"; 
     287     
     288    $form_action = isset($this->_opts['form_action']) ? $this->_opts['form_action'] : $_SERVER['PHP_SELF']; 
     289    $htmlout .= "<form name=\"$formname\" action=\"".$form_action."\" method=\"post\" onsubmit=\"return ".$formname."_onsubmit();\">\n"; 
    286290    $htmlout .= "<input type=\"hidden\" name=\"display\" value=\"$this->_compname\" />\n"; 
    287291    $htmlout .= "<input type=\"hidden\" name=\"type\" value=\"$this->_type\" />\n\n"; 
     
    303307    } 
    304308     
    305     // TODO: should _($section) have _() removed? 
    306309    // Middle 
    307310    if ( is_array($this->_guielems_middle) ) { 
     
    312315            continue; 
    313316          // Header for $section         
    314           $htmlout .= "\t<tr>\n"; 
     317          $htmlout .= "\t<tr class=\"guielToggle\" data-toggleClass=\"".preg_replace('/[^A-Za-z]/', '' ,$section)."\">\n"; 
    315318          $htmlout .= "\t\t<td colspan=\"2\">"; 
    316           $htmlout .= "<h5>" . $section . "<hr></h5>"; 
     319          if ($section) { 
     320            $state = isset($this_opts[$section]['guielToggle']) && $this_opts[$section]['guielToggle'] == true  
     321                ? '+' : '-  '; 
     322            $htmlout .= "<h5>"  
     323                . "<span class=\"guielToggleBut\">$state</span>"  
     324                . $section  
     325                . "</h5><hr>"; 
     326          } else { 
     327            $htmlout .= '<hr>'; 
     328          } 
     329 
    317330          $htmlout .= "</td>\n"; 
    318331          $htmlout .= "\t</tr>\n"; 
     
    324337            foreach ( array_keys($this->_guielems_middle[$section][$sortorder]) as $idx ) { 
    325338              $elem = $this->_guielems_middle[$section][$sortorder][$idx]; 
    326               $htmlout .= $elem->generatehtml(); 
     339              $htmlout .= $elem->generatehtml(preg_replace('/[^A-Za-z]/', '' ,$section)); 
    327340              $this->addjsfunc('onsubmit()', $elem->generatevalidation()); 
    328341            } 
     
    567580  } 
    568581   
    569   function generatehtml() { 
     582  function generatehtml($section = '') { 
    570583    // this effectivly creates the template using the prompttext and html_input 
    571584    // we would expect the $html_input to be set by the child class 
     
    574587     
    575588    // start new row 
    576     $output .= "\t<tr>\n"; 
     589    if ($section) { 
     590      $output .= "\t<tr class=\"$section\">\n"; 
     591    } else { 
     592      $output .= "\t<tr>\n"; 
     593    } 
     594     
    577595 
    578596    // prompt in first column 
    579597    $output .= "\t\t<td>"; 
    580598    if ($this->helptext != '') { 
    581       $output .= "<a href=\"#\" class=\"info\">$this->prompttext<span>$this->helptext</span></a>"
     599      $output .= fpbx_label($this->prompttext,$this->helptext)
    582600    } else { 
    583601      $output .= $this->prompttext; 
     
    766784  } 
    767785   
    768   function generatehtml() { 
     786  function generatehtml($section = '') { 
    769787    // this effectivly creates the template using the html_text 
    770788    // we would expect the $html_text to be set by the child class 
     
    773791     
    774792    // start new row 
    775     $output .= "\t<tr>\n"; 
     793    if ($section) { 
     794      $output .= "\t<tr class=\"$section\">\n"; 
     795    } else { 
     796      $output .= "\t<tr>\n"; 
     797    } 
     798     
    776799 
    777800    // actual input in second row