• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CodeExtinguisher 2.0 Release Candidate 14.2

#81
[eluser]ocergyNohtna[/eluser]
jtaby, i diff'd the appropriate files and don't see any changes that would make the post hooks not get called. oh and let me correct my last statement from saying i was trying to echo something to debug, i was actually calling exit('some relative debug message'). am i correct in assuming that the hooks are fired through codexcontroller::execute_edit() and codexcontroller::execute_add() here:
Code:
$this->event->trigger('preEditHook',array($this->table,$id));
    $db_data = $this->event->trigger('prepForDb',array($_POST));
    if($this->codexmodel->_edit($this->table,$id,$db_data[0])){
        $this->event->trigger('postEditHook',array($db_data[0]));
        $this->codexmessages->add('success',$this->codexadmin->get_message('edit_success'));
        redirect(str_replace('&','&',$this->controller_link));
    } else {
        $this->codexmessages->add('failure',$this->codexadmin->get_message('edit_failure'));
        redirect(str_replace('&','&',$this->controller_link));
    }
which fires off the corresponding event in codexevents, which in turn calls codeforms::iterate() on the given function. maybe you can tell me a bit of how the iterate method works? when it calls this line:
Code:
$return_array[$field] = $obj->$func_name($val,$field);
what is actually being called? initially i thought that was calling the corresponding hook method, in this case, of the manytomany plugin, but then i realized that the hook methods in manytomany only accept one parameter and the line above passes two, a value and it's corresponding field. is this not true? what am i not understanding here?? also, i notice that the iterate method returns the array, but nowhere do i see the calling of iterate storing that array. instead, iterate is only called like:
Code:
$this->CI->codexforms->iterate('postEditHook',$data);
and never storing that return array like this:
Code:
$temp = $this->CI->codexforms->iterate('postEditHook',$data);
is it even used? if so, how and where? i guess the khaos of codexevents has finally gotten to me... :grrr: any advice anyone?

#82
[eluser]Majd Taby[/eluser]
hahaha i love the pun...

Here's how it works:

Some plugins "contain" other plugins. For example, the FieldSet plugin contains other plugins inside it. Similarly, the ManyToMany plugin contains other plugins (when you click on Add New). Because each plugin has its own processing requirements and needs to have its hooks/callbacks called, then the containers (fieldset, manytomany) need to know which field is getting processed.

So if you have a fieldset with 4 plugins inside it, it will have prepForDisplay called on it four times, each time with a different $field parameter. On the other hand, standalone plugins don't contain any other plugins, so they don't need a second parameter.

As far as the iterate function returning an array, take a look at lines 102,110,123,128 of codexevents.php Smile

For your problem, I would change the iterate() function like this:

Code:
function iterate ($func_name,$param_array=array()){
        $return_array = array();

        foreach($this->objects as $name=>$obj){
            if(is_array($obj->getIterateNames())){
                foreach($obj->getIterateNames() as $field){
                    $val = (isset($param_array[$field]))? $param_array[$field] : '';
                    echo get_class($obj)."->$func_name($value,$field);<br>";
                    $return_array[$field] = $obj->$func_name($val,$field);
                }

            }
            else{
                $value = (isset($param_array[$name]))? $param_array[$name] : '';

                echo get_class($this->objects[$name])."->$func_name($value,$name);<br>";
                $return_array[$name] = $this->objects[$name]->$func_name($value,$name);
            }
        }
        return $return_array;
    }

That way you know exactly what's getting called.

#83
[eluser]daulex[/eluser]
jTaby, thanks for that, it works, u rock dude Big Grin

another newbie question: where do I change the date format? I changed it in the config and the date is still the same format Sad

#84
[eluser]abmcr[/eluser]
see into the date.php plugin....

#85
[eluser]daulex[/eluser]
I changed it to dd/mm/yy, after it simply does not work and return zeroes, HELP!!!

#86
[eluser]abmcr[/eluser]
try with this plugin date_eu.php
Code:
&lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Date_eu extends codexForms
{
    function Date_eu($name,$params) {
        codexForms::initiate($name,$params);
    }

    function prepForDisplay($value){
        if(!empty($value) AND ($value != 0 AND $value != "0000-00-00")){
            $explode = explode('-',$value);
            return date('F j, Y',mktime(0,0,0,$explode[1],$explode[2],$explode[0]));
        }
        else
            return '';
    }
    
    function prepForDB($value){
        $valori=explode("/",$value);
        $date_eu=$valori[2]."-".$valori[1]."-".$valori[0];
        return ($date_eu);
    }

    function getHTML()
    {
        $CI = &get;_instance();
        $CI->codextemplates->css_assets('css-datepicker','ui.datepicker.css');
        $CI->codextemplates->js('js-datepicker','ui.datepicker.eu.js');

        $html = $this->prefix;
        //format the data with eu format
        $valori=explode("-",$this->value);
        $new_date_eu=$valori[2]."/".$valori[1]."/".$valori[0];

        if($this->getMessage($this->name))
            $html .= '<div class="failure">'.$this->getMessage($this->name).'</div>';

        $html .= '
            <label for="'.$this->element_name.'">
                '.$this->label.'
            </label>';
        $html .='
            &lt;input class="text" id="codexdatepicker'.$this-&gt;name.'" type="text" value="'.$new_date_eu.'" name="'.$this->element_name.'" '.$this->getAttributes($this->attributes).'>
        ';
        $js ="$(document).ready(function() {
                $('#codexdatepicker".$this->name."').datepicker({dateFormat: 'dd/mm/yy'});
              });";
        $CI->codextemplates->inlineJS('js-'.$this->name.'-init',$js);
        $html .= $this->suffix;
        
        return $html;
    }
}

?&gt;
this is (experimental i have not try !!!) for show date in european format... tell me if it work... good night (for me... 22.49 pm)

#87
[eluser]daulex[/eluser]
I created the file, but wasn't sure where to include it Big Grin

#88
[eluser]Majd Taby[/eluser]
you want to put it into the plugins/ directory.

#89
[eluser]daulex[/eluser]
I did put it in there, I was wondering what exactly I need to do in the script, so it would read it so I could see if it works Smile

#90
[eluser]Majd Taby[/eluser]
ah ok, you just need to change the .yml file in the definitions/ library to use the Date_eu class instead of the Date class.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.