CodeIgniter Forums
CodeExtinguisher 2.0 Release Candidate 14.2 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: CodeExtinguisher 2.0 Release Candidate 14.2 (/showthread.php?tid=8451)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49


CodeExtinguisher 2.0 Release Candidate 14.2 - El Forum - 06-04-2008

[eluser]abmcr[/eluser]
But because you use the old version?: in the new release a plugin editor is not offcial, but i have inserted in the forum a TinyMCE 3.0 editor...
In each case, i think the problem is the correct settings of the editor
try insert a
Code:
relative_urls : false

into the js who launch the editor. This is for example the code for a tinyMCE 3.0
Code:
$js='tinyMCE.init({
                        mode : "exact",
                        elements : "'.$this->name.'",
                        theme : "advanced",
                        plugins : "advimage,advlink,media,contextmenu,table",
                        theme_advanced_buttons1_add_before : "newdocument,separator",
                        theme_advanced_buttons1_add : "fontselect",//fontsizeselect
                        theme_advanced_buttons2_add : "separator,forecolor,backcolor,liststyle",
                        theme_advanced_buttons2_add_before: "cut,copy,separator,",
                        theme_advanced_buttons3_add_before : "",
                        theme_advanced_buttons3_add : "media",
                        theme_advanced_buttons3_add : "tablecontrols",
                        theme_advanced_toolbar_location : "top",
                        theme_advanced_toolbar_align : "left",
                        theme_advanced_disable : "help",
                        extended_valid_elements : "hr[class|width|size|noshade]",
                        file_browser_callback : "ajaxfilemanager",
                        paste_use_dialog : false,
                        theme_advanced_resizing : true,
                        theme_advanced_resize_horizontal : true,
                        apply_source_formatting : true,
                        force_br_newlines : true,
                        force_p_newlines : false,    
                        relative_urls : false
                    });';
Ciao!!!


CodeExtinguisher 2.0 Release Candidate 14.2 - El Forum - 06-04-2008

[eluser]Majd Taby[/eluser]
daulex, don't use version 1.4, it has many security holes.


CodeExtinguisher 2.0 Release Candidate 14.2 - El Forum - 06-04-2008

[eluser]daulex[/eluser]
abmcr, thank you so much mate, found the tinymce thingy and modified:
Code:
this._def("relative_urls",false);this._def("remove_script_host",false);
set the true to false and it all worked like a charm. cheers

jTaby, I don't have too much choice really. I have no chance of fixing the version caused error (the one I pointed out and you said 5.12 or something), and I need the web site to work asap. in either way, the web site is very basic and the only place where there is any dynamic content is the news bit, so it doesn't matter that much Smile


CodeExtinguisher 2.0 Release Candidate 14.2 - El Forum - 06-04-2008

[eluser]gusa[/eluser]
[quote author="jTaby" date="1212538572"]gusa, you can add a custom label to _any_ plugin....

Code:
textbox_test:
    class: TextBox
    label: Some Other label
....
[/quote]

grrrrrrrrrrrreat!
another one:

my date picker was not working fine. i found that the css url was wrong: in the page source it appeared as:


if i change codextemplates::css from...

Code:
$this->loaded_objects['css'][$identifier] = '<link rel="stylesheet" href="'.$file.'" type="text/css">'."\n";

to...

Code:
$this->loaded_objects['css'][$identifier] = '<link rel="stylesheet" href="'.$this->asset_folder.'css/'.$file.'" type="text/css">'."\n";

...codexcontroller doesn't form the css' href properly (i think this is because codexcontroller tries to assamble an absolute url).

so, to solve this i decided to modify codextemplates::css:

Code:
function css ($identifier, $file,$force=false){
    if($force OR !in_array($identifier,$this->loaded_objects['css']))
        if (preg_match('/^\w+:\/\/.+$/', $file)) {
    // absolute url?
        $this->loaded_objects['css'][$identifier] = '<link rel="stylesheet" href="'.$file.'" type="text/css">'."\n";
    } else {
        $this->loaded_objects['css'][$identifier] = '<link rel="stylesheet" href="'.$this->asset_folder.'css/'.$file.'" type="text/css">'."\n";
    }
}

and, for the sake of consistency, i changed codextemplates::js too:

Code:
function js ($identifier, $file){
    if(!in_array($identifier,$this->loaded_objects['js'])){
        if (preg_match('/^\w+:\/\/.+$/', $file)) {
            // absolute url?
            $this->loaded_objects['js'][$identifier] = ''."\n";
        } else {
            $this->loaded_objects['js'][$identifier] = 'asset_folder.'js/'.$file.'">'."\n";
        }
    }
}

what do you think?


CodeExtinguisher 2.0 Release Candidate 14.2 - El Forum - 06-04-2008

[eluser]abmcr[/eluser]
but are you sure to use the latest version? this fix is already made....


CodeExtinguisher 2.0 Release Candidate 14.2 - El Forum - 06-04-2008

[eluser]gusa[/eluser]
this is fast:

i have a nullable integer column in my database. let's say, table1.COL1. and suppose there's a relationship between table1.COL1 and table2.COL2.

i created a textbox field to edit table1.COL1. if i enter an integer and there is a counterpart in table2 everything is fine. the problem arises when i try to keep the textbox blank.

the generated query is something like:

update table1
set col1=''
where ...

and sqlserver is returning an error because it doesn't find the foreignkey '' in table2.

how can i tell codex that '' means null?
should i create a new plugin that combines a checkbox and a textbox? (if the checkbox is empty, then the value is discarded... hum... but how can i unset that value... it's not clear to me).


CodeExtinguisher 2.0 Release Candidate 14.2 - El Forum - 06-04-2008

[eluser]Majd Taby[/eluser]
gusa, Actually, I'm not sure you can do that without modifying the code a little bit. At first glance, my instinct was to tell you to create a new plugin exactly like TextBox, but with a different prepForDb function. But if you return NULL from prepForDb, then the whole thing will be omitted from the query. If that's fine, then go ahead and do it. If you intend on setting the value as NULL, then I would add a checkbox and in your plugin's prepForDb function, I would do what needs to be done and return NULL.

Let me know if i'm not being clear.


CodeExtinguisher 2.0 Release Candidate 14.2 - El Forum - 06-04-2008

[eluser]gusa[/eluser]
[quote author="jTaby" date="1212624776"]gusa, Actually, I'm not sure you can do that without modifying the code a little bit. At first glance, my instinct was to tell you to create a new plugin exactly like TextBox, but with a different prepForDb function. But if you return NULL from prepForDb, then the whole thing will be omitted from the query. If that's fine, then go ahead and do it. If you intend on setting the value as NULL, then I would add a checkbox and in your plugin's prepForDb function, I would do what needs to be done and return NULL.

Let me know if i'm not being clear.[/quote]

very clear.
i think the only way is to add a custom execute_edit action on each controller that has the problem. actually, that action is a clone from the original codexcontroller one, with an addon between the following lines:

Code:
$db_data = $this->event->trigger('prepForDb',array($_POST));
/*
  iterate over db_data.
    if a nullable field $x is found and $x is actually null then
      set $db_data[$x] = null
*/
if($this->codexmodel->_edit($this->table,$id,$db_data[0])){
// ...

i can't imagine another solution, because if i return null from prepForDb, then that field is discarded (codexevents#130) and that's not what i want.

maybe in the future you can put another trigger between those lines Wink

UPDATE:

another possibility is to make a trick and tell codexmodel which fields are null. this solution come to my mind when i realized that each particular prepForDb on each plugin allows me to add more fields to the upper level result set (see codexevents::prepForDB, line 133).

so, if i somehow know that the field is null, then i can return this:

Code:
function prepForDb($value) {
    if (/* somehow i know that the field is null */) {
        return array('null:'.$this->name => true);
    }
    return $value;
}

the upper level mechanism will delete (unset) $result[$this->name], but it also will insert the new $result['null:'.$this->name].

then it comes the part when i have to edit codexmodel's _edit function:

Code:
function _edit($table,$id,$data){
    // for each null:<nullable_field> mock field,
    //   set <nullable_field> = null
    //   unset null:<nullable_field> mock field
        foreach ($data as $field => $value) {
            $s = split(':',$field);
            if ($s[0] == 'null' && $data[$field] === true) {
                $data[$s[1]] = null;
                unset($data[$field]);
            }
        }
        $this->db->where($this->codexadmin->primary_key,$id);
        return $this->db->update($table,$data);
    }

and that's all.
maybe it's dirty, but preferable to duplicate codexcontroller code on each controller.


CodeExtinguisher 2.0 Release Candidate 14.2 - El Forum - 06-05-2008

[eluser]gusa[/eluser]
i need to deal with another issue: database pagination.
as far as i'm concerned, codex implements a client-level pagination. that's right?
if the answer is yes then i'll have to find a way to implement a db pagination. any help is welcome. for example, how can i start?


CodeExtinguisher 2.0 Release Candidate 14.2 - El Forum - 06-05-2008

[eluser]abmcr[/eluser]
Jtaby hello: i have tried to download the svn version, from svn://codeextinguisher.com:3690/trunk/... but tortoise (under win) require a user/password..... It is normal or i made an error. Ciao