PHP on T R A X
Rapid Application Development Made Easy

Changeset 152 for trunk/trax

Show
Ignore:
Timestamp:
02/27/06 21:29:24 (3 years ago)
Author:
john
Message:

fixed some bugs in javascript and other helpers

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/trax/vendor/trax/action_view/helpers.php

    r148 r152  
    3838     * 
    3939     */ 
    40     function __construct() { 
     40    function __construct($object_name = null, $attribute_name = null) { 
     41        $this->object_name = $object_name; 
     42        $this->attribute_name = $attribute_name;         
    4143        $this->controller_name = $GLOBALS['current_controller_name']; 
    4244        $this->controller_path = $GLOBALS['current_controller_path']; 
     
    4446    } 
    4547 
     48    /** 
     49     * 
     50     */ 
     51    protected function value() { 
     52        if(!$value = $_REQUEST[$this->object_name][$this->attribute_name]) { 
     53            $object = $this->object(); 
     54            if(is_object($object) && $this->attribute_name) { 
     55                $value = $object->send($this->attribute_name); 
     56            } 
     57        } 
     58        return $value; 
     59    } 
     60 
     61    /** 
     62     * 
     63     */ 
     64    protected function object($object_name = null) { 
     65        $object_name = $object_name ? $object_name : $this->object_name; 
     66        if($object_name) { 
     67            return $this->controller_object->$object_name; 
     68        } 
     69        return null; 
     70    }    
     71     
    4672    /** 
    4773     * 
     
    121147        return $html."\n"; 
    122148    } 
     149     
     150    /** 
     151     * 
     152     */     
     153    function to_content_tag($tag_name, $options = array()) { 
     154        return $this->content_tag($tag_name, $this->value(), $options); 
     155    }      
    123156 
    124157} 
  • trunk/trax/vendor/trax/action_view/helpers/active_record_helper.php

    r144 r152  
    273273     * 
    274274     */ 
    275     function object($object_name = null) { 
    276         $object_name = $object_name ? $object_name : $this->object_name; 
    277         if($object_name) { 
    278             return $this->controller_object->$object_name; 
    279         } 
    280     } 
    281  
    282     /** 
    283      * 
    284      */ 
    285275    function tag_without_error_wrapping() { 
    286276        $args = func_get_args(); 
  • trunk/trax/vendor/trax/action_view/helpers/date_helper.php

    r144 r152  
    3939     */ 
    4040    function __construct($object_name = null, $attribute_name = null) { 
    41         parent::__construct(); 
    42         $this->object_name = $object_name; 
    43         $this->attribute_name = $attribute_name; 
    44     } 
    45  
    46     /** 
    47      * 
    48      */ 
    49     private function value() { 
    50         if(!$value = $this->check_request_for_value()) { 
    51             $object = $this->object(); 
    52             if(is_object($object) && $this->attribute_name) { 
    53                 $value = $object->send($this->attribute_name); 
    54             } 
    55         } 
    56         return $value; 
     41        parent::__construct($object_name, $attribute_name); 
    5742    } 
    5843     
     
    8570     * 
    8671     */ 
    87     private function object($object_name = null) { 
    88         $object_name = $object_name ? $object_name : $this->object_name; 
    89         return $this->controller_object->$object_name; 
    90     } 
    91  
    92     /** 
    93      * 
    94      */ 
    9572    private function select_html($type, $options, $prefix = null, $include_blank = false, $discard_type = false) { 
    9673        $select_html  = "<select name=\"$prefix";        
     
    11289    private function leading_zero_on_single_digits($number) { 
    11390        return $number > 9 ? $number : "0$number"; 
     91    } 
     92 
     93    /** 
     94     * 
     95     */ 
     96    protected function value() { 
     97        if(!$value = $this->check_request_for_value()) { 
     98            $object = $this->object(); 
     99            if(is_object($object) && $this->attribute_name) { 
     100                $value = $object->send($this->attribute_name); 
     101            } 
     102        } 
     103        return $value; 
    114104    } 
    115105     
  • trunk/trax/vendor/trax/action_view/helpers/form_helper.php

    r144 r152  
    3939     */ 
    4040    function __construct($object_name, $attribute_name) { 
    41         parent::__construct(); 
    42         $this->object_name = $object_name; 
    43         $this->attribute_name = $attribute_name; 
     41        parent::__construct($object_name, $attribute_name); 
    4442        $this->default_field_options = $GLOBALS['DEFAULT_FIELD_OPTIONS'] ? $GLOBALS['DEFAULT_FIELD_OPTIONS'] : array("size" => 30); 
    4543        $this->default_radio_options = $GLOBALS['DEFAULT_RADIO_OPTIONS'] ? $GLOBALS['DEFAULT_RADIO_OPTIONS'] : array(); 
    4644        $this->default_text_area_options = $GLOBALS['DEFAULT_TEXT_AREA_OPTIONS'] ? $GLOBALS['DEFAULT_TEXT_AREA_OPTIONS'] : array("cols" => 40, "rows" => 20); 
    4745        $this->default_date_options = $GLOBALS['DEFAULT_DATE_OPTIONS'] ? $GLOBALS['DEFAULT_DATE_OPTIONS'] : array(":discard_type" => true); 
    48     } 
    49  
    50     /** 
    51      * 
    52      */ 
    53     function value() { 
    54         if(!$value = $_REQUEST[$this->object_name][$this->attribute_name]) { 
    55             $object = $this->object(); 
    56             if(is_object($object) && $this->attribute_name) { 
    57                 $value = $object->send($this->attribute_name); 
    58             } 
    59         } 
    60         return $value; 
    61     } 
    62  
    63     /** 
    64      * 
    65      */ 
    66     function object($object_name = null) { 
    67         $object_name = $object_name ? $object_name : $this->object_name; 
    68         return $this->controller_object->$object_name; 
    6946    } 
    7047 
  • trunk/trax/vendor/trax/action_view/helpers/javascript_helper.php

    r148 r152  
    4747    } 
    4848 
    49     private function options_for_javascript($options) { 
     49    protected function options_for_javascript($options) { 
    5050        $javascript = array(); 
    5151        if(is_array($options)) { 
     
    115115        } 
    116116        return $callbacks; 
     117    } 
     118     
     119    private function remove_ajax_options($options) { 
     120        if(is_array($options)) { 
     121            $GLOBALS['ajax_options'] = $this->ajax_options; 
     122            foreach($options as $option_key => $option_value) { 
     123                if(!in_array($option_key, $this->ajax_options)) { 
     124                    $new_options[$option_key] = $option_value;   
     125                }   
     126            }  
     127            if(is_array($new_options)) { 
     128                $options = $new_options;  
     129            }            
     130        }     
     131        return $options;     
    117132    } 
    118133        
     
    503518            $options['onUpdate'] = "function(){" . $this->remote_function($options) . "}"; 
    504519        } 
    505         $options = array_filter($options, create_function('$value', 'return !in_array($value, $this->ajax_options);')); 
    506  
     520        $options = $this->remove_ajax_options($options); 
    507521        foreach(array('tag', 'overlap', 'constraint', 'handle') as $option) { 
    508522            if($options[$option]) { 
     
    552566            $options['onUpdate'] = "function(element){" . $this->remote_function($options) . "}"; 
    553567        } 
    554         $options = array_filter($options, create_function('$value', 'return !in_array($value, $this->ajax_options);')); 
    555          
     568        $options = $this->remove_ajax_options($options); 
    556569        if($options['accept']) { 
    557570            $options['accept'] = $this->array_or_string_for_javascript($options['accept']);