Changeset 13589

Show
Ignore:
Timestamp:
11/22/07 17:37:52 (1 year ago)
Author:
w_i
Message:

Hopefully better handling to Path generation through widget config

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/MidCOM_2_8/midcom.helper.datamanager2/exec/chooser_handler.php

    r13560 r13589  
    4545    '_renderer_callback_class', '_renderer_callback_args', 
    4646    'constraints', 'searchfields', 'orders', 
    47     'result_headers', 
     47    'result_headers', 'generate_path_for', 
    4848    'auto_wildcards', 
    4949    'reflector_key' 
     
    293293            $value = @$object->$item_name; 
    294294 
    295             if (   $class == 'midcom_db_topic' 
    296                 && $item_name == 'extra' ) 
     295            if (   $generate_path_for == $item_name 
     296                || (   $class == 'midcom_db_topic' 
     297                    && $item_name == 'extra') ) 
    297298            { 
    298299                $value = resolve_path_title($object->id, $value); 
  • branches/MidCOM_2_8/midcom.helper.datamanager2/widget/chooser.php

    r13060 r13589  
    143143     */ 
    144144    var $result_headers = array(); 
     145     
     146    /** 
     147     * In search results replaces given field with full path to the object 
     148     * 
     149     * Example: (in topics) 
     150     *      'generate_path_for' => 'extra', 
     151     * 
     152     * @var array 
     153     */     
     154    var $generate_path_for = null; 
    145155 
    146156    /** 
     
    253263     
    254264    var $allow_multiple = true; 
     265    var $require_corresponding_option = true; 
    255266     
    256267    var $reflector_key = null; 
     
    259270    var $creation_handler = null; 
    260271    var $creation_default_key = null; 
    261              
     272     
     273    var $js_format_items = array(); 
     274     
    262275    /** 
    263276     * The initialization event handler post-processes the maxlength setting. 
     
    281294         
    282295        $this->allow_multiple = $this->_type->allow_multiple; 
     296        $this->require_corresponding_option = $this->_type->require_corresponding_option; 
    283297         
    284298        if (   empty($this->class) 
     
    316330            return false; 
    317331        } 
    318  
    319         // if (empty($this->class)) 
    320         // { 
    321         //     debug_push_class(__CLASS__, __FUNCTION__); 
    322         //     debug_add("Warning, the field {$this->name} does not have class defined.", 
    323         //         MIDCOM_LOG_WARN); 
    324         //     debug_pop(); 
    325         //     return false; 
    326         // } 
    327  
    328         // if (empty($this->component)) 
    329         // { 
    330         //     debug_push_class(__CLASS__, __FUNCTION__); 
    331         //     debug_add("Warning, the field {$this->name} does not have component the class {$this->class} belongs to defined.", 
    332         //         MIDCOM_LOG_WARN); 
    333         //     debug_pop(); 
    334         //     return false; 
    335         // } 
    336332 
    337333        if (   empty($this->searchfields) 
     
    633629                    array('metadata.published' => 'ASC'), 
    634630                ), 
     631                'generate_path_for' => 'extra', 
    635632            ), 
    636633            'group' => array 
     
    680677                    $this->result_headers[] = $header; 
    681678                } 
     679            } 
     680            if (   is_null($this->generate_path_for) 
     681                && isset($clever_classes[$this->clever_class]['generate_path_for'])) 
     682            { 
     683                $this->generate_path_for = $clever_classes[$this->clever_class]['generate_path_for']; 
    682684            } 
    683685            if (empty($this->constraints)) 
     
    873875        $this->_js_widget_options['allow_multiple'] = 'true'; 
    874876        $this->_js_widget_options['id_field'] = "'$this->id_field'"; 
     877        $this->_js_widget_options['format_items'] = 'null'; 
    875878         
    876879        if ($this->creation_mode_enabled) 
     
    897900                $this->_js_widget_options['allow_multiple'] = 'true'; 
    898901            } 
     902        } 
     903        if (! empty($this->js_format_items)) 
     904        { 
     905            $format_items = "{ "; 
     906            $fi_count = count($this->js_format_items); 
     907            $i = 0; 
     908            foreach ($this->js_format_items as $k => $formatter) 
     909            { 
     910                $i++; 
     911                $format_items .= "'{$k}': '{$formatter}'"; 
     912 
     913                if ($i == $fi_count) 
     914                { 
     915                    $format_items .= " "; 
     916                } 
     917                else 
     918                { 
     919                    $format_items .= ", "; 
     920                } 
     921            } 
     922            $format_items .= "}"; 
     923            $this->_js_widget_options['format_items'] = $format_items;             
    899924        } 
    900925                 
     
    11831208                $item_name = $header_item['name']; 
    11841209                $value = @$object->$item_name; 
    1185                 $value = rawurlencode($value); 
     1210                $value = rawurlencode(utf8_decode($value)); 
    11861211                // debug_add("adding header item: name={$item_name} value={$value}"); 
    11871212                $jsdata .= "{$item_name}: '{$value}'";