Changeset 12138

Show
Ignore:
Timestamp:
09/11/07 22:41:19 (1 year ago)
Author:
w_i
Message:

Removed debugs and made it go along with ajax editor

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.helper.datamanager2/widget/chooser.php

    r12131 r12138  
    267267    function _on_initialize() 
    268268    { 
    269         debug_push_class(__CLASS__, __FUNCTION__); 
    270          
    271269        if (is_a('midcom_helper_datamanager2_type_select', $this->_type)) 
    272270        { 
     271            debug_push_class(__CLASS__, __FUNCTION__); 
    273272            debug_add("Warning, the field {$this->name} is not a select type or subclass thereoff, you cannot use the chooser widget with it.", 
    274273                MIDCOM_LOG_WARN); 
     
    289288                || empty($this->_callback_class)) 
    290289            { 
     290                debug_push_class(__CLASS__, __FUNCTION__); 
    291291                debug_add("Warning, the field {$this->name} does not have proper class definitions set.", 
    292292                    MIDCOM_LOG_WARN); 
     
    299299            && !$this->_check_renderer()) 
    300300        { 
     301            debug_push_class(__CLASS__, __FUNCTION__); 
    301302            debug_add("Warning, the field {$this->name} renderer wasn't found or not set properly, thus widget can never show results.", 
    302303                MIDCOM_LOG_WARN); 
     
    307308        if (!$this->_check_class()) 
    308309        { 
     310            debug_push_class(__CLASS__, __FUNCTION__); 
    309311            debug_add("Warning, cannot load class {$this->class}.", 
    310312                MIDCOM_LOG_WARN); 
     
    315317        if (empty($this->class)) 
    316318        { 
     319            debug_push_class(__CLASS__, __FUNCTION__); 
    317320            debug_add("Warning, the field {$this->name} does not have class defined.", 
    318321                MIDCOM_LOG_WARN); 
     
    323326        if (empty($this->component)) 
    324327        { 
     328            debug_push_class(__CLASS__, __FUNCTION__); 
    325329            debug_add("Warning, the field {$this->name} does not have component the class {$this->class} belongs to defined.", 
    326330                MIDCOM_LOG_WARN); 
     
    331335        if (empty($this->searchfields)) 
    332336        { 
     337            debug_push_class(__CLASS__, __FUNCTION__); 
    333338            debug_add("Warning, the field {$this->name} does not have searchfields defined, it can never return results.", 
    334339                MIDCOM_LOG_WARN); 
     
    358363 
    359364        $this->_init_widget_options(); 
    360  
    361         debug_pop(); 
     365         
    362366        return true; 
    363367    } 
     
    454458    function _check_callback() 
    455459    { 
    456         debug_push_class(__CLASS__, __FUNCTION__); 
    457          
    458         debug_add("Checking callback class {$this->_callback_class}"); 
     460        // debug_push_class(__CLASS__, __FUNCTION__);         
     461        // debug_add("Checking callback class {$this->_callback_class}"); 
    459462         
    460463        if (! class_exists($this->_callback_class)) 
     
    481484        $this->_callback = new $this->_callback_class($this->_callback_args); 
    482485         
    483         debug_pop(); 
     486        // debug_pop(); 
    484487        return $this->_callback->initialize(); 
    485488    } 
     
    487490    function _check_clever_class() 
    488491    { 
    489         debug_push_class(__CLASS__, __FUNCTION__); 
     492        // debug_push_class(__CLASS__, __FUNCTION__); 
    490493         
    491494        $current_user = $_MIDCOM->auth->user->get_storage(); 
     
    606609        if (array_key_exists($this->clever_class,$clever_classes)) 
    607610        { 
    608             debug_add("clever class {$this->clever_class} found!"); 
     611            // debug_add("clever class {$this->clever_class} found!"); 
    609612             
    610613            $this->class = $clever_classes[$this->clever_class]['class']; 
     
    648651            } 
    649652                                                 
    650             debug_pop(); 
     653            // debug_pop(); 
    651654            return true; 
    652655        } 
    653656        else 
    654657        { 
    655             debug_add("clever class {$this->clever_class} not found in predefined list. Trying to use reflector"); 
     658            // debug_add("clever class {$this->clever_class} not found in predefined list. Trying to use reflector"); 
    656659            $_MIDCOM->componentloader->load_graceful('midgard.admin.asgard'); 
    657660             
     
    664667                if ($pos !== false) 
    665668                { 
    666                     debug_add("found possible match: {$schema_type}"); 
     669                    // debug_add("found possible match: {$schema_type}"); 
    667670                    $matched_types[] = $schema_type; 
    668671                } 
    669672            } 
    670673             
    671             debug_print_r('$matched_types',$matched_types); 
     674            // debug_print_r('$matched_types',$matched_types); 
    672675             
    673676            if (count($matched_types) == 1) 
     
    695698            } 
    696699             
    697             debug_print_r('Decided to go with',$matching_type); 
     700            // debug_print_r('Decided to go with',$matching_type); 
    698701             
    699702            if (! $matching_type) 
    700703            { 
     704                debug_push_class(__CLASS__, __FUNCTION__); 
    701705                debug_add("no matches found for {$this->clever_class}!"); 
    702706                debug_pop(); 
     
    711715            $dummy_object = new $matching_type(); 
    712716            $type_fields = array_keys(get_object_vars($dummy_object));      
    713             debug_print_r('type_fields',$type_fields); 
     717            // debug_print_r('type_fields',$type_fields); 
    714718             
    715719            unset($type_fields['metadata']); 
    716720            foreach ($type_fields as $key) 
    717721            { 
    718                 debug_add("processing type field {$key}"); 
     722                // debug_add("processing type field {$key}"); 
    719723                if ($mgd_reflector->is_link($key)) 
    720724                { 
    721                     debug_add("type field {$key} is link"); 
     725                    // debug_add("type field {$key} is link"); 
    722726                } 
    723727                 
     
    734738            { 
    735739                $label_properties = $maa_reflector->get_label_property(); 
    736                 debug_print_r('$label_properties',$label_properties); 
     740                // debug_print_r('$label_properties',$label_properties); 
    737741                if (is_array($label_properties)) 
    738742                { 
     
    796800            } 
    797801             
    798             debug_add("using class: {$this->class}"); 
     802            /*debug_add("using class: {$this->class}"); 
    799803            debug_add("using component: {$this->component}"); 
    800804            debug_print_r('$this->searchfields',$this->searchfields); 
    801805            debug_print_r('$this->result_headers',$this->result_headers); 
    802806             
    803             debug_pop(); 
     807            debug_pop();*/ 
    804808            return true; 
    805809        } 
    806810         
    807         debug_pop(); 
     811        //debug_pop(); 
    808812        return false; 
    809813    } 
     
    865869        $this->_js_widget_options['result_headers'] = $headers; 
    866870         
    867         debug_push_class(__CLASS__, __FUNCTION__); 
     871        /*debug_push_class(__CLASS__, __FUNCTION__); 
    868872        debug_add("js result_headers: {$headers}"); 
    869         debug_pop(); 
     873        debug_pop();*/ 
    870874         
    871875        $this->_generate_extra_params();         
     
    901905    function add_elements_to_form() 
    902906    { 
    903         debug_push_class(__CLASS__, __FUNCTION__); 
     907        // debug_push_class(__CLASS__, __FUNCTION__); 
     908         
    904909        // Get url to search handler 
    905910        $nav = new midcom_helper_nav(); 
     
    956961            $dialog_html = '<div class="chooser_widget_creation_dialog" id="' . $dialog_id . '">'; 
    957962            $dialog_html .= '<div class="chooser_widget_creation_dialog_content_holder">'; 
    958             //$dialog_html .= '<img class="chooser_widget_creation_dialog_loading" src="' . MIDCOM_STATIC_URL . '/midcom.helper.datamanager2/ajax-loading.gif" alt="" />'; 
    959             //$dialog_html .= '<iframe width="450" height="500" class="chooser_widget_creation_dialog_content" src="">'; 
    960             //$dialog_html .= '</iframe>'; 
    961963            $dialog_html .= $dialog_js; 
    962964            $dialog_html .= '</div>'; 
     
    974976                '', 
    975977                $html 
    976             );             
    977         } 
    978          
    979         $group =& $this->_form->addGroup($this->widget_elements, $this->_element_id, $this->_translate($this->_field['title']), '', array('class' => 'chooser_widget_group')); 
    980         $group->setAttributes( 
    981             array('class' => 'midcom_helper_datamanager2_widget_chooser') 
    982         ); 
     978            ); 
     979        } 
    983980         
    984981        $this->_jscript .= '<script type="text/javascript">'; 
     
    10051002        // Add existing and static selections 
    10061003        $existing_elements = $this->_type->selection; 
    1007         debug_print_r('existing_elements',$existing_elements); 
    1008  
    1009         debug_print_r('static_options',$this->static_options); 
     1004        // debug_print_r('existing_elements',$existing_elements); 
     1005 
     1006        // debug_print_r('static_options',$this->static_options); 
    10101007         
    10111008        $elements = array_merge($this->static_options,$existing_elements); 
    1012         debug_print_r('all elements to be added',$elements); 
     1009        // debug_print_r('all elements to be added',$elements); 
    10131010                 
    10141011        $ee_script = ''; 
     
    10171014            foreach ($elements as $key) 
    10181015            { 
    1019                 debug_add("Passing key to renderer {$key}"); 
     1016                // debug_add("Passing key to renderer {$key}"); 
    10201017                $data = $this->_get_key_data($key); 
    10211018                if ($data) 
    10221019                { 
    1023                     debug_add("Got data: {$data}"); 
     1020                    // debug_add("Got data: {$data}"); 
    10241021                    $item = $this->_renderer_callback->render_data($data); 
    1025                     debug_add("Got item: {$item}"); 
     1022                    // debug_add("Got item: {$item}"); 
    10261023                    $ee_script .= "jQuery('#{$this->_element_id}_search_input').midcom_helper_datamanager2_widget_chooser_add_result_item({$data},'{$item}');\n";                     
    10271024                } 
     
    10321029            foreach ($elements as $key) 
    10331030            { 
    1034                 debug_add("Processing key {$key}"); 
     1031                // debug_add("Processing key {$key}"); 
    10351032                $data = $this->_get_key_data($key); 
    10361033                if ($data) 
    10371034                { 
    1038                     debug_add("Got data: {$data}"); 
     1035                    // debug_add("Got data: {$data}"); 
    10391036                    $ee_script .= "jQuery('#{$this->_element_id}_search_input').midcom_helper_datamanager2_widget_chooser_add_result_item({$data});\n";                     
    10401037                } 
     
    10461043        $this->_jscript .= '</script>'; 
    10471044         
    1048         $this->_form->addElement('static', "{$this->_element_id}_initscripts", '', $this->_jscript);         
     1045        //$this->_form->addElement('static', "{$this->_element_id}_initscripts", '', $this->_jscript);         
     1046 
     1047        $this->widget_elements[] =& HTML_QuickForm::createElement 
     1048        ( 
     1049            'static', 
     1050            "{$this->_element_id}_initscripts", 
     1051            '', 
     1052            $this->_jscript 
     1053        ); 
     1054         
     1055        $group =& $this->_form->addGroup($this->widget_elements, $this->name, $this->_translate($this->_field['title']), '', array('class' => 'midcom_helper_datamanager2_widget_chooser')); 
    10491056    } 
    10501057     
    10511058    function _resolve_object_name(&$object) 
    10521059    { 
    1053         debug_push_class(__CLASS__, __FUNCTION__); 
    1054         debug_add("resolving object name from id {$object->id}"); 
     1060        // debug_push_class(__CLASS__, __FUNCTION__); 
     1061        // debug_add("resolving object name from id {$object->id}"); 
    10551062         
    10561063        $name = @$object->get_label(); 
     
    10791086    function _object_to_jsdata(&$object) 
    10801087    { 
    1081         debug_push_class(__CLASS__, __FUNCTION__); 
    1082          
    1083         debug_add("converting object with id {$object->id} to jsdata"); 
     1088        // debug_push_class(__CLASS__, __FUNCTION__);         
     1089        // debug_add("converting object with id {$object->id} to jsdata"); 
    10841090         
    10851091        $id = @$object->id; 
     
    10971103            $value = @$object->get_label(); 
    10981104            $value = rawurlencode($value); 
    1099             debug_add("adding header item: name=label value={$value}"); 
     1105            // debug_add("adding header item: name=label value={$value}"); 
    11001106            $jsdata .= "label: '{$value}'"; 
    11011107        } 
     
    11091115                $value = @$object->$item_name; 
    11101116                $value = rawurlencode($value); 
    1111                 debug_add("adding header item: name={$item_name} value={$value}"); 
     1117                // debug_add("adding header item: name={$item_name} value={$value}"); 
    11121118                $jsdata .= "{$item_name}: '{$value}'"; 
    11131119                 
     
    11251131        return $jsdata;         
    11261132         
    1127         debug_pop(); 
     1133        // debug_pop(); 
    11281134    } 
    11291135     
    11301136    function _get_key_data($key, $in_render_mode=false) 
    11311137    { 
    1132         debug_push_class(__CLASS__, __FUNCTION__); 
    1133          
    1134         debug_add("get_key_data for key: {$key}"); 
     1138        // debug_push_class(__CLASS__, __FUNCTION__);         
     1139        // debug_add("get_key_data for key: {$key}"); 
    11351140         
    11361141        if ($this->_callback) 
    11371142        { 
    1138             debug_add("Using callback to fetch key data"); 
     1143            // debug_add("Using callback to fetch key data"); 
    11391144 
    11401145            if ($in_render_mode) 
    11411146            { 
    1142                 debug_pop(); 
     1147                // debug_pop(); 
    11431148                return $_callback->resolve_object_name($key); 
    11441149            } 
     
    11511156            } 
    11521157             
    1153             debug_pop(); 
     1158            // debug_pop(); 
    11541159             
    11551160            if ($this->_renderer_callback) 
     
    11611166        } 
    11621167         
    1163         debug_add("Using clever class or predefined class"); 
     1168        // debug_add("Using clever class or predefined class"); 
    11641169         
    11651170        $_MIDCOM->auth->request_sudo(); 
     
    11831188        if (! $qb) 
    11841189        { 
    1185             debug_add("use midgard_query_builder"); 
     1190            // debug_add("use midgard_query_builder"); 
    11861191            $qb = new midgard_query_builder($this->class); 
    11871192        } 
     
    11941199        $results = $qb->execute();         
    11951200         
    1196         debug_print_r("Got results:",$results); 
     1201        // debug_print_r("Got results:",$results); 
    11971202         
    11981203        if (count($results) == 0) 
    11991204        { 
    1200             debug_add("Fetching data for key '{$key}' failed."); 
     1205            // debug_add("Fetching data for key '{$key}' failed."); 
    12011206            return false; 
    12021207        } 
     
    12061211        $_MIDCOM->auth->drop_sudo(); 
    12071212         
    1208         debug_pop(); 
     1213        // debug_pop(); 
    12091214         
    12101215        if ($in_render_mode) 
     
    12421247     function get_default() 
    12431248     { 
    1244          debug_push_class(__CLASS__, __FUNCTION__); 
    1245           
     1249         // debug_push_class(__CLASS__, __FUNCTION__);          
    12461250         //debug_print_r('this->_type',$this->_type); 
    12471251          
     
    12521256         } 
    12531257          
    1254          debug_print_r('defaults',$defaults); 
     1258         // debug_print_r('defaults',$defaults);          
     1259         // debug_pop(); 
    12551260          
    1256          debug_pop(); 
    12571261         return Array($this->name => $defaults); 
    12581262     } 
     
    12631267    function sync_type_with_widget($results) 
    12641268    { 
    1265         debug_push_class(__CLASS__, __FUNCTION__); 
    1266          
    1267         debug_print_r('results:',$results); 
     1269        // debug_push_class(__CLASS__, __FUNCTION__);         
     1270        // debug_print_r('results:',$results); 
    12681271         
    12691272        $this->_type->selection = array(); 
     
    12761279        foreach ($real_results as $key => $value) 
    12771280        { 
    1278             debug_add("checking key {$key} with value ".var_dump($value)); 
     1281            // debug_add("checking key {$key} with value ".var_dump($value)); 
    12791282            if (   $value != "0" 
    12801283                || $value != 0) 
    12811284            { 
    1282                 debug_add("adding key {$key} to selection"); 
     1285                // debug_add("adding key {$key} to selection"); 
    12831286                $this->_type->selection[] = $key;                 
    12841287            } 
    12851288        } 
    12861289         
    1287         debug_print_r('real_results', $real_results); 
    1288         debug_print_r('_type->selection', $this->_type->selection); 
    1289                  
    1290         debug_pop();         
     1290        // debug_print_r('real_results', $real_results); 
     1291        // debug_print_r('_type->selection', $this->_type->selection);                 
     1292        // debug_pop(); 
    12911293    } 
    12921294 
    12931295    function render_content() 
    12941296    { 
    1295         debug_push_class(__CLASS__, __FUNCTION__); 
     1297        // debug_push_class(__CLASS__, __FUNCTION__); 
    12961298         
    12971299        echo '<ul>'; 
     
    13021304        else 
    13031305        { 
    1304             debug_add("We have selections!"); 
     1306            // debug_add("We have selections!"); 
    13051307             
    13061308            foreach ($this->_type->selection as $key) 
     
    13121314        echo '</ul>'; 
    13131315         
    1314         debug_pop(); 
     1316        // debug_pop(); 
    13151317    } 
    13161318