Changeset 17814

Show
Ignore:
Timestamp:
10/01/08 00:50:43 (2 months ago)
Author:
flack
Message:

formatting fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.helper.datamanager2/renderer/simple.php

    r17556 r17814  
    130130    * @access   private 
    131131    */ 
    132     var $_groupWraps = array( 
    133     ); 
     132    var $_groupWraps = array(); 
    134133 
    135134   /** 
     
    138137    * @access   private 
    139138    */ 
    140     var $_groupTemplates = array( 
     139    var $_groupTemplates = array 
     140    ( 
    141141        'datamanager_table' => "<label id='{element_name}_label'<!-- BEGIN required --> class='required'<!-- END required -->> </label>\n\t\t 
    142142        <span class=\"field_text\"> 
     
    167167    * @access   private 
    168168    */ 
    169     var $_groupElements = array( 
    170     ); 
     169    var $_groupElements = array(); 
    171170 
    172171   /** 
     
    251250        $this->_html = ''; 
    252251        $this->_hiddenHtml = ''; 
    253     } // end func startForm 
     252    } 
    254253 
    255254   /** 
     
    264263    { 
    265264        // add a required note, if one is needed 
    266         if (!empty($form->_required) && !$form->_freezeAll) { 
     265        if (!empty($form->_required) && !$form->_freezeAll) 
     266        { 
    267267            $this->_html .= str_replace('{requiredNote}', $form->getRequiredNote(), $this->_requiredNoteTemplate); 
    268268        } 
    269269        // add form attributes and content 
    270270        $html = str_replace('{attributes}', $form->getAttributes(true), $this->_formTemplate); 
    271         if (strpos($this->_formTemplate, '{hidden}')) { 
     271        if (strpos($this->_formTemplate, '{hidden}')) 
     272        { 
    272273            $html = str_replace('{hidden}', $this->_hiddenHtml, $html); 
    273         } else { 
     274        } 
     275        else 
     276        { 
    274277            $this->_html .= $this->_hiddenHtml; 
    275278        } 
    276279        $this->_html = str_replace('{content}', $this->_html, $html); 
    277280        // add a validation script 
    278         if ('' != ($script = $form->getValidationScript())) { 
     281        if ('' != ($script = $form->getValidationScript())) 
     282        { 
    279283            $this->_html = $script . "\n" . $this->_html; 
    280284        } 
    281     } // end func finishForm 
     285    } 
    282286 
    283287   /** 
     
    291295    { 
    292296        $name = $header->getName(); 
    293         if (!empty($name) && isset($this->_templates[$name])) { 
     297        if (!empty($name) && isset($this->_templates[$name])) 
     298        { 
    294299            $this->_html .= str_replace('{header}', $header->toHtml(), $this->_templates[$name]); 
    295         } else { 
     300        } 
     301        else 
     302        { 
    296303            $this->_html .= str_replace('{header}', $header->toHtml(), $this->_headerTemplate); 
    297304        } 
    298     } // end func renderHeader 
     305    } 
    299306 
    300307   /** 
     
    306313    * @param    string      Error message associated with the element 
    307314    * @param    string      Element type (optional) 
    308     * @access   private 
     315    * @access   private†
    309316    * @see      renderElement() 
    310317    * @return   string      Html for element 
     
    312319    function _prepareTemplate($name, $label, $required, $error, $type = false) 
    313320    { 
    314         if (is_array($label)) { 
     321        if (is_array($label)) 
     322        { 
    315323            $nameLabel = array_shift($label); 
    316         } else { 
     324        } 
     325        else 
     326        { 
    317327            $nameLabel = $label; 
    318328        } 
    319329 
    320         if (isset($this->_templates[$name])) { 
     330        if (isset($this->_templates[$name])) 
     331        { 
    321332            $html = str_replace('{label}', $nameLabel, $this->_templates[$name]); 
    322         } else if ($this->_inGroup) { 
     333        } 
     334        else if ($this->_inGroup) 
     335        { 
    323336            /* rambo: I'm pretty sure this is never reached... */ 
    324337            $html = str_replace('{label}', $nameLabel, $this->_defaultGroupTemplate); 
    325         } else { 
     338        } 
     339        else 
     340        { 
    326341            switch ($type) 
    327342            { 
     
    336351        } 
    337352 
    338         if ($required) { 
     353        if ($required) 
     354        { 
    339355            $html = str_replace('<!-- BEGIN required -->', '', $html); 
    340356            $html = str_replace('<!-- END required -->', '', $html); 
    341         } else { 
     357        } 
     358        else 
     359        { 
    342360            $html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN required -->.*?<!-- END required -->([ \t\n\r]*)?/is", '', $html); 
    343361        } 
    344362 
    345         if (isset($error)) { 
     363        if (isset($error)) 
     364        { 
    346365            $html = str_replace('{error}', $error, $html); 
    347366            $html = str_replace('<!-- BEGIN error -->', '', $html); 
    348367            $html = str_replace('<!-- END error -->', '', $html); 
    349         } else { 
     368        } 
     369        else 
     370        { 
    350371            //$html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN error -->.*?<!-- END error -->([ \t\n\r]*)?/is", '', $html); 
    351372 
     
    353374        } 
    354375 
    355         if (is_array($label)) { 
    356             foreach($label as $key => $text) { 
     376        if (is_array($label)) 
     377        { 
     378            foreach($label as $key => $text) 
     379            { 
    357380                $key  = is_int($key)? $key + 2: $key; 
    358381                $html = str_replace("{label_{$key}}", $text, $html); 
     
    363386 
    364387        $html = str_replace('{element_name}', $name , $html); 
    365         if (strpos($html, '{label_')) { 
     388        if (strpos($html, '{label_')) 
     389        { 
    366390            $html = preg_replace('/\s*<!-- BEGIN label_(\S+) -->.*<!-- END label_\1 -->\s*/i', '', $html); 
    367391        } 
    368392 
    369393        return $html; 
    370     } // end func _prepareTemplate 
     394    } 
    371395 
    372396   /** 
     
    382406    function renderElement(&$element, $required, $error) 
    383407    { 
    384         if (!$this->_inGroup) { 
     408        if (!$this->_inGroup) 
     409        { 
    385410            $html = $this->_prepareTemplate($element->getName(), $element->getLabel(), $required, $error, $element->getType()); 
    386411            $this->_html .= str_replace('{element}', $element->toHtml(), $html); 
    387412 
    388413 
    389         } elseif (!empty($this->_groupElementTemplate)) { 
     414        } 
     415        else if (!empty($this->_groupElementTemplate)) 
     416        { 
    390417 
    391418            $html = str_replace('{label}', $element->getLabel(), $this->_groupElementTemplate); 
    392             if ($required) { 
     419            if ($required) 
     420            { 
    393421                $html = str_replace('<!-- BEGIN required -->', '', $html); 
    394422                $html = str_replace('<!-- END required -->', '', $html); 
    395             } else { 
     423            } 
     424            else 
     425            { 
    396426                $html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN required -->(\s|\S)*<!-- END required -->([ \t\n\r]*)?/i", '', $html); 
    397427            } 
    398428            $this->_groupElements[] = str_replace('{element}', $element->toHtml(), $html); 
    399429 
    400         } else { 
     430        } 
     431        else 
     432        { 
    401433            $this->_groupElements[] = $element->toHtml(); 
    402434        } 
    403     } // end func renderElement 
     435    } 
    404436 
    405437   /** 
     
    414446    { 
    415447        $this->_hiddenHtml .= $element->toHtml() . "\n"; 
    416     } // end func renderHidden 
     448    } 
    417449 
    418450   /** 
     
    426458    { 
    427459        $this->_html .= $data->toHtml(); 
    428     } // end func renderHtml 
     460    } 
    429461 
    430462   /** 
     
    441473        $name = $group->getName(); 
    442474 
    443         if ($this->_inGroup) { 
     475        if ($this->_inGroup) 
     476        { 
    444477            // the rest of the variables are set in the other groups run of the startGroup function. 
    445         //    $this->_currentGroupTemplates[$this->_currentGroupName]['_groupElements'] = $this->_groupElements; 
    446         } 
    447  
    448  
    449         $this->_currentGroupTemplates[$name] = array ( 
     478            //$this->_currentGroupTemplates[$this->_currentGroupName]['_groupElements'] = $this->_groupElements; 
     479        } 
     480 
     481 
     482        $this->_currentGroupTemplates[$name] = array 
     483        ( 
    450484            // '_groupTemplate'        => $this->_prepareTemplate($name, $group->getLabel(), $required, $error), 
    451485            '_groupTemplate'        => $this->_prepareTemplate($name, $group->getLabel(), $required, $error, 'dummy:group'), 
     
    459493        $this->_currentGroupName = $name; 
    460494        $this->_currentGroups[] = $name; 
    461     } // end func startGroup 
     495    } 
    462496 
    463497 
     
    483517    { 
    484518        $separator = $group->_separator; 
    485         if (is_array($separator)) { 
     519        if (is_array($separator)) 
     520        { 
    486521            $count = count($separator); 
    487522            $html  = ''; 
    488             for ($i = 0; $i < count($this->_groupElements); $i++) { 
     523            for ($i = 0; $i < count($this->_groupElements); $i++) 
     524            { 
    489525                $html .= (0 == $i? '': $separator[($i - 1) % $count]) . $this->_groupElements[$i]; 
    490526 
    491527            } 
    492         } else { 
     528        } 
     529        else 
     530        { 
    493531            if (is_null($separator)) 
    494532            { 
     
    498536        } 
    499537 
    500         if (!empty($this->_groupWrap)) { 
     538        if (!empty($this->_groupWrap)) 
     539        { 
    501540            $html = str_replace('{content}', $html, $this->_groupWrap); 
    502541        } 
     
    507546 
    508547        array_pop($this->_currentGroups); 
    509         $currentGroupId = count($this->_currentGroups)-1; 
     548        $currentGroupId = count($this->_currentGroups) - 1; 
    510549        if ($currentGroupId > -1 ) 
    511550        { 
     
    515554            $this->_setGroupTemplates($this->_currentGroupName); 
    516555            $this->_inGroup = true; 
    517         } else 
     556        } 
     557        else 
    518558        { 
    519559            $this->_currentGroupName = ""; 
     
    522562        } 
    523563 
    524     } // end func finishGroup 
     564    } 
    525565 
    526566    /** 
     
    534574    function setElementTemplate($html, $element = null) 
    535575    { 
    536         if (is_null($element)) { 
     576        if (is_null($element)) 
     577        { 
    537578            $this->_elementTemplate = $html; 
    538         } else { 
     579        } 
     580        else 
     581        { 
    539582            $this->_templates[$element] = $html; 
    540583        } 
    541     } // end func setElementTemplate 
     584    } 
    542585 
    543586 
     
    557600    { 
    558601        $this->_groupWraps[$group] = $html; 
    559     } // end func setGroupTemplate 
     602    } 
    560603 
    561604    /** 
     
    570613    { 
    571614        $this->_groupTemplates[$group] = $html; 
    572     } // end func setGroupElementTemplate 
     615    } 
    573616 
    574617    /** 
     
    582625    { 
    583626        $this->_headerTemplate = $html; 
    584     } // end func setHeaderTemplate 
     627    } 
    585628 
    586629    /** 
     
    594637    { 
    595638        $this->_formTemplate = $html; 
    596     } // end func setFormTemplate 
     639    } 
    597640 
    598641    /** 
     
    606649    { 
    607650        $this->_requiredNoteTemplate = $html; 
    608     } // end func setRequiredNoteTemplate 
     651    } 
    609652 
    610653    /** 
     
    621664        $this->setRequiredNoteTemplate(''); 
    622665        $this->_templates = array(); 
    623     } // end func clearAllTemplates 
    624 } // end class HTML_QuickForm_Renderer_Default 
     666    } 
     667} 
    625668?>