Welcome Guest, Not a member yet? Register   Sign In
  Русская документация и сообщество | Russian documentation / community website
Posted by: El Forum - 03-01-2008, 04:51 AM - Replies (2)

[eluser]Sam Dark[/eluser]
Открыт русскоязычный сайт, целиком и полностью посвящённый CodeIgniter.

На данный момент из всего задуманного реализован только перевод документации на русский язык (работа над которым сейчас идет каждый день).

В самых базовых планах в ближайшее время появятся
- Форум
- Вики-система
- FAQ-система (будет написана на самом CI)

http://code-igniter.ru/

---

Russian CI-community website launched!

Now there is only russian documentation (not fully translated but we are working hard on it).

We are planning to add
- Forum
- Wiki
- FAQ (CI-based)

http://code-igniter.ru/


  CI 1.6.1 -> DB_active_rec.php -> TRUE instead of FALSE in function "or_where_not_in"
Posted by: El Forum - 03-01-2008, 03:50 AM - Replies (4)

[eluser]Unknown[/eluser]
hye,
i am not english. So, sorry for my poor english language.

The bug is localized in the file DB_active_rec.php at line 540

Code:
function or_where_not_in($key = NULL, $values = NULL)
{        
   return $this->_where_in($key, $values, FALSE, 'OR ');
}

The correction is :
Code:
function or_where_not_in($key = NULL, $values = NULL)
{        
    return $this->_where_in($key, $values, TRUE, 'OR ');
}

Best regards


  Need Help : Image Library - resize image
Posted by: El Forum - 03-01-2008, 03:44 AM - Replies (1)

[eluser]Unknown[/eluser]
I want to resize Original image twice in a one function.

I have used following function, but it is not work

$config['upload_path'] = './journal_photos/';
$config['allowed_types'] = 'gif|jpg|png|bmp';
$config['max_size'] = '';
$config['max_width'] = '';
$config['max_height'] = '';
$this->load->library('upload',$config);
$this->upload->do_upload();
$temp=$this->upload->data();

if($temp['file_name'] != NULL)
{
$config['image_library'] = 'GD2';
$config['source_image'] = './journal_photos/'.$temp['file_name'];
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 100;
$config['height'] = 75;

$this->load->library('image_lib', $config);

$first = $this->image_lib->resize();



$config1['image_library'] = 'GD2';
$config1['source_image'] = './journal_photos/'.$temp['file_name'];
$config1['create_thumb'] = FALSE;
$config1['new_image'] = './journal_photos/new.jpeg';
$config1['maintain_ratio'] = TRUE;
$config1['width'] = 60;
$config1['height'] = 40;

$this->load->library('image_lib', $config1);

$second = $this->image_lib->resize();

if (! $this->image_lib->resize())
{
echo $this->image_lib->display_errors();
}

}//if

Please suggest solution.


  Empty query result failsafe
Posted by: El Forum - 03-01-2008, 02:06 AM - No Replies

[eluser]Unknown[/eluser]
I know this is something very simple that I'm just not using the right terms when searching. I'm not extremely experienced with PHP or CI (built one simple CI app before.)

I just need a way to display a message either when a query result is empty or at the end of a foreach loop (prefered) that there are no more results that also displays when there are no results. Thanks in advance.


  Validation of listbox, checkbox groups and reselect multiple values using set_select, set_checkbox / Sol: Array to strin
Posted by: El Forum - 03-01-2008, 12:52 AM - Replies (23)

[eluser]vadivelan[/eluser]
Overview:
CI is not dealing with user submitted array values properly.

Impacts:
* You cannot validate listbox (select with multiple enabled), checkbox groups and reselect the user selected values using set_select, set_checkbox for multiple values

* You cannot use trim, htmlspecialchars or any other native php function in rules

* When you enable XSS_Clean in config.php error will pop-up when user select multiple values in list box or check checkbox groups ( ie: checking multiple checkboxes for hobbies in html form )

* You cannot use any other validation rules that CI provides like numeric, integer, xss_clean


What this post address:
This post address the following:

* Allowing to use trim, required, htmlspecialchars or any other native php function call in the rules.

* Allowing to use set_select, set_checkbox for listboxes and checkbox groups, checkboxgroupname_error, listboxname_error

Note:
Still you cannot use CI's validation rules like integer, numeric, xss_clean for arrays. But I don't think these validation will be needed for listboxes and checkbox groups as you are not going to store these values in db / re-display in html. Mostly, you will make use of the values from db / array to populate, validate against user submitted values.

But if you still need to validate for any purpose, you can call those functions in a loop for all the user selected values in a listbox / checkbox.


Solution:
Enabling CI's - Validation library to support list box and check box group is involve replacing the system's Validation.php with our version. To enable this copy system/library/validation.php to application/library/ and do the necessary modification listed below.

This file contains the following modifications:

1. set_select method has been modified to support arrays: (line 617 in original validation.php )

Code:
function set_select($field = '', $value = '')
    {
        if ($field == '' OR $value == '' OR  ! isset($_POST[$field]))
        {
            return '';
        }
        
        if(is_array($_POST[$field])) {
            if(in_array($value,$_POST[$field])) {
                return ' selected="selected"';
            }
        } elseif ($_POST[$field] == $value) {
            return ' selected="selected"';
        }
        
    }

2. set_checkbox has been modified to support arrays: (line 669 in original validation.php )

Code:
function set_checkbox($field = '', $value = '')
    {
        if ($field == '' OR $value == '' OR  ! isset($_POST[$field]))
        {
            return '';
        }
        
        if(is_array($_POST[$field])) {
            if(in_array($value,$_POST[$field])) {
                return ' checked="checked"';
            }
        } elseif ($_POST[$field] == $value) {
            return ' checked="checked"';
        }
    }


3. Prep_for_form function has been updated: (line 694 in original validation.php )

Code:
function prep_for_form($data = '')
    {
        if (is_array($data))
        {
            foreach ($data as $key => $val)
            {
                $data[$key] = $this->prep_for_form($val);
            }
        }
        
        if ($this->_safe_form_data == FALSE OR $data == '')
        {
            return $data;
        }
        
        if(is_array($data)) {
            return $data;
        } else {
            return str_replace(array("'", '"', '<', '>'), array("'", "&quot;", '&lt;', '&gt;'), stripslashes($data));    
        }
    }

4. Method php_func_caller has been added. This enables setting rules like trim, htmlspecial chars and other native php function calls that take single parameter and return the same.

Code:
/**
     * native php function caller
     *
     * This function calls native php functions for each values submitted from the form
     *
     * @access    public
     * @param    string
     * @return    string
     * @author r.vadivelan / hivelan [.at.] gmail [.dot.] com
     */
    function php_func_caller($rule, $data = '')
    {
        if (is_array($data))
        {
            foreach ($data as $key => $val)
            {
                $data[$key] = $this->php_func_caller($rule,$val);
            }
        }
        
        if ($data == '')
        {
            return $data;
        }
        
        if(is_array($data)) {
            return $data;
        } else {
            return $rule($data);
        }
    }

5. Call the php_func_caller when processing rules ( Line no 302 in original validation.php )

Code:
if (function_exists($rule))
                        {
                            $_POST[$field] = $this->php_func_caller($rule,$_POST[$field]);
                            $this->$field = $_POST[$field];
                        }


How to test

* Create a html file containing a select box with multiple enabled, and a checkbox group like hobbies. Make use of set_select, set_checkbox, error_string, checkboxgroupname_error, listboxname_error so that we can verify everything work properly.

* Create a controller, initialize validation libarary, set the rules and fields. Make sure you set trim, required and any other native php functions as rules. Rules like xss_clean, interger ( those given by CI ) will not work ( as CI's validation function's don't support arrays).

Now it would be possible to validate listbox and checkboxes without any problem.

Summary:
Even though I have explained in detail, the entire process is very simple:
1. Just copy system/library/Validation.php to application/library and do the modifications.

2. Validate the listbox and checkbox group as you will normally do for other fields.

Hope this will be useful to you. Please let me know your comments.


  User Profile URL
Posted by: El Forum - 03-01-2008, 12:38 AM - Replies (18)

[eluser]~Chris~[/eluser]
any tips on how i can make user URL's

for example

http://www.example.com/username

will display a dynamic page containing the user's profile.


  pass dropdown selected value
Posted by: El Forum - 02-29-2008, 06:55 PM - Replies (1)

[eluser]Unknown[/eluser]
hi. im kinda new to CI. i have a question. how do you pass selected data from a dropdown into the next page. tnx.


  Template views!
Posted by: El Forum - 02-29-2008, 06:10 PM - Replies (3)

[eluser]deadfrog[/eluser]
Hi all - I came to learn of CI when I started looking for a PHP version of Ruby on Rails, and I have a query which may be easy to answer.

In Rails, you can have a single global template that all views use by default (or you can specify a different template in the controller if required. If memory serves, the template file had a 'yield' command in the area where the view content per page should appear.

If anyone knows what I'm talking about, my question is whether there is a similar thing in CI or do you have to create a view from scratch for each page (or use traditional PHP includes).

Cheers and apologies for the poor description Smile


  parameter missing in language support
Posted by: El Forum - 02-29-2008, 04:07 PM - No Replies

[eluser]Unknown[/eluser]
With

$this->lang->load('filename', 'language');

you can provide 2 parameters; with autoload you can pass only one parameter, filename, not language - but this is supposed to work. How?

function language($file = array(), $lang = '')

doesn't tell where to get the second parameter from.


  Active Record, update using both with and like criteria, like criteria drops
Posted by: El Forum - 02-29-2008, 02:15 PM - Replies (9)

[eluser]Xollef[/eluser]
I must be blind :coolcheese: or something but I can't get this little query to work. For some reason the like criteria is dropped from the query.

Code:
$this->db->set('parentage', $parentage."-".$newSortOrder);
$this->db->like('parentage', '0-00004', 'after');
$this->db->where('language_code', $language);
$this->db->update('pages');

echo $this->db->last_query();
Produces
Quote:UPDATE `pages` SET `parentage` = '0-00001-00001-00001' WHERE `language_code` = 'en'


Can someone see what is wrong with this active record query and give a reason why the like criteria is dropped.

PS: I use the newest Codeigniter.


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
Undefined constant "CodeI...
by ozornick
Today, 12:38 AM
Docker Mastery: A Compreh...
by InsiteFX
Yesterday, 01:17 PM
How can get Response from...
by mylastof
Yesterday, 08:18 AM
DotEnv file is better loa...
by chenzen
Yesterday, 01:57 AM
How to understand entitie...
by spreaderman
06-07-2024, 09:48 PM
PHP fixes critical RCE fl...
by InsiteFX
06-07-2024, 12:01 PM
Login issue on huge traff...
by demyr
06-07-2024, 10:58 AM
How to create forgot pass...
by pratibha.cts
06-07-2024, 12:38 AM
PHP 8.3.8. This is a secu...
by InsiteFX
06-06-2024, 09:42 PM
What's new in PHP 8.3
by InsiteFX
06-06-2024, 09:30 PM

Forum Statistics
» Members: 90,866
» Latest member: soulsthatwrite
» Forum threads: 77,737
» Forum posts: 376,759

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB