Changeset 12723

Show
Ignore:
Timestamp:
10/09/07 22:28:27 (1 year ago)
Author:
w_i
Message:

Bug fixing

Files:

Legend:

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

    r11584 r12723  
    6565} 
    6666 
    67 if (!empty($reflector_key)) 
     67if (! empty($reflector_key)) 
    6868{ 
    6969    $_MIDCOM->componentloader->load_graceful('midgard.admin.asgard'); 
     
    7272debug_pop(); 
    7373debug_push_class('midcom_helper_datamanager2_widget_chooser_handler', 'search'); 
     74 
     75// Handle automatic wildcards 
     76if (   !empty($auto_wildcards) 
     77    && strpos($query, '%') === false) 
     78{ 
     79    switch($auto_wildcards) 
     80    { 
     81        case 'both': 
     82            $query = "%{$query}%"; 
     83            break; 
     84        case 'start': 
     85            $query = "%{$query}"; 
     86            break; 
     87        case 'end': 
     88            $query = "{$query}%"; 
     89            break; 
     90        default: 
     91            debug_add("Don't know how to handle auto_wildcards value '{$auto_wildcards}'", MIDCOM_LOG_WARN); 
     92            break; 
     93    } 
     94} 
    7495 
    7596if (!empty($_callback_class)) 
     
    127148        $_MIDCOM->finish(); 
    128149        exit(); 
    129     } 
    130  
    131     // Handle automatic wildcards 
    132     if (   !empty($auto_wildcards) 
    133         && strpos($query, '%') === false) 
    134     { 
    135         switch($auto_wildcards) 
    136         { 
    137             case 'both': 
    138                 $query = "%{$query}%"; 
    139                 break; 
    140             case 'start': 
    141                 $query = "%{$query}"; 
    142                 break; 
    143             case 'end': 
    144                 $query = "{$query}%"; 
    145                 break; 
    146             default: 
    147                 debug_add("Don't know how to handle auto_wildcards value '{$auto_wildcards}'", MIDCOM_LOG_WARN); 
    148                 break; 
    149         } 
    150150    } 
    151151 
  • trunk/midcom/midcom.helper.datamanager2/static/chooser/jquery.chooser_widget.js

    r12130 r12723  
    603603        function inactivate(id) 
    604604    { 
    605             jQuery('#'+options.widget_id + '_result_item_'+id+'_input', list).attr({ value: id }); 
     605            jQuery('#'+options.widget_id + '_result_item_'+id+'_input', list).attr({ value: 0 }); 
    606606            jQuery('#'+options.widget_id + '_result_item_'+id).removeClass(CLASSES.DELETED); 
    607607            jQuery('#'+options.widget_id + '_result_item_'+id).removeClass(CLASSES.ACTIVE); 
     
    609609            jQuery('#'+options.widget_id + '_result_item_'+id).attr("keep_on_list","false"); 
    610610            jQuery('#'+options.widget_id + '_result_item_'+id).attr("deleted","false"); 
    611             selected_items.push(id); 
     611            //selected_items.push(id); 
     612            selected_items = jQuery.grep( selected_items, function(n,i){ 
     613            return n != id; 
     614        }); 
    612615    } 
    613616     
  • trunk/midcom/midcom.helper.datamanager2/widget/chooser.php

    r12711 r12723  
    212212 
    213213    /** 
    214      * The argument to pass to the option callback constructor. 
     214     * The arguments to pass to the option callback constructor. 
    215215     * 
    216216     * @var mixed 
     
    293293                    MIDCOM_LOG_WARN); 
    294294                debug_pop(); 
    295             } 
    296             return false; 
     295                 
     296                return false; 
     297            } 
    297298        } 
    298299         
     
    316317        } 
    317318 
    318         if (empty($this->class)) 
    319         { 
    320             debug_push_class(__CLASS__, __FUNCTION__); 
    321             debug_add("Warning, the field {$this->name} does not have class defined.", 
    322                 MIDCOM_LOG_WARN); 
    323             debug_pop(); 
    324             return false; 
    325         } 
    326  
    327         if (empty($this->component)) 
    328         { 
    329             debug_push_class(__CLASS__, __FUNCTION__); 
    330             debug_add("Warning, the field {$this->name} does not have component the class {$this->class} belongs to defined.", 
    331                 MIDCOM_LOG_WARN); 
    332             debug_pop(); 
    333             return false; 
    334         } 
    335  
    336         if (empty($this->searchfields)) 
     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        // } 
     336 
     337        if (   empty($this->searchfields) 
     338            && !isset($this->_callback_class)) 
    337339        { 
    338340            debug_push_class(__CLASS__, __FUNCTION__); 
     
    353355        ); 
    354356         
    355         $_MIDCOM->add_jsfile(MIDCOM_STATIC_URL . '/midcom.helper.datamanager2/chooser/jquery.chooser_widget.pack.js'); 
     357        $_MIDCOM->add_jsfile(MIDCOM_STATIC_URL . '/midcom.helper.datamanager2/chooser/jquery.chooser_widget.js'); 
    356358         
    357359        $this->_element_id = "{$this->_namespace}{$this->name}_chooser_widget"; 
     
    458460    function _check_callback() 
    459461    { 
    460         // debug_push_class(__CLASS__, __FUNCTION__);         
    461         // debug_add("Checking callback class {$this->_callback_class}"); 
     462        debug_push_class(__CLASS__, __FUNCTION__);         
     463        debug_add("Checking callback class {$this->_callback_class}"); 
    462464         
    463465        if (! class_exists($this->_callback_class)) 
     
    484486        $this->_callback = new $this->_callback_class($this->_callback_args); 
    485487         
    486         // debug_pop(); 
    487         return $this->_callback->initialize(); 
     488        debug_pop(); 
     489         
     490        if (is_callable(array($this->_callback, 'initialize'))) 
     491        { 
     492            return $this->_callback->initialize(); 
     493        } 
     494         
     495        return $this->_callback; 
    488496    } 
    489497     
     
    948956    function add_elements_to_form() 
    949957    { 
    950         // debug_push_class(__CLASS__, __FUNCTION__); 
     958        //debug_push_class(__CLASS__, __FUNCTION__); 
    951959         
    952960        // Get url to search handler 
     
    10461054        $existing_elements = $this->_type->selection; 
    10471055         
    1048         // debug_print_r('existing_elements',$existing_elements); 
     1056        //debug_print_r('existing_elements',$existing_elements); 
    10491057 
    10501058        // debug_print_r('static_options',$this->static_options); 
     
    10521060        $elements = array_merge($this->static_options, $existing_elements); 
    10531061        // debug_print_r('all elements to be added',$elements); 
    1054                  
     1062        // debug_pop(); 
     1063         
    10551064        $ee_script = ''; 
    10561065        if ($this->_renderer_callback) 
     
    11301139    function _object_to_jsdata(&$object) 
    11311140    { 
    1132         // debug_push_class(__CLASS__, __FUNCTION__);         
    1133         // debug_add("converting object with id {$object->id} to jsdata"); 
     1141        debug_push_class(__CLASS__, __FUNCTION__);         
     1142        debug_add("converting object with id {$object->id} to jsdata"); 
    11341143         
    11351144        $id = @$object->id; 
     
    11471156            $value = @$object->get_label(); 
    11481157            $value = rawurlencode($value); 
    1149             // debug_add("adding header item: name=label value={$value}"); 
     1158            //debug_add("adding header item: name=label value={$value}"); 
    11501159            $jsdata .= "label: '{$value}'"; 
    11511160        } 
     
    11591168                $value = @$object->$item_name; 
    11601169                $value = rawurlencode($value); 
    1161                 // debug_add("adding header item: name={$item_name} value={$value}"); 
     1170                debug_add("adding header item: name={$item_name} value={$value}"); 
    11621171                $jsdata .= "{$item_name}: '{$value}'"; 
    11631172                 
     
    11731182        $jsdata .= "}"; 
    11741183         
    1175         return $jsdata;         
    1176          
    1177         // debug_pop()
     1184        debug_pop(); 
     1185         
     1186        return $jsdata
    11781187    } 
    11791188     
    11801189    function _get_key_data($key, $in_render_mode=false) 
    11811190    { 
    1182         // debug_push_class(__CLASS__, __FUNCTION__);         
    1183         // debug_add("get_key_data for key: {$key}"); 
     1191        debug_push_class(__CLASS__, __FUNCTION__);         
     1192        debug_add("get_key_data for key: {$key}"); 
    11841193         
    11851194        if ($this->_callback) 
     
    11901199            { 
    11911200                // debug_pop(); 
    1192                 return $_callback->resolve_object_name($key); 
    1193             } 
    1194              
    1195             $results = $_callback->get_key_data($key); 
     1201                return $this->_callback->resolve_object_name($key); 
     1202            } 
     1203             
     1204            $results = $this->_callback->get_key_data($key); 
    11961205             
    11971206            if (! $results) 
     
    12001209            } 
    12011210             
    1202             // debug_pop(); 
     1211            debug_pop(); 
    12031212             
    12041213            if ($this->_renderer_callback)