diff options
author | Andrey Andreev <narf@devilix.net> | 2014-01-20 14:03:43 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2014-01-20 14:03:43 +0100 |
commit | ea801ab4ab80042638ffddc6056483a1ec43fa80 (patch) | |
tree | f75f30c0df6a8f861ca7df22af09fa3240b0bbd6 /user_guide_src/source/libraries | |
parent | 1c08d557a21ecb0f79cd1a1de4e06817a26e0537 (diff) | |
parent | 4d0571666d03511ac5b4a1f2a6882ccb1509a209 (diff) |
Merge branch 'develop' into feature/user-guide-cleanup
Diffstat (limited to 'user_guide_src/source/libraries')
-rw-r--r-- | user_guide_src/source/libraries/caching.rst | 21 | ||||
-rw-r--r-- | user_guide_src/source/libraries/calendar.rst | 41 | ||||
-rw-r--r-- | user_guide_src/source/libraries/config.rst | 2 | ||||
-rw-r--r-- | user_guide_src/source/libraries/email.rst | 29 | ||||
-rw-r--r-- | user_guide_src/source/libraries/file_uploading.rst | 9 | ||||
-rw-r--r-- | user_guide_src/source/libraries/form_validation.rst | 35 | ||||
-rw-r--r-- | user_guide_src/source/libraries/input.rst | 26 | ||||
-rw-r--r-- | user_guide_src/source/libraries/loader.rst | 35 | ||||
-rw-r--r-- | user_guide_src/source/libraries/migration.rst | 4 | ||||
-rw-r--r-- | user_guide_src/source/libraries/security.rst | 9 | ||||
-rw-r--r-- | user_guide_src/source/libraries/sessions.rst | 7 | ||||
-rw-r--r-- | user_guide_src/source/libraries/xmlrpc.rst | 6 |
12 files changed, 173 insertions, 51 deletions
diff --git a/user_guide_src/source/libraries/caching.rst b/user_guide_src/source/libraries/caching.rst index 5a9742378..30a9fed2d 100644 --- a/user_guide_src/source/libraries/caching.rst +++ b/user_guide_src/source/libraries/caching.rst @@ -240,17 +240,28 @@ For more information on WinCache, please see Redis Caching ============= +Redis is an in-memory key-value store which can operate in LRU cache mode. +To use it, you need Redis server and phpredis PHP extension +`https://github.com/nicolasff/phpredis <https://github.com/nicolasff/phpredis>`_. + +Config options to connect to redis server must be stored in the application/config/redis.php file. +Available options are:: + + $config['socket_type'] = 'tcp'; //`tcp` or `unix` + $config['socket'] = '/var/run/redis.sock'; // in case of `unix` socket type + $config['host'] = '127.0.0.1'; + $config['password'] = NULL; + $config['port'] = 6379; + $config['timeout'] = 0; + All of the methods listed above can be accessed without passing a specific adapter to the driver loader as follows:: $this->load->driver('cache'); $this->cache->redis->save('foo', 'bar', 10); -.. important:: Redis may require one or more of the following options: - **host**, **post**, **timeout**, **password**. - -The Redis PHP extension repository is located at -`https://github.com/nicolasff/phpredis <https://github.com/nicolasff/phpredis>`_. +For more information on Redis, please see +`http://redis.io <http://redis.io>`_. Dummy Cache =========== diff --git a/user_guide_src/source/libraries/calendar.rst b/user_guide_src/source/libraries/calendar.rst index d9a336d08..3879672ce 100644 --- a/user_guide_src/source/libraries/calendar.rst +++ b/user_guide_src/source/libraries/calendar.rst @@ -97,21 +97,23 @@ The above code would start the calendar on saturday, use the "long" month heading, and the "short" day names. More information regarding preferences below. -====================== =========== =============================================== =================================================================== -Preference Default Options Description -====================== =========== =============================================== =================================================================== -**template** None None A string containing your calendar template. - See the template section below. -**local_time** time() None A Unix timestamp corresponding to the current time. -**start_day** sunday Any week day (sunday, monday, tuesday, etc.) Sets the day of the week the calendar should start on. -**month_type** long long, short Determines what version of the month name to use in the header. - long = January, short = Jan. -**day_type** abr long, short, abr Determines what version of the weekday names to use in - the column headers. long = Sunday, short = Sun, abr = Su. -**show_next_prev** FALSE TRUE/FALSE (boolean) Determines whether to display links allowing you to toggle - to next/previous months. See information on this feature below. -**next_prev_url** None A URL Sets the basepath used in the next/previous calendar links. -====================== =========== =============================================== =================================================================== +====================== ================= ============================================ =================================================================== +Preference Default Options Description +====================== ================= ============================================ =================================================================== +**template** None None A string containing your calendar template. + See the template section below. +**local_time** time() None A Unix timestamp corresponding to the current time. +**start_day** sunday Any week day (sunday, monday, tuesday, etc.) Sets the day of the week the calendar should start on. +**month_type** long long, short Determines what version of the month name to use in the header. + long = January, short = Jan. +**day_type** abr long, short, abr Determines what version of the weekday names to use in + the column headers. long = Sunday, short = Sun, abr = Su. +**show_next_prev** FALSE TRUE/FALSE (boolean) Determines whether to display links allowing you to toggle + to next/previous months. See information on this feature below. +**next_prev_url** controller/method A URL Sets the basepath used in the next/previous calendar links. +**show_other_days** FALSE TRUE/FALSE (boolean) Determines whether to display days of other months that share the + first or last week of the calendar month. +====================== ================= ============================================ =================================================================== Showing Next/Previous Month Links @@ -134,7 +136,8 @@ You'll notice a few things about the above example: - You must set the "show_next_prev" to TRUE. - You must supply the URL to the controller containing your calendar in - the "next_prev_url" preference. + the "next_prev_url" preference. If you don't, it will be set to the current + *controller/method*. - You must supply the "year" and "month" to the calendar generating function via the URI segments where they appear (Note: The calendar class automatically adds the year/month to the base URL you @@ -165,6 +168,8 @@ pair of pseudo-variables as shown here:: {cal_row_start}<tr>{/cal_row_start} {cal_cell_start}<td>{/cal_cell_start} + {cal_cell_start_today}<td>{/cal_cell_start_today} + {cal_cell_start_other}<td class="other-month">{/cal_cell_start_other} {cal_cell_content}<a href="{content}">{day}</a>{/cal_cell_content} {cal_cell_content_today}<div class="highlight"><a href="{content}">{day}</a></div>{/cal_cell_content_today} @@ -174,7 +179,11 @@ pair of pseudo-variables as shown here:: {cal_cell_blank} {/cal_cell_blank} + {cal_cell_other}{day}{cal_cel_other} + {cal_cell_end}</td>{/cal_cell_end} + {cal_cell_end_today}</td>{/cal_cell_end_today} + {cal_cell_end_other}</td>{/cal_cell_end_other} {cal_row_end}</tr>{/cal_row_end} {table_close}</table>{/table_close} diff --git a/user_guide_src/source/libraries/config.rst b/user_guide_src/source/libraries/config.rst index 54aa70b2d..8663324f2 100644 --- a/user_guide_src/source/libraries/config.rst +++ b/user_guide_src/source/libraries/config.rst @@ -99,7 +99,7 @@ example, to fetch your language choice you'll do this:: $lang = $this->config->item('language'); -The function returns FALSE (boolean) if the item you are trying to fetch +The function returns NULL if the item you are trying to fetch does not exist. If you are using the second parameter of the $this->config->load diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst index 1d9d2c171..ec639846f 100644 --- a/user_guide_src/source/libraries/email.rst +++ b/user_guide_src/source/libraries/email.rst @@ -254,7 +254,6 @@ Class Reference message CodeIgniter will extract the message from your HTML email and strip the tags. - .. method:: set_header($header, $value) :param string $header: header name @@ -330,8 +329,8 @@ Class Reference :returns: CI_Email object for method chaining Enables you to send an attachment. Put the file path/name in the first - parameter. Note: Use a file path, not a URL. For multiple attachments - use the method multiple times. For example:: + parameter. For multiple attachments use the method multiple times. + For example:: $this->email->attach('/path/to/photo1.jpg'); $this->email->attach('/path/to/photo2.jpg'); @@ -342,6 +341,10 @@ Class Reference $this->email->attach('image.jpg', 'inline'); + You can also use a URL:: + + $this->email->attach('http://example.com/filename.pdf'); + If you'd like to use a custom file name, you can use the third paramater:: $this->email->attach('filename.pdf', 'attachment', 'report.pdf'); @@ -352,6 +355,26 @@ Class Reference $this->email->attach($buffer, 'attachment', 'report.pdf', 'application/pdf'); + .. method:: attachment_cid($filename) + + :param string $filename: Existing attachment filename + :returns: string + + Sets and returns an attachment's Content-ID, which enables your to embed an inline + (picture) attachment into HTML. First parameter must be the already attached file name. + :: + + $filename = '/img/photo1.jpg'; + $this->email->attach($filename); + foreach ($list as $address) + { + $this->email->to($address); + $cid = $this->email->attach_cid($filename); + $this->email->message('<img src='cid:". $cid ."' alt="photo1" />'); + $this->email->send(); + } + + .. note:: Content-ID for each e-mail must be re-created for it to be unique. .. method:: print_debugger([$include = array('headers', 'subject', 'body')]) diff --git a/user_guide_src/source/libraries/file_uploading.rst b/user_guide_src/source/libraries/file_uploading.rst index 695998d73..d679d8aa2 100644 --- a/user_guide_src/source/libraries/file_uploading.rst +++ b/user_guide_src/source/libraries/file_uploading.rst @@ -90,7 +90,7 @@ place this code and save it to your **application/views/** directory:: The Controller ============== -Using a text editor, create a controller called upload.php. In it, place +Using a text editor, create a controller called Upload.php. In it, place this code and save it to your **application/controllers/** directory:: <?php @@ -231,6 +231,11 @@ Preference Default Value Options Descripti **detect_mime** TRUE TRUE/FALSE (boolean) If set to TRUE, a server side detection of the file type will be performed to avoid code injection attacks. DO NOT disable this option unless you have no other option as that would cause a security risk. +**mod_mime_fix** TRUE TRUE/FALSE (boolean) If set to TRUE, multiple filename extensions will be suffixed with an + underscore in order to avoid triggering `Apache mod_mime + <http://httpd.apache.org/docs/2.0/mod/mod_mime.html#multipleext>`_. + DO NOT turn off this option if your upload directory is public, as this + is a security risk. ============================ ================= ======================= ====================================================================== Setting preferences in a config file @@ -340,4 +345,4 @@ Class Reference image_height Image height image_type Image type. Typically the file extension without the period. image_size_str A string containing the width and height. Useful to put into an image tag. - ================ ================================================
\ No newline at end of file + ================ ================================================ diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 35f745fb7..42422f9d7 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -200,6 +200,7 @@ The above method takes **three** parameters as input: message. For example, if your field is named "user" you might give it a human name of "Username". #. The validation rules for this form field. +#. (optional) Set custom error messages on any rules given for current field. If not provided will use the default one. .. note:: If you would like the field name to be stored in a language file, please see :ref:`translating-field-names`. @@ -225,7 +226,9 @@ Your controller should now look like this:: $this->load->library('form_validation'); $this->form_validation->set_rules('username', 'Username', 'required'); - $this->form_validation->set_rules('password', 'Password', 'required'); + $this->form_validation->set_rules('password', 'Password', 'required', + array('required' => 'You must provide a %s.') + ); $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required'); $this->form_validation->set_rules('email', 'Email', 'required'); @@ -263,7 +266,10 @@ you use this approach, you must name your array keys as indicated:: array( 'field' => 'password', 'label' => 'Password', - 'rules' => 'required' + 'rules' => 'required', + 'errors' => array( + 'required' => 'You must provide a %s.', + ), ), array( 'field' => 'passconf', @@ -285,7 +291,14 @@ Cascading Rules CodeIgniter lets you pipe multiple rules together. Let's try it. Change your rules in the third parameter of rule setting method, like this:: - $this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]|is_unique[users.username]'); + $this->form_validation->set_rules( + 'username', 'Username', + 'required|min_length[5]|max_length[12]|is_unique[users.username]', + array( + 'required' => 'You have not provided %s.', + 'is_unique' => 'This %s already exists.' + ) + ); $this->form_validation->set_rules('password', 'Password', 'required'); $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required|matches[password]'); $this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[users.email]'); @@ -431,7 +444,7 @@ Here's how your controller should now look:: } } - protected function username_check($str) + public function username_check($str) { if ($str == 'test') { @@ -469,11 +482,18 @@ Setting Error Messages All of the native error messages are located in the following language file: **system/language/english/form_validation_lang.php** -To set your own custom message you can either edit that file, or use the -following method:: +To set your own global custom message for a rule, you can either +edit that file, or use the following method:: $this->form_validation->set_message('rule', 'Error Message'); +If you need to set a custom error message for a particular field on +some particular rule, use the set_rules() method:: + + $this->form_validation->set_rules('field_name', 'Field Label', 'rule1|rule2|rule3', + array('rule2' => 'Error Message on rule2 for this field_name') + ); + Where rule corresponds to the name of a particular rule, and Error Message is the text you would like displayed. @@ -866,7 +886,8 @@ Rule Parameter Description **is_unique** Yes Returns FALSE if the form element is not unique to the table and field name in the is_unique[table.field] parameter. Note: This rule requires :doc:`Query Builder <../database/query_builder>` to be enabled in order to work. -**max_length** Yes Returns FALSE if the form element is longer then the parameter value. max_length[12] +**min_length** Yes Returns FALSE if the form element is shorter than the parameter value. min_length[3] +**max_length** Yes Returns FALSE if the form element is longer than the parameter value. max_length[12] **exact_length** Yes Returns FALSE if the form element is not exactly the parameter value. exact_length[8] **greater_than** Yes Returns FALSE if the form element is less than or equal to the parameter value or not greater_than[8] numeric. diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst index f5ab04883..8a83207af 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -32,7 +32,8 @@ following: (and a few other) characters. - Provides XSS (Cross-site Scripting Hacks) filtering. This can be enabled globally, or upon request. -- Standardizes newline characters to \\n(In Windows \\r\\n) +- Standardizes newline characters to ``PHP_EOL`` (\\n in UNIX-based OSes, + \\r\\n under Windows). This is configurable. XSS Filtering ============= @@ -155,18 +156,32 @@ Class Reference $this->input->get(NULL, TRUE); // returns all GET items with XSS filter $this->input->get(NULL, FALSE); // returns all GET items without XSS filtering + .. method:: post_get([$index = ''[, $xss_clean = NULL]]) + + :param string $index: POST/GET parameter name + :param bool $xss_clean: Whether to apply XSS filtering + :returns: mixed + + This method works the same way as ``post()`` and ``get()``, only combined. + It will search through both POST and GET streams for data, looking in POST + first, and then in GET:: + + $this->input->post_get('some_data', TRUE); + .. method:: get_post([$index = ''[, $xss_clean = NULL]]) :param string $index: GET/POST parameter name :param bool $xss_clean: Whether to apply XSS filtering :returns: mixed - This method works the same way as ``post()`` and ``get()``, only combined. - It will search through both POST and GET streams for data, looking first - in POST, and then in GET:: + This method works the same way as ``post_get()`` only it looks for GET + data first. $this->input->get_post('some_data', TRUE); + .. note:: This method used to act EXACTLY like ``post_get()``, but it's + behavior has changed in CodeIgniter 3.0. + .. method:: cookie([$index = ''[, $xss_clean = NULL]]) :param string $index: COOKIE parameter name @@ -362,6 +377,9 @@ Class Reference $this->input->is_cli_request() + .. note:: This method is DEPRECATED and is now just an alias for the + :func:`is_cli()` function. + .. method:: method([$upper = FALSE]) :param bool $upper: Whether to return the request method name in upper or lower case diff --git a/user_guide_src/source/libraries/loader.rst b/user_guide_src/source/libraries/loader.rst index ec5a87bb4..15d9d80fc 100644 --- a/user_guide_src/source/libraries/loader.rst +++ b/user_guide_src/source/libraries/loader.rst @@ -278,6 +278,12 @@ Class Reference This method retrieves all variables available to your views. + .. method:: clear_vars() + + :returns: object + + Clears cached view variables. + .. method:: model($model[, $name = ''[, $db_conn = FALSE]]) :param mixed $model: Model name or an array containing multiple models @@ -292,7 +298,7 @@ Class Reference If your model is located in a subdirectory, include the relative path from your models directory. For example, if you have a model located at - *application/models/blog/queries.php* you'll load it using:: + *application/models/blog/Queries.php* you'll load it using:: $this->load->model('blog/queries'); @@ -370,6 +376,33 @@ Class Reference This method is an alias of the :doc:`config file loading method <config>`: ``$this->config->load()`` + .. method:: is_loaded($class) + + :param string $class: Class name + :returns: mixed + + Allows you to check if a class has already been loaded or not. + + .. note:: The word "class" here refers to libraries and drivers. + + If the requested class has been loaded, the method returns its assigned + name in the CI Super-object and FALSE if it's not:: + + $this->load->library('form_validation'); + $this->load->is_loaded('Form_validation'); // returns 'form_validation' + + $this->load->is_loaded('Nonexistent_library'); // returns FALSE + + .. important:: If you have more than one instance of a class (assigned to + different properties), then the first one will be returned. + + :: + + $this->load->library('form_validation', $config, 'fv'); + $this->load->library('form_validation'); + + $this->load->is_loaded('Form_validation'); // returns 'fv' + .. method:: add_package_path($path[, $view_cascade = TRUE]) :param string $path: Path to add diff --git a/user_guide_src/source/libraries/migration.rst b/user_guide_src/source/libraries/migration.rst index 128796c4d..4143609bb 100644 --- a/user_guide_src/source/libraries/migration.rst +++ b/user_guide_src/source/libraries/migration.rst @@ -94,7 +94,7 @@ Then in **application/config/migration.php** set ``$config['migration_version'] Usage Example ************* -In this example some simple code is placed in **application/controllers/migrate.php** +In this example some simple code is placed in **application/controllers/Migrate.php** to update the schema.:: <?php @@ -175,4 +175,4 @@ Class Reference specific versions. It works just like ``current()`` but ignores ``$config['migration_version']``. :: - $this->migration->version(5);
\ No newline at end of file + $this->migration->version(5); diff --git a/user_guide_src/source/libraries/security.rst b/user_guide_src/source/libraries/security.rst index 8d7ccb1ab..451fadf93 100644 --- a/user_guide_src/source/libraries/security.rst +++ b/user_guide_src/source/libraries/security.rst @@ -67,12 +67,13 @@ file in the following way:: If you use the :doc:`form helper <../helpers/form_helper>`, then :func:`form_open()` will automatically insert a hidden csrf field in -your forms. If not, then you can use ``csrf_get_token_name()`` and ``csrf_get_hash()`` +your forms. If not, then you can use ``get_csrf_token_name()`` +and ``get_csrf_hash()`` :: $csrf = array( - 'name' => $this->security->csrf_get_token_name(), - 'hash' => $this->security->csrf_get_hash() + 'name' => $this->security->get_csrf_token_name(), + 'hash' => $this->security->get_csrf_hash() ); ... @@ -149,4 +150,4 @@ Class Reference This method acts a lot like PHP's own native ``html_entity_decode()`` function in ENT_COMPAT mode, only it tries to detect HTML entities that don't end in a semicolon because some browsers allow that. - If the ``$charset`` parameter is left empty, then your configured ``$config['charset']`` value will be used.
\ No newline at end of file + If the ``$charset`` parameter is left empty, then your configured ``$config['charset']`` value will be used. diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst index 010b464d3..3e6dcf28b 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -262,7 +262,7 @@ Session Preferences =================== You'll find the following Session related preferences in your -application/config/config.php file: +*application/config/config.php* file: =========================== =============== =========================== ========================================================================== Preference Default Options Description @@ -281,7 +281,8 @@ Preference Default Options Descript table before enabling this option (Cookie driver only). **sess_table_name** ci_sessions Any valid SQL table name The name of the session database table (Cookie driver only). **sess_time_to_update** 300 Time in seconds This options controls how often the session class will regenerate itself - and create a new session id. + and create a new session ID. Setting it to 0 will disable session + ID regeneartion. **sess_match_ip** FALSE TRUE/FALSE (boolean) Whether to match the user's IP address when reading the session data. Note that some ISPs dynamically changes the IP, so if you want a non-expiring session you will likely set this to FALSE. @@ -673,4 +674,4 @@ Class Reference Example:: $this->session->tempdata('message'); - //returns 'Test message.' considering the set_tempdata example.
\ No newline at end of file + //returns 'Test message.' considering the set_tempdata example. diff --git a/user_guide_src/source/libraries/xmlrpc.rst b/user_guide_src/source/libraries/xmlrpc.rst index 53fe965d7..d9b2dfb1a 100644 --- a/user_guide_src/source/libraries/xmlrpc.rst +++ b/user_guide_src/source/libraries/xmlrpc.rst @@ -307,7 +307,7 @@ Client to send a request to the Server and receive a response. The Client ---------- -Using a text editor, create a controller called xmlrpc_client.php. In +Using a text editor, create a controller called Xmlrpc_client.php. In it, place this code and save it to your application/controllers/ folder:: @@ -348,7 +348,7 @@ folder:: The Server ---------- -Using a text editor, create a controller called xmlrpc_server.php. In +Using a text editor, create a controller called Xmlrpc_server.php. In it, place this code and save it to your application/controllers/ folder:: @@ -569,4 +569,4 @@ Class Reference 'struct' ); - return $this->xmlrpc->send_response($response);
\ No newline at end of file + return $this->xmlrpc->send_response($response); |