diff options
Diffstat (limited to 'user_guide_src/source/libraries')
29 files changed, 1059 insertions, 705 deletions
diff --git a/user_guide_src/source/libraries/benchmark.rst b/user_guide_src/source/libraries/benchmark.rst index ddbe04869..8fc06be12 100644 --- a/user_guide_src/source/libraries/benchmark.rst +++ b/user_guide_src/source/libraries/benchmark.rst @@ -131,16 +131,16 @@ this pseudo-variable, if you prefer not to use the pure PHP:: Class Reference *************** -.. class:: CI_Benchmark +.. php:class:: CI_Benchmark - .. method:: mark($name) + .. php:method:: mark($name) :param string $name: the name you wish to assign to your marker :rtype: void Sets a benchmark marker. - .. method:: elapsed_time([$point1 = ''[, $point2 = ''[, $decimals = 4]]]) + .. php:method:: elapsed_time([$point1 = ''[, $point2 = ''[, $decimals = 4]]]) :param string $point1: a particular marked point :param string $point2: a particular marked point @@ -156,7 +156,7 @@ Class Reference swap the real value for this variable. - .. method:: memory_usage() + .. php:method:: memory_usage() :returns: Memory usage info :rtype: string diff --git a/user_guide_src/source/libraries/caching.rst b/user_guide_src/source/libraries/caching.rst index caece1aee..86439b4ee 100644 --- a/user_guide_src/source/libraries/caching.rst +++ b/user_guide_src/source/libraries/caching.rst @@ -52,9 +52,9 @@ to avoid collisions when you're running multiple applications on the same enviro Class Reference *************** -.. class:: CI_Cache +.. php:class:: CI_Cache - .. method:: is_supported($driver) + .. php:method:: is_supported($driver) :param string $driver: the name of the caching driver :returns: TRUE if supported, FALSE if not @@ -74,7 +74,7 @@ Class Reference } } - .. method:: get($id) + .. php:method:: get($id) :param string $id: Cache item name :returns: Item value or FALSE if not found @@ -86,7 +86,7 @@ Class Reference $foo = $this->cache->get('my_cached_item'); - .. method:: save($id, $data[, $ttl = 60[, $raw = FALSE]]) + .. php:method:: save($id, $data[, $ttl = 60[, $raw = FALSE]]) :param string $id: Cache item name :param mixed $data: the data to save @@ -104,7 +104,7 @@ Class Reference .. note:: The ``$raw`` parameter is only utilized by APC and Memcache, in order to allow usage of ``increment()`` and ``decrement()``. - .. method:: delete($id) + .. php:method:: delete($id) :param string $id: name of cached item :returns: TRUE on success, FALSE on failure @@ -116,7 +116,7 @@ Class Reference $this->cache->delete('cache_item_id'); - .. method:: increment($id[, $offset = 1]) + .. php:method:: increment($id[, $offset = 1]) :param string $id: Cache ID :param int $offset: Step/value to add @@ -132,7 +132,7 @@ Class Reference $this->cache->increment('iterator', 3); // 'iterator' is now 6 - .. method:: decrement($id[, $offset = 1]) + .. php:method:: decrement($id[, $offset = 1]) :param string $id: Cache ID :param int $offset: Step/value to reduce by @@ -148,7 +148,7 @@ Class Reference $this->cache->decrement('iterator', 2); // 'iterator' is now 3 - .. method:: clean() + .. php:method:: clean() :returns: TRUE on success, FALSE on failure :rtype: bool @@ -159,7 +159,7 @@ Class Reference $this->cache->clean(); - .. method:: cache_info() + .. php:method:: cache_info() :returns: Information on the entire cache database :rtype: mixed @@ -172,7 +172,7 @@ Class Reference .. note:: The information returned and the structure of the data is dependent on which adapter is being used. - .. method:: get_metadata($id) + .. php:method:: get_metadata($id) :param string $id: Cache item name :returns: Metadata for the cached item diff --git a/user_guide_src/source/libraries/calendar.rst b/user_guide_src/source/libraries/calendar.rst index 20832740b..52883d297 100644 --- a/user_guide_src/source/libraries/calendar.rst +++ b/user_guide_src/source/libraries/calendar.rst @@ -213,9 +213,9 @@ Example:: Class Reference *************** -.. class:: CI_Calendar +.. php:class:: CI_Calendar - .. method:: initialize([$config = array()]) + .. php:method:: initialize([$config = array()]) :param array $config: Configuration parameters :returns: CI_Calendar instance (method chaining) @@ -223,7 +223,7 @@ Class Reference Initializes the Calendaring preferences. Accepts an associative array as input, containing display preferences. - .. method:: generate([$year = ''[, $month = ''[, $data = array()]]]) + .. php:method:: generate([$year = ''[, $month = ''[, $data = array()]]]) :param int $year: Year :param int $month: Month @@ -234,7 +234,7 @@ Class Reference Generate the calendar. - .. method:: get_month_name($month) + .. php:method:: get_month_name($month) :param int $month: Month :returns: Month name @@ -242,7 +242,7 @@ Class Reference Generates a textual month name based on the numeric month provided. - .. method:: get_day_names($day_type = '') + .. php:method:: get_day_names($day_type = '') :param string $day_type: 'long', 'short', or 'abr' :returns: Array of day names @@ -253,7 +253,7 @@ Class Reference if an invalid type is provided) this method will return the "abbreviated" style. - .. method:: adjust_date($month, $year) + .. php:method:: adjust_date($month, $year) :param int $month: Month :param int $year: Year @@ -274,7 +274,7 @@ Class Reference [year] => '2015' ) - .. method:: get_total_days($month, $year) + .. php:method:: get_total_days($month, $year) :param int $month: Month :param int $year: Year @@ -287,9 +287,9 @@ Class Reference // 29 .. note:: This method is an alias for :doc:`Date Helper - <../helpers/date_helper>` function :func:`days_in_month()`. + <../helpers/date_helper>` function :php:func:`days_in_month()`. - .. method:: default_template() + .. php:method:: default_template() :returns: An array of template values :rtype: array @@ -298,7 +298,7 @@ Class Reference your own template. - .. method:: parse_template() + .. php:method:: parse_template() :returns: CI_Calendar instance (method chaining) :rtype: CI_Calendar diff --git a/user_guide_src/source/libraries/cart.rst b/user_guide_src/source/libraries/cart.rst index a023ccb36..be343320d 100644 --- a/user_guide_src/source/libraries/cart.rst +++ b/user_guide_src/source/libraries/cart.rst @@ -7,7 +7,7 @@ while a user is browsing your site. These items can be retrieved and displayed in a standard "shopping cart" format, allowing the user to update the quantity or remove items from the cart. -.. important:: The Card library is DEPRECATED and should not be used. +.. important:: The Cart library is DEPRECATED and should not be used. It is currently only kept for backwards compatibility. Please note that the Cart Class ONLY provides the core "cart" @@ -285,7 +285,7 @@ the update form is submitted. Please examine the construction of the Class Reference *************** -.. class:: CI_Cart +.. php:class:: CI_Cart .. attribute:: $product_id_rules = '\.a-z0-9_-' @@ -302,7 +302,7 @@ Class Reference Whether or not to only allow safe product names. Default TRUE. - .. method:: insert([$items = array()]) + .. php:method:: insert([$items = array()]) :param array $items: Items to insert into the cart :returns: TRUE on success, FALSE on failure @@ -312,7 +312,7 @@ Class Reference on success and FALSE on failure. - .. method:: update([$items = array()]) + .. php:method:: update([$items = array()]) :param array $items: Items to update in the cart :returns: TRUE on success, FALSE on failure @@ -323,7 +323,7 @@ Class Reference to the quantity before checkout. That array must contain the rowid for each item. - .. method:: remove($rowid) + .. php:method:: remove($rowid) :param int $rowid: ID of the item to remove from the cart :returns: TRUE on success, FALSE on failure @@ -332,7 +332,7 @@ Class Reference Allows you to remove an item from the shopping cart by passing it the ``$rowid``. - .. method:: total() + .. php:method:: total() :returns: Total amount :rtype: int @@ -340,7 +340,7 @@ Class Reference Displays the total amount in the cart. - .. method:: total_items() + .. php:method:: total_items() :returns: Total amount of items in the cart :rtype: int @@ -348,7 +348,7 @@ Class Reference Displays the total number of items in the cart. - .. method:: contents([$newest_first = FALSE]) + .. php:method:: contents([$newest_first = FALSE]) :param bool $newest_first: Whether to order the array with newest items first :returns: An array of cart contents @@ -359,7 +359,7 @@ Class Reference will be sorted from newest to oldest, otherwise it is sorted from oldest to newest. - .. method:: get_item($row_id) + .. php:method:: get_item($row_id) :param int $row_id: Row ID to retrieve :returns: Array of item data @@ -368,7 +368,7 @@ Class Reference Returns an array containing data for the item matching the specified row ID, or FALSE if no such item exists. - .. method:: has_options($row_id = '') + .. php:method:: has_options($row_id = '') :param int $row_id: Row ID to inspect :returns: TRUE if options exist, FALSE otherwise @@ -379,7 +379,7 @@ Class Reference you must pass the rowid to this method, as shown in the Displaying the Cart example above. - .. method:: product_options([$row_id = '']) + .. php:method:: product_options([$row_id = '']) :param int $row_id: Row ID :returns: Array of product options @@ -390,7 +390,7 @@ Class Reference must pass the rowid to this method, as shown in the Displaying the Cart example above. - .. method:: destroy() + .. php:method:: destroy() :rtype: void diff --git a/user_guide_src/source/libraries/config.rst b/user_guide_src/source/libraries/config.rst index 3116b768a..3138e3403 100644 --- a/user_guide_src/source/libraries/config.rst +++ b/user_guide_src/source/libraries/config.rst @@ -171,7 +171,7 @@ folders: Class Reference *************** -.. class:: CI_Config +.. php:class:: CI_Config .. attribute:: $config @@ -182,7 +182,7 @@ Class Reference Array of all loaded config files - .. method:: item($item[, $index='']) + .. php:method:: item($item[, $index='']) :param string $item: Config item name :param string $index: Index name @@ -191,7 +191,7 @@ Class Reference Fetch a config file item. - .. method:: set_item($item, $value) + .. php:method:: set_item($item, $value) :param string $item: Config item name :param string $value: Config item value @@ -199,7 +199,7 @@ Class Reference Sets a config file item to the specified value. - .. method:: slash_item($item) + .. php:method:: slash_item($item) :param string $item: config item name :returns: Config item value with a trailing forward slash or NULL if not found @@ -208,7 +208,7 @@ Class Reference This method is identical to ``item()``, except it appends a forward slash to the end of the item, if it exists. - .. method:: load([$file = ''[, $use_sections = FALSE[, $fail_gracefully = FALSE]]]) + .. php:method:: load([$file = ''[, $use_sections = FALSE[, $fail_gracefully = FALSE]]]) :param string $file: Configuration file name :param bool $use_sections: Whether config values shoud be loaded into their own section (index of the main config array) @@ -218,7 +218,7 @@ Class Reference Loads a configuration file. - .. method:: site_url() + .. php:method:: site_url() :returns: Site URL :rtype: string @@ -229,7 +229,7 @@ Class Reference This method is normally accessed via the corresponding functions in the :doc:`URL Helper </helpers/url_helper>`. - .. method:: base_url() + .. php:method:: base_url() :returns: Base URL :rtype: string @@ -240,7 +240,7 @@ Class Reference This method is normally accessed via the corresponding functions in the :doc:`URL Helper </helpers/url_helper>`. - .. method:: system_url() + .. php:method:: system_url() :returns: URL pointing at your CI system/ directory :rtype: string diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst index ebfde809b..54fb53f44 100644 --- a/user_guide_src/source/libraries/email.rst +++ b/user_guide_src/source/libraries/email.rst @@ -141,9 +141,9 @@ Place the item you do not want word-wrapped between: {unwrap} {/unwrap} Class Reference *************** -.. class:: CI_Email +.. php:class:: CI_Email - .. method:: from($from[, $name = ''[, $return_path = NULL]]) + .. php:method:: from($from[, $name = ''[, $return_path = NULL]]) :param string $from: "From" e-mail address :param string $name: "From" display name @@ -162,7 +162,7 @@ Class Reference .. note:: Return-Path can't be used if you've configured 'smtp' as your protocol. - .. method:: reply_to($replyto[, $name = '']) + .. php:method:: reply_to($replyto[, $name = '']) :param string $replyto: E-mail address for replies :param string $name: Display name for the reply-to e-mail address @@ -174,7 +174,7 @@ Class Reference $this->email->reply_to('you@example.com', 'Your Name'); - .. method:: to($to) + .. php:method:: to($to) :param mixed $to: Comma-delimited string or an array of e-mail addresses :returns: CI_Email instance (method chaining) @@ -195,7 +195,7 @@ Class Reference array('one@example.com', 'two@example.com', 'three@example.com') ); - .. method:: cc($cc) + .. php:method:: cc($cc) :param mixed $cc: Comma-delimited string or an array of e-mail addresses :returns: CI_Email instance (method chaining) @@ -204,7 +204,7 @@ Class Reference Sets the CC email address(s). Just like the "to", can be a single e-mail, a comma-delimited list or an array. - .. method:: bcc($bcc[, $limit = '']) + .. php:method:: bcc($bcc[, $limit = '']) :param mixed $bcc: Comma-delimited string or an array of e-mail addresses :param int $limit: Maximum number of e-mails to send per batch @@ -218,7 +218,7 @@ Class Reference the emails to batches, with each batch not exceeding the specified ``$limit``. - .. method:: subject($subject) + .. php:method:: subject($subject) :param string $subject: E-mail subject line :returns: CI_Email instance (method chaining) @@ -228,7 +228,7 @@ Class Reference $this->email->subject('This is my subject'); - .. method:: message($body) + .. php:method:: message($body) :param string $body: E-mail message body :returns: CI_Email instance (method chaining) @@ -238,7 +238,7 @@ Class Reference $this->email->message('This is my message'); - .. method:: set_alt_message($str) + .. php:method:: set_alt_message($str) :param string $str: Alternative e-mail message body :returns: CI_Email instance (method chaining) @@ -255,7 +255,7 @@ Class Reference message CodeIgniter will extract the message from your HTML email and strip the tags. - .. method:: set_header($header, $value) + .. php:method:: set_header($header, $value) :param string $header: Header name :param string $value: Header value @@ -267,7 +267,7 @@ Class Reference $this->email->set_header('Header1', 'Value1'); $this->email->set_header('Header2', 'Value2'); - .. method:: clear([$clear_attachments = FALSE]) + .. php:method:: clear([$clear_attachments = FALSE]) :param bool $clear_attachments: Whether or not to clear attachments :returns: CI_Email instance (method chaining) @@ -295,7 +295,7 @@ Class Reference $this->email->clear(TRUE); - .. method:: send([$auto_clear = TRUE]) + .. php:method:: send([$auto_clear = TRUE]) :param bool $auto_clear: Whether to clear message data automatically :returns: TRUE on success, FALSE on failure @@ -320,7 +320,7 @@ Class Reference .. note:: In order to use the ``print_debugger()`` method, you need to avoid clearing the email parameters. - .. method:: attach($filename[, $disposition = ''[, $newname = NULL[, $mime = '']]]) + .. php:method:: attach($filename[, $disposition = ''[, $newname = NULL[, $mime = '']]]) :param string $filename: File name :param string $disposition: 'disposition' of the attachment. Most @@ -358,7 +358,7 @@ Class Reference $this->email->attach($buffer, 'attachment', 'report.pdf', 'application/pdf'); - .. method:: attachment_cid($filename) + .. php:method:: attachment_cid($filename) :param string $filename: Existing attachment filename :returns: Attachment Content-ID or FALSE if not found @@ -380,7 +380,7 @@ Class Reference .. note:: Content-ID for each e-mail must be re-created for it to be unique. - .. method:: print_debugger([$include = array('headers', 'subject', 'body')]) + .. php:method:: print_debugger([$include = array('headers', 'subject', 'body')]) :param array $include: Which parts of the message to print out :returns: Formatted debug data diff --git a/user_guide_src/source/libraries/encrypt.rst b/user_guide_src/source/libraries/encrypt.rst index 6b65099a6..67e2a0190 100644 --- a/user_guide_src/source/libraries/encrypt.rst +++ b/user_guide_src/source/libraries/encrypt.rst @@ -80,9 +80,9 @@ Once loaded, the Encrypt library object will be available using:: Class Reference *************** -.. class:: CI_Encrypt +.. php:class:: CI_Encrypt - .. method:: encode($string[, $key = '']) + .. php:method:: encode($string[, $key = '']) :param string $string: Data to encrypt :param string $key: Encryption key @@ -103,7 +103,7 @@ Class Reference $encrypted_string = $this->encrypt->encode($msg, $key); - .. method:: decode($string[, $key = '']) + .. php:method:: decode($string[, $key = '']) :param string $string: String to decrypt :param string $key: Encryption key @@ -124,7 +124,7 @@ Class Reference $encrypted_string = $this->encrypt->decode($msg, $key); - .. method:: set_cipher($cipher) + .. php:method:: set_cipher($cipher) :param int $cipher: Valid PHP MCrypt cypher constant :returns: CI_Encrypt instance (method chaining) @@ -142,7 +142,7 @@ Class Reference echo extension_loaded('mcrypt') ? 'Yup' : 'Nope'; - .. method:: set_mode($mode) + .. php:method:: set_mode($mode) :param int $mode: Valid PHP MCrypt mode constant :returns: CI_Encrypt instance (method chaining) @@ -155,7 +155,7 @@ Class Reference Please visit php.net for a list of `available modes <http://php.net/mcrypt>`_. - .. method:: encode_from_legacy($string[, $legacy_mode = MCRYPT_MODE_ECB[, $key = '']]) + .. php:method:: encode_from_legacy($string[, $legacy_mode = MCRYPT_MODE_ECB[, $key = '']]) :param string $string: String to encrypt :param int $legacy_mode: Valid PHP MCrypt cipher constant diff --git a/user_guide_src/source/libraries/encryption.rst b/user_guide_src/source/libraries/encryption.rst index 2d0ee23a3..d445bf42f 100644 --- a/user_guide_src/source/libraries/encryption.rst +++ b/user_guide_src/source/libraries/encryption.rst @@ -474,9 +474,9 @@ appear and become widely available. Class Reference *************** -.. class:: CI_Encryption +.. php:class:: CI_Encryption - .. method:: initialize($params) + .. php:method:: initialize($params) :param array $params: Configuration parameters :returns: CI_Encryption instance (method chaining) @@ -493,7 +493,7 @@ Class Reference Please refer to the :ref:`configuration` section for detailed info. - .. method:: encrypt($data[, $params = NULL]) + .. php:method:: encrypt($data[, $params = NULL]) :param string $data: Data to encrypt :param array $params: Optional parameters @@ -509,7 +509,7 @@ Class Reference Please refer to the :ref:`custom-parameters` section for information on the optional parameters. - .. method:: decrypt($data[, $params = NULL]) + .. php:method:: decrypt($data[, $params = NULL]) :param string $data: Data to decrypt :param array $params: Optional parameters @@ -525,7 +525,7 @@ Class Reference Please refer to the :ref:`custom-parameters` secrion for information on the optional parameters. - .. method:: hkdf($key[, $digest = 'sha512'[, $salt = NULL[, $length = NULL[, $info = '']]]]) + .. php:method:: hkdf($key[, $digest = 'sha512'[, $salt = NULL[, $length = NULL[, $info = '']]]]) :param string $key: Input key material :param string $digest: A SHA-2 family digest algorithm diff --git a/user_guide_src/source/libraries/file_uploading.rst b/user_guide_src/source/libraries/file_uploading.rst index d93acb842..ea2fef7f2 100644 --- a/user_guide_src/source/libraries/file_uploading.rst +++ b/user_guide_src/source/libraries/file_uploading.rst @@ -252,16 +252,16 @@ preferences in a config file. Class Reference *************** -.. class:: CI_Upload +.. php:class:: CI_Upload - .. method:: initialize([array $config = array()[, $reset = TRUE]]) + .. php:method:: initialize([array $config = array()[, $reset = TRUE]]) :param array $config: Preferences :param bool $reset: Whether to reset preferences (that are not provided in $config) to their defaults :returns: CI_Upload instance (method chaining) :rtype: CI_Upload - .. method:: do_upload([$field = 'userfile']) + .. php:method:: do_upload([$field = 'userfile']) :param string $field: Name of the form field :returns: TRUE on success, FALSE on failure @@ -283,7 +283,7 @@ Class Reference $field_name = "some_field_name"; $this->upload->do_upload($field_name); - .. method:: display_errors([$open = '<p>'[, $close = '</p>']]) + .. php:method:: display_errors([$open = '<p>'[, $close = '</p>']]) :param string $open: Opening markup :param string $close: Closing markup @@ -302,7 +302,7 @@ Class Reference $this->upload->display_errors('<p>', '</p>'); - .. method:: data([$index = NULL]) + .. php:method:: data([$index = NULL]) :param string $data: Element to return instead of the full array :returns: Information about the uploaded file diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index f964965ec..da43a4bec 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -352,9 +352,9 @@ commonly is:: set_value('field name') Open your myform.php view file and update the **value** in each field -using the :func:`set_value()` function: +using the :php:func:`set_value()` function: -**Don't forget to include each field name in the :func:`set_value()` +**Don't forget to include each field name in the :php:func:`set_value()` function calls!** :: @@ -643,7 +643,7 @@ Showing Errors Individually =========================== If you prefer to show an error message next to each form field, rather -than as a list, you can use the :func:`form_error()` function. +than as a list, you can use the :php:func:`form_error()` function. Try it! Change your form so that it looks like this:: @@ -961,6 +961,7 @@ Rule Parameter Description not numeric. **less_than_equal_to** Yes Returns FALSE if the form element is greater than the parameter value, less_than_equal_to[8] or not numeric. +**in_list** Yes Returns FALSE if the form element is not within a predetermined list. in_list[red,blue,green] **alpha** No Returns FALSE if the form element contains anything other than alphabetical characters. **alpha_numeric** No Returns FALSE if the form element contains anything other than alpha-numeric characters. **alpha_numeric_spaces** No Returns FALSE if the form element contains anything other than alpha-numeric characters @@ -1017,9 +1018,9 @@ Name Parameter Description Class Reference *************** -.. class:: CI_Form_validation +.. php:class:: CI_Form_validation - .. method:: set_rules($field[, $label = ''[, $rules = '']]) + .. php:method:: set_rules($field[, $label = ''[, $rules = '']]) :param string $field: Field name :param string $label: Field label @@ -1033,7 +1034,7 @@ Class Reference - :ref:`setting-validation-rules` - :ref:`saving-groups` - .. method:: run([$group = '']) + .. php:method:: run([$group = '']) :param string $group: The name of the validation group to run :returns: TRUE on success, FALSE if validation failed @@ -1043,7 +1044,7 @@ Class Reference on failure. You can optionally pass the name of the validation group via the method, as described in: :ref:`saving-groups` - .. method:: set_message($lang[, $val = '']) + .. php:method:: set_message($lang[, $val = '']) :param string $lang: The rule the message is for :param string $val: The message @@ -1052,7 +1053,7 @@ Class Reference Permits you to set custom error messages. See :ref:`setting-error-messages` - .. method:: set_error_delimiters([$prefix = '<p>'[, $suffix = '</p>']]) + .. php:method:: set_error_delimiters([$prefix = '<p>'[, $suffix = '</p>']]) :param string $prefix: Error message prefix :param string $suffix: Error message suffix @@ -1061,7 +1062,7 @@ Class Reference Sets the default prefix and suffix for error messages. - .. method:: set_data($data) + .. php:method:: set_data($data) :param array $data: Array of data validate :returns: CI_Form_validation instance (method chaining) @@ -1070,7 +1071,7 @@ Class Reference Permits you to set an array for validation, instead of using the default ``$_POST`` array. - .. method:: reset_validation() + .. php:method:: reset_validation() :returns: CI_Form_validation instance (method chaining) :rtype: CI_Form_validation @@ -1078,14 +1079,14 @@ Class Reference Permits you to reset the validation when you validate more than one array. This method should be called before validating each new array. - .. method:: error_array() + .. php:method:: error_array() :returns: Array of error messages :rtype: array Returns the error messages as an array. - .. method:: error_string([$prefix = ''[, $suffix = '']]) + .. php:method:: error_string([$prefix = ''[, $suffix = '']]) :param string $prefix: Error message prefix :param string $suffix: Error message suffix @@ -1095,7 +1096,7 @@ Class Reference Returns all error messages (as returned from error_array()) formatted as a string and separated by a newline character. - .. method:: error($field[, $prefix = ''[, $suffix = '']]) + .. php:method:: error($field[, $prefix = ''[, $suffix = '']]) :param string $field: Field name :param string $prefix: Optional prefix @@ -1106,7 +1107,7 @@ Class Reference Returns the error message for a specific field, optionally adding a prefix and/or suffix to it (usually HTML tags). - .. method:: has_rule($field) + .. php:method:: has_rule($field) :param string $field: Field name :returns: TRUE if the field has rules set, FALSE if not @@ -1123,12 +1124,12 @@ Helper Reference Please refer to the :doc:`Form Helper <../helpers/form_helper>` manual for the following functions: -- :func:`form_error()` -- :func:`validation_errors()` -- :func:`set_value()` -- :func:`set_select()` -- :func:`set_checkbox()` -- :func:`set_radio()` +- :php:func:`form_error()` +- :php:func:`validation_errors()` +- :php:func:`set_value()` +- :php:func:`set_select()` +- :php:func:`set_checkbox()` +- :php:func:`set_radio()` Note that these are procedural functions, so they **do not** require you to prepend them with ``$this->form_validation``.
\ No newline at end of file diff --git a/user_guide_src/source/libraries/ftp.rst b/user_guide_src/source/libraries/ftp.rst index 4be1a6ea4..ddd4442fd 100644 --- a/user_guide_src/source/libraries/ftp.rst +++ b/user_guide_src/source/libraries/ftp.rst @@ -90,9 +90,9 @@ In this example a local directory is mirrored on the server. Class Reference *************** -.. class:: CI_FTP +.. php:class:: CI_FTP - .. method:: connect([$config = array()]) + .. php:method:: connect([$config = array()]) :param array $config: Connection values :returns: TRUE on success, FALSE on failure @@ -135,7 +135,7 @@ Class Reference **passive** TRUE TRUE/FALSE (boolean): Whether to use passive mode ============== =============== ============================================================================= - .. method:: upload($locpath, $rempath[, $mode = 'auto'[, $permissions = NULL]]) + .. php:method:: upload($locpath, $rempath[, $mode = 'auto'[, $permissions = NULL]]) :param string $locpath: Local file path :param string $rempath: Remote file path @@ -154,7 +154,7 @@ Class Reference If set, permissions have to be passed as an octal value. - .. method:: download($rempath, $locpath[, $mode = 'auto']) + .. php:method:: download($rempath, $locpath[, $mode = 'auto']) :param string $rempath: Remote file path :param string $locpath: Local file path @@ -172,7 +172,7 @@ Class Reference Returns FALSE if the download does not execute successfully (including if PHP does not have permission to write the local file). - .. method:: rename($old_file, $new_file[, $move = FALSE]) + .. php:method:: rename($old_file, $new_file[, $move = FALSE]) :param string $old_file: Old file name :param string $new_file: New file name @@ -186,7 +186,7 @@ Class Reference // Renames green.html to blue.html $this->ftp->rename('/public_html/foo/green.html', '/public_html/foo/blue.html'); - .. method:: move($old_file, $new_file) + .. php:method:: move($old_file, $new_file) :param string $old_file: Old file name :param string $new_file: New file name @@ -200,7 +200,7 @@ Class Reference .. note:: If the destination file name is different the file will be renamed. - .. method:: delete_file($filepath) + .. php:method:: delete_file($filepath) :param string $filepath: Path to file to delete :returns: TRUE on success, FALSE on failure @@ -211,7 +211,7 @@ Class Reference $this->ftp->delete_file('/public_html/joe/blog.html'); - .. method:: delete_dir($filepath) + .. php:method:: delete_dir($filepath) :param string $filepath: Path to directory to delete :returns: TRUE on success, FALSE on failure @@ -229,7 +229,7 @@ Class Reference $this->ftp->delete_dir('/public_html/path/to/folder/'); - .. method:: list_files([$path = '.']) + .. php:method:: list_files([$path = '.']) :param string $path: Directory path :returns: An array list of files or FALSE on failure @@ -242,7 +242,7 @@ Class Reference $list = $this->ftp->list_files('/public_html/'); print_r($list); - .. method:: mirror($locpath, $rempath) + .. php:method:: mirror($locpath, $rempath) :param string $locpath: Local path :param string $rempath: Remote path @@ -256,7 +256,7 @@ Class Reference $this->ftp->mirror('/path/to/myfolder/', '/public_html/myfolder/'); - .. method:: mkdir($path[, $permissions = NULL]) + .. php:method:: mkdir($path[, $permissions = NULL]) :param string $path: Path to directory to create :param int $permissions: Permissions (octal) @@ -272,7 +272,7 @@ Class Reference // Creates a folder named "bar" $this->ftp->mkdir('/public_html/foo/bar/', 0755); - .. method:: chmod($path, $perm) + .. php:method:: chmod($path, $perm) :param string $path: Path to alter permissions for :param int $perm: Permissions (octal) @@ -285,7 +285,7 @@ Class Reference // Chmod "bar" to 755 $this->ftp->chmod('/public_html/foo/bar/', 0755); - .. method:: changedir($path[, $suppress_debug = FALSE]) + .. php:method:: changedir($path[, $suppress_debug = FALSE]) :param string $path: Directory path :param bool $suppress_debug: Whether to turn off debug messages for this command @@ -297,7 +297,7 @@ Class Reference The ``$suppress_debug`` parameter is useful in case you want to use this method as an ``is_dir()`` alternative for FTP. - .. method:: close() + .. php:method:: close() :returns: TRUE on success, FALSE on failure :rtype: bool diff --git a/user_guide_src/source/libraries/image_lib.rst b/user_guide_src/source/libraries/image_lib.rst index a52cf3e02..ae2c8478e 100644 --- a/user_guide_src/source/libraries/image_lib.rst +++ b/user_guide_src/source/libraries/image_lib.rst @@ -316,9 +316,9 @@ Preference Default Value Options Description Class Reference *************** -.. class:: CI_Image_lib +.. php:class:: CI_Image_lib - .. method:: initialize([$props = array()]) + .. php:method:: initialize([$props = array()]) :param array $props: Image processing preferences :returns: TRUE on success, FALSE in case of invalid settings @@ -326,7 +326,7 @@ Class Reference Initializes the class for processing an image. - .. method:: resize() + .. php:method:: resize() :returns: TRUE on success, FALSE on failure :rtype: bool @@ -373,7 +373,7 @@ Class Reference new_image) are used, the resizing method will instead target the original image for processing. - .. method:: crop() + .. php:method:: crop() :returns: TRUE on success, FALSE on failure :rtype: bool @@ -409,7 +409,7 @@ Class Reference in ExpressionEngine, the CMS we develop. We added a JavaScript UI that lets the cropping area be selected. - .. method:: rotate() + .. php:method:: rotate() :returns: TRUE on success, FALSE on failure :rtype: bool @@ -441,7 +441,7 @@ Class Reference echo $this->image_lib->display_errors(); } - .. method:: watermark() + .. php:method:: watermark() :returns: TRUE on success, FALSE on failure :rtype: bool @@ -449,7 +449,7 @@ Class Reference Creates a watermark over an image, please refer to the :ref:`watermarking` section for more info. - .. method:: clear() + .. php:method:: clear() :rtype: void @@ -461,7 +461,7 @@ Class Reference $this->image_lib->clear(); - .. method:: display_errors([$open = '<p>[, $close = '</p>']]) + .. php:method:: display_errors([$open = '<p>[, $close = '</p>']]) :param string $open: Error message opening tag :param string $close: Error message closing tag diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst index 4464e0fdc..967f69d13 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -112,9 +112,9 @@ a boolean value as the second parameter:: Class Reference *************** -.. class:: CI_Input +.. php:class:: CI_Input - .. method:: post([$index = NULL[, $xss_clean = NULL]]) + .. php:method:: post([$index = NULL[, $xss_clean = NULL]]) :param mixed $index: POST parameter name :param bool $xss_clean: Whether to apply XSS filtering @@ -157,7 +157,7 @@ Class Reference $this->input->post(array('field1', 'field2'), TRUE); - .. method:: get([$index = NULL[, $xss_clean = NULL]]) + .. php:method:: get([$index = NULL[, $xss_clean = NULL]]) :param mixed $index: GET parameter name :param bool $xss_clean: Whether to apply XSS filtering @@ -190,7 +190,7 @@ Class Reference $this->input->get(array('field1', 'field2'), TRUE); - .. method:: post_get($index[, $xss_clean = NULL]) + .. php:method:: post_get($index[, $xss_clean = NULL]) :param string $index: POST/GET parameter name :param bool $xss_clean: Whether to apply XSS filtering @@ -203,7 +203,7 @@ Class Reference $this->input->post_get('some_data', TRUE); - .. method:: get_post($index[, $xss_clean = NULL]) + .. php:method:: get_post($index[, $xss_clean = NULL]) :param string $index: GET/POST parameter name :param bool $xss_clean: Whether to apply XSS filtering @@ -218,7 +218,7 @@ Class Reference .. note:: This method used to act EXACTLY like ``post_get()``, but it's behavior has changed in CodeIgniter 3.0. - .. method:: cookie([$index = NULL[, $xss_clean = NULL]]) + .. php:method:: cookie([$index = NULL[, $xss_clean = NULL]]) :param mixed $index: COOKIE name :param bool $xss_clean: Whether to apply XSS filtering @@ -237,7 +237,11 @@ Class Reference $this->input->cookie(array('some_cookie', 'some_cookie2')); - .. method:: server($index[, $xss_clean = NULL]) + .. note:: Unlike the :doc:`Cookie Helper <../helpers/cookie_helper>` + function :php:func:`get_cookie()`, this method does NOT prepend + your configured ``$config['cookie_prefix']`` value. + + .. php:method:: server($index[, $xss_clean = NULL]) :param mixed $index: Value name :param bool $xss_clean: Whether to apply XSS filtering @@ -255,7 +259,7 @@ Class Reference $this->input->server(array('SERVER_PROTOCOL', 'REQUEST_URI')); - .. method:: input_stream([$index = NULL[, $xss_clean = NULL]]) + .. php:method:: input_stream([$index = NULL[, $xss_clean = NULL]]) :param mixed $index: Key name :param bool $xss_clean: Whether to apply XSS filtering @@ -265,7 +269,7 @@ Class Reference This method is identical to ``get()``, ``post()`` and ``cookie()``, only it fetches the *php://input* stream data. - .. method:: set_cookie($name = ''[, $value = ''[, $expire = ''[, $domain = ''[, $path = '/'[, $prefix = ''[, $secure = FALSE[, $httponly = FALSE]]]]]]]) + .. php:method:: set_cookie($name = ''[, $value = ''[, $expire = ''[, $domain = ''[, $path = '/'[, $prefix = ''[, $secure = FALSE[, $httponly = FALSE]]]]]]]) :param mixed $name: Cookie name or an array of parameters :param string $value: Cookie value @@ -328,7 +332,7 @@ Class Reference $this->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure); - .. method:: ip_address() + .. php:method:: ip_address() :returns: Visitor's IP address or '0.0.0.0' if not valid :rtype: string @@ -343,7 +347,7 @@ Class Reference HTTP_CLIENT_IP, HTTP_X_CLIENT_IP or HTTP_X_CLUSTER_CLIENT_IP address for the allowed IP addresses. - .. method:: valid_ip($ip[, $which = '']) + .. php:method:: valid_ip($ip[, $which = '']) :param string $ip: IP address :param string $which: IP protocol ('ipv4' or 'ipv6') @@ -370,7 +374,7 @@ Class Reference Accepts an optional second string parameter of 'ipv4' or 'ipv6' to specify an IP format. The default checks for both formats. - .. method:: user_agent([$xss_clean = NULL]) + .. php:method:: user_agent([$xss_clean = NULL]) :returns: User agent string or NULL if not set :param bool $xss_clean: Whether to apply XSS filtering @@ -385,7 +389,7 @@ Class Reference See the :doc:`User Agent Class <user_agent>` for methods which extract information from the user agent string. - .. method:: request_headers([$xss_clean = FALSE]) + .. php:method:: request_headers([$xss_clean = FALSE]) :param bool $xss_clean: Whether to apply XSS filtering :returns: An array of HTTP request headers @@ -399,7 +403,7 @@ Class Reference $headers = $this->input->request_headers(); - .. method:: get_request_header($index[, $xss_clean = FALSE]) + .. php:method:: get_request_header($index[, $xss_clean = FALSE]) :param string $index: HTTP request header name :param bool $xss_clean: Whether to apply XSS filtering @@ -412,7 +416,7 @@ Class Reference $this->input->get_request_header('some-header', TRUE); - .. method:: is_ajax_request() + .. php:method:: is_ajax_request() :returns: TRUE if it is an Ajax request, FALSE if not :rtype: bool @@ -420,7 +424,7 @@ Class Reference Checks to see if the HTTP_X_REQUESTED_WITH server header has been set, and returns boolean TRUE if it is or FALSE if not. - .. method:: is_cli_request() + .. php:method:: is_cli_request() :returns: TRUE if it is a CLI request, FALSE if not :rtype: bool @@ -439,7 +443,7 @@ Class Reference .. note:: This method is DEPRECATED and is now just an alias for the :func:`is_cli()` function. - .. method:: method([$upper = FALSE]) + .. php:method:: method([$upper = FALSE]) :param bool $upper: Whether to return the request method name in upper or lower case :returns: HTTP request method diff --git a/user_guide_src/source/libraries/language.rst b/user_guide_src/source/libraries/language.rst index e833d9757..ee1cefcd0 100644 --- a/user_guide_src/source/libraries/language.rst +++ b/user_guide_src/source/libraries/language.rst @@ -169,7 +169,7 @@ Using language lines as form labels ----------------------------------- This feature has been deprecated from the language library and moved to -the :func:`lang()` function of the :doc:`Language Helper +the :php:func:`lang()` function of the :doc:`Language Helper <../helpers/language_helper>`. Auto-loading Languages @@ -185,9 +185,9 @@ language(s) to the autoload array. Class Reference *************** -.. class:: CI_Lang +.. php:class:: CI_Lang - .. method:: load($langfile[, $idiom = ''[, $return = FALSE[, $add_suffix = TRUE[, $alt_path = '']]]]) + .. php:method:: load($langfile[, $idiom = ''[, $return = FALSE[, $add_suffix = TRUE[, $alt_path = '']]]]) :param mixed $langfile: Language file to load or array with multiple files :param string $idiom: Language name (i.e. 'english') @@ -199,7 +199,7 @@ Class Reference Loads a language file. - .. method:: line($line[, $log_errors = TRUE]) + .. php:method:: line($line[, $log_errors = TRUE]) :param string $line: Language line key name :param bool $log_errors: Whether to log an error if the line isn't found diff --git a/user_guide_src/source/libraries/loader.rst b/user_guide_src/source/libraries/loader.rst index 48ac6e174..efa9d519b 100644 --- a/user_guide_src/source/libraries/loader.rst +++ b/user_guide_src/source/libraries/loader.rst @@ -77,9 +77,9 @@ calling ``add_package_path()``. Class Reference *************** -.. class:: CI_Loader +.. php:class:: CI_Loader - .. method:: library($library[, $params = NULL[, $object_name = NULL]]) + .. php:method:: library($library[, $params = NULL[, $object_name = NULL]]) :param mixed $library: Library name as a string or an array with multiple libraries :param array $params: Optional array of parameters to pass to the loaded library's constructor @@ -156,7 +156,7 @@ Class Reference Please take note, when multiple libraries are supplied in an array for the first parameter, this parameter is discarded. - .. method:: driver($library[, $params = NULL[, $object_name]]) + .. php:method:: driver($library[, $params = NULL[, $object_name]]) :param mixed $library: Library name as a string or an array with multiple libraries :param array $params: Optional array of parameters to pass to the loaded library's constructor @@ -217,7 +217,7 @@ Class Reference // Session class is now accessed using: $this->my_session - .. method:: view($view[, $vars = array()[, return = FALSE]]) + .. php:method:: view($view[, $vars = array()[, return = FALSE]]) :param string $view: View name :param array $vars: An associative array of variables @@ -251,7 +251,7 @@ Class Reference $string = $this->load->view('myfile', '', TRUE); - .. method:: vars($vars[, $val = '']) + .. php:method:: vars($vars[, $val = '']) :param mixed $vars: An array of variables or a single variable name :param mixed $val: Optional variable value @@ -268,7 +268,7 @@ Class Reference have multiple calls to this method. The data get cached and merged into one array for conversion to variables. - .. method:: get_var($key) + .. php:method:: get_var($key) :param string $key: Variable name key :returns: Value if key is found, NULL if not @@ -278,21 +278,21 @@ Class Reference your views. This is useful if for any reason a var is set in a library or another controller method using ``$this->load->vars()``. - .. method:: get_vars() + .. php:method:: get_vars() :returns: An array of all assigned view variables :rtype: array This method retrieves all variables available to your views. - .. method:: clear_vars() + .. php:method:: clear_vars() :returns: CI_Loader instance (method chaining) :rtype: CI_Loader Clears cached view variables. - .. method:: model($model[, $name = ''[, $db_conn = FALSE]]) + .. php:method:: model($model[, $name = ''[, $db_conn = FALSE]]) :param mixed $model: Model name or an array containing multiple models :param string $name: Optional object name to assign the model to @@ -317,7 +317,7 @@ Class Reference $this->load->model('model_name', 'fubar'); $this->fubar->method(); - .. method:: database([$params = ''[, $return = FALSE[, $query_builder = NULL]]]) + .. php:method:: database([$params = ''[, $return = FALSE[, $query_builder = NULL]]]) :param mixed $params: Database group name or configuration options :param bool $return: Whether to return the loaded database object @@ -329,7 +329,7 @@ Class Reference **optional**. Please see the :doc:`database <../database/index>` section for more info. - .. method:: dbforge([$db = NULL[, $return = FALSE]]) + .. php:method:: dbforge([$db = NULL[, $return = FALSE]]) :param object $db: Database object :param bool $return: Whether to return the Database Forge instance @@ -339,7 +339,7 @@ Class Reference Loads the :doc:`Database Forge <../database/forge>` class, please refer to that manual for more info. - .. method:: dbutil([$db = NULL[, $return = FALSE]]) + .. php:method:: dbutil([$db = NULL[, $return = FALSE]]) :param object $db: Database object :param bool $return: Whether to return the Database Utilities instance @@ -349,7 +349,7 @@ Class Reference Loads the :doc:`Database Utilities <../database/utilities>` class, please refer to that manual for more info. - .. method:: helper($helpers) + .. php:method:: helper($helpers) :param mixed $helpers: Helper name as a string or an array containing multiple helpers :returns: CI_Loader instance (method chaining) @@ -358,7 +358,7 @@ Class Reference This method loads helper files, where file_name is the name of the file, without the _helper.php extension. - .. method:: file($path[, $return = FALSE]) + .. php:method:: file($path[, $return = FALSE]) :param string $path: File path :param bool $return: Whether to return the loaded file @@ -371,7 +371,7 @@ Class Reference second parameter to boolean TRUE it will instead return the data as a string. - .. method:: language($files[, $lang = '']) + .. php:method:: language($files[, $lang = '']) :param mixed $files: Language file name or an array of multiple language files :param string $lang: Language name @@ -381,7 +381,7 @@ Class Reference This method is an alias of the :doc:`language loading method <language>`: ``$this->lang->load()``. - .. method:: config($file[, $use_sections = FALSE[, $fail_gracefully = FALSE]]) + .. php:method:: config($file[, $use_sections = FALSE[, $fail_gracefully = FALSE]]) :param string $file: Configuration file name :param bool $use_sections: Whether configuration values should be loaded into their own section @@ -392,7 +392,7 @@ Class Reference This method is an alias of the :doc:`config file loading method <config>`: ``$this->config->load()`` - .. method:: is_loaded($class) + .. php:method:: is_loaded($class) :param string $class: Class name :returns: Singleton property name if found, FALSE if not @@ -420,7 +420,7 @@ Class Reference $this->load->is_loaded('Form_validation'); // returns 'fv' - .. method:: add_package_path($path[, $view_cascade = TRUE]) + .. php:method:: add_package_path($path[, $view_cascade = TRUE]) :param string $path: Path to add :param bool $view_cascade: Whether to use cascading views @@ -435,7 +435,7 @@ Class Reference $this->load->add_package_path(APPPATH.'third_party/foo_bar/') ->library('foo_bar'); - .. method:: remove_package_path([$path = '']) + .. php:method:: remove_package_path([$path = '']) :param string $path: Path to remove :returns: CI_Loader instance (method chaining) @@ -452,7 +452,7 @@ Class Reference $this->load->remove_package_path(APPPATH.'third_party/foo_bar/'); - .. method:: get_package_paths([$include_base = TRUE]) + .. php:method:: get_package_paths([$include_base = TRUE]) :param bool $include_base: Whether to include BASEPATH :returns: An array of package paths diff --git a/user_guide_src/source/libraries/migration.rst b/user_guide_src/source/libraries/migration.rst index e8ea1d977..25be0c93c 100644 --- a/user_guide_src/source/libraries/migration.rst +++ b/user_guide_src/source/libraries/migration.rst @@ -138,9 +138,9 @@ Preference Default Options Des Class Reference *************** -.. class:: CI_Migration +.. php:class:: CI_Migration - .. method:: current() + .. php:method:: current() :returns: TRUE if no migrations are found, current version string on success, FALSE on failure :rtype: mixed @@ -148,21 +148,21 @@ Class Reference Migrates up to the current version (whatever is set for ``$config['migration_version']`` in *application/config/migration.php*). - .. method:: error_string() + .. php:method:: error_string() :returns: Error messages :rtype: string This returns a string of errors that were detected while performing a migration. - .. method:: find_migrations() + .. php:method:: find_migrations() :returns: An array of migration files :rtype: array An array of migration filenames are returned that are found in the **migration_path** property. - .. method:: latest() + .. php:method:: latest() :returns: TRUE if no migrations are found, current version string on success, FALSE on failure :rtype: mixed @@ -171,7 +171,7 @@ Class Reference the ``$config['migration_version']`` the Migration class will use the very newest migration found in the filesystem. - .. method:: version($target_version) + .. php:method:: version($target_version) :param mixed $target_version: Migration version to process :returns: TRUE if no migrations are found, current version string on success, FALSE on failure diff --git a/user_guide_src/source/libraries/output.rst b/user_guide_src/source/libraries/output.rst index e808561bd..4b36d2a03 100644 --- a/user_guide_src/source/libraries/output.rst +++ b/user_guide_src/source/libraries/output.rst @@ -29,7 +29,7 @@ need to. Class Reference *************** -.. class:: CI_Output +.. php:class:: CI_Output .. attribute:: $parse_exec_vars = TRUE; @@ -41,7 +41,7 @@ Class Reference $this->output->parse_exec_vars = FALSE; - .. method:: set_output($output) + .. php:method:: set_output($output) :param string $output: String to set the output to :returns: CI_Output instance (method chaining) @@ -55,7 +55,7 @@ Class Reference in the function you call it from. For example, if you build a page in one of your controller methods, don't set the output until the end. - .. method:: set_content_type($mime_type[, $charset = NULL]) + .. php:method:: set_content_type($mime_type[, $charset = NULL]) :param string $mime_type: MIME Type idenitifer string :param string $charset: Character set @@ -80,7 +80,7 @@ Class Reference $this->output->set_content_type('css', 'utf-8'); - .. method:: get_content_type() + .. php:method:: get_content_type() :returns: Content-Type string :rtype: string @@ -92,7 +92,7 @@ Class Reference .. note:: If not set, the default return value is 'text/html'. - .. method:: get_header($header) + .. php:method:: get_header($header) :param string $header: HTTP header name :returns: HTTP response header or NULL if not found @@ -109,7 +109,7 @@ Class Reference .. note:: Raw headers sent via PHP's native ``header()`` function are also detected. - .. method:: get_output() + .. php:method:: get_output() :returns: Output string :rtype: string @@ -123,7 +123,7 @@ Class Reference been previously sent to the output class by one of the CodeIgniter functions like ``$this->load->view()``. - .. method:: append_output($output) + .. php:method:: append_output($output) :param string $output: Additional output data to append :returns: CI_Output instance (method chaining) @@ -134,7 +134,7 @@ Class Reference $this->output->append_output($data); - .. method:: set_header($header[, $replace = TRUE]) + .. php:method:: set_header($header[, $replace = TRUE]) :param string $header: HTTP response header :param bool $replace: Whether to replace the old header value, if it is already set @@ -151,7 +151,7 @@ Class Reference $this->output->set_header('Cache-Control: post-check=0, pre-check=0'); $this->output->set_header('Pragma: no-cache'); - .. method:: set_status_header([$code = 200[, $text = '']]) + .. php:method:: set_status_header([$code = 200[, $text = '']]) :param int $code: HTTP status code :param string $text: Optional message @@ -168,7 +168,7 @@ Class Reference .. note:: This method is an alias for :doc:`Common function <../general/common_functions>` :func:`set_status_header()`. - .. method:: enable_profiler([$val = TRUE]) + .. php:method:: enable_profiler([$val = TRUE]) :param bool $val: Whether to enable or disable the Profiler :returns: CI_Output instance (method chaining) @@ -188,7 +188,7 @@ Class Reference $this->output->enable_profiler(FALSE); - .. method:: set_profiler_sections($sections) + .. php:method:: set_profiler_sections($sections) :param array $sections: Profiler sections :returns: CI_Output instance (method chaining) @@ -197,7 +197,7 @@ Class Reference Permits you to enable/disable specific sections of the Profiler when it is enabled. Please refer to the :doc:`Profiler <../general/profiling>` documentation for further information. - .. method:: cache($time) + .. php:method:: cache($time) :param int $time: Cache expiration time in seconds :returns: CI_Output instance (method chaining) @@ -207,7 +207,7 @@ Class Reference For more information, please see the :doc:`caching documentation <../general/caching>`. - .. method:: _display([$output = '']) + .. php:method:: _display([$output = '']) :param string $output: Output data override :returns: void diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst index 8c5c2c63a..913717c67 100644 --- a/user_guide_src/source/libraries/pagination.rst +++ b/user_guide_src/source/libraries/pagination.rst @@ -131,6 +131,12 @@ the offset segment. A custom suffix added to the path. The sufix value will be right after the offset segment. +**$config['use_global_url_suffix'] = FALSE;** + +When set to TRUE, it will **override** the ``$config['suffix']`` value and +instead set it to the one that you have in ``$config['url_suffix']`` in +your **application/config/config.php** file. + *********************** Adding Enclosing Markup *********************** @@ -290,9 +296,9 @@ you can pass boolean FALSE as a regular attribute Class Reference *************** -.. class:: CI_Pagination +.. php:class:: CI_Pagination - .. method:: initialize([$params = array()]) + .. php:method:: initialize([$params = array()]) :param array $params: Configuration parameters :returns: CI_Pagination instance (method chaining) @@ -300,7 +306,7 @@ Class Reference Initializes the Pagination class with your preferred options. - .. method:: create_links() + .. php:method:: create_links() :returns: HTML-formatted pagination :rtype: string diff --git a/user_guide_src/source/libraries/parser.rst b/user_guide_src/source/libraries/parser.rst index d66684d9b..6c9d28959 100644 --- a/user_guide_src/source/libraries/parser.rst +++ b/user_guide_src/source/libraries/parser.rst @@ -276,9 +276,9 @@ Result:: Class Reference *************** -.. class:: CI_Parser +.. php:class:: CI_Parser - .. method:: parse($template, $data[, $return = FALSE]) + .. php:method:: parse($template, $data[, $return = FALSE]) :param string $template: Path to view file :param array $data: Variable data @@ -288,7 +288,7 @@ Class Reference Parses a template from the provided path and variables. - .. method:: parse_string($template, $data[, $return = FALSE]) + .. php:method:: parse_string($template, $data[, $return = FALSE]) :param string $template: Path to view file :param array $data: Variable data @@ -299,7 +299,7 @@ Class Reference This method works exactly like ``parse()``, only it accepts the template as a string instead of loading a view file. - .. method:: set_delimiters([$l = '{'[, $r = '}']]) + .. php:method:: set_delimiters([$l = '{'[, $r = '}']]) :param string $l: Left delimiter :param string $r: Right delimiter diff --git a/user_guide_src/source/libraries/security.rst b/user_guide_src/source/libraries/security.rst index a39ef5976..27e6e561b 100644 --- a/user_guide_src/source/libraries/security.rst +++ b/user_guide_src/source/libraries/security.rst @@ -110,9 +110,9 @@ Regular expressions are also supported (case-insensitive):: Class Reference *************** -.. class:: CI_Security +.. php:class:: CI_Security - .. method:: xss_clean($str[, $is_image = FALSE]) + .. php:method:: xss_clean($str[, $is_image = FALSE]) :param mixed $str: Input string or an array of strings :returns: XSS-clean data @@ -121,7 +121,7 @@ Class Reference Tries to remove XSS exploits from the input data and returns the cleaned string. If the optional second parameter is set to true, it will return boolean TRUE if the image is safe to use and FALSE if malicious data was detected in it. - .. method:: sanitize_filename($str[, $relative_path = FALSE]) + .. php:method:: sanitize_filename($str[, $relative_path = FALSE]) :param string $str: File name/path :param bool $relative_path: Whether to preserve any directories in the file path @@ -140,14 +140,14 @@ Class Reference $filename = $this->security->sanitize_filename($this->input->post('filename'), TRUE); - .. method:: get_csrf_token_name() + .. php:method:: get_csrf_token_name() :returns: CSRF token name :rtype: string Returns the CSRF token name (the ``$config['csrf_token_name']`` value). - .. method:: get_csrf_hash() + .. php:method:: get_csrf_hash() :returns: CSRF hash :rtype: string @@ -155,7 +155,7 @@ Class Reference Returns the CSRF hash value. Useful in combination with ``get_csrf_token_name()`` for manually building forms or sending valid AJAX POST requests. - .. method:: entity_decode($str[, $charset = NULL]) + .. php:method:: entity_decode($str[, $charset = NULL]) :param string $str: Input string :param string $charset: Character set of the input string @@ -167,7 +167,7 @@ Class Reference If the ``$charset`` parameter is left empty, then your configured ``$config['charset']`` value will be used. - .. method:: get_random_bytes($length) + .. php:method:: get_random_bytes($length) :param int $length: Output length :returns: A binary stream of random bytes or FALSE on failure diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst index f05f86af1..e2780683f 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -1,13 +1,20 @@ -############## -Session Driver -############## +############### +Session Library +############### The Session class permits you maintain a user's "state" and track their -activity while they browse your site. CodeIgniter offers two default -session drivers: the classic `Cookie Driver`_, and the `Native Driver`_, -which supports usage of the native PHP Session mechanism. In addition, -you may create your own `Custom Drivers`_ to store session data however -you wish, while still taking advantage of the features of the Session class. +activity while they browse your site. + +CodeIgniter comes with a few session storage drivers: + + - files (default; file-system based) + - database + - redis + - memcached + +In addition, you may create your own, custom session drivers based on other +kinds of storage, while still taking advantage of the features of the +Session class. .. contents:: :local: @@ -23,122 +30,165 @@ Using the Session Class Initializing a Session ====================== -Sessions will typically run globally with each page load, so the session -class must either be :doc:`initialized <../general/drivers>` in your -:doc:`controller <../general/controllers>` constructors, or it can be -:doc:`auto-loaded <../general/autoloader>` by the system. For the most -part the session class will run unattended in the background, so simply -initializing the class will cause it to read, create, and update -sessions. +Sessions will typically run globally with each page load, so the Session +class should either be initialized in your :doc:`controller +<../general/controllers>` constructors, or it can be :doc:`auto-loaded +<../general/autoloader>` by the system. +For the most part the session class will run unattended in the background, +so simply initializing the class will cause it to read, create, and update +sessions when necessary. To initialize the Session class manually in your controller constructor, -use the ``$this->load->driver`` function:: +use the ``$this->load->library()`` method:: - $this->load->driver('session'); + $this->load->library('session'); Once loaded, the Sessions library object will be available using:: $this->session +.. important:: Because the :doc:`Loader Class </libraries/loader>` is instantiated + by CodeIgniter's base controller, make sure to call + ``parent::__construct()`` before trying to load a library from + inside a controller constructor. + How do Sessions work? ===================== When a page is loaded, the session class will check to see if valid -session data exists in the user's session. If sessions data does **not** -exist (or if it has expired) a new session will be created and saved. -If a session does exist, its information will be updated. With each update, -the session_id will be regenerated. +session cookie is sent by the user's browser. If a sessions cookie does +**not** exist (or if it doesn't match one stored on the server or has +expired) a new session will be created and saved. + +If a valid session does exist, its information will be updated. With each +update, the session ID may be regenerated if configured to do so. It's important for you to understand that once initialized, the Session class runs automatically. There is nothing you need to do to cause the -above behavior to happen. You can, as you'll see below, work with -session data or even add your own data to a user's session, but the -process of reading, writing, and updating a session is automatic. +above behavior to happen. You can, as you'll see below, work with session +data, but the process of reading, writing, and updating a session is +automatic. + +.. note:: Under CLI, the Session library will automatically halt itself, + as this is a concept based entirely on the HTTP protocol. + +A note about concurrency +------------------------ + +Unless you're developing a website with heavy AJAX usage, you can skip this +section. If you are, however, and if you're experiencing performance +issues, then this note is exactly what you're looking for. + +Sessions in previous versions of CodeIgniter didn't implement locking, +which meant that two HTTP requests using the same session could run exactly +at the same time. To use a more appropriate technical term - requests were +non-blocking. + +However, non-blocking requests in the context of sessions also means +unsafe, because modifications to session data (or session ID regeneration) +in one request can interfere with the execution of a second, concurrent +request. This detail was at the root of many issues and the main reason why +CodeIgniter 3.0 has a completely re-written Session library. + +Why are we telling you this? Because it is likely that after trying to +find the reason for your performance issues, you may conclude that locking +is the issue and therefore look into how to remove the locks ... + +DO NOT DO THAT! Removing locks would be **wrong** and it will cause you +more problems! + +Locking is not the issue, it is a solution. Your issue is that you still +have the session open, while you've already processed it and therefore no +longer need it. So, what you need is to close the session for the +current request after you no longer need it. + +Long story short - call ``session_write_close()`` once you no longer need +anything to do with session variables. What is Session Data? ===================== -A *session*, as far as CodeIgniter is concerned, is simply an array -containing the following information: - -- The user's unique Session ID (this is a statistically random string - with very strong entropy, hashed with MD5 for portability, and - regenerated (by default) every five minutes) -- The user's IP Address -- The user's User Agent data (the first 120 characters of the browser - data string) -- The "last activity" time stamp. - -The above data is stored in a cookie as a serialized array with this -prototype:: - - [array] - ( - 'session_id' => random hash, - 'ip_address' => 'string - user IP address', - 'user_agent' => 'string - user agent data', - 'last_activity' => timestamp - ) - -.. note:: Sessions are only updated every five minutes by default to - reduce processor load. If you repeatedly reload a page you'll notice - that the "last activity" time only updates if five minutes or more has - passed since the last time the cookie was written. This time is - configurable by changing the $config['sess_time_to_update'] line in - your system/config/config.php file. +Session data is simply an array associated with a particular session ID +(cookie). + +If you've used sessions in PHP before, you should be familiar with PHP's +`$_SESSION superglobal <http://php.net/manual/en/reserved.variables.session.php>`_ +(if not, please read the content on that link). + +CodeIgniter gives access to its session data through the same means, as it +uses the session handlers' mechanism provided by PHP. Using session data is +as simple as manipulating (read, set and unset values) the ``$_SESSION`` +array. + +In addition, CodeIgniter also provides 2 special types of session data +that are further explained below: flashdata and tempdata. + +.. note:: In previous versions, regular session data in CodeIgniter was + referred to as 'userdata'. Have this in mind if that term is used + elsewhere in the manual. Most of it is written to explain how + the custom 'userdata' methods work. Retrieving Session Data ======================= -Any piece of information from the session array is available using the -following function:: +Any piece of information from the session array is available through the +``$_SESSION`` superglobal:: + + $_SESSION['item'] + +Or through the magic getter:: + + $this->session->item + +And for backwards compatibility, through the ``userdata()`` method:: $this->session->userdata('item'); -Where item is the array index corresponding to the item you wish to -fetch. For example, to fetch the session ID you will do this:: +Where item is the array key corresponding to the item you wish to fetch. +For example, to assign a previously stored 'name' item to the ``$name`` +variable, you will do this:: + + $name = $_SESSION['name']; + + // or: + + $name = $this->session->name + + // or: - $session_id = $this->session->userdata('session_id'); + $name = $this->session->userdata('name'); -.. note:: The function returns NULL if the item you are - trying to access does not exist. +.. note:: The ``userdata()`` method returns NULL if the item you are trying + to access does not exist. If you want to retrieve all of the existing userdata, you can simply -omit the item key parameter:: +omit the item key (magic getter only works for properties):: - $this->session->userdata(); + $_SESSION - /** - * Produces something similar to: - * - * Array - * ( - * [session_id] => 4a5a5dca22728fb0a84364eeb405b601 - * [ip_address] => 127.0.0.1 - * [user_agent] => Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; - * [last_activity] => 1303142623 - * ) - */ - -Adding Custom Session Data -========================== + // or: -A useful aspect of the session array is that you can add your own data -to it and it will be stored in the user's cookie. Why would you want to -do this? Here's one example: + $this->session->userdata(); + +Adding Session Data +=================== Let's say a particular user logs into your site. Once authenticated, you -could add their username and email address to the session, making -that data globally available to you without having to run a database -query when you need it. +could add their username and e-mail address to the session, making that +data globally available to you without having to run a database query when +you need it. -To add your data to the session array involves passing an array -containing your new data to this function:: +You can simply assign data to the ``$_SESSION`` array, as with any other +variable. Or as a property of ``$this->session``. + +Alternatively, the old method of assigning it as "userdata" is also +available. That however passing an array containing your new data to the +``set_userdata()`` method:: $this->session->set_userdata($array); -Where $array is an associative array containing your new data. Here's an -example:: +Where ``$array`` is an associative array containing your new data. Here's +an example:: $newdata = array( 'username' => 'johndoe', @@ -149,68 +199,108 @@ example:: $this->session->set_userdata($newdata); If you want to add userdata one value at a time, ``set_userdata()`` also -supports this syntax. - -:: +supports this syntax:: $this->session->set_userdata('some_name', 'some_value'); -If you want to verify that a userdata value exists, call ``has_userdata()``. +If you want to verify that a session value exists, simply check with +``isset()``:: -:: + // returns FALSE if the 'some_name' item doesn't exist or is NULL, + // TRUE otherwise: + isset($_SESSION['some_name']) + +Or you can call ``has_userdata()``:: $this->session->has_userdata('some_name'); Removing Session Data ===================== -Just as set_userdata() can be used to add information into a session, -unset_userdata() can be used to remove it, by passing the session key. -For example, if you wanted to remove 'some_name' from your session -information:: +Just as with any other variable, unsetting a value in ``$_SESSION`` can be +done through ``unset()``:: - $this->session->unset_userdata('some_name'); + unset($_SESSION['some_name']); + // or multiple values: -This function can also be passed an associative array of items to unset. + unset( + $_SESSION['some_name'], + $_SESSION['another_name'] + ); -:: +Also, just as ``set_userdata()`` can be used to add information to a +session, ``unset_userdata()`` can be used to remove it, by passing the +session key. For example, if you wanted to remove 'some_name' from your +session data array:: + + $this->session->unset_userdata('some_name'); - $array_items = array('username' => '', 'email' => ''); +This method also accepts an array of item keys to unset:: + + $array_items = array('username', 'email'); $this->session->unset_userdata($array_items); +.. note:: In previous versions, the ``unset_userdata()`` method used + to accept an associative array of ``key => 'dummy value'`` + pairs. This is no longer supported. Flashdata ========= CodeIgniter supports "flashdata", or session data that will only be -available for the next server request, and are then automatically -cleared. These can be very useful, and are typically used for -informational or status messages (for example: "record 2 deleted"). +available for the next request, and is then automatically cleared. + +This can be very useful, especially for one-time informational, error or +status messages (for example: "Record 2 deleted"). + +It should be noted that flashdata variables are regular session vars, +only marked in a specific way under the '__ci_vars' key (please don't touch +that one, you've been warned). + +To mark an existing item as "flashdata":: + + $this->session->mark_as_flash('item'); + +If you want to mark multiple items as flashdata, simply pass the keys as an +array:: -.. note:: Flash variables are prefaced with "flash\_" so avoid this prefix - in your own session names. + $this->session->mark_as_flash(array('item', 'item2')); To add flashdata:: - $this->session->set_flashdata('item', 'value'); + $_SESSION['item'] = 'value'; + $this->session->mark_as_flash('item'); + +Or alternatively, using the ``set_flashdata()`` method:: + $this->session->set_flashdata('item', 'value'); You can also pass an array to ``set_flashdata()``, in the same manner as ``set_userdata()``. -To read a flashdata variable:: +Reading flashdata variables is the same as reading regular session data +through ``$_SESSION``:: + + $_SESSION['item'] + +.. important:: The ``userdata()`` method will NOT return flashdata items. + +However, if you want to be sure that you're reading "flashdata" (and not +any other kind), you can also use the ``flashdata()`` method:: $this->session->flashdata('item'); -An array of all flashdata can be retrieved as follows:: +Or to get an array with all flashdata, simply omit the key parameter:: $this->session->flashdata(); +.. note:: The ``flashdata()`` method returns NULL if the item cannot be + found. If you find that you need to preserve a flashdata variable through an -additional request, you can do so using the ``keep_flashdata()`` function. +additional request, you can do so using the ``keep_flashdata()`` method. You can either pass a single item or an array of flashdata items to keep. :: @@ -218,8 +308,6 @@ You can either pass a single item or an array of flashdata items to keep. $this->session->keep_flashdata('item'); $this->session->keep_flashdata(array('item1', 'item2', 'item3')); -.. note:: The function will return NULL if the item cannot be found. - Tempdata ======== @@ -227,22 +315,56 @@ CodeIgniter also supports "tempdata", or session data with a specific expiration time. After the value expires, or the session expires or is deleted, the value is automatically removed. +Similarly to flashdata, tempdata variables are regular session vars that +are marked in a specific way under the '__ci_vars' key (again, don't touch +that one). + +To mark an existing item as "tempdata", simply pass its key and expiry time +(in seconds!) to the ``mark_as_temp()`` method:: + + // 'item' will be erased after 300 seconds + $this->session->mark_as_temp('item', 300); + +You can mark multiple items as tempdata in two ways, depending on whether +you want them all to have the same expiry time or not:: + + // Both 'item' and 'item2' will expire after 300 seconds + $this->session->mark_as_temp(array('item', 'item2'), 300); + + // 'item' will be erased after 300 seconds, while 'item2' + // will do so after only 240 seconds + $this->session->mark_as_temp(array( + 'item' => 300, + 'item2' => 240 + )); + To add tempdata:: - $expire = 300; // Expire in 5 minutes + $_SESSION['item'] = 'value'; + $this->session->mark_as_temp('item', 300); // Expire in 5 minutes - $this->session->set_tempdata('item', 'value', $expire); +Or alternatively, using the ``set_tempdata()`` method:: + + $this->session->set_tempdata('item', 'value', 300); You can also pass an array to ``set_tempdata()``:: $tempdata = array('newuser' => TRUE, 'message' => 'Thanks for joining!'); - $this->session->set_tempdata($tempdata, '', $expire); + $this->session->set_tempdata($tempdata, NULL, $expire); + +.. note:: If the expiration is omitted or set to 0, the default + time-to-live value of 300 seconds (or 5 minutes) will be used. -.. note:: If the expiration is omitted or set to 0, the default expiration of - 5 minutes will be used. +To read a tempdata variable, again you can just access it through the +``$_SESSION`` superglobal array:: -To read a tempdata variable:: + $_SESSION['item'] + +.. important:: The ``userdata()`` method will NOT return tempdata items. + +Or if you want to be sure that you're reading "flashdata" (and not any +other kind), you can also use the ``tempdata()`` method:: $this->session->tempdata('item'); @@ -250,453 +372,675 @@ And of course, if you want to retrieve all existing tempdata:: $this->session->tempdata(); -If you need to remove a tempdata value before it expires, -use ``unset_tempdata()``:: +.. note:: The ``tempdata()`` method returns NULL if the item cannot be + found. + +If you need to remove a tempdata value before it expires, you can directly +unset it from the ``$_SESSION`` array:: + + unset($_SESSION['item']); + +However, this won't remove the marker that makes this specific item to be +tempdata (it will be invalidated on the next HTTP request), so if you +intend to reuse that same key in the same request, you'd want to use +``unset_tempdata()``:: $this->session->unset_tempdata('item'); Destroying a Session ==================== -To clear the current session:: +To clear the current session (for example, during a logout), you may +simply use either PHP's `session_destroy() <http://php.net/session_destroy>`_ +function, or the ``sess_destroy()`` method. Both will work in exactly the +same way:: + + session_destroy(); + + // or $this->session->sess_destroy(); -.. note:: This function should be the last one called, and even flash - variables will no longer be available. If you only want some items - destroyed and not all, use ``unset_userdata()``. +.. note:: This must be the last session-related operation that you do + during the same request. All session data (including flashdata and + tempdata) will be destroyed permanently and functions will be + unusable during the same request after you destroy the session. + +Accessing session metadata +========================== + +In previous CodeIgniter versions, the session data array included 4 items +by default: 'session_id', 'ip_address', 'user_agent', 'last_activity'. + +This was due to the specifics of how sessions worked, but is now no longer +necessary with our new implementation. However, it may happen that your +application relied on these values, so here are alternative methods of +accessing them: + + - session_id: ``session_id()`` + - ip_address: ``$_SERVER['REMOTE_ADDR']`` + - user_agent: ``$this->input->user_agent()`` (unused by sessions) + - last_activity: Depends on the storage, no straightforward way. Sorry! Session Preferences =================== +CodeIgniter will usually make everything work out of the box. However, +Sessions are a very sensitive component of any application, so some +careful configuration must be done. Please take your time to consider +all of the options and their effects. + You'll find the following Session related preferences in your -*application/config/config.php* file: - -=========================== =============== =========================== ========================================================================== -Preference Default Options Description -=========================== =============== =========================== ========================================================================== -**sess_driver** cookie cookie/native/*custom* The initial session driver to load. -**sess_valid_drivers** cookie, native None Additional valid drivers which may be loaded. -**sess_cookie_name** ci_session None The name you want the session cookie saved as (data for Cookie driver or - session ID for Native driver). -**sess_expiration** 7200 None The number of seconds you would like the session to last. The default - value is 2 hours (7200 seconds). If you would like a non-expiring - session set the value to zero: 0 -**sess_expire_on_close** FALSE TRUE/FALSE (boolean) Whether to cause the session to expire automatically when the browser - window is closed. -**sess_encrypt_cookie** FALSE TRUE/FALSE (boolean) Whether to encrypt the session data (Cookie driver only). -**sess_use_database** FALSE TRUE/FALSE (boolean) Whether to save the session data to a database. You must create the - 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. 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. -**sess_match_useragent** TRUE TRUE/FALSE (boolean) Whether to match the User Agent when reading the session data. -=========================== =============== =========================== ========================================================================== +**application/config/config.php** file: + +======================== =============== ======================================== ============================================================================================ +Preference Default Options Description +======================== =============== ======================================== ============================================================================================ +**sess_driver** files files/database/redis/memcached/*custom* The session storage driver to use. +**sess_cookie_name** ci_session [A-Za-z\_-] characters only The name used for the session cookie. +**sess_expiration** 7200 (2 hours) Time in seconds (integer) The number of seconds you would like the session to last. + If you would like a non-expiring session (until browser is closed) set the value to zero: 0 +**sess_save_path** NULL None Specifies the storage location, depends on the driver being used. +**sess_time_to_update** 300 Time in seconds (integer) This option controls how often the session class will regenerate itself and create a new + session ID. Setting it to 0 will disable session ID regeneration. +**sess_match_ip** FALSE TRUE/FALSE (boolean) Whether to validate the user's IP address when reading the session cookie. + Note that some ISPs dynamically changes the IP, so if you want a non-expiring session you + will likely set this to FALSE. +======================== =============== ======================================== ============================================================================================ + +.. note:: As a last resort, the Session library will try to fetch PHP's + session related INI settings, as well as legacy CI settings such as + 'sess_expire_on_close' when any of the above is not configured. + However, you should never rely on this behavior as it can cause + unexpected results or be changed in the future. Please configure + everything properly. In addition to the values above, the cookie and native drivers apply the following configuration values shared by the :doc:`Input <input>` and :doc:`Security <security>` classes: -=========================== =============== ========================================================================== -Preference Default Description -=========================== =============== ========================================================================== -**cookie_prefix** '' Set a cookie name prefix in order to avoid name collisions -**cookie_domain** '' The domain for which the session is applicable -**cookie_path** / The path to which the session is applicable -=========================== =============== ========================================================================== +================== =============== =========================================================================== +Preference Default Description +================== =============== =========================================================================== +**cookie_domain** '' The domain for which the session is applicable +**cookie_path** / The path to which the session is applicable +**cookie_secure** FALSE Whether to create the session cookie only on encrypted (HTTPS) connections +================== =============== =========================================================================== + +.. note:: The 'cookie_httponly' setting doesn't have an effect on sessions. + Instead the HttpOnly parameter is always enabled, for security + reasons. Additionaly, the 'cookie_prefix' setting is completely + ignored. Session Drivers =============== -By default, the `Cookie Driver`_ is loaded when a session is initialized. -However, any valid driver may be selected with the $config['sess_driver'] -line in your config.php file. - -The session driver library comes with the cookie and native drivers -installed, and `Custom Drivers`_ may also be installed by the user. - -Typically, only one driver will be used at a time, but CodeIgniter does -support loading multiple drivers. If a specific valid driver is called, it -will be automatically loaded. Or, an additional driver may be explicitly -loaded by ``calling load_driver()``:: - - $this->session->load_driver('native'); - -The Session library keeps track of the most recently selected driver to call -for driver methods. Normally, session class methods are called directly on -the parent class, as illustrated above. However, any methods called through -a specific driver will select that driver before invoking the parent method. - -So, alternation between multiple drivers can be achieved by specifying which -driver to use for each call:: - - $this->session->native->set_userdata('foo', 'bar'); - - $this->session->cookie->userdata('foo'); - - $this->session->native->unset_userdata('foo'); - -Notice in the previous example that the *native* userdata value 'foo' -would be set to 'bar', which would NOT be returned by the call for -the *cookie* userdata 'foo', nor would the *cookie* value be unset by -the call to unset the *native* 'foo' value. The drivers maintain independent -sets of values, regardless of key names. - -A specific driver may also be explicitly selected for use by pursuant -methods with the ``select_driver()`` call:: - - $this->session->select_driver('native'); - - $this->session->userdata('item'); // Uses the native driver - -Cookie Driver -------------- - -The Cookie driver stores session information for each user as serialized -(and optionally encrypted) data in a cookie. It can also store the session -data in a database table for added security, as this permits the session ID -in the user's cookie to be matched against the stored session ID. By default -only the cookie is saved. If you choose to use the database option you'll -need to create the session table as indicated below. - -If you have the encryption option enabled, the serialized array will be -encrypted before being stored in the cookie, making the data highly -secure and impervious to being read or altered by someone. More info -regarding encryption can be :doc:`found here <encryption>`, although -the Session class will take care of initializing and encrypting the data -automatically. - -.. note:: Even if you are not using encrypted sessions, you must set - an :doc:`encryption key <./encryption>` in your config file which is used - to aid in preventing session data manipulation. - -.. note:: Cookies can only hold 4KB of data, so be careful not to exceed - the capacity. The encryption process in particular produces a longer - data string than the original so keep careful track of how much data you - are storing. - -Saving Session Data to a Database -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -While the session data array stored in the user's cookie contains a -Session ID, unless you store session data in a database there is no way -to validate it. For some applications that require little or no -security, session ID validation may not be needed, but if your -application requires security, validation is mandatory. Otherwise, an -old session could be restored by a user modifying their cookies. - -When session data is available in a database, every time a valid session -is found in the user's cookie, a database query is performed to match -it. If the session ID does not match, the session is destroyed. Session -IDs can never be updated, they can only be generated when a new session -is created. - -In order to store sessions, you must first create a database table for -this purpose. Here is the basic prototype (for MySQL) required by the -session class:: - - CREATE TABLE IF NOT EXISTS `ci_sessions` ( - session_id varchar(40) DEFAULT '0' NOT NULL, - ip_address varchar(45) DEFAULT '0' NOT NULL, - user_agent varchar(120) NOT NULL, - last_activity int(10) unsigned DEFAULT 0 NOT NULL, - user_data text NOT NULL, - PRIMARY KEY (session_id, ip_address, user_agent), - KEY `last_activity_idx` (`last_activity`) +As already mentioned, the Session library comes with 4 drivers, or storage +engines, that you can use: + + - files + - database + - redis + - memcached + +By default, the `Files Driver`_ will be used when a session is initialized, +because it is the most safe choice and is expected to work everywhere +(virtually every environment has a file system). + +However, any other driver may be selected via the ``$config['sess_driver']`` +line in your **application/config/config.php** file, if you chose to do so. +Have it in mind though, every driver has different caveats, so be sure to +get yourself familiar with them (below) before you make that choice. + +In addition, you may also create and use `Custom Drivers`_, if the ones +provided by default don't satisfy your use case. + +.. note:: In previous CodeIgniter versions, a different, "cookie driver" + was the only option and we have received negative feedback on not + providing that option. While we do listen to feedback from the + community, we want to warn you that it was dropped because it is + **unsafe** and we advise you NOT to try to replicate it via a + custom driver. + +Files Driver +------------ + +The 'files' driver uses your file system for storing session data. + +It can safely be said that it works exactly like PHP's own default session +implementation, but in case this is an important detail for you, have it +mind that it is in fact not the same code and it has some limitations +(and advantages). + +To be more specific, it doesn't support PHP's `directory level and mode +formats used in session.save_path +<http://php.net/manual/en/session.configuration.php#ini.session.save-path>`_, +and it has most of the options hard-coded for safety. Instead, only +absolute paths are supported for ``$config['sess_save_path']``. + +Another important thing that you should know, is to make sure that you +don't use a publicly-readable or shared directory for storing your session +files. Make sure that *only you* have access to see the contents of your +chosen *sess_save_path* directory. Otherwise, anybody who can do that, can +also steal any of the current sessions (also known as "session fixation" +attack). + +On UNIX-like operating systems, this is usually achieved by setting the +0700 mode permissions on that directory via the `chmod` command, which +allows only the directory's owner to perform read and write operations on +it. But be careful because the system user *running* the script is usually +not your own, but something like 'www-data' instead, so only setting those +permissions will probable break your application. + +Instead, you should do something like this, depending on your environment +:: + + mkdir /<path to your application directory>/sessions/ + chmod 0700 /<path to your application directory>/sessions/ + chown www-data /<path to your application directory>/sessions/ + +Bonus Tip +^^^^^^^^^ + +Some of you will probably opt to choose another session driver because +file storage is usually slower. This is only half true. + +A very basic test will probably trick you into believing that an SQL +database is faster, but in 99% of the cases, this is only true while you +only have a few current sessions. As the sessions count and server loads +increase - which is the time when it matters - the file system will +consistently outperform almost all relational database setups. + +In addition, if performance is your only concern, you may want to look +into using `tmpfs <http://eddmann.com/posts/storing-php-sessions-file-caches-in-memory-using-tmpfs/>`_, +(warning: external resource), which can make your sessions blazing fast. + +Database Driver +--------------- + +The 'database' driver uses a relational database such as MySQL or +PostgreSQL to store sessions. This is a popular choice among many users, +because it allows the developer easy access to the session data within +an application - it is just another table in your database. + +However, there are some conditions that must be met: + + - Only your **default** database connection (or the one that you access + as ``$this->db`` from your controllers) can be used. + - You can NOT use a persistent connection. + - You must have the :doc:`Query Builder </database/query_builder>` + enabled. + +In order to use the 'database' session driver, you must also create this +table that we already mentioned and then set it as your +``$config['sess_save_path']`` value. +For example, if you would like to use 'ci_sessions' as your table name, +you would do this:: + + $config['sess_driver'] = 'database'; + $config['sess_save_path'] = 'ci_sessions'; + +.. note:: If you've upgraded from a previous version of CodeIgniter and + you don't have 'sess_save_path' configured, then the Session + library will look for the old 'sess_table_name' setting and use + it instead. Please don't rely on this behavior as it will get + removed in the future. + +And then of course, create the database table ... + +For MySQL:: + + CREATE TABLE IF NOT EXISTS `ci_sessions` ( + `id` varchar(40) NOT NULL, + `ip_address` varchar(45) NOT NULL, + `timestamp` int(10) unsigned DEFAULT 0 NOT NULL, + `data` blob DEFAULT '' NOT NULL, + PRIMARY KEY (id), + KEY `ci_sessions_timestamp` (`timestamp`) ); -Or if you're using PostgreSQL:: +For PostgreSQL:: - CREATE TABLE ci_sessions ( - session_id varchar(40) DEFAULT '0' NOT NULL, - ip_address varchar(45) DEFAULT '0' NOT NULL, - user_agent varchar(120) NOT NULL, - last_activity bigint DEFAULT 0 NOT NULL, - user_data text NOT NULL, - PRIMARY KEY (session_id) + CREATE TABLE "ci_sessions" ( + "id" varchar(40) NOT NULL, + "ip_address" varchar(45) NOT NULL, + "timestamp" bigint DEFAULT 0 NOT NULL, + "data" text DEFAULT '' NOT NULL, + PRIMARY KEY ("id") ); - CREATE INDEX last_activity_idx ON ci_sessions(last_activity); + CREATE INDEX "ci_sessions_timestamp" ON "ci_sessions" ("timestamp"); + +However, if you want to turn on the *sess_match_ip* setting, you should +also do the following, after creating the table:: + + // Works both on MySQL and PostgreSQL + ALTER TABLE ci_sessions ADD CONSTRAINT ci_sessions_id_ip UNIQUE (id, ip_address); + +.. important:: Only MySQL and PostgreSQL databases are officially + supported, due to lack of advisory locking mechanisms on other + platforms. Using sessions without locks can cause all sorts of + problems, especially with heavy usage of AJAX, and we will not + support such cases. Use ``session_write_close()`` after you've + done processing session data if you're having performance + issues. + +Redis Driver +------------ + +Redis is a storage engine typically used for caching and popular because +of its high performance, which is also probably your reason to use the +'redis' session driver. + +The downside is that it is not as ubiquitous as relational databases and +requires the `phpredis <https://github.com/nicolasff/phpredis>`_ PHP +extension to be installed on your system, and that one doesn't come +bundled with PHP. +Chances are, you're only be using the 'redis' driver only if you're already +both familiar with Redis and using it for other purposes. + +Just as with the 'files' and 'database' drivers, you must also configure +the storage location for your sessions via the +``$config['sess_save_path']`` setting. +The format here is a bit different and complicated at the same time. It is +best explained by the *phpredis* extension's README file, so we'll simply +link you to it: + + https://github.com/phpredis/phpredis#php-session-handler + +.. warning:: CodeIgniter's Session library does NOT use the actual 'redis' + ``session.save_handler``. Take note **only** of the path format in + the link above. + +For the most common case however, a simple ``host:port`` pair should be +sufficient:: + + $config['sess_driver'] = 'redis'; + $config['sess_save_path'] = 'tcp://localhost:6379'; -.. note:: By default the table is called ci_sessions, but you can name - it anything you want as long as you update the - *application/config/config.php* file so that it contains the name - you have chosen. Once you have created your database table you - can enable the database option in your config.php file as follows:: +Memcached Driver +---------------- - $config['sess_use_database'] = TRUE; +The 'memcached' driver is very similar to the 'redis' one in all of its +properties, except perhaps for availability, because PHP's `Memcached +<http://php.net/memcached>`_ extension is distributed via PECL and some +Linux distrubutions make it available as an easy to install package. - Once enabled, the Session class will store session data in the DB. +Other than that, and without any intentional bias towards Redis, there's +not much different to be said about Memcached - it is also a popular +product that is usually used for caching and famed for its speed. - Make sure you've specified the table name in your config file as well:: +However, it is worth noting that the only guarantee given by Memcached +is that setting value X to expire after Y seconds will result in it being +deleted after Y seconds have passed (but not necessarily that it won't +expire earlier than that time). This happens very rarely, but should be +considered as it may result in loss of sessions. - $config['sess_table_name'] = 'ci_sessions'; +The ``$config['sess_save_path']`` format is fairly straightforward here, +being just a ``host:port`` pair:: -.. note:: The Cookie driver has built-in garbage collection which clears - out expired sessions so you do not need to write your own routine to do - it. + $config['sess_driver'] = 'memcached'; + $config['sess_save_path'] = 'localhost:11211'; -Native Driver -------------- +Bonus Tip +^^^^^^^^^ -The Native driver relies on native PHP sessions to store data in the -$_SESSION superglobal array. All stored values continue to be available -through $_SESSION, but flash- and temp- data items carry special prefixes. +Multi-server configuration with an optional *weight* parameter as the +third colon-separated (``:weight``) value is also supported, but we have +to note that we haven't tested if that is reliable. + +If you want to experiment with this feature (on your own risk), simply +separate the multiple server paths with commas:: + + // localhost will be given higher priority (5) here, + // compared to 192.0.2.1 with a weight of 1. + $config['sess_save_path'] = 'localhost:11211:5,192.0.2.1:11211:1'; Custom Drivers -------------- -You may also :doc:`create your own <../general/creating_drivers>` custom -session drivers. A session driver basically manages an array of name/value -pairs with some sort of storage mechanism. +You may also create your own, custom session drivers. However, have it in +mind that this is typically not an easy task, as it takes a lot of +knowledge to do it properly. + +You need to know not only how sessions work in general, but also how they +work specifically in PHP, how the underlying storage mechanism works, how +to handle concurrency, avoid deadlocks (but NOT through lack of locks) and +last but not least - how to handle the potential security issues, which +is far from trivial. + +Long story short - if you don't know how to do that already in raw PHP, +you shouldn't be trying to do it within CodeIgniter either. You've been +warned. + +If you only want to add some extra functionality to your sessions, just +extend the base Session class, which is a lot more easier. Read the +:doc:`Creating Libraries <../general/creating_libraries>` article to +learn how to do that. + +Now, to the point - there are three general rules that you must follow +when creating a session driver for CodeIgniter: + + - Put your driver's file under **application/libraries/Session/drivers/** + and follow the naming conventions used by the Session class. + + For example, if you were to create a 'dummy' driver, you would have + a ``Session_dummy_driver`` class name, that is declared in + *application/libraries/Session/drivers/Session_dummy_driver.php*. + + - Extend the ``CI_Session_driver`` class. + + This is just a basic class with a few internal helper methods. It is + also extendable like any other library, if you really need to do that, + but we are not going to explain how ... if you're familiar with how + class extensions/overrides work in CI, then you already know how to do + it. If not, well, you shouldn't be doing it in the first place. -To make a new driver, extend CI_Session_driver. Overload the ``initialize()`` -method and read or create session data. Then implement a save handler to -write changed data to storage (sess_save), a destroy handler to remove -deleted data (sess_destroy), a regenerate handler to make a new session ID -(sess_regenerate), and an access handler to expose the data (get_userdata). -Your initial class might look like:: - class CI_Session_custom extends CI_Session_driver { + - Implement the `SessionHandlerInterface + <http://php.net/sessionhandlerinterface>`_ interface. + + .. note:: You may notice that ``SessionHandlerInterface`` is provided + by PHP since version 5.4.0. CodeIgniter will automatically declare + the same interface if you're running an older PHP version. + + The link will explain why and how. + +So, based on our 'dummy' driver example above, you'd end up with something +like this:: + + // application/libraries/Session/drivers/Session_dummy_driver.php: + + class CI_Session_dummy_driver extends CI_Session_driver implements SessionHandlerInterface + { + + public function __construct(&$params) + { + // DO NOT forget this + parent::__construct($params); + + // Configuration & other initializations + } + + public function open($save_path, $name) + { + // Initialize storage mechanism (connection) + } - protected function initialize() + public function read($session_id) { - // Read existing session data or create a new one + // Read session data (if exists), acquire locks } - public function sess_save() + public function write($session_id, $session_data) { - // Save current data to storage + // Create / update session data (it might not exist!) } - public function sess_destroy() + public function close() { - // Destroy the current session and clean up storage + // Free locks, close connections / streams / etc. } - public function sess_regenerate() + public function destroy($session_id) { - // Create new session ID + // Call close() method & destroy data for current session (order may differ) } - public function &get_userdata() + public function gc($maxlifetime) { - // Return a reference to your userdata array + // Erase data for expired sessions } } -Notice that ``get_userdata()`` returns a reference so the parent library is -accessing the same array the driver object is using. This saves memory -and avoids synchronization issues during usage. +If you've done everything properly, you can now set your *sess_driver* +configuration value to 'dummy' and use your own driver. Congratulations! -Put your driver in the libraries/Session/drivers folder anywhere in your -package paths. This includes the application directory, the system directory, -or any path you add with ``$CI->load->add_package_path()``. Your driver must be -named CI_Session_<name>, and your filename must be Session_<name>.php, -preferably also capitalized, such as:: +*************** +Class Reference +*************** - CI_Session_foo in libraries/Session/drivers/Session_foo.php +.. php:class:: CI_Session -Then specify the driver by setting 'sess_driver' in your config.php file or as a -parameter when loading the CI_Session object:: + .. php:method:: userdata([$key = NULL]) - $config['sess_driver'] = 'foo'; + :param mixed $key: Session item key or NULL + :returns: Value of the specified item key, or an array of all userdata + :rtype: mixed -OR:: + Gets the value for a specific ``$_SESSION`` item, or an + array of all "userdata" items if not key was specified. + + .. note:: This is a legacy method kept only for backwards + compatibility with older applications. You should + directly access ``$_SESSION`` instead. - $CI->load->driver('session', array('sess_driver' => 'foo')); + .. php:method:: all_userdata() -The driver specified by 'sess_driver' is automatically included as a valid -driver. However, if you want to make a custom driver available as an option -without making it the initially loaded driver, set 'sess_valid_drivers' in -your config.php file to an array including your driver name:: + :returns: An array of all userdata + :rtype: array - $config['sess_valid_drivers'] = array('sess_driver'); + Returns an array containing all "userdata" items. -*************** -Class Reference -*************** + .. note:: This method is DEPRECATED. Use ``userdata()`` + with no parameters instead. -.. class:: CI_Session + .. php:method:: &get_usedata() - .. method:: load_driver($driver) + :returns: A reference to ``$_SESSION`` + :rtype: array - :param string $driver: Driver name - :returns: Instance of currently loaded session driver - :rtype: mixed + Returns a reference to the ``$_SESSION`` array. - Loads a session storage driver + .. note:: This is a legacy method kept only for backwards + compatibility with older applications. - .. method:: select_driver($driver) + .. php:method:: has_userdata($key) - :param string $driver: Driver name - :rtype: void + :param string $key: Session item key + :returns: TRUE if the specified key exists, FALSE if not + :rtype: bool + + Checks if an item exists in ``$_SESSION``. - Selects default session storage driver. + .. note:: This is a legacy method kept only for backwards + compatibility with older applications. It is just + an alias for ``isset($_SESSION[$key])`` - please + use that instead. - .. method:: sess_destroy() + .. php:method:: set_userdata($data[, $value = NULL]) + :param mixed $data: An array of key/value pairs to set as session data, or the key for a single item + :param mixed $value: The value to set for a specific session item, if $data is a key :rtype: void - Destroys current session + Assigns data to the ``$_SESSION`` superglobal. - .. note:: This method should be the last one called, and even flash - variables will no longer be available after it is used. - If you only want some items destroyed and not all, use - ``unset_userdata()``. + .. note:: This is a legacy method kept only for backwards + compatibility with older applications. - .. method:: sess_regenerate([$destroy = FALSE]) + .. php:method:: unset_userdata($key) - :param bool $destroy: Whether to destroy session data + :param mixed $key: Key for the session data item to unset, or an array of multiple keys :rtype: void - Regenerate the current session data. - - .. method:: userdata([$item = NULL]) + Unsets the specified key(s) from the ``$_SESSION`` + superglobal. - :param string $item: Session item name - :returns: Item value if found, NULL if not or an array of all userdata if $item parameter is not used - :rtype: mixed + .. note:: This is a legacy method kept only for backwards + compatibility with older applications. It is just + an alias for ``unset($_SESSION[$key])`` - please + use that instead. - If no parameter is passed, it will return an associative array of all existing userdata. + .. php:method:: mark_as_flash($key) - Otherwise returns a string containing the value of the passed item or NULL if the item is not found. - Example:: + :param mixed $key: Key to mark as flashdata, or an array of multiple keys + :returns: TRUE on success, FALSE on failure + :rtype: bool - $this->session->userdata('user'); - //returns example@example.com considering the set_userdata example. + Marks a ``$_SESSION`` item key (or multiple ones) as + "flashdata". - .. method:: all_userdata() + .. php:method:: get_flash_keys() - :returns: An array of all userdata + :returns: Array containing the keys of all "flashdata" items. :rtype: array - Returns an array with all of the session userdata items. + Gets a list of all ``$_SESSION`` that have been marked as + "flashdata". - .. note:: This method is DEPRECATED. Use ``userdata()`` with no parameters instead. + .. php:method:: umark_flash($key) - .. method:: &get_userdata() + :param mixed $key: Key to be un-marked as flashdata, or an array of multiple keys + :rtype: void - :returns: A reference to the userdata array - :rtype: &array + Unmarks a ``$_SESSION`` item key (or multiple ones) as + "flashdata". - Returns a reference to the userdata array. + .. php:method:: flashdata([$key = NULL]) - .. method:: set_userdata($newdata[, $newval = '']) + :param mixed $key: Flashdata item key or NULL + :returns: Value of the specified item key, or an array of all flashdata + :rtype: mixed - :param mixed $newdata: Item name or array of items - :param mixed $newval: Item value or empty string (not required if $newdata is array) - :rtype: void + Gets the value for a specific ``$_SESSION`` item that has + been marked as "flashdata", or an array of all "flashdata" + items if no key was specified. + + .. note:: This is a legacy method kept only for backwards + compatibility with older applications. You should + directly access ``$_SESSION`` instead. - Sets items into session example usages:: + .. php:method:: keep_flashdata($key) - $this->session->set_userdata('user', 'example@example.com'); - // adds item user with value example@example.com to the session + :param mixed $key: Flashdata key to keep, or an array of multiple keys + :returns: TRUE on success, FALSE on failure + :rtype: bool - $this->session->set_userdata(array('user'=>'example@example.com')); - // does the same as the above example - adds item user with value example@example.com to the session + Retains the specified session data key(s) as "flashdata" + through the next request. - .. method:: unset_userdata($item) + .. note:: This is a legacy method kept only for backwards + compatibility with older applications. It is just + an alias for the ``mark_as_flash()`` method. - :param mixed $item: Item name or an array containing multiple items - :rtype: void + .. php:method:: set_flashdata($data[, $value = NULL]) - Unsets previously set items from the session. Example:: + :param mixed $data: An array of key/value pairs to set as flashdata, or the key for a single item + :param mixed $value: The value to set for a specific session item, if $data is a key + :rtype: void - $this->session->unset_userdata('user'); - //unsets 'user' from session data. + Assigns data to the ``$_SESSION`` superglobal and marks it + as "flashdata". - $this->session->unset_userdata(array('user', 'useremail')); - //unsets both 'user' and 'useremail' from the session data. + .. note:: This is a legacy method kept only for backwards + compatibility with older applications. - .. method:: has_userdata($item) + .. php:method:: mark_as_temp($key[, $ttl = 300]) - :param string $item: Item name - :returns: TRUE if item exists, FALSE if not + :param mixed $key: Key to mark as tempdata, or an array of multiple keys + :param int $ttl: Time-to-live value for the tempdata, in seconds + :returns: TRUE on success, FALSE on failure :rtype: bool - Checks if an item exists in the session. - - .. method:: flashdata([$item = NULL]) + Marks a ``$_SESSION`` item key (or multiple ones) as + "tempdata". - :param string $item: Flashdata item name - :returns: Item value if found, NULL if not or an array of all flashdata if $item parameter is not used - :rtype: mixed + .. php:method:: get_temp_keys() - If no parameter is passed, it will return an associative array of all existing flashdata. + :returns: Array containing the keys of all "tempdata" items. + :rtype: array - Otherwise returns a string containing the value of the passed item or NULL if the item is not found. - Example:: + Gets a list of all ``$_SESSION`` that have been marked as + "tempdata". - $this->session->flashdata('message'); - //returns 'Test message.' considering the set_flashdata example. + .. php:method:: umark_temp($key) - .. method:: set_flashdata($newdata[, $newval = '']) + :param mixed $key: Key to be un-marked as tempdata, or an array of multiple keys + :rtype: void - :param mixed $newdata: Item name or an array of items - :param mixed $newval: Item value or empty string (not required if $newdata is array) - :rtype: void + Unmarks a ``$_SESSION`` item key (or multiple ones) as + "tempdata". - Sets items into session flashdata example usages:: + .. php:method:: tempdata([$key = NULL]) - $this->session->set_flashdata('message', 'Test message.'); - // adds item 'message' with value 'Test message.' to the session flashdata + :param mixed $key: Tempdata item key or NULL + :returns: Value of the specified item key, or an array of all tempdata + :rtype: mixed - $this->session->set_flashdata(array('message'=>'Test message.')); - // does the same as the above example - adds item 'message' with value 'Test message.' - to the session flashdata + Gets the value for a specific ``$_SESSION`` item that has + been marked as "tempdata", or an array of all "tempdata" + items if no key was specified. + + .. note:: This is a legacy method kept only for backwards + compatibility with older applications. You should + directly access ``$_SESSION`` instead. - .. method:: keep_flashdata($item) + .. php:method:: set_tempdata($data[, $value = NULL]) - :param mixed $item: Item name or an array containing multiple flashdata items + :param mixed $data: An array of key/value pairs to set as tempdata, or the key for a single item + :param mixed $value: The value to set for a specific session item, if $data is a key + :param int $ttl: Time-to-live value for the tempdata item(s), in seconds :rtype: void - Keeps items into flashdata for one more request. + Assigns data to the ``$_SESSION`` superglobal and marks it + as "tempdata". - .. method:: tempdata([$item = NULL]) + .. note:: This is a legacy method kept only for backwards + compatibility with older applications. - :param string $item: Tempdata item name - :returns: Item value if found, NULL if not or an array of all tempdata if $item parameter is not used - :rtype: mixed + .. php:method:: sess_regenerate([$destroy = FALSE]) - If no parameter is passed, it will return an associative array of all existing tempdata. + :param bool $destroy: Whether to destroy session data + :rtype: void - Otherwise returns a string containing the value of the passed item or NULL if the item is not found. - Example:: + Regenerate session ID, optionally destroying the current + session's data. - $this->session->tempdata('message'); - //returns 'Test message.' considering the set_tempdata example. + .. note:: This method is just an alias for PHP's native + `session_regenerate_id() + <http://php.net/session_regenerate_id>`_ function. - .. method:: set_tempdata($newdata[, $newval = ''[, $expire = 0]]) + .. php:method:: sess_destroy() - :param mixed $newdata: Item name or array containing multiple items - :param string $newval: Item value or empty string (not required if $newdata is array) - :param int $expire: Lifetime in seconds (0 for default) :rtype: void - Sets items into session tempdata example:: + Destroys the current session. - $this->session->set_tempdata('message', 'Test message.', '60'); - // adds item 'message' with value 'Test message.' to the session tempdata for 60 seconds + .. note:: This must be the *last* session-related function + that you call. All session data will be lost after + you do that. - $this->session->set_tempdata(array('message'=>'Test message.')); - // does the same as the above example - adds item 'message' with value 'Test message.' - to the session tempdata for the default value of + .. note:: This method is just an alias for PHP's native + `session_destroy() + <http://php.net/session_destroy>`_ function. - .. method:: unset_tempdata($item) + .. php:method:: __get($key) - :param mixed $item: Item name or an array containing multiple items - :rtype: void + :param string $key: Session item key + :returns: The requested session data item, or NULL if it doesn't exist + :rtype: mixed + + A magic method that allows you to use + ``$this->session->item`` instead of ``$_SESSION['item']``, + if that's what you prefer. + + It will also return the session ID by calling + ``session_id()`` if you try to access + ``$this->session->session_id``. + + .. php:method:: __set($key, $value) + + :param string $key: Session item key + :param mixed $value: Value to assign to the session item key + :returns: void - Unsets previously set items from tempdata. Example:: + A magic method that allows you to assign items to + ``$_SESSION`` by accessing them as ``$this->session`` + properties:: - $this->session->unset_tempdata('user'); - //unsets 'user' from tempdata. + $this->session->foo = 'bar'; - $this->session->unset_tempdata(array('user', 'useremail')); - //unsets both 'user' and 'useremail' from the tempdata.
\ No newline at end of file + // Results in: + // $_SESSION['foo'] = 'bar';
\ No newline at end of file diff --git a/user_guide_src/source/libraries/table.rst b/user_guide_src/source/libraries/table.rst index bb001e84c..91ae1ae8d 100644 --- a/user_guide_src/source/libraries/table.rst +++ b/user_guide_src/source/libraries/table.rst @@ -143,7 +143,7 @@ You can also set defaults for these in a config file. Class Reference *************** -.. class:: CI_Table +.. php:class:: CI_Table .. attribute:: $function = NULL @@ -162,7 +162,7 @@ Class Reference <td>Fred</td><td><strong>Blue</strong></td><td>Small</td> - .. method:: generate([$table_data = NULL]) + .. php:method:: generate([$table_data = NULL]) :param mixed $table_data: Data to populate the table rows with :returns: HTML table @@ -170,7 +170,7 @@ Class Reference Returns a string containing the generated table. Accepts an optional parameter which can be an array or a database result object. - .. method:: set_caption($caption) + .. php:method:: set_caption($caption) :param string $caption: Table caption :returns: CI_Table instance (method chaining) @@ -181,7 +181,7 @@ Class Reference $this->table->set_caption('Colors'); - .. method:: set_heading([$args = array()[, ...]]) + .. php:method:: set_heading([$args = array()[, ...]]) :param mixed $args: An array or multiple strings containing the table column titles :returns: CI_Table instance (method chaining) @@ -193,7 +193,7 @@ Class Reference $this->table->set_heading(array('Name', 'Color', 'Size')); - .. method:: add_row([$args = array()[, ...]]) + .. php:method:: add_row([$args = array()[, ...]]) :param mixed $args: An array or multiple strings containing the row values :returns: CI_Table instance (method chaining) @@ -214,7 +214,7 @@ Class Reference // generates // <td class='highlight' colspan='2'>Blue</td><td>Red</td><td>Green</td> - .. method:: make_columns([$array = array()[, $col_limit = 0]]) + .. php:method:: make_columns([$array = array()[, $col_limit = 0]]) :param array $array: An array containing multiple rows' data :param int $col_limit: Count of columns in the table @@ -244,7 +244,7 @@ Class Reference </table> - .. method:: set_template($template) + .. php:method:: set_template($template) :param array $template: An associative array containing template values :returns: TRUE on success, FALSE on failure @@ -259,7 +259,7 @@ Class Reference $this->table->set_template($template); - .. method:: set_empty($value) + .. php:method:: set_empty($value) :param mixed $value: Value to put in empty cells :returns: CI_Table instance (method chaining) @@ -270,7 +270,7 @@ Class Reference $this->table->set_empty(" "); - .. method:: clear() + .. php:method:: clear() :returns: CI_Table instance (method chaining) :rtype: CI_Table diff --git a/user_guide_src/source/libraries/trackback.rst b/user_guide_src/source/libraries/trackback.rst index 22859a13d..4e0cb5541 100644 --- a/user_guide_src/source/libraries/trackback.rst +++ b/user_guide_src/source/libraries/trackback.rst @@ -67,7 +67,7 @@ Description of array data: - **blog_name** - The name of your weblog. - **charset** - The character encoding your weblog is written in. If omitted, UTF-8 will be used. -.. note:: the Trackback class will automatically send only the first 500 characters of your +.. note:: The Trackback class will automatically send only the first 500 characters of your entry. It will also strip all HTML. The Trackback sending method returns TRUE/FALSE (boolean) on success @@ -213,7 +213,7 @@ message using:: Class Reference *************** -.. class:: CI_Trackback +.. php:class:: CI_Trackback .. attribute:: $data = array('url' => '', 'title' => '', 'excerpt' => '', 'blog_name' => '', 'charset' => '') @@ -223,7 +223,7 @@ Class Reference Whether to convert high ASCII and MS Word characters to HTML entities. - .. method:: send($tb_data) + .. php:method:: send($tb_data) :param array $tb_data: Trackback data :returns: TRUE on success, FALSE on failure @@ -231,7 +231,7 @@ Class Reference Send trackback. - .. method:: receive() + .. php:method:: receive() :returns: TRUE on success, FALSE on failure :rtype: bool @@ -239,7 +239,7 @@ Class Reference This method simply validates the incoming TB data, returning TRUE on success and FALSE on failure. If the data is valid it is set to the ``$this->data`` array so that it can be inserted into a database. - .. method:: send_error([$message = 'Incomplete information') + .. php:method:: send_error([$message = 'Incomplete information') :param string $message: Error message :rtype: void @@ -248,7 +248,7 @@ Class Reference .. note:: This method will terminate script execution. - .. method:: send_success() + .. php:method:: send_success() :rtype: void @@ -256,7 +256,7 @@ Class Reference .. note:: This method will terminate script execution. - .. method:: data($item) + .. php:method:: data($item) :param string $item: Data key :returns: Data value or empty string if not found @@ -264,7 +264,7 @@ Class Reference Returns a single item from the reponse data array. - .. method:: process($url, $data) + .. php:method:: process($url, $data) :param string $url: Target url :param string $data: Raw POST data @@ -273,7 +273,7 @@ Class Reference Opens a socket connection and passes the data to the server, returning TRUE on success and FALSE on failure. - .. method:: extract_urls($urls) + .. php:method:: extract_urls($urls) :param string $urls: Comma-separated URL list :returns: Array of URLs @@ -281,14 +281,14 @@ Class Reference This method lets multiple trackbacks to be sent. It takes a string of URLs (separated by comma or space) and puts each URL into an array. - .. method:: validate_url(&$url) + .. php:method:: validate_url(&$url) :param string $url: Trackback URL :rtype: void Simply adds the *http://* prefix it it's not already present in the URL. - .. method:: get_id($url) + .. php:method:: get_id($url) :param string $url: Trackback URL :returns: URL ID or FALSE on failure @@ -296,7 +296,7 @@ Class Reference Find and return a trackback URL's ID or FALSE on failure. - .. method:: convert_xml($str) + .. php:method:: convert_xml($str) :param string $str: Input string :returns: Converted string @@ -304,7 +304,7 @@ Class Reference Converts reserved XML characters to entities. - .. method:: limit_characters($str[, $n = 500[, $end_char = '…']]) + .. php:method:: limit_characters($str[, $n = 500[, $end_char = '…']]) :param string $str: Input string :param int $n: Max characters number @@ -314,7 +314,7 @@ Class Reference Limits the string based on the character count. Will preserve complete words. - .. method:: convert_ascii($str) + .. php:method:: convert_ascii($str) :param string $str: Input string :returns: Converted string @@ -322,14 +322,14 @@ Class Reference Converts high ASCII text and MS Word special characterss to HTML entities. - .. method:: set_error($msg) + .. php:method:: set_error($msg) :param string $msg: Error message :rtype: void Set an log an error message. - .. method:: display_errors([$open = '<p>'[, $close = '</p>']]) + .. php:method:: display_errors([$open = '<p>'[, $close = '</p>']]) :param string $open: Open tag :param string $close: Close tag diff --git a/user_guide_src/source/libraries/typography.rst b/user_guide_src/source/libraries/typography.rst index 65fea9d8e..1d1e4f3c4 100644 --- a/user_guide_src/source/libraries/typography.rst +++ b/user_guide_src/source/libraries/typography.rst @@ -31,7 +31,7 @@ Once loaded, the Typography library object will be available using:: Class Reference *************** -.. class:: CI_Typography +.. php:class:: CI_Typography .. attribute:: $protect_braced_quotes = FALSE @@ -75,7 +75,7 @@ Class Reference .. note:: Typographic formatting can be processor intensive, particularly if you have a lot of content being formatted. If you choose to use this method you may want to consider :doc:`caching <../general/caching>` your pages. - .. method:: format_characters($str) + .. php:method:: format_characters($str) :param string $str: Input string :returns: Formatted string @@ -93,7 +93,7 @@ Class Reference $string = $this->typography->format_characters($string); - .. method:: nl2br_except_pre($str) + .. php:method:: nl2br_except_pre($str) :param string $str: Input string :returns: Formatted string diff --git a/user_guide_src/source/libraries/unit_testing.rst b/user_guide_src/source/libraries/unit_testing.rst index 7e91a7b95..026781cb7 100644 --- a/user_guide_src/source/libraries/unit_testing.rst +++ b/user_guide_src/source/libraries/unit_testing.rst @@ -177,9 +177,9 @@ template. Note the required pseudo-variables:: Class Reference *************** -.. class:: CI_Unit_test +.. php:class:: CI_Unit_test - .. method:: set_test_items($items) + .. php:method:: set_test_items($items) :param array $items: List of visible test items :returns: void @@ -195,7 +195,7 @@ Class Reference - line - notes - .. method:: run($test[, $expected = TRUE[, $test_name = 'undefined'[, $notes = '']]]) + .. php:method:: run($test[, $expected = TRUE[, $test_name = 'undefined'[, $notes = '']]]) :param mixed $test: Test data :param mixed $expected: Expected result @@ -206,7 +206,7 @@ Class Reference Runs unit tests. - .. method:: report([$result = array()]) + .. php:method:: report([$result = array()]) :param array $result: Array containing tests results :returns: Test report @@ -214,21 +214,21 @@ Class Reference Generates a report about already complete tests. - .. method:: use_strict([$state = TRUE]) + .. php:method:: use_strict([$state = TRUE]) :param bool $state: Strict state flag :rtype: void Enables/disables strict type comparison in tests. - .. method:: active([$state = TRUE]) + .. php:method:: active([$state = TRUE]) :param bool $state: Whether to enable testing :rtype: void Enables/disables unit testing. - .. method:: result([$results = array()]) + .. php:method:: result([$results = array()]) :param array $results: Tests results list :returns: Array of raw result data @@ -236,7 +236,7 @@ Class Reference Returns raw tests results data. - .. method:: set_template($template) + .. php:method:: set_template($template) :param string $template: Test result template :rtype: void diff --git a/user_guide_src/source/libraries/uri.rst b/user_guide_src/source/libraries/uri.rst index 7db758ce7..ae56184cc 100644 --- a/user_guide_src/source/libraries/uri.rst +++ b/user_guide_src/source/libraries/uri.rst @@ -20,9 +20,9 @@ information about the re-routed segments. Class Reference *************** -.. class:: CI_URI +.. php:class:: CI_URI - .. method:: segment($n[, $no_result = NULL]) + .. php:method:: segment($n[, $no_result = NULL]) :param int $n: Segment index number :param mixed $no_result: What to return if the searched segment is not found @@ -59,7 +59,7 @@ Class Reference $product_id = $this->uri->segment(3); } - .. method:: rsegment($n[, $no_result = NULL]) + .. php:method:: rsegment($n[, $no_result = NULL]) :param int $n: Segment index number :param mixed $no_result: What to return if the searched segment is not found @@ -70,7 +70,7 @@ Class Reference a specific segment from your re-routed URI in the event you are using CodeIgniter's :doc:`URI Routing <../general/routing>` feature. - .. method:: slash_segment($n[, $where = 'trailing']) + .. php:method:: slash_segment($n[, $where = 'trailing']) :param int $n: Segment index number :param string $where: Where to add the slash ('trailing' or 'leading') @@ -91,7 +91,7 @@ Class Reference #. /segment #. /segment/ - .. method:: slash_rsegment($n[, $where = 'trailing']) + .. php:method:: slash_rsegment($n[, $where = 'trailing']) :param int $n: Segment index number :param string $where: Where to add the slash ('trailing' or 'leading') @@ -103,7 +103,7 @@ Class Reference are using CodeIgniter's :doc:`URI Routing <../general/routing>` feature. - .. method:: uri_to_assoc([$n = 3[, $default = array()]]) + .. php:method:: uri_to_assoc([$n = 3[, $default = array()]]) :param int $n: Segment index number :param array $default: Default values @@ -145,7 +145,7 @@ Class Reference Lastly, if a corresponding value is not found for a given key (if there is an odd number of URI segments) the value will be set to NULL. - .. method:: ruri_to_assoc([$n = 3[, $default = array()]]) + .. php:method:: ruri_to_assoc([$n = 3[, $default = array()]]) :param int $n: Segment index number :param array $default: Default values @@ -156,7 +156,7 @@ Class Reference an associative array using the re-routed URI in the event you are using CodeIgniter's :doc:`URI Routing <../general/routing>` feature. - .. method:: assoc_to_uri($array) + .. php:method:: assoc_to_uri($array) :param array $array: Input array of key/value pairs :returns: URI string @@ -170,7 +170,7 @@ Class Reference // Produces: product/shoes/size/large/color/red - .. method:: uri_string() + .. php:method:: uri_string() :returns: URI string :rtype: string @@ -183,7 +183,7 @@ Class Reference news/local/345 - .. method:: ruri_string() + .. php:method:: ruri_string() :returns: Routed URI string :rtype: string @@ -192,14 +192,14 @@ Class Reference the re-routed URI in the event you are using CodeIgniter's :doc:`URI Routing <../general/routing>` feature. - .. method:: total_segments() + .. php:method:: total_segments() :returns: Count of URI segments :rtype: int Returns the total number of segments. - .. method:: total_rsegments() + .. php:method:: total_rsegments() :returns: Count of routed URI segments :rtype: int @@ -208,7 +208,7 @@ Class Reference the total number of segments in your re-routed URI in the event you are using CodeIgniter's :doc:`URI Routing <../general/routing>` feature. - .. method:: segment_array() + .. php:method:: segment_array() :returns: URI segments array :rtype: array @@ -223,7 +223,7 @@ Class Reference echo '<br />'; } - .. method:: rsegment_array() + .. php:method:: rsegment_array() :returns: Routed URI segments array :rtype: array diff --git a/user_guide_src/source/libraries/user_agent.rst b/user_guide_src/source/libraries/user_agent.rst index 517382a65..a1d969abf 100644 --- a/user_guide_src/source/libraries/user_agent.rst +++ b/user_guide_src/source/libraries/user_agent.rst @@ -72,9 +72,9 @@ is available. Class Reference *************** -.. class:: CI_User_agent +.. php:class:: CI_User_agent - .. method:: is_browser([$key = NULL]) + .. php:method:: is_browser([$key = NULL]) :param string $key: Optional browser name :returns: TRUE if the user agent is a (specified) browser, FALSE if not @@ -96,7 +96,7 @@ Class Reference You can find this list in **application/config/user_agents.php** if you want to add new browsers or change the stings. - .. method:: is_mobile([$key = NULL]) + .. php:method:: is_mobile([$key = NULL]) :param string $key: Optional mobile device name :returns: TRUE if the user agent is a (specified) mobile device, FALSE if not @@ -118,7 +118,7 @@ Class Reference $this->load->view('web/home'); } - .. method:: is_robot([$key = NULL]) + .. php:method:: is_robot([$key = NULL]) :param string $key: Optional robot name :returns: TRUE if the user agent is a (specified) robot, FALSE if not @@ -131,49 +131,49 @@ Class Reference that commonly visit your site are missing from the list you can add them to your **application/config/user_agents.php** file. - .. method:: is_referral() + .. php:method:: is_referral() :returns: TRUE if the user agent is a referral, FALSE if not :rtype: bool Returns TRUE/FALSE (boolean) if the user agent was referred from another site. - .. method:: browser() + .. php:method:: browser() :returns: Detected browser or an empty string :rtype: string Returns a string containing the name of the web browser viewing your site. - .. method:: version() + .. php:method:: version() :returns: Detected browser version or an empty string :rtype: string Returns a string containing the version number of the web browser viewing your site. - .. method:: mobile() + .. php:method:: mobile() :returns: Detected mobile device brand or an empty string :rtype: string Returns a string containing the name of the mobile device viewing your site. - .. method:: robot() + .. php:method:: robot() :returns: Detected robot name or an empty string :rtype: string Returns a string containing the name of the robot viewing your site. - .. method:: platform() + .. php:method:: platform() :returns: Detected operating system or an empty string :rtype: string Returns a string containing the platform viewing your site (Linux, Windows, OS X, etc.). - .. method:: referrer() + .. php:method:: referrer() :returns: Detected referrer or an empty string :rtype: string @@ -185,7 +185,7 @@ Class Reference echo $this->agent->referrer(); } - .. method:: agent_string() + .. php:method:: agent_string() :returns: Full user agent string or an empty string :rtype: string @@ -194,7 +194,7 @@ Class Reference Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.0.4) Gecko/20060613 Camino/1.0.2 - .. method:: accept_lang([$lang = 'en']) + .. php:method:: accept_lang([$lang = 'en']) :param string $lang: Language key :returns: TRUE if provided language is accepted, FALSE if not @@ -210,14 +210,14 @@ Class Reference .. note:: This method is not typically very reliable since some browsers do not provide language info, and even among those that do, it is not always accurate. - .. method:: languages() + .. php:method:: languages() :returns: An array list of accepted languages :rtype: array Returns an array of languages supported by the user agent. - .. method:: accept_charset([$charset = 'utf-8']) + .. php:method:: accept_charset([$charset = 'utf-8']) :param string $charset: Character set :returns: TRUE if the character set is accepted, FALSE if not @@ -233,14 +233,14 @@ Class Reference .. note:: This method is not typically very reliable since some browsers do not provide character-set info, and even among those that do, it is not always accurate. - .. method:: charsets() + .. php:method:: charsets() :returns: An array list of accepted character sets :rtype: array Returns an array of character sets accepted by the user agent. - .. method:: parse($string) + .. php:method:: parse($string) :param string $string: A custom user-agent string :rtype: void diff --git a/user_guide_src/source/libraries/xmlrpc.rst b/user_guide_src/source/libraries/xmlrpc.rst index 5f1c917a9..4d7ed66d5 100644 --- a/user_guide_src/source/libraries/xmlrpc.rst +++ b/user_guide_src/source/libraries/xmlrpc.rst @@ -456,16 +456,16 @@ seven types of values that you can send via XML-RPC: Class Reference *************** -.. class:: CI_Xmlrpc +.. php:class:: CI_Xmlrpc - .. method:: initialize([$config = array()]) + .. php:method:: initialize([$config = array()]) :param array $config: Configuration data :rtype: void Initializes the XML-RPC library. Accepts an associative array containing your settings. - .. method:: server($url[, $port = 80[, $proxy = FALSE[, $proxy_port = 8080]]]) + .. php:method:: server($url[, $port = 80[, $proxy = FALSE[, $proxy_port = 8080]]]) :param string $url: XML-RPC server URL :param int $port: Server port @@ -481,7 +481,7 @@ Class Reference $this->xmlrpc->server('http://user:pass@localhost/', 80); - .. method:: timeout($seconds = 5) + .. php:method:: timeout($seconds = 5) :param int $seconds: Timeout in seconds :rtype: void @@ -490,7 +490,7 @@ Class Reference $this->xmlrpc->timeout(6); - .. method:: method($function) + .. php:method:: method($function) :param string $function: Method name :rtype: void @@ -501,7 +501,7 @@ Class Reference Where method is the name of the method. - .. method:: request($incoming) + .. php:method:: request($incoming) :param array $incoming: Request data :rtype: void @@ -511,7 +511,7 @@ Class Reference $request = array(array('My Photoblog', 'string'), 'http://www.yoursite.com/photoblog/'); $this->xmlrpc->request($request); - .. method:: send_request() + .. php:method:: send_request() :returns: TRUE on success, FALSE on failure :rtype: bool @@ -525,7 +525,7 @@ Class Reference Enables or disables debugging, which will display a variety of information and error data helpful during development. - .. method:: display_error() + .. php:method:: display_error() :returns: Error message string :rtype: string @@ -535,7 +535,7 @@ Class Reference echo $this->xmlrpc->display_error(); - .. method:: display_response() + .. php:method:: display_response() :returns: Response :rtype: mixed @@ -545,7 +545,7 @@ Class Reference $this->xmlrpc->display_response(); - .. method:: send_error_message($number, $message) + .. php:method:: send_error_message($number, $message) :param int $number: Error number :param string $message: Error message diff --git a/user_guide_src/source/libraries/zip.rst b/user_guide_src/source/libraries/zip.rst index b509236de..816f49ca1 100644 --- a/user_guide_src/source/libraries/zip.rst +++ b/user_guide_src/source/libraries/zip.rst @@ -2,9 +2,8 @@ Zip Encoding Class ################## -CodeIgniter's Zip Encoding Class classes permit you to create Zip -archives. Archives can be downloaded to your desktop or saved to a -directory. +CodeIgniter's Zip Encoding Class permits you to create Zip archives. +Archives can be downloaded to your desktop or saved to a directory. .. contents:: :local: @@ -52,7 +51,7 @@ your server, and download it to your desktop. Class Reference *************** -.. class:: CI_Zip +.. php:class:: CI_Zip .. attribute:: $compression_level = 2 @@ -62,7 +61,7 @@ Class Reference $this->zip->compression_level = 0; - .. method:: add_data($filepath[, $data = NULL]) + .. php:method:: add_data($filepath[, $data = NULL]) :param mixed $filepath: A single file path or an array of file => data pairs :param array $data: File contents (ignored if $filepath is an array) @@ -101,7 +100,7 @@ Class Reference The above example will place my_bio.txt inside a folder called personal. - .. method:: add_dir($directory) + .. php:method:: add_dir($directory) :param mixed $directory: Directory name string or an array of multiple directories :rtype: void @@ -112,7 +111,7 @@ Class Reference $this->zip->add_dir('myfolder'); // Creates a directory called "myfolder" - .. method:: read_file($path[, $archive_filepath = FALSE]) + .. php:method:: read_file($path[, $archive_filepath = FALSE]) :param string $path: Path to file :param mixed $archive_filepath: New file name/path (string) or (boolean) whether to maintain the original filepath @@ -151,7 +150,7 @@ Class Reference // Download ZIP archive containing /new/path/some_photo.jpg $this->zip->download('my_archive.zip'); - .. method:: read_dir($path[, $preserve_filepath = TRUE[, $root_path = NULL]]) + .. php:method:: read_dir($path[, $preserve_filepath = TRUE[, $root_path = NULL]]) :param string $path: Path to directory :param bool $preserve_filepath: Whether to maintain the original path @@ -181,7 +180,7 @@ Class Reference This will create a ZIP with a directory named "directory" inside, then all sub-directories stored correctly inside that, but will not include the */path/to/your* part of the path. - .. method:: archive($filepath) + .. php:method:: archive($filepath) :param string $filepath: Path to target zip archive :returns: TRUE on success, FALSE on failure @@ -193,7 +192,7 @@ Class Reference $this->zip->archive('/path/to/folder/myarchive.zip'); // Creates a file named myarchive.zip - .. method:: download($filename = 'backup.zip') + .. php:method:: download($filename = 'backup.zip') :param string $filename: Archive file name :rtype: void @@ -207,7 +206,7 @@ Class Reference this method since it sends various server headers that cause the download to happen and the file to be treated as binary. - .. method:: get_zip() + .. php:method:: get_zip() :returns: Zip file content :rtype: string @@ -222,7 +221,7 @@ Class Reference $zip_file = $this->zip->get_zip(); - .. method:: clear_data() + .. php:method:: clear_data() :rtype: void |