diff options
author | Ahmad Anbar <aanbar@gmail.com> | 2015-02-04 18:20:01 +0100 |
---|---|---|
committer | Ahmad Anbar <aanbar@gmail.com> | 2015-02-04 18:20:01 +0100 |
commit | e5454f9b28f123a5549971f580255a065b2f8cc2 (patch) | |
tree | c4927e7b7afb0bf242976034630cc60f2f1db00f /user_guide_src | |
parent | 6db62ab0ad0e223806a1367e12b1884b48dc65d7 (diff) | |
parent | eccac6e6a73a4d1a5b40f383ce64359c2c94ae12 (diff) |
Merge remote-tracking branch 'upstream/develop' into develop
Diffstat (limited to 'user_guide_src')
76 files changed, 1878 insertions, 1324 deletions
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 42ef52c52..a0c0de83f 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -58,57 +58,58 @@ Release Date: Not Released - Added support for turning newline standardization on/off via ``$config['standardize_newlines']`` and set it to FALSE by default. - Added configuration setting ``$config['composer_autoload']`` to enable loading of a `Composer <https://getcomposer.org/>`_ auto-loader. - Removed the automatic conversion of 'programmatic characters' to HTML entities from the :doc:`URI Library <libraries/uri>`. + - Changed log messages that say a class or file was loaded to "info" level instead of "debug", so that they don't pollute log files when ``$config['log_threshold']`` is set to 2 (debug). - Helpers - :doc:`Date Helper <helpers/date_helper>` changes include: - - Added an optional third parameter to :func:`timespan()` that constrains the number of time units displayed. - - Added an optional parameter to :func:`timezone_menu()` that allows more attributes to be added to the generated select tag. - - Added function :func:`date_range()` that generates a list of dates between a specified period. + - Added an optional third parameter to :php:func:`timespan()` that constrains the number of time units displayed. + - Added an optional parameter to :php:func:`timezone_menu()` that allows more attributes to be added to the generated select tag. + - Added function :php:func:`date_range()` that generates a list of dates between a specified period. - Deprecated ``standard_date()``, which now just uses the native ``date()`` with `DateTime constants <http://www.php.net/manual/en/class.datetime.php#datetime.constants.types>`_. - - Changed :func:`now()` to work with all timezone strings supported by PHP. - - Changed :func:`days_in_month()` to use the native ``cal_days_in_month()`` PHP function, if available. + - Changed :php:func:`now()` to work with all timezone strings supported by PHP. + - Changed :php:func:`days_in_month()` to use the native ``cal_days_in_month()`` PHP function, if available. - :doc:`URL Helper <helpers/url_helper>` changes include: - - Deprecated *separator* options **dash** and **underscore** for function :func:`url_title()` (they are only aliases for '-' and '_' respectively). - - :func:`url_title()` will now trim extra dashes from beginning and end. - - :func:`anchor_popup()` will now fill the *href* attribute with the URL and its JS code will return FALSE instead. - - Added JS window name support to the :func:`anchor_popup()` function. - - Added support for menubar attribute to the :func:`anchor_popup()`. - - Added support (auto-detection) for HTTP/1.1 response codes 303, 307 in :func:`redirect()`. - - Changed :func:`redirect()` to choose the **refresh** method only on IIS servers, instead of all servers on Windows (when **auto** is used). - - Changed :func:`anchor()`, :func:`anchor_popup()`, and :func:`redirect()` to support protocol-relative URLs (e.g. *//ellislab.com/codeigniter*). + - Deprecated *separator* options **dash** and **underscore** for function :php:func:`url_title()` (they are only aliases for '-' and '_' respectively). + - :php:func:`url_title()` will now trim extra dashes from beginning and end. + - :php:func:`anchor_popup()` will now fill the *href* attribute with the URL and its JS code will return FALSE instead. + - Added JS window name support to the :php:func:`anchor_popup()` function. + - Added support for menubar attribute to the :php:func:`anchor_popup()`. + - Added support (auto-detection) for HTTP/1.1 response codes 303, 307 in :php:func:`redirect()`. + - Changed :php:func:`redirect()` to choose the **refresh** method only on IIS servers, instead of all servers on Windows (when **auto** is used). + - Changed :php:func:`anchor()`, :php:func:`anchor_popup()`, and :php:func:`redirect()` to support protocol-relative URLs (e.g. *//ellislab.com/codeigniter*). - :doc:`HTML Helper <helpers/html_helper>` changes include: - Added more doctypes. - Changed application and environment config files to be loaded in a cascade-like manner. - - Changed :func:`doctype()` to cache and only load once the doctypes array. + - Changed :php:func:`doctype()` to cache and only load once the doctypes array. - Deprecated functions ``nbs()`` and ``br()``, which are just aliases for the native ``str_repeat()`` with `` `` and ``<br />`` respectively. - :doc:`Inflector Helper <helpers/inflector_helper>` changes include: - - Changed :func:`humanize()` to allow passing an input separator as its second parameter. - - Changed :func:`humanize()` and :func:`underscore()` to utilize `mbstring <http://php.net/mbstring>`_, if available. - - Changed :func:`plural()` and :func:`singular()` to avoid double pluralization and support more words. + - Changed :php:func:`humanize()` to allow passing an input separator as its second parameter. + - Changed :php:func:`humanize()` and :php:func:`underscore()` to utilize `mbstring <http://php.net/mbstring>`_, if available. + - Changed :php:func:`plural()` and :php:func:`singular()` to avoid double pluralization and support more words. - :doc:`Download Helper <helpers/download_helper>` changes include: - - Added an optional third parameter to :func:`force_download()` that enables/disables sending the actual file MIME type in the Content-Type header (disabled by default). - - Added a work-around in :func:`force_download()` for a bug Android <= 2.1, where the filename extension needs to be in uppercase. - - Added support for reading from an existing file path by passing NULL as the second parameter to :func:`force_download()` (useful for large files and/or safely transmitting binary data). + - Added an optional third parameter to :php:func:`force_download()` that enables/disables sending the actual file MIME type in the Content-Type header (disabled by default). + - Added a work-around in :php:func:`force_download()` for a bug Android <= 2.1, where the filename extension needs to be in uppercase. + - Added support for reading from an existing file path by passing NULL as the second parameter to :php:func:`force_download()` (useful for large files and/or safely transmitting binary data). - :doc:`Form Helper <helpers/form_helper>` changes include: - - :func:`form_dropdown()` will now also take an array for unity with other form helpers. - - :func:`form_prep()`'s second argument now only accepts a boolean value, which determines whether the value is escaped for a <textarea> or a regular <input> element. + - :php:func:`form_dropdown()` will now also take an array for unity with other form helpers. + - :php:func:`form_prep()` is now DEPRECATED and only acts as an alias for :doc:`common function <general/common_functions>` :php:func:`html_escape()`. - :doc:`Security Helper <helpers/security_helper>` changes include: - - :func:`do_hash()` now uses PHP's native ``hash()`` function (supporting more algorithms) and is deprecated. - - :func:`strip_image_tags()` is now an alias for the same method in the :doc:`Security Library <libraries/security>`. + - :php:func:`do_hash()` now uses PHP's native ``hash()`` function (supporting more algorithms) and is deprecated. + - :php:func:`strip_image_tags()` is now an alias for the same method in the :doc:`Security Library <libraries/security>`. - :doc:`Smiley Helper <helpers/smiley_helper>` changes include: @@ -119,15 +120,15 @@ Release Date: Not Released - :doc:`File Helper <helpers/file_helper>` changes include: - - :func:`set_realpath()` can now also handle file paths as opposed to just directories. - - Added an optional paramater to :func:`delete_files()` to enable it to skip deleting files such as *.htaccess* and *index.html*. + - :php:func:`set_realpath()` can now also handle file paths as opposed to just directories. + - Added an optional paramater to :php:func:`delete_files()` to enable it to skip deleting files such as *.htaccess* and *index.html*. - Deprecated function ``read_file()`` - it's just an alias for PHP's native ``file_get_contents()``. - :doc:`String Helper <helpers/string_helper>` changes include: - Deprecated function ``repeater()`` - it's just an alias for PHP's native ``str_repeat()``. - Deprecated function ``trim_slashes()`` - it's just an alias for PHP's native ``trim()`` (with a slash as its second argument). - - Deprecated randomization type options **unique** and **encrypt** for funcion :func:`random_string()` (they are only aliases for **md5** and **sha1** respectively). + - Deprecated randomization type options **unique** and **encrypt** for funcion :php:func:`random_string()` (they are only aliases for **md5** and **sha1** respectively). - :doc:`CAPTCHA Helper <helpers/captcha_helper>` changes include: @@ -140,12 +141,12 @@ Release Date: Not Released - :doc:`Text Helper <helpers/text_helper>` changes include: - - Changed the default tag for use in :func:`highlight_phrase()` to ``<mark>`` (formerly ``<strong>``). - - Changed :func:`character_limiter()`, :func:`word_wrap()` and :func:`ellipsize()` to utilize `mbstring <http://php.net/mbstring>`_ or `iconv <http://php.net/iconv>`_, if available. + - Changed the default tag for use in :php:func:`highlight_phrase()` to ``<mark>`` (formerly ``<strong>``). + - Changed :php:func:`character_limiter()`, :php:func:`word_wrap()` and :php:func:`ellipsize()` to utilize `mbstring <http://php.net/mbstring>`_ or `iconv <http://php.net/iconv>`_, if available. - - :doc:`Directory Helper <helpers/directory_helper>` :func:`directory_map()` will now append ``DIRECTORY_SEPARATOR`` to directory names in the returned array. - - :doc:`Array Helper <helpers/array_helper>` :func:`element()` and :func:`elements()` now return NULL instead of FALSE when the required elements don't exist. - - :doc:`Language Helper <helpers/language_helper>` :func:`lang()` now accepts an optional list of additional HTML attributes. + - :doc:`Directory Helper <helpers/directory_helper>` :php:func:`directory_map()` will now append ``DIRECTORY_SEPARATOR`` to directory names in the returned array. + - :doc:`Array Helper <helpers/array_helper>` :php:func:`element()` and :php:func:`elements()` now return NULL instead of FALSE when the required elements don't exist. + - :doc:`Language Helper <helpers/language_helper>` :php:func:`lang()` now accepts an optional list of additional HTML attributes. - Deprecated the :doc:`Email Helper <helpers/email_helper>` as its ``valid_email()``, ``send_email()`` functions are now only aliases for PHP native functions ``filter_var()`` and ``mail()`` respectively. - Database @@ -283,19 +284,19 @@ Release Date: Not Released - :doc:`Session Library <libraries/sessions>` changes include: - - Library changed to :doc:`Driver <general/drivers>` with classic 'cookie' driver as the default. - - Added a 'native' PHP Session driver to work with ``$_SESSION``. - - Added a new **tempdata** feature that allows setting userdata items with expiration time (``tempdata()``, ``set_tempdata()``, ``unset_tempdata()``). - - Added default ``$config['sess_driver']`` and ``$config['sess_valid_drivers']`` items to *application/config.php* file. - - Changed 'cookie' driver to respect php.ini's *session.gc_probability* and *session.gc_divisor* settings. - - Changed 'cookie' driver to use HMAC authentication instead of a simple md5 checksum. - - Changed 'cookie' driver to select only one row when using database sessions. - - Changed 'cookie' driver to write to only write to the database at end of page execution. + - Completely re-written the library to use self-contained drivers via ``$config['sess_driver']``. + - Added 'files', 'database', 'redis' and 'memcached' drivers (using 'files' by default). + - Added ``$config['sess_save_path']`` setting to specify where the session data is stored, depending on the driver. + - Dropped support for storing session data in cookies (which renders ``$config['sess_encrypt_cookie']`` useless and is therefore also removed). + - Dropped official support for storing session data in databases other than MySQL and PostgreSQL. + - Changed table structure for the 'database' driver. + - Added a new **tempdata** feature that allows setting userdata items with expiration time (``mark_as_temp()``, ``tempdata()``, ``set_tempdata()``, ``unset_tempdata()``). - Changed method ``keep_flashdata()`` to also accept an array of keys. - Changed methods ``userdata()``, ``flashdata()`` to return an array of all userdata/flashdata when no parameter is passed. - Deprecated method ``all_userdata()`` - it is now just an alias for ``userdata()`` with no parameters. - Added method ``has_userdata()`` that verifies the existence of a userdata item. - Added *debug* level log messages for key events in the session validation process. + - Dropped support for the *sess_match_useragent* option. - :doc:`File Uploading Library <libraries/file_uploading>` changes include: @@ -317,7 +318,7 @@ Release Date: Not Released - Added configuration to generate days of other months instead of blank cells. - Added auto-configuration for *next_prev_url* if it is empty and *show_prev_next* is set to TRUE. - Added support for templating via an array in addition to the encoded string. - - Changed method ``get_total_days()`` to be an alias for :doc:`Date Helper <helpers/date_helper>` :func:`days_in_month()`. + - Changed method ``get_total_days()`` to be an alias for :doc:`Date Helper <helpers/date_helper>` :php:func:`days_in_month()`. - :doc:`Cart Library <libraries/cart>` changes include: @@ -336,7 +337,7 @@ Release Date: Not Released - Class properties *wm_font_color*, *wm_shadow_color* and *wm_use_drop_shadow* are now protected, to avoid breaking the ``text_watermark()`` method if they are set manually after initialization. - If property *maintain_ratio* is set to TRUE, ``image_reproportion()`` now doesn't need both width and height to be specified. - Property *maintain_ratio* is now taken into account when resizing images using ImageMagick library. - - Added support for maintaining transparency for PNG images in method ``text_watermark()``. + - Added support for maintaining transparency for PNG images when watermarking. - Added a **file_permissions** setting. - :doc:`Form Validation Library <libraries/form_validation>` changes include: @@ -352,6 +353,7 @@ Release Date: Not Released - Fields that have empty rules set no longer run through validation (and therefore are not considered erroneous). - Added rule **differs** to check if the value of a field differs from the value of another field. - Added rule **valid_url**. + - Added rule **in_list** to check if the value of a field is within a given list. - Added support for named parameters in error messages. - :doc:`Language <libraries/language>` line keys must now be prefixed with **form_validation_**. - Added rule **alpha_numeric_spaces**. @@ -395,9 +397,10 @@ Release Date: Not Released - Added support for the anchor "rel" attribute. - Added support for setting custom attributes. - Added support for language translations of the *first_link*, *next_link*, *prev_link* and *last_link* values. + - Added support for ``$config['num_links'] = 0`` configuration. - Added ``$config['reuse_query_string']`` to allow automatic repopulation of query string arguments, combined with normal URI segments. + - Added ``$config['use_global_url_suffix']`` to allow overriding the library 'suffix' value with that of the global ``$config['url_suffix']`` setting. - Removed the default `` `` from a number of the configuration variables. - - Added support for ``$config['num_links'] = 0`` configuration. - :doc:`Profiler Library <general/profiling>` changes include: @@ -486,23 +489,23 @@ Release Date: Not Released - Changed method ``_fetch_from_array()`` to parse array notation in field name. - Changed method ``_fetch_from_array()`` to allow retrieving multiple fields at once. - Added an option for ``_clean_input_keys()`` to return FALSE instead of terminating the whole script. - - Deprecated the ``is_cli_request()`` method, it is now an alias for the new :func:`is_cli()` common function. + - Deprecated the ``is_cli_request()`` method, it is now an alias for the new :php:func:`is_cli()` common function. - Added an ``$xss_clean`` parameter to method ``user_agent()`` and removed the ``$user_agent`` property. - :doc:`Common functions <general/common_functions>` changes include: - - Added function :func:`get_mimes()` to return the *application/config/mimes.php* array. - - Added support for HTTP code 303 ("See Other") in :func:`set_status_header()`. - - Removed redundant conditional to determine HTTP server protocol in :func:`set_status_header()`. + - Added function :php:func:`get_mimes()` to return the *application/config/mimes.php* array. + - Added support for HTTP code 303 ("See Other") in :php:func:`set_status_header()`. + - Removed redundant conditional to determine HTTP server protocol in :php:func:`set_status_header()`. - Renamed ``_exception_handler()`` to ``_error_handler()`` and replaced it with a real exception handler. - Changed ``_error_handler()`` to respect php.ini *display_errors* setting. - - Added function :func:`is_https()` to check if a secure connection is used. - - Added function :func:`is_cli()` to replace the ``CI_Input::is_cli_request()`` method. - - Added function :func:`function_usable()` to work around a bug in `Suhosin <http://www.hardened-php.net/suhosin/>`. - - Removed the third (`$php_error`) argument from function :func:`log_message()`. + - Added function :php:func:`is_https()` to check if a secure connection is used. + - Added function :php:func:`is_cli()` to replace the ``CI_Input::is_cli_request()`` method. + - Added function :php:func:`function_usable()` to work around a bug in `Suhosin <http://www.hardened-php.net/suhosin/>`. + - Removed the third (`$php_error`) argument from function :php:func:`log_message()`. - Changed internal function ``load_class()`` to accept a constructor parameter instead of (previously unused) class name prefix. - - Removed default parameter value of :func:`is_php()`. - - Added a second argument ``$double_encode`` to :func:`html_escape()`. + - Removed default parameter value of :php:func:`is_php()`. + - Added a second argument ``$double_encode`` to :php:func:`html_escape()`. - Changed function ``config_item()`` to return NULL instead of FALSE when no value is found. - :doc:`Output Library <libraries/output>` changes include: @@ -535,7 +538,7 @@ Release Date: Not Released - Changed method ``load()`` to filter the language name with ``ctype_alpha()``. - Changed method ``load()`` to also accept an array of language files. - Added an optional second parameter to method ``line()`` to disable error logging for line keys that were not found. - - Language files are now loaded in a cascading style with the one in **system/** always loaded and overriden afterwards, if another one is found. + - Language files are now loaded in a cascading style with the one in **system/** always loaded and overridden afterwards, if another one is found. - :doc:`Hooks Library <general/hooks>` changes include: @@ -553,6 +556,7 @@ Release Date: Not Released - Added a ``$config['log_file_permissions']`` setting. - Changed the library constructor to try to create the **log_path** directory if it doesn't exist. + - Added support for microseconds ("u" date format character) in ``$config['log_date_format']``. - Added `compatibility layers <general/compatibility_functions>` for: @@ -574,13 +578,13 @@ Bug fixes for 3.0 - Fixed a bug (#181) - a typo in the form validation language file. - Fixed a bug (#159, #163) - :doc:`Query Builder <database/query_builder>` nested transactions didn't work properly due to ``$_trans_depth`` not being incremented. - Fixed a bug (#737, #75) - :doc:`Pagination <libraries/pagination>` anchor class was not set properly when using initialize method. -- Fixed a bug (#419) - :doc:`URL Helper <helpers/url_helper>` :func:`auto_link()` didn't recognize URLs that come after a word boundary. +- Fixed a bug (#419) - :doc:`URL Helper <helpers/url_helper>` :php:func:`auto_link()` didn't recognize URLs that come after a word boundary. - Fixed a bug (#724) - :doc:`Form Validation Library <libraries/form_validation>` rule **is_unique** didn't check if a database connection exists. - Fixed a bug (#647) - :doc:`Zip Library <libraries/zip>` internal method ``_get_mod_time()`` didn't suppress possible "stat failed" errors generated by ``filemtime()``. - Fixed a bug (#157, #174) - :doc:`Image Manipulation Library <libraries/image_lib>` method ``clear()`` didn't completely clear properties. - Fixed a bug where :doc:`Database Forge <database/forge>` method ``create_table()`` with PostgreSQL database could lead to fetching the whole table. -- Fixed a bug (#795) - :doc:`Form Helper <helpers/form_helper>` :func:`form_open()` didn't add the default form *method* and *accept-charset* when an empty array is passed to it. -- Fixed a bug (#797) - :doc:`Date Helper <helpers/date_helper>` :func:`timespan()` was using incorrect seconds for year and month. +- Fixed a bug (#795) - :doc:`Form Helper <helpers/form_helper>` :php:func:`form_open()` didn't add the default form *method* and *accept-charset* when an empty array is passed to it. +- Fixed a bug (#797) - :doc:`Date Helper <helpers/date_helper>` :php:func:`timespan()` was using incorrect seconds for year and month. - Fixed a bug in :doc:`Cart Library <libraries/cart>` method ``contents()`` where if called without a TRUE (or equal) parameter, it would fail due to a typo. - Fixed a bug (#406) - SQLSRV DB driver not returning resource on ``db_pconnect()``. - Fixed a bug in :doc:`Image Manipulation Library <libraries/image_lib>` method ``gd_loaded()`` where it was possible for the script execution to end or a PHP E_WARNING message to be emitted. @@ -654,24 +658,24 @@ Bug fixes for 3.0 - Fixed a bug in :doc:`Query Builder <database/query_builder>` method ``protect_identifiers()`` where if passed along with the field names, operators got escaped as well. - Fixed a bug (#10) - :doc:`URI Library <libraries/uri>` internal method ``_detect_uri()`` failed with paths containing a colon. - Fixed a bug (#1387) - :doc:`Query Builder <database/query_builder>` method ``from()`` didn't escape table aliases. -- Fixed a bug (#520) - :doc:`Date Helper <helpers/date_helper>` function :func:``nice_date()`` failed when the optional second parameter is not passed. +- Fixed a bug (#520) - :doc:`Date Helper <helpers/date_helper>` function :php:func:``nice_date()`` failed when the optional second parameter is not passed. - Fixed a bug (#167) - ``$config['permitted_uri_chars']`` didn't affect URL-encoded characters. - Fixed a bug (#318) - :doc:`Profiling Library <general/profiling>` setting *query_toggle_count* was not settable as described in the manual. - Fixed a bug (#938) - :doc:`Config Library <libraries/config>` method ``site_url()`` added a question mark to the URL string when query strings are enabled even if it already existed. - Fixed a bug (#999) - :doc:`Config Library <libraries/config>` method ``site_url()`` always appended ``$config['url_suffix']`` to the end of the URL string, regardless of whether a query string exists in it. -- Fixed a bug where :doc:`URL Helper <helpers/url_helper>` function :func:`anchor_popup()` ignored the attributes argument if it is not an array. +- Fixed a bug where :doc:`URL Helper <helpers/url_helper>` function :php:func:`anchor_popup()` ignored the attributes argument if it is not an array. - Fixed a bug (#1328) - :doc:`Form Validation Library <libraries/form_validation>` didn't properly check the type of the form fields before processing them. - Fixed a bug (#79) - :doc:`Form Validation Library <libraries/form_validation>` didn't properly validate array fields that use associative keys or have custom indexes. - Fixed a bug (#427) - :doc:`Form Validation Library <libraries/form_validation>` method ``strip_image_tags()`` was an alias to a non-existent method. - Fixed a bug (#1545) - :doc:`Query Builder <database/query_builder>` method ``limit()`` wasn't executed properly under Oracle. -- Fixed a bug (#1551) - :doc:`Date Helper <helpers/date_helper>` function :func:`standard_date()` didn't properly format *W3C* and *ATOM* standard dates. +- Fixed a bug (#1551) - :doc:`Date Helper <helpers/date_helper>` function :php:func:`standard_date()` didn't properly format *W3C* and *ATOM* standard dates. - Fixed a bug where :doc:`Query Builder <database/query_builder>` method ``join()`` escaped literal values as if they were fields. - Fixed a bug (#135) - PHP Error logging was impossible without the errors being displayed. -- Fixed a bug (#1613) - :doc:`Form Helper <helpers/form_helper>` functions :func:`form_multiselect()`, :func:`form_dropdown()` didn't properly handle empty array option groups. +- Fixed a bug (#1613) - :doc:`Form Helper <helpers/form_helper>` functions :php:func:`form_multiselect()`, :php:func:`form_dropdown()` didn't properly handle empty array option groups. - Fixed a bug (#1605) - :doc:`Pagination Library <libraries/pagination>` produced incorrect *previous* and *next* link values. - Fixed a bug in SQLSRV's ``affected_rows()`` method where an erroneous function name was used. - Fixed a bug (#1000) - Change syntax of ``$view_file`` to ``$_ci_view_file`` to prevent being overwritten by application. -- Fixed a bug (#1757) - :doc:`Directory Helper <helpers/directory_helper>` function :func:`directory_map()` was skipping files and directories named '0'. +- Fixed a bug (#1757) - :doc:`Directory Helper <helpers/directory_helper>` function :php:func:`directory_map()` was skipping files and directories named '0'. - Fixed a bug (#1789) - :doc:`Database Library <database/index>` method ``escape_str()`` escaped quote characters in LIKE conditions twice under MySQL. - Fixed a bug (#395) - :doc:`Unit Testing Library <libraries/unit_testing>` method ``result()`` didn't properly check array result columns when called from ``report()``. - Fixed a bug (#1692) - :doc:`Database Class <database/index>` method ``display_error()`` didn't properly trace the possible error source on Windows systems. @@ -690,13 +694,13 @@ Bug fixes for 3.0 - Fixed a bug (#134) - :doc:`Database Caching <database/caching>` method ``delete_cache()`` didn't work in some cases due to *cachedir* not being initialized properly. - Fixed a bug (#191) - :doc:`Loader Library <libraries/loader>` ignored attempts for (re)loading databases to ``get_instance()->db`` even when the old database connection is dead. - Fixed a bug (#1255) - :doc:`User Agent Library <libraries/user_agent>` method ``is_referral()`` only checked if ``$_SERVER['HTTP_REFERER']`` exists. -- Fixed a bug (#1146) - :doc:`Download Helper <helpers/download_helper>` function :func:`force_download()` incorrectly sent *Cache-Control* directives *pre-check* and *post-check* to Internet Explorer. +- Fixed a bug (#1146) - :doc:`Download Helper <helpers/download_helper>` function :php:func:`force_download()` incorrectly sent *Cache-Control* directives *pre-check* and *post-check* to Internet Explorer. - Fixed a bug (#1811) - :doc:`URI Library <libraries/uri>` didn't properly cache segments for ``uri_to_assoc()`` and ``ruri_to_assoc()``. - Fixed a bug (#1506) - :doc:`Form Helpers <helpers/form_helper>` set empty *name* attributes. - Fixed a bug (#59) - :doc:`Query Builder <database/query_builder>` method ``count_all_results()`` ignored the DISTINCT clause. - Fixed a bug (#1624) - :doc:`Form Validation Library <libraries/form_validation>` rule **matches** didn't property handle array field names. -- Fixed a bug (#1630) - :doc:`Form Helper <helpers/form_helper>` function :func:`set_value()` didn't escape HTML entities. -- Fixed a bug (#142) - :doc:`Form Helper <helpers/form_helper>` function :func:`form_dropdown()` didn't escape HTML entities in option values. +- Fixed a bug (#1630) - :doc:`Form Helper <helpers/form_helper>` function :php:func:`set_value()` didn't escape HTML entities. +- Fixed a bug (#142) - :doc:`Form Helper <helpers/form_helper>` function :php:func:`form_dropdown()` didn't escape HTML entities in option values. - Fixed a bug (#50) - :doc:`Session Library <libraries/sessions>` unnecessarily stripped slashed from serialized data, making it impossible to read objects in a namespace. - Fixed a bug (#658) - :doc:`Routing <general/routing>` wildcard **:any** didn't work as advertised and matched multiple URI segments instead of all characters within a single segment. - Fixed a bug (#1938) - :doc:`Email Library <libraries/email>` removed multiple spaces inside a pre-formatted plain text message. @@ -705,7 +709,7 @@ Bug fixes for 3.0 - Fixed a bug - :doc:`Routing Library <general/routing>` didn't properly handle *default_controller* in a subdirectory when a method is also specified. - Fixed a bug (#953) - :doc:`post_controller_constructor hook <general/hooks>` wasn't called with a *404_override*. - Fixed a bug (#1220) - :doc:`Profiler Library <general/profiling>` didn't display information for database objects that are instantiated inside models. -- Fixed a bug (#1978) - :doc:`Directory Helper <helpers/directory_helper>` function :func:`directory_map()`'s return array didn't make a distinction between directories and file indexes when a directory with a numeric name is present. +- Fixed a bug (#1978) - :doc:`Directory Helper <helpers/directory_helper>` function :php:func:`directory_map()`'s return array didn't make a distinction between directories and file indexes when a directory with a numeric name is present. - Fixed a bug (#777) - :doc:`Loader Library <libraries/loader>` didn't look for helper extensions in added package paths. - Fixed a bug (#18) - :doc:`APC Cache <libraries/caching>` driver didn't (un)serialize data, resulting in failure to store objects. - Fixed a bug (#188) - :doc:`Unit Testing Library <libraries/unit_testing>` filled up logs with error messages for non-existing language keys. @@ -713,13 +717,12 @@ Bug fixes for 3.0 - Fixed a bug (#2061) - :doc:`Routing Class <general/routing>` didn't properly sanitize directory, controller and function triggers with **enable_query_strings** set to TRUE. - Fixed a bug - SQLSRV didn't support ``escape_like_str()`` or escaping an array of values. - Fixed a bug - :doc:`Database Results <database/results>` method ``list_fields()`` didn't reset its field pointer for the 'mysql', 'mysqli' and 'mssql' drivers. -- Fixed a bug (#73) - :doc:`Security Library <libraries/security>` method ``sanitize_filename()`` could be tricked by an XSS attack. - Fixed a bug (#2211) - :doc:`Migration Library <libraries/migration>` extensions couldn't execute ``CI_Migration::__construct()``. - Fixed a bug (#2255) - :doc:`Email Library <libraries/email>` didn't apply *smtp_timeout* to socket reads and writes. - Fixed a bug (#2239) - :doc:`Email Library <libraries/email>` improperly handled the Subject when used with *bcc_batch_mode* resulting in E_WARNING messages and an empty Subject. - Fixed a bug (#2234) - :doc:`Query Builder <database/query_builder>` didn't reset JOIN cache for write-type queries. - Fixed a bug (#2298) - :doc:`Database Results <database/results>` method ``next_row()`` kept returning the last row, allowing for infinite loops. -- Fixed a bug (#2236, #2639) - :doc:`Form Helper <helpers/form_helper>` functions :func:`set_value()`, :func:`set_select()`, :func:`set_radio()`, :func:`set_checkbox()` didn't parse array notation for keys if the rule was not present in the :doc:`Form Validation Library <libraries/form_validation>`. +- Fixed a bug (#2236, #2639) - :doc:`Form Helper <helpers/form_helper>` functions :php:func:`set_value()`, :php:func:`set_select()`, :php:func:`set_radio()`, :php:func:`set_checkbox()` didn't parse array notation for keys if the rule was not present in the :doc:`Form Validation Library <libraries/form_validation>`. - Fixed a bug (#2353) - :doc:`Query Builder <database/query_builder>` erroneously prefixed literal strings with **dbprefix**. - Fixed a bug (#78) - :doc:`Cart Library <libraries/cart>` didn't allow non-English letters in product names. - Fixed a bug (#77) - :doc:`Database Class <database/index>` didn't properly handle the transaction "test mode" flag. @@ -729,33 +732,30 @@ Bug fixes for 3.0 - Fixed a bug (#2425) - OCI8 :doc:`database <database/index>` driver method ``stored_procedure()`` didn't log an error unless **db_debug** was set to TRUE. - Fixed a bug (#2490) - :doc:`Database Class <database/queries>` method ``query()`` returning boolean instead of a result object for PostgreSQL-specific *INSERT INTO ... RETURNING* statements. - Fixed a bug (#249) - :doc:`Cache Library <libraries/caching>` didn't properly handle Memcache(d) configurations with missing options. -- Fixed a bug (#180) - :func:`config_item()` didn't take into account run-time configuration changes. +- Fixed a bug (#180) - :php:func:`config_item()` didn't take into account run-time configuration changes. - Fixed a bug (#2551) - :doc:`Loader Library <libraries/loader>` method ``library()`` didn't properly check if a class that is being loaded already exists. -- Fixed a bug (#2560) - :doc:`Form Helper <helpers/form_helper>` function :func:`form_open()` set the 'method="post"' attribute only if the passed attributes equaled an empty string. +- Fixed a bug (#2560) - :doc:`Form Helper <helpers/form_helper>` function :php:func:`form_open()` set the 'method="post"' attribute only if the passed attributes equaled an empty string. - Fixed a bug (#2585) - :doc:`Query Builder <database/query_builder>` methods ``min()``, ``max()``, ``avg()``, ``sum()`` didn't escape field names. -- Fixed a bug (#2590) - :doc:`Common function <general/common_functions>` :func:`log_message()` didn't actually cache the ``CI_Log`` class instance. -- Fixed a bug (#2609) - :doc:`Common function <general/common_functions>` :func:`get_config()` optional argument was only effective on first function call. Also, it can now add items, in addition to updating existing items. +- Fixed a bug (#2590) - :doc:`Common function <general/common_functions>` :php:func:`log_message()` didn't actually cache the ``CI_Log`` class instance. +- Fixed a bug (#2609) - :doc:`Common function <general/common_functions>` :php:func:`get_config()` optional argument was only effective on first function call. Also, it can now add items, in addition to updating existing items. - Fixed a bug in the 'postgre' :doc:`database <database/index>` driver where the connection ID wasn't passed to ``pg_escape_string()``. - Fixed a bug (#33) - Script execution was terminated when an invalid cookie key was encountered. -- Fixed a bug (#2681) - :doc:`Security Library <libraries/security>` method ``entity_decode()`` used the `PREG_REPLACE_EVAL` flag, which is deprecated since PHP 5.5. - Fixed a bug (#2691) - nested :doc:`database <database/index>` transactions could end in a deadlock when an error is encountered with *db_debug* set to TRUE. - Fixed a bug (#2515) - ``_exception_handler()`` used to send the 200 "OK" HTTP status code and didn't stop script exection even on fatal errors. - Fixed a bug - Redis :doc:`Caching <libraries/caching>` driver didn't handle connection failures properly. - Fixed a bug (#2756) - :doc:`Database Class <database/index>` executed the MySQL-specific `SET SESSION sql_mode` query for all drivers when the 'stricton' option is set. - Fixed a bug (#2579) - :doc:`Query Builder <database/query_builder>` "no escape" functionality didn't work properly with query cache. - Fixed a bug (#2237) - :doc:`Parser Library <libraries/parser>` failed if the same tag pair is used more than once within a template. -- Fixed a bug (#2268) - :doc:`Security Library <libraries/security>` didn't properly match JavaScript events. - Fixed a bug (#2143) - :doc:`Form Validation Library <libraries/form_validation>` didn't check for rule groups named in a *controller/method* manner when trying to load from a config file. - Fixed a bug (#2762) - :doc:`Hooks Class <general/hooks>` didn't properly check if the called class/function exists. - Fixed a bug (#148) - :doc:`Input Library <libraries/input>` internal method ``_clean_input_data()`` assumed that it data is URL-encoded, stripping certain character sequences from it. - Fixed a bug (#346) - with ``$config['global_xss_filtering']`` turned on, the ``$_GET``, ``$_POST``, ``$_COOKIE`` and ``$_SERVER`` superglobals were overwritten during initialization time, resulting in XSS filtering being either performed twice or there was no possible way to get the original data, even though options for this do exist. - Fixed an edge case (#555) - :doc:`User Agent Library <libraries/user_agent>` reported an incorrect version Opera 10+ due to a non-standard user-agent string. -- Fixed a bug (#133) - :doc:`Text Helper <helpers/text_helper>` :func:`ascii_to_entities()` stripped the last character if it happens to be in the extended ASCII group. +- Fixed a bug (#133) - :doc:`Text Helper <helpers/text_helper>` :php:func:`ascii_to_entities()` stripped the last character if it happens to be in the extended ASCII group. - Fixed a bug (#2822) - ``fwrite()`` was used incorrectly throughout the whole framework, allowing incomplete writes when writing to a network stream and possibly a few other edge cases. - Fixed a bug where :doc:`User Agent Library <libraries/user_agent>` methods ``accept_charset()`` and ``accept_lang()`` didn't properly parse HTTP headers that contain spaces. - Fixed a bug where *default_controller* was called instad of triggering a 404 error if the current route is in a controller directory. - Fixed a bug (#2737) - :doc:`XML-RPC Library <libraries/xmlrpc>` used objects as array keys, which triggered E_NOTICE messages. -- Fixed a bug (#2729) - :doc:`Security Library <libraries/security>` internal method ``_validate_entities()`` used overly-intrusive ``preg_replace()`` patterns that produced false-positives. - Fixed a bug (#2771) - :doc:`Security Library <libraries/security>` method ``xss_clean()`` didn't take into account HTML5 entities. - Fixed a bug (#2856) - ODBC method ``affected_rows()`` passed an incorrect value to ``odbc_num_rows()``. - Fixed a bug (#43) :doc:`Image Manipulation Library <libraries/image_lib>` method ``text_watermark()`` didn't properly determine watermark placement. @@ -767,6 +767,31 @@ Bug fixes for 3.0 - Fixed a bug (#3161) - :doc:`Cache Library <libraries/caching>` methods `increment()`, `decrement()` didn't auto-create non-existent items when using redis and/or file storage. - Fixed a bug (#3189) - :doc:`Parser Library <libraries/parser>` used double replacement on ``key->value`` pairs, exposing a potential template injection vulnerability. +Version 2.2.1 +============= + +Release Date: January 22, 2015 + +- General Changes + + - Improved security in ``xss_clean()``. + - Updated timezones in :doc:`Date Helper <helpers/date_helper>`. + +Bug fixes for 2.2.1 +------------------- + +- Fixed a bug (#3094) - Internal method ``CI_Input::_clean_input_data()`` breaks encrypted session cookies. +- Fixed a bug (#2268) - :doc:`Security Library <libraries/security>` method ``xss_clean()`` didn't properly match JavaScript events. +- Fixed a bug (#3309) - :doc:`Security Library <libraries/security>` method ``xss_clean()`` used an overly-invasive pattern to strip JS event handlers. +- Fixed a bug (#2771) - :doc:`Security Library <libraries/security>` method ``xss_clean()`` didn't take into account HTML5 entities. +- Fixed a bug (#73) - :doc:`Security Library <libraries/security>` method ``sanitize_filename()`` could be tricked by an XSS attack. +- Fixed a bug (#2681) - :doc:`Security Library <libraries/security>` method ``entity_decode()`` used the ``PREG_REPLACE_EVAL`` flag, which is deprecated since PHP 5.5. +- Fixed a bug (#3302) - Internal function ``get_config()`` triggered an E_NOTICE message on PHP 5.6. +- Fixed a bug (#2508) - :doc:`Config Library <libraries/config>` didn't properly detect if the current request is via HTTPS. +- Fixed a bug (#3314) - SQLSRV :doc:`Database driver <database/index>`'s method ``count_all()`` didn't escape the supplied table name. +- Fixed a bug (#3404) - MySQLi :doc:`Database driver <database/index>`'s method ``escape_str()`` had a wrong fallback to ``mysql_escape_string()`` when there was no active connection. +- Fixed a bug in the :doc:`Session Library <libraries/sessions>` where session ID regeneration occurred during AJAX requests. + Version 2.2.0 ============= @@ -2255,7 +2280,7 @@ Release Date: January 30, 2008 - Added an "integer" rule into the Validation library. - Added valid_base64() to the Validation library. - Documented clear() in the :doc:`Image - Processing <../libraries/image_lib>` library. + Processing <./libraries/image_lib>` library. - Changed the behaviour of custom callbacks so that they no longer trigger the "required" rule. - Modified Upload class $_FILES error messages to be more precise. diff --git a/user_guide_src/source/conf.py b/user_guide_src/source/conf.py index 482d4936f..d65fe0dfd 100644 --- a/user_guide_src/source/conf.py +++ b/user_guide_src/source/conf.py @@ -69,11 +69,11 @@ exclude_patterns = [] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None -# If true, '()' will be appended to :func: etc. cross-reference text. +# If true, '()' will be appended to :php:func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description -# unit titles (such as .. function::). +# unit titles (such as .. php:function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the diff --git a/user_guide_src/source/contributing/index.rst b/user_guide_src/source/contributing/index.rst index 89bceaa61..e88147753 100644 --- a/user_guide_src/source/contributing/index.rst +++ b/user_guide_src/source/contributing/index.rst @@ -92,10 +92,10 @@ must also be updated for every change. Also PHPDoc blocks must be maintained. Compatibility ============= -CodeIgniter recommends PHP 5.4 or newer to be used, but is compatible with -PHP 5.2.4 so all code supplied must stick to this requirement. If PHP 5.3 -(and above) functions or features are used then there must be a fallback -for PHP 5.2.4. +CodeIgniter recommends PHP 5.4 or newer to be used, but it should be +compatible with PHP 5.2.4 so all code supplied must stick to this +requirement. If PHP 5.3 (and above) functions or features are used then +there must be a fallback for PHP 5.2.4. Branching ========= diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index 9f52ad2a2..074725664 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -165,9 +165,9 @@ Explanation of Values: **password** The password used to connect to the database. **database** The name of the database you want to connect to. **dbdriver** The database type. ie: mysqli, postgre, odbc, etc. Must be specified in lower case. -**dbprefix** An optional table prefix which will added to the table name when running :doc: - `Query Builder <query_builder>` queries. This permits multiple CodeIgniter installations - to share one database. +**dbprefix** An optional table prefix which will added to the table name when running + :doc:`Query Builder <query_builder>` queries. This permits multiple CodeIgniter + installations to share one database. **pconnect** TRUE/FALSE (boolean) - Whether to use a persistent connection. **db_debug** TRUE/FALSE (boolean) - Whether database errors should be displayed. **cache_on** TRUE/FALSE (boolean) - Whether database query caching is enabled, diff --git a/user_guide_src/source/database/db_driver_reference.rst b/user_guide_src/source/database/db_driver_reference.rst index 7bee555c8..005e6b3dc 100644 --- a/user_guide_src/source/database/db_driver_reference.rst +++ b/user_guide_src/source/database/db_driver_reference.rst @@ -13,9 +13,9 @@ This article is intended to be a reference for them. some of them may fail (and return FALSE) if the underlying driver does not support them. -.. class:: CI_DB_driver +.. php:class:: CI_DB_driver - .. method:: initialize() + .. php:method:: initialize() :returns: TRUE on success, FALSE on failure :rtype: bool @@ -23,7 +23,7 @@ This article is intended to be a reference for them. Initialize database settings, establish a connection to the database. - .. method:: db_connect($persistent = TRUE) + .. php:method:: db_connect($persistent = TRUE) :param bool $persistent: Whether to establish a persistent connection or a regular one :returns: Database connection resource/object or FALSE on failure @@ -35,7 +35,7 @@ This article is intended to be a reference for them. driver in use. For example, a ``mysqli`` instance will be returned with the 'mysqli' driver. - .. method:: db_pconnect() + .. php:method:: db_pconnect() :returns: Database connection resource/object or FALSE on failure :rtype: mixed @@ -44,7 +44,7 @@ This article is intended to be a reference for them. .. note:: This method is just an alias for ``db_connect(TRUE)``. - .. method:: reconnect() + .. php:method:: reconnect() :returns: TRUE on success, FALSE on failure :rtype: bool @@ -53,7 +53,7 @@ This article is intended to be a reference for them. have been sent for a length of time exceeding the server's idle timeout. - .. method:: db_select([$database = '']) + .. php:method:: db_select([$database = '']) :param string $database: Database name :returns: TRUE on success, FALSE on failure @@ -61,7 +61,7 @@ This article is intended to be a reference for them. Select / switch the current database. - .. method:: db_set_charset($charset) + .. php:method:: db_set_charset($charset) :param string $charset: Character set name :returns: TRUE on success, FALSE on failure @@ -69,21 +69,21 @@ This article is intended to be a reference for them. Set client character set. - .. method:: platform() + .. php:method:: platform() :returns: Platform name :rtype: string The name of the platform in use (mysql, mssql, etc...). - .. method:: version() + .. php:method:: version() :returns: The version of the database being used :rtype: string Database version number. - .. method:: query($sql[, $binds = FALSE[, $return_object = NULL]]]) + .. php:method:: query($sql[, $binds = FALSE[, $return_object = NULL]]]) :param string $sql: The SQL statement to execute :param array $binds: An array of binding data @@ -106,7 +106,7 @@ This article is intended to be a reference for them. page will be displayed instead of returning FALSE on failures and script execution will stop. - .. method:: simple_query($sql) + .. php:method:: simple_query($sql) :param string $sql: The SQL statement to execute :returns: Whatever the underlying driver's "query" function returns @@ -116,7 +116,7 @@ This article is intended to be a reference for them. for use when you don't need to get a result object or to just send a query to the database and not care for the result. - .. method:: trans_strict([$mode = TRUE]) + .. php:method:: trans_strict([$mode = TRUE]) :param bool $mode: Strict mode flag :rtype: void @@ -131,26 +131,26 @@ This article is intended to be a reference for them. autonomously, meaning a failure of one group will not affect any others. - .. method:: trans_off() + .. php:method:: trans_off() :rtype: void Disables transactions at run-time. - .. method:: trans_start([$test_mode = FALSE]) + .. php:method:: trans_start([$test_mode = FALSE]) :param bool $test_mode: Test mode flag :rtype: void Start a transaction. - .. method:: trans_complete() + .. php:method:: trans_complete() :rtype: void Complete Transaction. - .. method:: trans_status() + .. php:method:: trans_status() :returns: TRUE if the transaction succeeded, FALSE if it failed :rtype: bool @@ -158,7 +158,7 @@ This article is intended to be a reference for them. Lets you retrieve the transaction status flag to determine if it has failed. - .. method:: compile_binds($sql, $binds) + .. php:method:: compile_binds($sql, $binds) :param string $sql: The SQL statement :param array $binds: An array of binding data @@ -167,7 +167,7 @@ This article is intended to be a reference for them. Compiles an SQL query with the bind values passed for it. - .. method:: is_write_type($sql) + .. php:method:: is_write_type($sql) :param string $sql: The SQL statement :returns: TRUE if the SQL statement is of "write type", FALSE if not @@ -176,7 +176,7 @@ This article is intended to be a reference for them. Determines if a query is of a "write" type (such as INSERT, UPDATE, DELETE) or "read" type (i.e. SELECT). - .. method:: elapsed_time([$decimals = 6]) + .. php:method:: elapsed_time([$decimals = 6]) :param int $decimals: The number of decimal places :returns: The aggregate query elapsed time, in microseconds @@ -184,7 +184,7 @@ This article is intended to be a reference for them. Calculate the aggregate query elapsed time. - .. method:: total_queries() + .. php:method:: total_queries() :returns: The total number of queries executed :rtype: int @@ -192,14 +192,14 @@ This article is intended to be a reference for them. Returns the total number of queries that have been executed so far. - .. method:: last_query() + .. php:method:: last_query() :returns: The last query executed :rtype: string Returns the last query that was executed. - .. method:: escape($str) + .. php:method:: escape($str) :param mixed $str: The value to escape, or an array of multiple ones :returns: The escaped value(s) @@ -208,7 +208,7 @@ This article is intended to be a reference for them. Escapes input data based on type, including boolean and NULLs. - .. method:: escape_str($str[, $like = FALSE]) + .. php:method:: escape_str($str[, $like = FALSE]) :param mixed $str: A string value or array of multiple ones :param bool $like: Whether or not the string will be used in a LIKE condition @@ -220,7 +220,7 @@ This article is intended to be a reference for them. .. warning:: The returned strings do NOT include quotes around them. - .. method:: escape_like_str($str) + .. php:method:: escape_like_str($str) :param mixed $str: A string value or array of multiple ones :returns: The escaped string(s) @@ -232,7 +232,7 @@ This article is intended to be a reference for them. and ``_`` wildcard characters, so that they don't cause false-positives in LIKE conditions. - .. method:: primary($table) + .. php:method:: primary($table) :param string $table: Table name :returns: The primary key name, FALSE if none @@ -244,7 +244,7 @@ This article is intended to be a reference for them. key detection, the first column name may be assumed as the primary key. - .. method:: count_all([$table = '']) + .. php:method:: count_all([$table = '']) :param string $table: Table name :returns: Row count for the specified table @@ -253,7 +253,7 @@ This article is intended to be a reference for them. Returns the total number of rows in a table, or 0 if no table was provided. - .. method:: list_tables([$constrain_by_prefix = FALSE]) + .. php:method:: list_tables([$constrain_by_prefix = FALSE]) :param bool $constrain_by_prefix: TRUE to match table names by the configured dbprefix :returns: Array of table names or FALSE on failure @@ -261,7 +261,7 @@ This article is intended to be a reference for them. Gets a list of the tables in the current database. - .. method:: table_exists($table_name) + .. php:method:: table_exists($table_name) :param string $table_name: The table name :returns: TRUE if that table exists, FALSE if not @@ -269,7 +269,7 @@ This article is intended to be a reference for them. Determine if a particular table exists. - .. method:: list_fields($table) + .. php:method:: list_fields($table) :param string $table: The table name :returns: Array of field names or FALSE on failure @@ -277,7 +277,7 @@ This article is intended to be a reference for them. Gets a list of the field names in a table. - .. method:: field_exists($field_name, $table_name) + .. php:method:: field_exists($field_name, $table_name) :param string $table_name: The table name :param string $field_name: The field name @@ -286,7 +286,7 @@ This article is intended to be a reference for them. Determine if a particular field exists. - .. method:: field_data($table) + .. php:method:: field_data($table) :param string $table: The table name :returns: Array of field data items or FALSE on failure @@ -294,7 +294,7 @@ This article is intended to be a reference for them. Gets a list containing field data about a table. - .. method:: escape_identifiers($item) + .. php:method:: escape_identifiers($item) :param mixed $item: The item or array of items to escape :returns: The input item(s), escaped @@ -302,7 +302,7 @@ This article is intended to be a reference for them. Escape SQL identifiers, such as column, table and names. - .. method:: insert_string($table, $data) + .. php:method:: insert_string($table, $data) :param string $table: The target table :param array $data: An associative array of key/value pairs @@ -311,7 +311,7 @@ This article is intended to be a reference for them. Generate an INSERT statement string. - .. method:: update_string($table, $data, $where) + .. php:method:: update_string($table, $data, $where) :param string $table: The target table :param array $data: An associative array of key/value pairs @@ -321,7 +321,7 @@ This article is intended to be a reference for them. Generate an UPDATE statement string. - .. method:: call_function($function) + .. php:method:: call_function($function) :param string $function: Function name :returns: The function result @@ -330,28 +330,28 @@ This article is intended to be a reference for them. Runs a native PHP function , using a platform agnostic wrapper. - .. method:: cache_set_path([$path = '']) + .. php:method:: cache_set_path([$path = '']) :param string $path: Path to the cache directory :rtype: void Sets the directory path to use for caching storage. - .. method:: cache_on() + .. php:method:: cache_on() :returns: TRUE if caching is on, FALSE if not :rtype: bool Enable database results caching. - .. method:: cache_off() + .. php:method:: cache_off() :returns: TRUE if caching is on, FALSE if not :rtype: bool Disable database results caching. - .. method:: cache_delete([$segment_one = ''[, $segment_two = '']]) + .. php:method:: cache_delete([$segment_one = ''[, $segment_two = '']]) :param string $segment_one: First URI segment :param string $segment_two: Second URI segment @@ -360,20 +360,20 @@ This article is intended to be a reference for them. Delete the cache files associated with a particular URI. - .. method:: cache_delete_all() + .. php:method:: cache_delete_all() :returns: TRUE on success, FALSE on failure :rtype: bool Delete all cache files. - .. method:: close() + .. php:method:: close() :rtype: void Close the DB Connection. - .. method:: display_error([$error = ''[, $swap = ''[, $native = FALSE]]]) + .. php:method:: display_error([$error = ''[, $swap = ''[, $native = FALSE]]]) :param string $error: The error message :param string $swap: Any "swap" values @@ -388,7 +388,7 @@ This article is intended to be a reference for them. The message is displayed using the *application/views/errors/error_db.php* template. - .. method:: protect_identifiers($item[, $prefix_single = FALSE[, $protect_identifiers = NULL[, $field_exists = TRUE]]]) + .. php:method:: protect_identifiers($item[, $prefix_single = FALSE[, $protect_identifiers = NULL[, $field_exists = TRUE]]]) :param string $item: The item to work with :param bool $prefix_single: Whether to apply the dbprefix even if the input item is a single identifier diff --git a/user_guide_src/source/database/forge.rst b/user_guide_src/source/database/forge.rst index 59a6591b7..89fac023e 100644 --- a/user_guide_src/source/database/forge.rst +++ b/user_guide_src/source/database/forge.rst @@ -316,9 +316,9 @@ change the name you can add a "name" key into the field defining array. Class Reference *************** -.. class:: CI_DB_forge +.. php:class:: CI_DB_forge - .. method:: add_column($table[, $field = array()[, $_after = NULL]]) + .. php:method:: add_column($table[, $field = array()[, $_after = NULL]]) :param string $table: Table name to add the column to :param array $field: Column definition(s) @@ -328,7 +328,7 @@ Class Reference Adds a column to a table. Usage: See `Adding a Column to a Table`_. - .. method:: add_field($field) + .. php:method:: add_field($field) :param array $field: Field definition to add :returns: CI_DB_forge instance (method chaining) @@ -336,7 +336,7 @@ Class Reference Adds a field to the set that will be used to create a table. Usage: See `Adding fields`_. - .. method:: add_key($key[, $primary = FALSE]) + .. php:method:: add_key($key[, $primary = FALSE]) :param array $key: Name of a key field :param bool $primary: Set to TRUE if it should be a primary key or a regular one @@ -345,7 +345,7 @@ Class Reference Adds a key to the set that will be used to create a table. Usage: See `Adding Keys`_. - .. method:: create_database($db_name) + .. php:method:: create_database($db_name) :param string $db_name: Name of the database to create :returns: TRUE on success, FALSE on failure @@ -353,7 +353,7 @@ Class Reference Creates a new database. Usage: See `Creating and Dropping Databases`_. - .. method:: create_table($table[, $if_not_exists = FALSE[, array $attributes = array()]]) + .. php:method:: create_table($table[, $if_not_exists = FALSE[, array $attributes = array()]]) :param string $table: Name of the table to create :param string $if_not_exists: Set to TRUE to add an 'IF NOT EXISTS' clause @@ -363,7 +363,7 @@ Class Reference Creates a new table. Usage: See `Creating a table`_. - .. method:: drop_column($table, $column_name) + .. php:method:: drop_column($table, $column_name) :param string $table: Table name :param array $column_name: The column name to drop @@ -372,7 +372,7 @@ Class Reference Drops a column from a table. Usage: See `Dropping a Column From a Table`_. - .. method:: drop_database($db_name) + .. php:method:: drop_database($db_name) :param string $db_name: Name of the database to drop :returns: TRUE on success, FALSE on failure @@ -380,7 +380,7 @@ Class Reference Drops a database. Usage: See `Creating and Dropping Databases`_. - .. method:: drop_table($table_name[, $if_exists = FALSE]) + .. php:method:: drop_table($table_name[, $if_exists = FALSE]) :param string $table: Name of the table to drop :param string $if_exists: Set to TRUE to add an 'IF EXISTS' clause @@ -389,7 +389,7 @@ Class Reference Drops a table. Usage: See `Dropping a table`_. - .. method:: modify_column($table, $field) + .. php:method:: modify_column($table, $field) :param string $table: Table name :param array $field: Column definition(s) @@ -398,7 +398,7 @@ Class Reference Modifies a table column. Usage: See `Modifying a Column in a Table`_. - .. method:: rename_table($table_name, $new_table_name) + .. php:method:: rename_table($table_name, $new_table_name) :param string $table: Current of the table :param string $new_table_name: New name of the table diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index b06396e96..fa1e90353 100644 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -1044,9 +1044,9 @@ run the query:: Class Reference *************** -.. class:: CI_DB_query_builder +.. php:class:: CI_DB_query_builder - .. method:: reset_query() + .. php:method:: reset_query() :returns: CI_DB_query_builder instance (method chaining) :rtype: CI_DB_query_builder @@ -1054,28 +1054,28 @@ Class Reference Resets the current Query Builder state. Useful when you want to build a query that can be cancelled under certain conditions. - .. method:: start_cache() + .. php:method:: start_cache() :returns: CI_DB_query_builder instance (method chaining) :rtype: CI_DB_query_builder Starts the Query Builder cache. - .. method:: stop_cache() + .. php:method:: stop_cache() :returns: CI_DB_query_builder instance (method chaining) :rtype: CI_DB_query_builder Stops the Query Builder cache. - .. method:: flush_cache() + .. php:method:: flush_cache() :returns: CI_DB_query_builder instance (method chaining) :rtype: CI_DB_query_builder Empties the Query Builder cache. - .. method:: set_dbprefix([$prefix = '']) + .. php:method:: set_dbprefix([$prefix = '']) :param string $prefix: The new prefix to use :returns: The DB prefix in use @@ -1083,7 +1083,7 @@ Class Reference Sets the database prefix, without having to reconnect. - .. method:: dbprefix([$table = '']) + .. php:method:: dbprefix([$table = '']) :param string $table: The table name to prefix :returns: The prefixed table name @@ -1091,7 +1091,7 @@ Class Reference Prepends a database prefix, if one exists in configuration. - .. method:: count_all_results([$table = '']) + .. php:method:: count_all_results([$table = '']) :param string $table: Table name :returns: Number of rows in the query result @@ -1100,7 +1100,7 @@ Class Reference Generates a platform-specific query string that counts all records returned by an Query Builder query. - .. method:: get([$table = ''[, $limit = NULL[, $offset = NULL]]]) + .. php:method:: get([$table = ''[, $limit = NULL[, $offset = NULL]]]) :param string $table: The table to query :param int $limit: The LIMIT clause @@ -1111,7 +1111,7 @@ Class Reference Compiles and runs SELECT statement based on the already called Query Builder methods. - .. method:: get_where([$table = ''[, $where = NULL[, $limit = NULL[, $offset = NULL]]]]) + .. php:method:: get_where([$table = ''[, $where = NULL[, $limit = NULL[, $offset = NULL]]]]) :param mixed $table: The table(s) to fetch data from; string or array :param string $where: The WHERE clause @@ -1122,7 +1122,7 @@ Class Reference Same as ``get()``, but also allows the WHERE to be added directly. - .. method:: select([$select = '*'[, $escape = NULL]]) + .. php:method:: select([$select = '*'[, $escape = NULL]]) :param string $select: The SELECT portion of a query :param bool $escape: Whether to escape values and identifiers @@ -1131,7 +1131,7 @@ Class Reference Adds a SELECT clause to a query. - .. method:: select_avg([$select = ''[, $alias = '']]) + .. php:method:: select_avg([$select = ''[, $alias = '']]) :param string $select: Field to compute the average of :param string $alias: Alias for the resulting value name @@ -1140,7 +1140,7 @@ Class Reference Adds a SELECT AVG(field) clause to a query. - .. method:: select_max([$select = ''[, $alias = '']]) + .. php:method:: select_max([$select = ''[, $alias = '']]) :param string $select: Field to compute the maximum of :param string $alias: Alias for the resulting value name @@ -1149,7 +1149,7 @@ Class Reference Adds a SELECT MAX(field) clause to a query. - .. method:: select_min([$select = ''[, $alias = '']]) + .. php:method:: select_min([$select = ''[, $alias = '']]) :param string $select: Field to compute the minimum of :param string $alias: Alias for the resulting value name @@ -1158,7 +1158,7 @@ Class Reference Adds a SELECT MIN(field) clause to a query. - .. method:: select_sum([$select = ''[, $alias = '']]) + .. php:method:: select_sum([$select = ''[, $alias = '']]) :param string $select: Field to compute the sum of :param string $alias: Alias for the resulting value name @@ -1167,7 +1167,7 @@ Class Reference Adds a SELECT SUM(field) clause to a query. - .. method:: distinct([$val = TRUE]) + .. php:method:: distinct([$val = TRUE]) :param bool $val: Desired value of the "distinct" flag :returns: CI_DB_query_builder instance (method chaining) @@ -1176,7 +1176,7 @@ Class Reference Sets a flag which tells the query builder to add a DISTINCT clause to the SELECT portion of the query. - .. method:: from($from) + .. php:method:: from($from) :param mixed $from: Table name(s); string or array :returns: CI_DB_query_builder instance (method chaining) @@ -1184,7 +1184,7 @@ Class Reference Specifies the FROM clause of a query. - .. method:: join($table, $cond[, $type = ''[, $escape = NULL]]) + .. php:method:: join($table, $cond[, $type = ''[, $escape = NULL]]) :param string $table: Table name to join :param string $cond: The JOIN ON condition @@ -1195,7 +1195,7 @@ Class Reference Adds a JOIN clause to a query. - .. method:: where($key[, $value = NULL[, $escape = NULL]]) + .. php:method:: where($key[, $value = NULL[, $escape = NULL]]) :param mixed $key: Name of field to compare, or associative array :param mixed $value: If a single key, compared to this value @@ -1206,7 +1206,7 @@ Class Reference Generates the WHERE portion of the query. Separates multiple calls with 'AND'. - .. method:: or_where($key[, $value = NULL[, $escape = NULL]]) + .. php:method:: or_where($key[, $value = NULL[, $escape = NULL]]) :param mixed $key: Name of field to compare, or associative array :param mixed $value: If a single key, compared to this value @@ -1217,7 +1217,7 @@ Class Reference Generates the WHERE portion of the query. Separates multiple calls with 'OR'. - .. method:: or_where_in([$key = NULL[, $values = NULL[, $escape = NULL]]]) + .. php:method:: or_where_in([$key = NULL[, $values = NULL[, $escape = NULL]]]) :param string $key: The field to search :param array $values: The values searched on @@ -1228,7 +1228,7 @@ Class Reference Generates a WHERE field IN('item', 'item') SQL query, joined with 'OR' if appropriate. - .. method:: or_where_not_in([$key = NULL[, $values = NULL[, $escape = NULL]]]) + .. php:method:: or_where_not_in([$key = NULL[, $values = NULL[, $escape = NULL]]]) :param string $key: The field to search :param array $values: The values searched on @@ -1239,7 +1239,7 @@ Class Reference Generates a WHERE field NOT IN('item', 'item') SQL query, joined with 'OR' if appropriate. - .. method:: where_in([$key = NULL[, $values = NULL[, $escape = NULL]]]) + .. php:method:: where_in([$key = NULL[, $values = NULL[, $escape = NULL]]]) :param string $key: Name of field to examine :param array $values: Array of target values @@ -1250,7 +1250,7 @@ Class Reference Generates a WHERE field IN('item', 'item') SQL query, joined with 'AND' if appropriate. - .. method:: where_not_in([$key = NULL[, $values = NULL[, $escape = NULL]]]) + .. php:method:: where_not_in([$key = NULL[, $values = NULL[, $escape = NULL]]]) :param string $key: Name of field to examine :param array $values: Array of target values @@ -1261,42 +1261,42 @@ Class Reference Generates a WHERE field NOT IN('item', 'item') SQL query, joined with 'AND' if appropriate. - .. method:: group_start() + .. php:method:: group_start() :returns: CI_DB_query_builder instance (method chaining) :rtype: CI_DB_query_builder Starts a group expression, using ANDs for the conditions inside it. - .. method:: or_group_start() + .. php:method:: or_group_start() :returns: CI_DB_query_builder instance (method chaining) :rtype: CI_DB_query_builder Starts a group expression, using ORs for the conditions inside it. - .. method:: not_group_start() + .. php:method:: not_group_start() :returns: CI_DB_query_builder instance (method chaining) :rtype: CI_DB_query_builder Starts a group expression, using AND NOTs for the conditions inside it. - .. method:: or_not_group_start() + .. php:method:: or_not_group_start() :returns: CI_DB_query_builder instance (method chaining) :rtype: CI_DB_query_builder Starts a group expression, using OR NOTs for the conditions inside it. - .. method:: group_end() + .. php:method:: group_end() :returns: DB_query_builder instance :rtype: object Ends a group expression. - .. method:: like($field[, $match = ''[, $side = 'both'[, $escape = NULL]]]) + .. php:method:: like($field[, $match = ''[, $side = 'both'[, $escape = NULL]]]) :param string $field: Field name :param string $match: Text portion to match @@ -1307,7 +1307,7 @@ Class Reference Adds a LIKE clause to a query, separating multiple calls with AND. - .. method:: or_like($field[, $match = ''[, $side = 'both'[, $escape = NULL]]]) + .. php:method:: or_like($field[, $match = ''[, $side = 'both'[, $escape = NULL]]]) :param string $field: Field name :param string $match: Text portion to match @@ -1318,7 +1318,7 @@ Class Reference Adds a LIKE clause to a query, separating multiple class with OR. - .. method:: not_like($field[, $match = ''[, $side = 'both'[, $escape = NULL]]]) + .. php:method:: not_like($field[, $match = ''[, $side = 'both'[, $escape = NULL]]]) :param string $field: Field name :param string $match: Text portion to match @@ -1329,7 +1329,7 @@ Class Reference Adds a NOT LIKE clause to a query, separating multiple calls with AND. - .. method:: or_not_like($field[, $match = ''[, $side = 'both'[, $escape = NULL]]]) + .. php:method:: or_not_like($field[, $match = ''[, $side = 'both'[, $escape = NULL]]]) :param string $field: Field name :param string $match: Text portion to match @@ -1340,7 +1340,7 @@ Class Reference Adds a NOT LIKE clause to a query, separating multiple calls with OR. - .. method:: having($key[, $value = NULL[, $escape = NULL]]) + .. php:method:: having($key[, $value = NULL[, $escape = NULL]]) :param mixed $key: Identifier (string) or associative array of field/value pairs :param string $value: Value sought if $key is an identifier @@ -1350,7 +1350,7 @@ Class Reference Adds a HAVING clause to a query, separating multiple calls with AND. - .. method:: or_having($key[, $value = NULL[, $escape = NULL]]) + .. php:method:: or_having($key[, $value = NULL[, $escape = NULL]]) :param mixed $key: Identifier (string) or associative array of field/value pairs :param string $value: Value sought if $key is an identifier @@ -1360,7 +1360,7 @@ Class Reference Adds a HAVING clause to a query, separating multiple calls with OR. - .. method:: group_by($by[, $escape = NULL]) + .. php:method:: group_by($by[, $escape = NULL]) :param mixed $by: Field(s) to group by; string or array :returns: CI_DB_query_builder instance (method chaining) @@ -1368,7 +1368,7 @@ Class Reference Adds a GROUP BY clause to a query. - .. method:: order_by($orderby[, $direction = ''[, $escape = NULL]]) + .. php:method:: order_by($orderby[, $direction = ''[, $escape = NULL]]) :param string $orderby: Field to order by :param string $direction: The order requested - ASC, DESC or random @@ -1378,7 +1378,7 @@ Class Reference Adds an ORDER BY clause to a query. - .. method:: limit($value[, $offset = 0]) + .. php:method:: limit($value[, $offset = 0]) :param int $value: Number of rows to limit the results to :param int $offset: Number of rows to skip @@ -1387,7 +1387,7 @@ Class Reference Adds LIMIT and OFFSET clauses to a query. - .. method:: offset($offset) + .. php:method:: offset($offset) :param int $offset: Number of rows to skip :returns: CI_DB_query_builder instance (method chaining) @@ -1395,7 +1395,7 @@ Class Reference Adds an OFFSET clause to a query. - .. method:: set($key[, $value = ''[, $escape = NULL]]) + .. php:method:: set($key[, $value = ''[, $escape = NULL]]) :param mixed $key: Field name, or an array of field/value pairs :param string $value: Field value, if $key is a single field @@ -1406,7 +1406,7 @@ Class Reference Adds field/value pairs to be passed later to ``insert()``, ``update()`` or ``replace()``. - .. method:: insert([$table = ''[, $set = NULL[, $escape = NULL]]]) + .. php:method:: insert([$table = ''[, $set = NULL[, $escape = NULL]]]) :param string $table: Table name :param array $set: An associative array of field/value pairs @@ -1416,7 +1416,7 @@ Class Reference Compiles and executes an INSERT statement. - .. method:: insert_batch([$table = ''[, $set = NULL[, $escape = NULL]]]) + .. php:method:: insert_batch([$table = ''[, $set = NULL[, $escape = NULL]]]) :param string $table: Table name :param array $set: Data to insert @@ -1426,7 +1426,7 @@ Class Reference Compiles and executes batch INSERT statements. - .. method:: set_insert_batch($key[, $value = ''[, $escape = NULL]]) + .. php:method:: set_insert_batch($key[, $value = ''[, $escape = NULL]]) :param mixed $key: Field name or an array of field/value pairs :param string $value: Field value, if $key is a single field @@ -1436,7 +1436,7 @@ Class Reference Adds field/value pairs to be inserted in a table later via ``insert_batch()``. - .. method:: update([$table = ''[, $set = NULL[, $where = NULL[, $limit = NULL]]]]) + .. php:method:: update([$table = ''[, $set = NULL[, $where = NULL[, $limit = NULL]]]]) :param string $table: Table name :param array $set: An associative array of field/value pairs @@ -1447,7 +1447,7 @@ Class Reference Compiles and executes an UPDATE statement. - .. method:: update_batch([$table = ''[, $set = NULL[, $value = NULL]]]) + .. php:method:: update_batch([$table = ''[, $set = NULL[, $value = NULL]]]) :param string $table: Table name :param array $set: Field name, or an associative array of field/value pairs @@ -1457,7 +1457,7 @@ Class Reference Compiles and executes batch UPDATE statements. - .. method:: set_update_batch($key[, $value = ''[, $escape = NULL]]) + .. php:method:: set_update_batch($key[, $value = ''[, $escape = NULL]]) :param mixed $key: Field name or an array of field/value pairs :param string $value: Field value, if $key is a single field @@ -1467,7 +1467,7 @@ Class Reference Adds field/value pairs to be updated in a table later via ``update_batch()``. - .. method:: replace([$table = ''[, $set = NULL]]) + .. php:method:: replace([$table = ''[, $set = NULL]]) :param string $table: Table name :param array $set: An associative array of field/value pairs @@ -1476,7 +1476,7 @@ Class Reference Compiles and executes a REPLACE statement. - .. method:: delete([$table = ''[, $where = ''[, $limit = NULL[, $reset_data = TRUE]]]]) + .. php:method:: delete([$table = ''[, $where = ''[, $limit = NULL[, $reset_data = TRUE]]]]) :param mixed $table: The table(s) to delete from; string or array :param string $where: The WHERE clause @@ -1487,7 +1487,7 @@ Class Reference Compiles and executes a DELETE query. - .. method:: truncate([$table = '']) + .. php:method:: truncate([$table = '']) :param string $table: Table name :returns: TRUE on success, FALSE on failure @@ -1498,7 +1498,7 @@ Class Reference .. note:: If the database platform in use doesn't support TRUNCATE, a DELETE statement will be used instead. - .. method:: empty_table([$table = '']) + .. php:method:: empty_table([$table = '']) :param string $table: Table name :returns: TRUE on success, FALSE on failure @@ -1506,7 +1506,7 @@ Class Reference Deletes all records from a table via a DELETE statement. - .. method:: get_compiled_select([$table = ''[, $reset = TRUE]]) + .. php:method:: get_compiled_select([$table = ''[, $reset = TRUE]]) :param string $table: Table name :param bool $reset: Whether to reset the current QB values or not @@ -1515,7 +1515,7 @@ Class Reference Compiles a SELECT statement and returns it as a string. - .. method:: get_compiled_insert([$table = ''[, $reset = TRUE]]) + .. php:method:: get_compiled_insert([$table = ''[, $reset = TRUE]]) :param string $table: Table name :param bool $reset: Whether to reset the current QB values or not @@ -1524,7 +1524,7 @@ Class Reference Compiles an INSERT statement and returns it as a string. - .. method:: get_compiled_update([$table = ''[, $reset = TRUE]]) + .. php:method:: get_compiled_update([$table = ''[, $reset = TRUE]]) :param string $table: Table name :param bool $reset: Whether to reset the current QB values or not @@ -1533,7 +1533,7 @@ Class Reference Compiles an UPDATE statement and returns it as a string. - .. method:: get_compiled_delete([$table = ''[, $reset = TRUE]]) + .. php:method:: get_compiled_delete([$table = ''[, $reset = TRUE]]) :param string $table: Table name :param bool $reset: Whether to reset the current QB values or not diff --git a/user_guide_src/source/database/results.rst b/user_guide_src/source/database/results.rst index ae81998c7..a22c2e8c3 100644 --- a/user_guide_src/source/database/results.rst +++ b/user_guide_src/source/database/results.rst @@ -245,9 +245,9 @@ TRUE on success or FALSE on failure. Class Reference *************** -.. class:: CI_DB_result +.. php:class:: CI_DB_result - .. method:: result([$type = 'object']) + .. php:method:: result([$type = 'object']) :param string $type: Type of requested results - array, object, or class name :returns: Array containing the fetched rows @@ -258,7 +258,7 @@ Class Reference Usage: see `Result Arrays`_. - .. method:: result_array() + .. php:method:: result_array() :returns: Array containing the fetched rows :rtype: array @@ -268,7 +268,7 @@ Class Reference Usage: see `Result Arrays`_. - .. method:: result_object() + .. php:method:: result_object() :returns: Array containing the fetched rows :rtype: array @@ -278,7 +278,7 @@ Class Reference Usage: see `Result Arrays`_. - .. method:: custom_result_object($class_name) + .. php:method:: custom_result_object($class_name) :param string $class_name: Class name for the resulting rows :returns: Array containing the fetched rows @@ -287,7 +287,7 @@ Class Reference Returns the query results as an array of rows, where each row is an instance of the specified class. - .. method:: row([$n = 0[, $type = 'object']]) + .. php:method:: row([$n = 0[, $type = 'object']]) :param int $n: Index of the query results row to be returned :param string $type: Type of the requested result - array, object, or class name @@ -299,7 +299,7 @@ Class Reference Usage: see `Result Rows`_. - .. method:: unbuffered_row([$type = 'object']) + .. php:method:: unbuffered_row([$type = 'object']) :param string $type: Type of the requested result - array, object, or class name :returns: Next row from the result set or NULL if it doesn't exist @@ -310,7 +310,7 @@ Class Reference Usage: see `Result Rows`_. - .. method:: row_array([$n = 0]) + .. php:method:: row_array([$n = 0]) :param int $n: Index of the query results row to be returned :returns: The requested row or NULL if it doesn't exist @@ -320,7 +320,7 @@ Class Reference Usage: see `Result Rows`_. - .. method:: row_object([$n = 0]) + .. php:method:: row_object([$n = 0]) :param int $n: Index of the query results row to be returned :returns: The requested row or NULL if it doesn't exist @@ -331,7 +331,7 @@ Class Reference Usage: see `Result Rows`_. - .. method:: custom_row_object($n, $type) + .. php:method:: custom_row_object($n, $type) :param int $n: Index of the results row to return :param string $class_name: Class name for the resulting row @@ -341,7 +341,7 @@ Class Reference Returns the requested result row as an instance of the requested class. - .. method:: data_seek([$n = 0]) + .. php:method:: data_seek([$n = 0]) :param int $n: Index of the results row to be returned next :returns: TRUE on success, FALSE on failure @@ -351,7 +351,7 @@ Class Reference Usage: see `Result Helper Methods`_. - .. method:: set_row($key[, $value = NULL]) + .. php:method:: set_row($key[, $value = NULL]) :param mixed $key: Column name or array of key/value pairs :param mixed $value: Value to assign to the column, $key is a single field name @@ -359,7 +359,7 @@ Class Reference Assigns a value to a particular column. - .. method:: next_row([$type = 'object']) + .. php:method:: next_row([$type = 'object']) :param string $type: Type of the requested result - array, object, or class name :returns: Next row of result set, or NULL if it doesn't exist @@ -367,7 +367,7 @@ Class Reference Returns the next row from the result set. - .. method:: previous_row([$type = 'object']) + .. php:method:: previous_row([$type = 'object']) :param string $type: Type of the requested result - array, object, or class name :returns: Previous row of result set, or NULL if it doesn't exist @@ -375,7 +375,7 @@ Class Reference Returns the previous row from the result set. - .. method:: first_row([$type = 'object']) + .. php:method:: first_row([$type = 'object']) :param string $type: Type of the requested result - array, object, or class name :returns: First row of result set, or NULL if it doesn't exist @@ -383,7 +383,7 @@ Class Reference Returns the first row from the result set. - .. method:: last_row([$type = 'object']) + .. php:method:: last_row([$type = 'object']) :param string $type: Type of the requested result - array, object, or class name :returns: Last row of result set, or NULL if it doesn't exist @@ -391,7 +391,7 @@ Class Reference Returns the last row from the result set. - .. method:: num_rows() + .. php:method:: num_rows() :returns: Number of rows in the result set :rtype: int @@ -400,7 +400,7 @@ Class Reference Usage: see `Result Helper Methods`_. - .. method:: num_fields() + .. php:method:: num_fields() :returns: Number of fields in the result set :rtype: int @@ -409,7 +409,7 @@ Class Reference Usage: see `Result Helper Methods`_. - .. method:: field_data() + .. php:method:: field_data() :returns: Array containing field meta-data :rtype: array @@ -417,7 +417,7 @@ Class Reference Generates an array of ``stdClass`` objects containing field meta-data. - .. method:: free_result() + .. php:method:: free_result() :rtype: void @@ -425,7 +425,7 @@ Class Reference Usage: see `Result Helper Methods`_. - .. method:: list_fields() + .. php:method:: list_fields() :returns: Array of column names :rtype: array diff --git a/user_guide_src/source/database/utilities.rst b/user_guide_src/source/database/utilities.rst index 0d8137dd7..2da1f981d 100644 --- a/user_guide_src/source/database/utilities.rst +++ b/user_guide_src/source/database/utilities.rst @@ -247,9 +247,9 @@ Preference Default Value Options Descript Class Reference *************** -.. class:: CI_DB_utility +.. php:class:: CI_DB_utility - .. method:: backup([$params = array()]) + .. php:method:: backup([$params = array()]) :param array $params: An associative array of options :returns: void @@ -257,7 +257,7 @@ Class Reference Perform a database backup, per user preferences. - .. method:: database_exists($database_name) + .. php:method:: database_exists($database_name) :param string $database_name: Database name :returns: TRUE if the database exists, FALSE otherwise @@ -265,21 +265,21 @@ Class Reference Check for the existence of a database. - .. method:: list_databases() + .. php:method:: list_databases() :returns: Array of database names found :rtype: array Retrieve a list of all the database names. - .. method:: optimize_database() + .. php:method:: optimize_database() :returns: Array of optimization messages or FALSE on failure :rtype: array Optimizes the database. - .. method:: optimize_table($table_name) + .. php:method:: optimize_table($table_name) :param string $table_name: Name of the table to optimize :returns: Array of optimization messages or FALSE on failure @@ -287,7 +287,7 @@ Class Reference Optimizes a database table. - .. method:: repair_table($table_name) + .. php:method:: repair_table($table_name) :param string $table_name: Name of the table to repair :returns: Array of repair messages or FALSE on failure @@ -295,7 +295,7 @@ Class Reference Repairs a database table. - .. method:: csv_from_results($query[, $delim = ','[, $newline = "\n"[, $enclosure = '"']]]) + .. php:method:: csv_from_results($query[, $delim = ','[, $newline = "\n"[, $enclosure = '"']]]) :param object $query: A database result object :param string $delim: The CSV field delimiter to use @@ -306,7 +306,7 @@ Class Reference Translates a database result object into a CSV document. - .. method:: xml_from_results($query[, $params = array()]) + .. php:method:: xml_from_results($query[, $params = array()]) :param object $query: A database result object :param array $params: An associative array of preferences diff --git a/user_guide_src/source/documentation/index.rst b/user_guide_src/source/documentation/index.rst index 6d4c94bc1..60c6b4ed6 100644 --- a/user_guide_src/source/documentation/index.rst +++ b/user_guide_src/source/documentation/index.rst @@ -115,9 +115,9 @@ For example, consider the following ReST: .. code-block:: rst - .. class:: Some_class + .. php:class:: Some_class - .. method:: some_method ( $foo [, $bar [, $bat]]) + .. php:method:: some_method ( $foo [, $bar [, $bat]]) This function will perform some action. The ``$bar`` array must contain a something and something else, and along with ``$bat`` is an optional @@ -151,7 +151,7 @@ For example, consider the following ReST: See also :meth:`Some_class::should_do_something` - .. method:: should_do_something() + .. php:method:: should_do_something() :returns: Whether or not something should be done :rtype: bool @@ -159,10 +159,10 @@ For example, consider the following ReST: It creates the following display: -.. class:: Some_class +.. php:class:: Some_class - .. method:: some_method ( $foo [, $bar [, $bat]]) + .. php:method:: some_method ( $foo [, $bar [, $bat]]) This function will perform some action. The ``$bar`` array must contain a something and something else, and along with ``$bat`` is an optional @@ -196,7 +196,7 @@ It creates the following display: See also :meth:`Some_class::should_do_something` - .. method:: should_do_something() + .. php:method:: should_do_something() :returns: Whether or not something should be done :rtype: bool
\ No newline at end of file diff --git a/user_guide_src/source/general/ancillary_classes.rst b/user_guide_src/source/general/ancillary_classes.rst index f9b6ba231..6a64742ce 100644 --- a/user_guide_src/source/general/ancillary_classes.rst +++ b/user_guide_src/source/general/ancillary_classes.rst @@ -9,7 +9,7 @@ resources. This is easily possible as you'll see. get_instance() ============== -.. function:: get_instance() +.. php:function:: get_instance() :returns: object of class CI_Controller @@ -52,7 +52,7 @@ Once you've assigned the object to a variable, you'll use that variable This is very important. Assigning by reference allows you to use the original CodeIgniter object rather than creating a copy of it. -Furthermore, if you'll be using ``get_intance()`` inside anoter class, +Furthermore, if you'll be using ``get_instance()`` inside another class, then it would be better if you assign it to a property. This way, you won't need to call ``get_instance()`` in every single method. diff --git a/user_guide_src/source/general/cli.rst b/user_guide_src/source/general/cli.rst index 4f3b07d9e..b45be1aa8 100644 --- a/user_guide_src/source/general/cli.rst +++ b/user_guide_src/source/general/cli.rst @@ -23,7 +23,7 @@ but they are not always obvious. - Run your cron-jobs without needing to use *wget* or *curl* - Make your cron-jobs inaccessible from being loaded in the URL by - checking the return value of :func:`is_cli()`. + checking the return value of :php:func:`is_cli()`. - Make interactive "tasks" that can do things like set permissions, prune cache folders, run backups, etc. - Integrate with other applications in other languages. For example, a diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst index 399a323cc..6d6744cf7 100644 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -13,7 +13,7 @@ loading any libraries or helpers. <div class="custom-index container"></div> -.. function:: is_php($version) +.. php:function:: is_php($version) :param string $version: Version number :returns: TRUE if the running PHP version is at least the one specified or FALSE if not @@ -33,7 +33,7 @@ loading any libraries or helpers. greater than the supplied version number. Returns FALSE if the installed version of PHP is lower than the supplied version number. -.. function:: is_really_writable($file) +.. php:function:: is_really_writable($file) :param string $file: File path :returns: TRUE if the path is writable, FALSE if not @@ -60,7 +60,7 @@ loading any libraries or helpers. .. note:: See also `PHP bug #54709 <https://bugs.php.net/bug.php?id=54709>`_ for more info. -.. function:: config_item($key) +.. php:function:: config_item($key) :param string $key: Config item key :returns: Configuration key value or NULL if not found @@ -99,7 +99,7 @@ loading any libraries or helpers. This function is an alias for ``CI_Log::write_log()``. For more info, please see the :doc:`Error Handling <errors>` documentation. -.. function:: set_status_header($code[, $text = '']) +.. php:function:: set_status_header($code[, $text = '']) :param int $code: HTTP Reponse status code :param string $text: A custom message to set with the status code @@ -113,7 +113,7 @@ loading any libraries or helpers. `See here <http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html>`_ for a full list of headers. -.. function:: remove_invisible_characters($str[, $url_encoded = TRUE]) +.. php:function:: remove_invisible_characters($str[, $url_encoded = TRUE]) :param string $str: Input string :param bool $url_encoded: Whether to remove URL-encoded characters as well @@ -128,7 +128,7 @@ loading any libraries or helpers. remove_invisible_characters('Java\\0script'); // Returns: 'Javascript' -.. function:: html_escape($var) +.. php:function:: html_escape($var) :param mixed $var: Variable to escape (string or array) :returns: HTML escaped string(s) @@ -139,7 +139,7 @@ loading any libraries or helpers. It is useful in preventing Cross Site Scripting (XSS). -.. function:: get_mimes() +.. php:function:: get_mimes() :returns: An associative array of file types :rtype: array @@ -147,7 +147,7 @@ loading any libraries or helpers. This function returns a *reference* to the MIMEs array from *application/config/mimes.php*. -.. function:: is_https() +.. php:function:: is_https() :returns: TRUE if currently using HTTP-over-SSL, FALSE if not :rtype: bool @@ -155,7 +155,7 @@ loading any libraries or helpers. Returns TRUE if a secure (HTTPS) connection is used and FALSE in any other case (including non-HTTP requests). -.. function:: is_cli() +.. php:function:: is_cli() :returns: TRUE if currently running under CLI, FALSE otherwise :rtype: bool @@ -166,7 +166,7 @@ loading any libraries or helpers. .. note:: This function checks both if the ``PHP_SAPI`` value is 'cli' or if the ``STDIN`` constant is defined. -.. function:: function_usable($function_name) +.. php:function:: function_usable($function_name) :param string $function_name: Function name :returns: TRUE if the function can be used, FALSE if not diff --git a/user_guide_src/source/general/compatibility_functions.rst b/user_guide_src/source/general/compatibility_functions.rst index aee9b1ef0..434b0982f 100644 --- a/user_guide_src/source/general/compatibility_functions.rst +++ b/user_guide_src/source/general/compatibility_functions.rst @@ -44,7 +44,7 @@ Constants Function reference ================== -.. function:: password_get_info($hash) +.. php:function:: password_get_info($hash) :param string $hash: Password hash :returns: Information about the hashed password @@ -53,7 +53,7 @@ Function reference For more information, please refer to the `PHP manual for password_get_info() <http://php.net/password_get_info>`_. -.. function:: password_hash($password, $algo[, $options = array()]) +.. php:function:: password_hash($password, $algo[, $options = array()]) :param string $password: Plain-text password :param int $algo: Hashing algorithm @@ -72,7 +72,7 @@ Function reference - /dev/arandom - /dev/urandom -.. function:: password_needs_rehash() +.. php:function:: password_needs_rehash() :param string $hash: Password hash :param int $algo: Hashing algorithm @@ -83,7 +83,7 @@ Function reference For more information, please refer to the `PHP manual for password_needs_rehash() <http://php.net/password_needs_rehash>`_. -.. function:: password_verify($password, $hash) +.. php:function:: password_verify($password, $hash) :param string $password: Plain-text password :param string $hash: Password hash @@ -109,7 +109,7 @@ Dependencies Function reference ================== -.. function:: hash_equals($known_string, $user_string) +.. php:function:: hash_equals($known_string, $user_string) :param string $known_string: Known string :param string $user_string: User-supplied string @@ -119,7 +119,7 @@ Function reference For more information, please refer to the `PHP manual for hash_equals() <http://php.net/hash_equals>`_. -.. function:: hash_pbkdf2($algo, $password, $salt, $iterations[, $length = 0[, $raw_output = FALSE]]) +.. php:function:: hash_pbkdf2($algo, $password, $salt, $iterations[, $length = 0[, $raw_output = FALSE]]) :param string $algo: Hashing algorithm :param string $password: Password @@ -162,7 +162,7 @@ Dependencies Function reference ================== -.. function:: mb_strlen($str[, $encoding = NULL]) +.. php:function:: mb_strlen($str[, $encoding = NULL]) :param string $str: Input string :param string $encoding: Character set @@ -172,7 +172,7 @@ Function reference For more information, please refer to the `PHP manual for mb_strlen() <http://php.net/mb_strlen>`_. -.. function:: mb_strpos($haystack, $needle[, $offset = 0[, $encoding = NULL]]) +.. php:function:: mb_strpos($haystack, $needle[, $offset = 0[, $encoding = NULL]]) :param string $haystack: String to search in :param string $needle: Part of string to search for @@ -184,7 +184,7 @@ Function reference For more information, please refer to the `PHP manual for mb_strpos() <http://php.net/mb_strpos>`_. -.. function:: mb_substr($str, $start[, $length = NULL[, $encoding = NULL]]) +.. php:function:: mb_substr($str, $start[, $length = NULL[, $encoding = NULL]]) :param string $str: Input string :param int $start: Position of first character @@ -211,7 +211,7 @@ Dependencies Function reference ================== -.. function:: array_column(array $array, $column_key[, $index_key = NULL]) +.. php:function:: array_column(array $array, $column_key[, $index_key = NULL]) :param array $array: Array to fetch results from :param mixed $column_key: Key of the column to return values from @@ -222,7 +222,7 @@ Function reference For more information, please refer to the `PHP manual for array_column() <http://php.net/array_column>`_. -.. function:: array_replace(array $array1[, ...]) +.. php:function:: array_replace(array $array1[, ...]) :param array $array1: Array in which to replace elements :param array ...: Array (or multiple ones) from which to extract elements @@ -232,7 +232,7 @@ Function reference For more information, please refer to the `PHP manual for array_replace() <http://php.net/array_replace>`_. -.. function:: array_replace_recursive(array $array1[, ...]) +.. php:function:: array_replace_recursive(array $array1[, ...]) :param array $array1: Array in which to replace elements :param array ...: Array (or multiple ones) from which to extract elements @@ -245,7 +245,7 @@ Function reference .. important:: Only PHP's native function can detect endless recursion. Unless you are running PHP 5.3+, be careful with references! -.. function:: hex2bin($data) +.. php:function:: hex2bin($data) :param array $data: Hexadecimal representation of data :returns: Binary representation of the given data @@ -254,7 +254,7 @@ Function reference For more information, please refer to the `PHP manual for hex2bin() <http://php.net/hex2bin>`_. -.. function:: quoted_printable_encode($str) +.. php:function:: quoted_printable_encode($str) :param string $str: Input string :returns: 8bit-encoded string diff --git a/user_guide_src/source/general/creating_libraries.rst b/user_guide_src/source/general/creating_libraries.rst index 0e3ae4c85..d6b0631af 100644 --- a/user_guide_src/source/general/creating_libraries.rst +++ b/user_guide_src/source/general/creating_libraries.rst @@ -54,8 +54,6 @@ Classes should have this basic prototype:: } } - /* End of file Someclass.php */ - .. note:: We are using the name Someclass purely as an example. Using Your Class diff --git a/user_guide_src/source/general/credits.rst b/user_guide_src/source/general/credits.rst index 371808fe4..d22e3a9bc 100644 --- a/user_guide_src/source/general/credits.rst +++ b/user_guide_src/source/general/credits.rst @@ -12,7 +12,7 @@ It was, for years, developed and maintained by EllisLab, the ExpressionEngine Development Team and a group of community members called the Reactor Team. In 2014, CodeIgniter was acquired by the `British Columbia Institute of Technology -<http://bcit.ca/>`_ and was then officially announced as a community-maintaned +<http://bcit.ca/>`_ and was then officially announced as a community-maintained project. Bleeding edge development is spearheaded by the handpicked contributors diff --git a/user_guide_src/source/general/errors.rst b/user_guide_src/source/general/errors.rst index 26c26bea1..9c190feb1 100644 --- a/user_guide_src/source/general/errors.rst +++ b/user_guide_src/source/general/errors.rst @@ -29,84 +29,93 @@ software keep track of your scripts and the health of your application. The following functions let you generate errors: -.. function:: show_error($message, $status_code, $heading = 'An Error Was Encountered') +.. php:function:: show_error($message, $status_code, $heading = 'An Error Was Encountered') :param mixed $message: Error message :param int $status_code: HTTP Response status code :param string $heading: Error page heading :rtype: void -This function will display the error message supplied to it using the -following error template:: + This function will display the error message supplied to it using + the error template appropriate to your execution:: - application/views/errors/error_general.php + application/views/errors/html/error_general.php -The optional parameter ``$status_code`` determines what HTTP status -code should be sent with the error. If ``$status_code`` is less than 100, -the HTTP status code will be set to 500, and the exit status code will -be set to ``$status_code + EXIT__AUTO_MIN``. If that value is larger than -``EXIT__AUTO_MAX``, or if ``$status_code`` is 100 or higher, the exit -status code will be set to ``EXIT_ERROR``. You can check in -*application/config/constants.php* for more detail. + or: -.. function:: show_404($page = '', $log_error = TRUE) + application/views/errors/cli/error_general.php + + The optional parameter ``$status_code`` determines what HTTP status + code should be sent with the error. If ``$status_code`` is less + than 100, the HTTP status code will be set to 500, and the exit + status code will be set to ``$status_code + EXIT__AUTO_MIN``. + If that value is larger than ``EXIT__AUTO_MAX``, or if + ``$status_code`` is 100 or higher, the exit status code will be set + to ``EXIT_ERROR``. + You can check in *application/config/constants.php* for more detail. + +.. php:function:: show_404($page = '', $log_error = TRUE) :param string $page: URI string :param bool $log_error: Whether to log the error :rtype: void -This function will display the 404 error message supplied to it using -the following error template:: + This function will display the 404 error message supplied to it + using the error template appropriate to your execution:: + + application/views/errors/html/error_404.php + + or: - application/views/errors/error_404.php + application/views/errors/cli/error_404.php -The function expects the string passed to it to be the file path to the -page that isn't found. The exit status code will be set to ``EXIT_UNKNOWN_FILE``. -Note that CodeIgniter automatically shows 404 messages if controllers are -not found. + The function expects the string passed to it to be the file path to + the page that isn't found. The exit status code will be set to + ``EXIT_UNKNOWN_FILE``. + Note that CodeIgniter automatically shows 404 messages if + controllers are not found. -CodeIgniter automatically logs any ``show_404()`` calls. Setting the -optional second parameter to FALSE will skip logging. + CodeIgniter automatically logs any ``show_404()`` calls. Setting the + optional second parameter to FALSE will skip logging. -.. function:: log_message($level, $message, $php_error = FALSE) +.. php:function:: log_message($level, $message, $php_error = FALSE) :param string $level: Log level: 'error', 'debug' or 'info' :param string $message: Message to log :param bool $php_error: Whether we're logging a native PHP error message :rtype: void -This function lets you write messages to your log files. You must supply -one of three "levels" in the first parameter, indicating what type of -message it is (debug, error, info), with the message itself in the -second parameter. - -Example:: - - if ($some_var == '') - { - log_message('error', 'Some variable did not contain a value.'); - } - else - { - log_message('debug', 'Some variable was correctly set'); - } - - log_message('info', 'The purpose of some variable is to provide some value.'); - -There are three message types: - -#. Error Messages. These are actual errors, such as PHP errors or user - errors. -#. Debug Messages. These are messages that assist in debugging. For - example, if a class has been initialized, you could log this as - debugging info. -#. Informational Messages. These are the lowest priority messages, - simply giving information regarding some process. CodeIgniter doesn't - natively generate any info messages but you may want to in your - application. - -.. note:: In order for the log file to actually be written, the *logs* - directory must be writable. In addition, you must set the "threshold" - for logging in *application/config/config.php*. You might, for example, - only want error messages to be logged, and not the other two types. - If you set it to zero logging will be disabled.
\ No newline at end of file + This function lets you write messages to your log files. You must + supply one of three "levels" in the first parameter, indicating what + type of message it is (debug, error, info), with the message itself + in the second parameter. + + Example:: + + if ($some_var == '') + { + log_message('error', 'Some variable did not contain a value.'); + } + else + { + log_message('debug', 'Some variable was correctly set'); + } + + log_message('info', 'The purpose of some variable is to provide some value.'); + + There are three message types: + + #. Error Messages. These are actual errors, such as PHP errors or + user errors. + #. Debug Messages. These are messages that assist in debugging. For + example, if a class has been initialized, you could log this as + debugging info. + #. Informational Messages. These are the lowest priority messages, + simply giving information regarding some process. + + .. note:: In order for the log file to actually be written, the + *logs/* directory must be writable. In addition, you must + set the "threshold" for logging in + *application/config/config.php*. You might, for example, + only want error messages to be logged, and not the other + two types. If you set it to zero logging will be disabled. diff --git a/user_guide_src/source/general/requirements.rst b/user_guide_src/source/general/requirements.rst index 1cb5938aa..e3f73dba8 100644 --- a/user_guide_src/source/general/requirements.rst +++ b/user_guide_src/source/general/requirements.rst @@ -2,10 +2,15 @@ Server Requirements ################### -- `PHP <http://www.php.net/>`_ version 5.4 or newer is recommended and 5.2.4 as the absolute minimum required. -- A Database is required for most web application programming. +`PHP <http://www.php.net/>`_ version 5.4 or newer is recommended. + +It should work on 5.2.4 as well, but we strongly advise you NOT to run +such old versions of PHP, because of potential security and performance +issues, as well as missing features. + +A database is required for most web application programming. +Currently supported databases are: - Currently supported databases are: - MySQL (5.1+) via the *mysql* (deprecated), *mysqli* and *pdo* drivers - Oracle via the *oci8* and *pdo* drivers - PostgreSQL via the *postgre* and *pdo* drivers diff --git a/user_guide_src/source/general/reserved_names.rst b/user_guide_src/source/general/reserved_names.rst index 9da94b398..a7b0c3465 100644 --- a/user_guide_src/source/general/reserved_names.rst +++ b/user_guide_src/source/general/reserved_names.rst @@ -23,22 +23,22 @@ your controller any of these: Functions --------- -- :func:`is_php()` -- :func:`is_really_writable()` +- :php:func:`is_php()` +- :php:func:`is_really_writable()` - ``load_class()`` - ``is_loaded()`` - ``get_config()`` -- :func:`config_item()` -- :func:`show_error()` -- :func:`show_404()` -- :func:`log_message()` -- :func:`set_status_header()` -- :func:`get_mimes()` -- :func:`html_escape()` -- :func:`remove_invisible_characters()` -- :func:`is_https()` -- :func:`function_usable()` -- :func:`get_instance()` +- :php:func:`config_item()` +- :php:func:`show_error()` +- :php:func:`show_404()` +- :php:func:`log_message()` +- :php:func:`set_status_header()` +- :php:func:`get_mimes()` +- :php:func:`html_escape()` +- :php:func:`remove_invisible_characters()` +- :php:func:`is_https()` +- :php:func:`function_usable()` +- :php:func:`get_instance()` - ``_error_handler()`` - ``_exception_handler()`` - ``_stringify_attributes()`` diff --git a/user_guide_src/source/general/security.rst b/user_guide_src/source/general/security.rst index 3f93443bb..0c58f96b4 100644 --- a/user_guide_src/source/general/security.rst +++ b/user_guide_src/source/general/security.rst @@ -23,12 +23,12 @@ the following: - Space Register_globals -================= +================ + +During system initialization all global variables that are found to exist +in the ``$_GET``, ``$_POST``, ``$_REQUEST`` and ``$_COOKIE`` are unset. -During system initialization all global variables are unset, except -those found in the ``$_GET``, ``$_POST``, and ``$_COOKIE`` arrays. -The unsetting routine is effectively the same as -*register_globals = off*. +The unsetting routine is effectively the same as *register_globals = off*. display_errors ============== @@ -60,12 +60,14 @@ from a form submission, COOKIE data, URI data, XML-RPC data, or even data from the SERVER array, you are encouraged to practice this three step approach: -#. Filter the data as if it were tainted. #. Validate the data to ensure it conforms to the correct type, length, size, etc. (sometimes this step can replace step one) -#. Escape the data before submitting it into your database. +#. Filter the data as if it were tainted. +#. Escape the data before submitting it into your database or outputting + it to a browser. -CodeIgniter provides the following functions to assist in this process: +CodeIgniter provides the following functions and tips to assist you +in this process: XSS Filtering ============= @@ -76,13 +78,95 @@ your data, or other types of code that attempt to hijack cookies or do other malicious things. The XSS Filter is described :doc:`here <../libraries/security>`. -Validate the data +.. note:: XSS filtering should *only be performed on output*. Filtering + input data may modify the data in undesirable ways, including + stripping special characters from passwords, which reduces + security instead of improving it. + +CSRF protection +=============== + +CSRF stands for Cross-Site Request Forgery, which is the process of an +attacker tricking their victim into unknowingly submitting a request. + +CodeIgniter provides CSRF protection out of the box, which will get +automatically triggered for every non-GET HTTP request, but also needs +you to create your submit forms in a certain way. This is explained in +the :doc:`Security Library <../libraries/security>` documentation. + +Password handling ================= +It is *critical* that you handle passwords in your application properly. + +Unfortunately, many developers don't know how to do that, and the web is +full of outdated or otherwise wrongful advices, which doesn't help. + +We would like to give you a list of combined do's and don'ts to help you +with that. Please read below. + +- DO NOT store passwords in plain-text format. + + Always **hash** your passwords. + +- DO NOT use Base64 or similar encoding for storing passwords. + + This is as good as storing them in plain-text. Really. Do **hashing**, + not *encoding*. + + Encoding, and encryption too, are two-way processes. Passwords are + secrets that must only be known to their owner, and thus must work + only in one direction. Hashing does that - there's *no* un-hashing or + de-hashing, but there is decoding and decryption. + +- DO NOT use weak or broken hashing algorithms like MD5 or SHA1. + + These algorithms are old, proven to be flawed, and not designed for + password hashing in the first place. + + Also, DON'T invent your own algorithms. + + Only use strong password hashing algorithms like BCrypt, which is used + in PHP's own `Password Hashing <http://php.net/password>`_ functions. + + Please use them, even if you're not running PHP 5.5+, CodeIgniter + provides them for you as long as you're running at least PHP version + 5.3.7 (and if you don't meet that requirement - please, upgrade). + +- DO NOT ever display or send a password in plain-text format! + + Even to the password's owner, if you need a "Forgotten password" + feature, just randomly generate a new, one-time (this is also important) + password and send that instead. + +- DO NOT put artificial limits on your users' passwords. + + There's no point in forcing a rule that a password can only be up to + a number of characters, or that it can't contain a certain set of + special characters. + + Not only does this **reduce** security instead of improving it, but + there's literally no reason to do it. No technical limitations and + no (practical) storage constraints apply once you've hashed them, none! + +Validate input data +=================== + CodeIgniter has a :doc:`Form Validation Library <../libraries/form_validation>` that assists you in validating, filtering, and prepping your data. +Even if that doesn't work for your use case however, be sure to always +validate and sanitize all input data. For example, if you expect a numeric +string for an input variable, you can check for that with ``is_numeric()`` +or ``ctype_digit()``. Always try to narrow down your checks to a certain +pattern. + +Have it in mind that this includes not only ``$_POST`` and ``$_GET`` +variables, but also cookies, the user-agent string and basically +*all data that is not created directly by your own code*. + + Escape all data before database insertion ========================================= diff --git a/user_guide_src/source/general/styleguide.rst b/user_guide_src/source/general/styleguide.rst index 3d8f0a78a..7704a59c5 100644 --- a/user_guide_src/source/general/styleguide.rst +++ b/user_guide_src/source/general/styleguide.rst @@ -52,31 +52,8 @@ The PHP closing tag on a PHP document **?>** is optional to the PHP parser. However, if used, any whitespace following the closing tag, whether introduced by the developer, user, or an FTP application, can cause unwanted output, PHP errors, or if the latter are suppressed, -blank pages. For this reason, all PHP files should **OMIT** the closing -PHP tag, and instead use a comment block to mark the end of file and -its location relative to the application root. This allows you to still -identify a file as being complete and not truncated. - -**INCORRECT**:: - - <?php - - echo "Here's my code!"; - - ?> - -**CORRECT**:: - - <?php - - echo "Here's my code!"; - - /* End of file Myfile.php */ - /* Location: ./system/modules/mymodule/myfile.php */ - -.. note:: There should be no empty line or newline character(s) following - the closing comments. If you happen to see one when - submitting a pull request, please check your IDE settings and fix it. +blank pages. For this reason, all PHP files MUST OMIT the PHP closing +tag and end with a single empty line instead. File Naming =========== @@ -368,10 +345,10 @@ inability for CodeIgniter to send proper headers. Compatibility ============= -CodeIgniter recommends PHP 5.4 or newer to be used, but the absolute -minimum version required is 5.2.4. Your code must either be compatible -with this minimum requirement, provide a suitable fallback, or be an -optional feature that dies quietly without affecting a user's application. +CodeIgniter recommends PHP 5.4 or newer to be used, but it should be +compatible with PHP 5.2.4. Your code must either be compatible with this +requirement, provide a suitable fallback, or be an optional feature that +dies quietly without affecting a user's application. Additionally, do not use PHP functions that require non-default libraries to be installed unless your code contains an alternative method when the diff --git a/user_guide_src/source/helpers/array_helper.rst b/user_guide_src/source/helpers/array_helper.rst index 4805f581a..d6b48773f 100644 --- a/user_guide_src/source/helpers/array_helper.rst +++ b/user_guide_src/source/helpers/array_helper.rst @@ -26,7 +26,7 @@ Available Functions The following functions are available: -.. function:: element($item, $array[, $default = NULL]) +.. php:function:: element($item, $array[, $default = NULL]) :param string $item: Item to fetch from the array :param array $array: Input array @@ -51,7 +51,7 @@ The following functions are available: echo element('size', $array, 'foobar'); // returns "foobar" -.. function:: elements($items, $array[, $default = NULL]) +.. php:function:: elements($items, $array[, $default = NULL]) :param string $item: Item to fetch from the array :param array $array: Input array @@ -111,7 +111,7 @@ The following functions are available: updated. -.. function:: random_element($array) +.. php:function:: random_element($array) :param array $array: Input array :returns: A random element from the array diff --git a/user_guide_src/source/helpers/captcha_helper.rst b/user_guide_src/source/helpers/captcha_helper.rst index 4aacafd49..986c1d3e1 100644 --- a/user_guide_src/source/helpers/captcha_helper.rst +++ b/user_guide_src/source/helpers/captcha_helper.rst @@ -132,7 +132,7 @@ Available Functions The following functions are available: -.. function:: create_captcha([$data = ''[, $img_path = ''[, $img_url = ''[, $font_path = '']]]]) +.. php:function:: create_captcha([$data = ''[, $img_path = ''[, $img_url = ''[, $font_path = '']]]]) :param array $data: Array of data for the CAPTCHA :param string $img_path: Path to create the image in diff --git a/user_guide_src/source/helpers/cookie_helper.rst b/user_guide_src/source/helpers/cookie_helper.rst index 22fd0f77f..da26151cb 100644 --- a/user_guide_src/source/helpers/cookie_helper.rst +++ b/user_guide_src/source/helpers/cookie_helper.rst @@ -25,7 +25,7 @@ Available Functions The following functions are available: -.. function:: set_cookie($name[, $value = ''[, $expire = ''[, $domain = ''[, $path = '/'[, $prefix = ''[, $secure = FALSE[, $httponly = FALSE]]]]]]]]) +.. php:function:: set_cookie($name[, $value = ''[, $expire = ''[, $domain = ''[, $path = '/'[, $prefix = ''[, $secure = FALSE[, $httponly = FALSE]]]]]]]]) :param mixed $name: Cookie name *or* associative array of all of the parameters available to this function :param string $value: Cookie value @@ -37,25 +37,26 @@ The following functions are available: :param bool $httponly: Whether to hide the cookie from JavaScript :rtype: void - This helper function gives you view file friendly syntax to set browser - cookies. Refer to the :doc:`Input Library <../libraries/input>` for a - description of its use, as this function is an alias for + This helper function gives you friendlier syntax to set browser + cookies. Refer to the :doc:`Input Library <../libraries/input>` for + a description of its use, as this function is an alias for ``CI_Input::set_cookie()``. - -.. function:: get_cookie($index[, $xss_clean = NULL]]) +.. php:function:: get_cookie($index[, $xss_clean = NULL]]) :param string $index: Cookie name :param bool $xss_clean: Whether to apply XSS filtering to the returned value :returns: The cookie value or NULL if not found :rtype: mixed - This helper function gives you view file friendly syntax to get browser - cookies. Refer to the :doc:`Input Library <../libraries/input>` for a - description of its use, as this function is an alias for ``CI_Input::cookie()``. - + This helper function gives you friendlier syntax to get browser + cookies. Refer to the :doc:`Input Library <../libraries/input>` for + detailed description of its use, as this function acts very + similarly to ``CI_Input::cookie()``, except it will also prepend + the ``$config['cookie_prefix']`` that you might've set in your + *application/config/config.php* file. -.. function:: delete_cookie($name[, $domain = ''[, $path = '/'[, $prefix = '']]]]) +.. php:function:: delete_cookie($name[, $domain = ''[, $path = '/'[, $prefix = '']]]]) :param string $name: Cookie name :param string $domain: Cookie domain (usually: .yourdomain.com) @@ -75,4 +76,4 @@ The following functions are available: parameters. :: - delete_cookie($name, $domain, $path, $prefix)
\ No newline at end of file + delete_cookie($name, $domain, $path, $prefix); diff --git a/user_guide_src/source/helpers/date_helper.rst b/user_guide_src/source/helpers/date_helper.rst index dcff7a4e5..bed3b32a2 100644 --- a/user_guide_src/source/helpers/date_helper.rst +++ b/user_guide_src/source/helpers/date_helper.rst @@ -24,7 +24,7 @@ Available Functions The following functions are available: -.. function:: now([$timezone = NULL]) +.. php:function:: now([$timezone = NULL]) :param string $timezone: Timezone :returns: UNIX timestamp @@ -43,7 +43,7 @@ The following functions are available: If a timezone is not provided, it will return ``time()`` based on the **time_reference** setting. -.. function:: mdate([$datestr = ''[, $time = '']]) +.. php:function:: mdate([$datestr = ''[, $time = '']]) :param string $datestr: Date string :param int $time: UNIX timestamp @@ -67,7 +67,7 @@ The following functions are available: If a timestamp is not included in the second parameter the current time will be used. -.. function:: standard_date([$fmt = 'DATE_RFC822'[, $time = NULL]]) +.. php:function:: standard_date([$fmt = 'DATE_RFC822'[, $time = NULL]]) :param string $fmt: Date format :param int $time: UNIX timestamp @@ -106,7 +106,7 @@ The following functions are available: DATE_W3C W3C 2005-08-14T16:13:03+0000 =============== ======================= ====================================== -.. function:: local_to_gmt([$time = '']) +.. php:function:: local_to_gmt([$time = '']) :param int $time: UNIX timestamp :returns: UNIX timestamp @@ -118,7 +118,7 @@ The following functions are available: $gmt = local_to_gmt(time()); -.. function:: gmt_to_local([$time = ''[, $timezone = 'UTC'[, $dst = FALSE]]]) +.. php:function:: gmt_to_local([$time = ''[, $timezone = 'UTC'[, $dst = FALSE]]]) :param int $time: UNIX timestamp :param string $timezone: Timezone @@ -140,7 +140,7 @@ The following functions are available: .. note:: For a list of timezones see the reference at the bottom of this page. -.. function:: mysql_to_unix([$time = '']) +.. php:function:: mysql_to_unix([$time = '']) :param string $time: MySQL timestamp :returns: UNIX timestamp @@ -152,7 +152,7 @@ The following functions are available: $unix = mysql_to_unix('20061124092345'); -.. function:: unix_to_human([$time = ''[, $seconds = FALSE[, $fmt = 'us']]]) +.. php:function:: unix_to_human([$time = ''[, $seconds = FALSE[, $fmt = 'us']]]) :param int $time: UNIX timestamp :param bool $seconds: Whether to show seconds @@ -179,13 +179,13 @@ The following functions are available: echo unix_to_human($now, TRUE, 'us'); // U.S. time with seconds echo unix_to_human($now, TRUE, 'eu'); // Euro time with seconds -.. function:: human_to_unix([$datestr = '']) +.. php:function:: human_to_unix([$datestr = '']) :param int $datestr: Date string :returns: UNIX timestamp or FALSE on failure :rtype: int - The opposite of the :func:`unix_to_time()` function. Takes a "human" + The opposite of the :php:func:`unix_to_time()` function. Takes a "human" time as input and returns it as a UNIX timestamp. This is useful if you accept "human" formatted dates submitted via a form. Returns boolean FALSE date string passed to it is not formatted as indicated above. @@ -196,7 +196,7 @@ The following functions are available: $human = unix_to_human($now); $unix = human_to_unix($human); -.. function:: nice_date([$bad_date = ''[, $format = FALSE]]) +.. php:function:: nice_date([$bad_date = ''[, $format = FALSE]]) :param int $bad_date: The terribly formatted date-like string :param string $format: Date format to return (same as PHP's ``date()`` function) @@ -220,7 +220,7 @@ The following functions are available: // Should Produce: 2001-09-11 $better_date = nice_date($bad_date, 'Y-m-d'); -.. function:: timespan([$seconds = 1[, $time = ''[, $units = '']]]) +.. php:function:: timespan([$seconds = 1[, $time = ''[, $units = '']]]) :param int $seconds: Number of seconds :param string $time: UNIX timestamp @@ -252,7 +252,7 @@ The following functions are available: .. note:: The text generated by this function is found in the following language file: `language/<your_lang>/date_lang.php` -.. function:: days_in_month([$month = 0[, $year = '']]) +.. php:function:: days_in_month([$month = 0[, $year = '']]) :param int $month: a numeric month :param int $year: a numeric year @@ -271,7 +271,7 @@ The following functions are available: .. note:: This function will alias the native ``cal_days_in_month()``, if it is available. -.. function:: date_range([$unix_start = ''[, $mixed = ''[, $is_unix = TRUE[, $format = 'Y-m-d']]]]) +.. php:function:: date_range([$unix_start = ''[, $mixed = ''[, $is_unix = TRUE[, $format = 'Y-m-d']]]]) :param int $unix_start: UNIX timestamp of the range start date :param int $mixed: UNIX timestamp of the range end date or interval in days @@ -291,7 +291,7 @@ The following functions are available: echo $date."\n"; } -.. function:: timezones([$tz = '']) +.. php:function:: timezones([$tz = '']) :param string $tz: A numeric timezone :returns: Hour difference from UTC @@ -306,9 +306,9 @@ The following functions are available: echo timezones('UM5'); - This function is useful when used with :func:`timezone_menu()`. + This function is useful when used with :php:func:`timezone_menu()`. -.. function:: timezone_menu([$default = 'UTC'[, $class = ''[, $name = 'timezones'[, $attributes = '']]]]) +.. php:function:: timezone_menu([$default = 'UTC'[, $class = ''[, $name = 'timezones'[, $attributes = '']]]]) :param string $default: Timezone :param string $class: Class name diff --git a/user_guide_src/source/helpers/directory_helper.rst b/user_guide_src/source/helpers/directory_helper.rst index 030e0ef53..b5f1093c1 100644 --- a/user_guide_src/source/helpers/directory_helper.rst +++ b/user_guide_src/source/helpers/directory_helper.rst @@ -27,7 +27,7 @@ Available Functions The following functions are available: -.. function:: directory_map($source_dir[, $directory_depth = 0[, $hidden = FALSE]]) +.. php:function:: directory_map($source_dir[, $directory_depth = 0[, $hidden = FALSE]]) :param string $source_dir: Path to the source directory :param int $directory_depth: Depth of directories to traverse (0 = fully recursive, 1 = current dir, etc) diff --git a/user_guide_src/source/helpers/download_helper.rst b/user_guide_src/source/helpers/download_helper.rst index f374d491f..1a4065073 100644 --- a/user_guide_src/source/helpers/download_helper.rst +++ b/user_guide_src/source/helpers/download_helper.rst @@ -24,7 +24,7 @@ Available Functions The following functions are available: -.. function:: force_download([$filename = ''[, $data = ''[, $set_mime = FALSE]]]) +.. php:function:: force_download([$filename = ''[, $data = ''[, $set_mime = FALSE]]]) :param string $filename: Filename :param mixed $data: File contents diff --git a/user_guide_src/source/helpers/email_helper.rst b/user_guide_src/source/helpers/email_helper.rst index 3b771a0b6..685226951 100644 --- a/user_guide_src/source/helpers/email_helper.rst +++ b/user_guide_src/source/helpers/email_helper.rst @@ -29,7 +29,7 @@ Available Functions The following functions are available: -.. function:: valid_email($email) +.. php:function:: valid_email($email) :param string $email: E-mail address :returns: TRUE if a valid email is supplied, FALSE otherwise @@ -54,7 +54,7 @@ The following functions are available: (bool) filter_var($email, FILTER_VALIDATE_EMAIL); -.. function:: send_email($recipient, $subject, $message) +.. php:function:: send_email($recipient, $subject, $message) :param string $recipient: E-mail address :param string $subject: Mail subject diff --git a/user_guide_src/source/helpers/file_helper.rst b/user_guide_src/source/helpers/file_helper.rst index 013b583a0..92cb31a82 100644 --- a/user_guide_src/source/helpers/file_helper.rst +++ b/user_guide_src/source/helpers/file_helper.rst @@ -24,7 +24,7 @@ Available Functions The following functions are available: -.. function:: read_file($file) +.. php:function:: read_file($file) :param string $file: File path :returns: File contents or FALSE on failure @@ -49,7 +49,7 @@ The following functions are available: function might not work if you are trying to access a file above the calling script. -.. function:: write_file($path, $data[, $mode = 'wb']) +.. php:function:: write_file($path, $data[, $mode = 'wb']) :param string $path: File path :param string $data: Data to write to file @@ -89,7 +89,7 @@ The following functions are available: .. note:: This function acquires an exclusive lock on the file while writing to it. -.. function:: delete_files($path[, $del_dir = FALSE[, $htdocs = FALSE]]) +.. php:function:: delete_files($path[, $del_dir = FALSE[, $htdocs = FALSE]]) :param string $path: Directory path :param bool $del_dir: Whether to also delete directories @@ -112,7 +112,7 @@ The following functions are available: .. note:: The files must be writable or owned by the system in order to be deleted. -.. function:: get_filenames($source_dir[, $include_path = FALSE]) +.. php:function:: get_filenames($source_dir[, $include_path = FALSE]) :param string $source_dir: Directory path :param bool $include_path: Whether to include the path as part of the filenames @@ -127,7 +127,7 @@ The following functions are available: $controllers = get_filenames(APPPATH.'controllers/'); -.. function:: get_dir_file_info($source_dir, $top_level_only) +.. php:function:: get_dir_file_info($source_dir, $top_level_only) :param string $source_dir: Directory path :param bool $top_level_only: Whether to look only at the specified directory (excluding sub-directories) @@ -143,7 +143,7 @@ The following functions are available: $models_info = get_dir_file_info(APPPATH.'models/'); -.. function:: get_file_info($file[, $returned_values = array('name', 'server_path', 'size', 'date')]) +.. php:function:: get_file_info($file[, $returned_values = array('name', 'server_path', 'size', 'date')]) :param string $file: File path :param array $returned_values: What type of info to return @@ -157,7 +157,7 @@ The following functions are available: Valid ``$returned_values`` options are: `name`, `size`, `date`, `readable`, `writeable`, `executable` and `fileperms`. -.. function:: get_mime_by_extension($filename) +.. php:function:: get_mime_by_extension($filename) :param string $filename: File name :returns: MIME type string or FALSE on failure @@ -175,7 +175,7 @@ The following functions are available: is here strictly for convenience. It should not be used for security purposes. -.. function:: symbolic_permissions($perms) +.. php:function:: symbolic_permissions($perms) :param int $perms: Permissions :returns: Symbolic permissions string @@ -188,7 +188,7 @@ The following functions are available: echo symbolic_permissions(fileperms('./index.php')); // -rw-r--r-- -.. function:: octal_permissions($perms) +.. php:function:: octal_permissions($perms) :param int $perms: Permissions :returns: Octal permissions string diff --git a/user_guide_src/source/helpers/form_helper.rst b/user_guide_src/source/helpers/form_helper.rst index 4fa5f246b..15f5d7825 100644 --- a/user_guide_src/source/helpers/form_helper.rst +++ b/user_guide_src/source/helpers/form_helper.rst @@ -19,13 +19,38 @@ This helper is loaded using the following code:: $this->load->helper('form'); +Escaping field values +===================== + +You may need to use HTML and characters such as quotes within your form +elements. In order to do that safely, you'll need to use +:doc:`common function <../general/common_functions>` +:func:`html_escape()`. + +Consider the following example:: + + $string = 'Here is a string containing "quoted" text.'; + + <input type="text" name="myfield" value="<?php echo $string; ?>" /> + +Since the above string contains a set of quotes, it will cause the form +to break. The :php:func:`html_escape()` function converts HTML special +characters so that it can be used safely:: + + <input type="text" name="myfield" value="<?php echo html_escape($string); ?>" /> + +.. note:: If you use any of the form helper functions listed on this page, + the form values will be automatically escaped, so there is no need + to call this function. Use it only if you are creating your own + form elements. + Available Functions =================== The following functions are available: -.. function:: form_open([$action = ''[, $attributes = ''[, $hidden = array()]]]) +.. php:function:: form_open([$action = ''[, $attributes = ''[, $hidden = array()]]]) :param string $action: Form action/target URI string :param array $attributes: HTML attributes @@ -83,7 +108,7 @@ The following functions are available: <input type="hidden" name="member_id" value="234" /> -.. function:: form_open_multipart([$action = ''[, $attributes = array()[, $hidden = array()]]) +.. php:function:: form_open_multipart([$action = ''[, $attributes = array()[, $hidden = array()]]) :param string $action: Form action/target URI string :param array $attributes: HTML attributes @@ -91,12 +116,12 @@ The following functions are available: :returns: An HTML multipart form opening tag :rtype: string - This function is absolutely identical to :func:`form_open()` above, + This function is absolutely identical to :php:func:`form_open()` above, except that it adds a *multipart* attribute, which is necessary if you would like to use the form to upload files with. -.. function:: form_hidden($name[, $value = '']) +.. php:function:: form_hidden($name[, $value = '']) :param string $name: Field name :param string $value: Field value @@ -162,7 +187,7 @@ The following functions are available: <input type="hidden" name="email" value="john@example.com" id="hiddenemail" class="hiddenemail" /> */ -.. function:: form_input([$data = ''[, $value = ''[, $extra = '']]) +.. php:function:: form_input([$data = ''[, $value = ''[, $extra = '']]) :param array $data: Field attributes data :param string $value: Field value @@ -201,7 +226,7 @@ The following functions are available: $js = 'onClick="some_function()"'; echo form_input('username', 'johndoe', $js); -.. function:: form_password([$data = ''[, $value = ''[, $extra = '']]]) +.. php:function:: form_password([$data = ''[, $value = ''[, $extra = '']]]) :param array $data: Field attributes data :param string $value: Field value @@ -209,11 +234,11 @@ The following functions are available: :returns: An HTML password input field tag :rtype: string - This function is identical in all respects to the :func:`form_input()` + This function is identical in all respects to the :php:func:`form_input()` function above except that it uses the "password" input type. -.. function:: form_upload([$data = ''[, $value = ''[, $extra = '']]]) +.. php:function:: form_upload([$data = ''[, $value = ''[, $extra = '']]]) :param array $data: Field attributes data :param string $value: Field value @@ -221,12 +246,12 @@ The following functions are available: :returns: An HTML file upload input field tag :rtype: string - This function is identical in all respects to the :func:`form_input()` + This function is identical in all respects to the :php:func:`form_input()` function above except that it uses the "file" input type, allowing it to be used to upload files. -.. function:: form_textarea([$data = ''[, $value = ''[, $extra = '']]]) +.. php:function:: form_textarea([$data = ''[, $value = ''[, $extra = '']]]) :param array $data: Field attributes data :param string $value: Field value @@ -234,13 +259,13 @@ The following functions are available: :returns: An HTML textarea tag :rtype: string - This function is identical in all respects to the :func:`form_input()` + This function is identical in all respects to the :php:func:`form_input()` function above except that it generates a "textarea" type. .. note:: Instead of the *maxlength* and *size* attributes in the above example, you will instead specify *rows* and *cols*. -.. function:: form_dropdown([$name = ''[, $options = array()[, $selected = array()[, $extra = '']]]]) +.. php:function:: form_dropdown([$name = ''[, $options = array()[, $selected = array()[, $extra = '']]]]) :param string $name: Field name :param array $options: An associative array of options to be listed @@ -304,7 +329,7 @@ The following functions are available: label. -.. function:: form_multiselect([$name = ''[, $options = array()[, $selected = array()[, $extra = '']]]]) +.. php:function:: form_multiselect([$name = ''[, $options = array()[, $selected = array()[, $extra = '']]]]) :param string $name: Field name :param array $options: An associative array of options to be listed @@ -318,12 +343,12 @@ The following functions are available: associative array of options, and the third parameter will contain the value or values you wish to be selected. - The parameter usage is identical to using :func:`form_dropdown()` above, + The parameter usage is identical to using :php:func:`form_dropdown()` above, except of course that the name of the field will need to use POST array syntax, e.g. foo[]. -.. function:: form_fieldset([$legend_text = ''[, $attributes = array()]]) +.. php:function:: form_fieldset([$legend_text = ''[, $attributes = array()]]) :param string $legend_text: Text to put in the <legend> tag :param array $attributes: Attributes to be set on the <fieldset> tag @@ -369,7 +394,7 @@ The following functions are available: */ -.. function:: form_fieldset_close([$extra = '']) +.. php:function:: form_fieldset_close([$extra = '']) :param string $extra: Anything to append after the closing tag, *as is* :returns: An HTML fieldset closing tag @@ -387,7 +412,7 @@ The following functions are available: // Would produce: </fieldset></div></div> -.. function:: form_checkbox([$data = ''[, $value = ''[, $checked = FALSE[, $extra = '']]]]) +.. php:function:: form_checkbox([$data = ''[, $value = ''[, $checked = FALSE[, $extra = '']]]]) :param array $data: Field attributes data :param string $value: Field value @@ -426,7 +451,7 @@ The following functions are available: echo form_checkbox('newsletter', 'accept', TRUE, $js) -.. function:: form_radio([$data = ''[, $value = ''[, $checked = FALSE[, $extra = '']]]]) +.. php:function:: form_radio([$data = ''[, $value = ''[, $checked = FALSE[, $extra = '']]]]) :param array $data: Field attributes data :param string $value: Field value @@ -435,11 +460,11 @@ The following functions are available: :returns: An HTML radio input tag :rtype: string - This function is identical in all respects to the :func:`form_checkbox()` + This function is identical in all respects to the :php:func:`form_checkbox()` function above except that it uses the "radio" input type. -.. function:: form_label([$label_text = ''[, $id = ''[, $attributes = array()]]]) +.. php:function:: form_label([$label_text = ''[, $id = ''[, $attributes = array()]]]) :param string $label_text: Text to put in the <label> tag :param string $id: ID of the form element that we're making a label for @@ -466,7 +491,7 @@ The following functions are available: // Would produce: <label for="username" class="mycustomclass" style="color: #000;">What is your Name</label> -.. function:: form_submit([$data = ''[, $value = ''[, $extra = '']]]) +.. php:function:: form_submit([$data = ''[, $value = ''[, $extra = '']]]) :param string $data: Button name :param string $value: Button value @@ -484,7 +509,7 @@ The following functions are available: parameter lets you add extra data to your form, like JavaScript. -.. function:: form_reset([$data = ''[, $value = ''[, $extra = '']]]) +.. php:function:: form_reset([$data = ''[, $value = ''[, $extra = '']]]) :param string $data: Button name :param string $value: Button value @@ -496,7 +521,7 @@ The following functions are available: :func:`form_submit()`. -.. function:: form_button([$data = ''[, $content = ''[, $extra = '']]]) +.. php:function:: form_button([$data = ''[, $content = ''[, $extra = '']]]) :param string $data: Button name :param string $content: Button label @@ -531,7 +556,7 @@ The following functions are available: echo form_button('mybutton', 'Click Me', $js); -.. function:: form_close([$extra = '']) +.. php:function:: form_close([$extra = '']) :param string $extra: Anything to append after the closing tag, *as is* :returns: An HTML form closing tag @@ -546,37 +571,10 @@ The following functions are available: // Would produce: </form> </div></div> -.. function:: form_prep([$str = ''[, $is_textarea = FALSE]]) - - :param string $str: Value to escape - :param bool $is_textarea: Whether we're preparing for <textarea> or a regular input tag - :returns: Escaped value - :rtype: string - - Allows you to safely use HTML and characters such as quotes within form - elements without breaking out of the form. - - Consider this example:: - - $string = 'Here is a string containing "quoted" text.'; - <input type="text" name="myform" value="$string" /> - - Since the above string contains a set of quotes it will cause the form - to break. The ``form_prep()`` function converts HTML so that it can be used - safely:: - - <input type="text" name="myform" value="<?php echo form_prep($string); ?>" /> - - .. note:: If you use any of the form helper functions listed in this page the form - values will be prepped automatically, so there is no need to call this - function. Use it only if you are creating your own form elements. - - -.. function:: set_value([$field = ''[, $default = ''[, $is_textarea = FALSE]]]) +.. php:function:: set_value($field[, $default = '']) :param string $field: Field name :param string $default: Default value - :param bool $is_textarea: Whether we're setting <textarea> content :returns: Field value :rtype: string @@ -587,12 +585,16 @@ The following functions are available: Example:: - <input type="text" name="quantity" value="<?=set_value('quantity', '0');?>" size="50" /> + <input type="text" name="quantity" value="<?php echo set_value('quantity', '0'); ?>" size="50" /> The above form will show "0" when loaded for the first time. + .. note:: Only use this function with raw HTML fields, as it + internally calls :php:func:`html_escape()` and combining its + usage with other form helper functions will result in + double HTML encoding! -.. function:: set_select([$field = ''[, $value = ''[, $default = FALSE]]]) +.. php:function:: set_select($field[, $value = ''[, $default = FALSE]]) :param string $field: Field name :param string $value: Value to check for @@ -615,7 +617,7 @@ The following functions are available: <option value="three" <?php echo set_select('myselect', 'three'); ?> >Three</option> </select> -.. function:: set_checkbox([$field = ''[, $value = ''[, $default = FALSE]]]) +.. php:function:: set_checkbox($field[, $value = ''[, $default = FALSE]]) :param string $field: Field name :param string $value: Value to check for @@ -634,7 +636,7 @@ The following functions are available: <input type="checkbox" name="mycheck" value="1" <?php echo set_checkbox('mycheck', '1'); ?> /> <input type="checkbox" name="mycheck" value="2" <?php echo set_checkbox('mycheck', '2'); ?> /> -.. function:: set_radio([$field = ''[, $value = ''[, $default = FALSE]]]) +.. php:function:: set_radio($field[, $value = ''[, $default = FALSE]]) :param string $field: Field name :param string $value: Value to check for @@ -643,7 +645,7 @@ The following functions are available: :rtype: string Permits you to display radio buttons in the state they were submitted. - This function is identical to the :func:`set_checkbox()` function above. + This function is identical to the :php:func:`set_checkbox()` function above. Example:: @@ -656,7 +658,7 @@ The following functions are available: defined, the control for ``set_*()`` is handed over to a method of the class instead of the generic helper function. -.. function:: form_error([$field = ''[, $prefix = ''[, $suffix = '']]]) +.. php:function:: form_error([$field = ''[, $prefix = ''[, $suffix = '']]]) :param string $field: Field name :param string $prefix: Error opening tag @@ -677,14 +679,14 @@ The following functions are available: // Would produce: <div class="error">Error message associated with the "username" field.</div> -.. function:: validation_errors([$prefix = ''[, $suffix = '']]) +.. php:function:: validation_errors([$prefix = ''[, $suffix = '']]) :param string $prefix: Error opening tag :param string $suffix: Error closing tag :returns: HTML-formatted form validation error message(s) :rtype: string - Similarly to the :func:`form_error()` function, returns all validation + Similarly to the :php:func:`form_error()` function, returns all validation error messages produced by the :doc:`Form Validation Library <../libraries/form_validation>`, with optional opening and closing tags around each of the messages. @@ -699,4 +701,21 @@ The following functions are available: <span class="error">The "email" field doesn't contain a valid e-mail address!</span> <span class="error">The "password" field doesn't match the "repeat_password" field!</span> - */
\ No newline at end of file + */ + +.. php:function:: form_prep($str) + + :param string $str: Value to escape + :returns: Escaped value + :rtype: string + + Allows you to safely use HTML and characters such as quotes within form + elements without breaking out of the form. + + .. note:: If you use any of the form helper functions listed in this page the form + values will be prepped automatically, so there is no need to call this + function. Use it only if you are creating your own form elements. + + .. note:: This function is DEPRECATED and is just an alias for + :doc:`common function <../general/common_functions>` + :func:`html_escape()` - please use that instead.
\ No newline at end of file diff --git a/user_guide_src/source/helpers/html_helper.rst b/user_guide_src/source/helpers/html_helper.rst index ff387be10..d35be396a 100644 --- a/user_guide_src/source/helpers/html_helper.rst +++ b/user_guide_src/source/helpers/html_helper.rst @@ -25,7 +25,7 @@ Available Functions The following functions are available: -.. function:: heading([$data = ''[, $h = '1'[, $attributes = '']]]) +.. php:function:: heading([$data = ''[, $h = '1'[, $attributes = '']]]) :param string $data: Content :param string $h: Heading level @@ -51,7 +51,7 @@ The following functions are available: <h3 class="pink">Welcome!<h3> -.. function:: img([$src = ''[, $index_page = FALSE[, $attributes = '']]]) +.. php:function:: img([$src = ''[, $index_page = FALSE[, $attributes = '']]]) :param string $src: Image source data :param bool $index_page: Whether to treat $src as a routed URI string @@ -90,7 +90,7 @@ The following functions are available: img($image_properties); // <img src="http://site.com/index.php/images/picture.jpg" alt="Me, demonstrating how to eat 4 slices of pizza at one time" class="post_images" width="200" height="200" title="That was quite a night" rel="lightbox" /> -.. function:: link_tag([$href = ''[, $rel = 'stylesheet'[, $type = 'text/css'[, $title = ''[, $media = ''[, $index_page = FALSE]]]]]]) +.. php:function:: link_tag([$href = ''[, $rel = 'stylesheet'[, $type = 'text/css'[, $title = ''[, $media = ''[, $index_page = FALSE]]]]]]) :param string $href: What are we linking to :param string $rel: Relation type @@ -135,7 +135,7 @@ The following functions are available: // <link href="http://site.com/css/printer.css" rel="stylesheet" type="text/css" media="print" /> -.. function:: ul($list[, $attributes = '']) +.. php:function:: ul($list[, $attributes = '']) :param array $list: List entries :param array $attributes: HTML attributes @@ -255,17 +255,17 @@ The following functions are available: </li> </ul> -.. function:: ol($list, $attributes = '') +.. php:function:: ol($list, $attributes = '') :param array $list: List entries :param array $attributes: HTML attributes :returns: HTML-formatted ordered list :rtype: string - Identical to :func:`ul()`, only it produces the <ol> tag for + Identical to :php:func:`ul()`, only it produces the <ol> tag for ordered lists instead of <ul>. -.. function:: meta([$name = ''[, $content = ''[, $type = 'name'[, $newline = "\n"]]]]) +.. php:function:: meta([$name = ''[, $content = ''[, $type = 'name'[, $newline = "\n"]]]]) :param string $name: Meta name :param string $content: Meta content @@ -321,7 +321,7 @@ The following functions are available: // <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> -.. function:: doctype([$type = 'xhtml1-strict']) +.. php:function:: doctype([$type = 'xhtml1-strict']) :param string $type: Doctype name :returns: HTML DocType tag @@ -363,7 +363,7 @@ The following functions are available: XHTML+RDFa 1.1 xhtml-rdfa-2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd"> =============================== =================== ================================================================================================================================================== -.. function:: br([$count = 1]) +.. php:function:: br([$count = 1]) :param int $count: Number of times to repeat the tag :returns: HTML line break tag @@ -383,7 +383,7 @@ The following functions are available: .. note:: This function is DEPRECATED. Use the native ``str_repeat()`` in combination with ``<br />`` instead. -.. function:: nbs([$num = 1]) +.. php:function:: nbs([$num = 1]) :param int $num: Number of space entities to produce :returns: A sequence of non-breaking space HTML entities diff --git a/user_guide_src/source/helpers/inflector_helper.rst b/user_guide_src/source/helpers/inflector_helper.rst index d0cb17c18..ed1e2b30f 100644 --- a/user_guide_src/source/helpers/inflector_helper.rst +++ b/user_guide_src/source/helpers/inflector_helper.rst @@ -25,7 +25,7 @@ Available Functions The following functions are available: -.. function:: singular($str) +.. php:function:: singular($str) :param string $str: Input string :returns: A singular word @@ -35,7 +35,7 @@ The following functions are available: echo singular('dogs'); // Prints 'dog' -.. function:: plural($str) +.. php:function:: plural($str) :param string $str: Input string :returns: A plular word @@ -45,7 +45,7 @@ The following functions are available: echo plural('dog'); // Prints 'dogs' -.. function:: camelize($str) +.. php:function:: camelize($str) :param string $str: Input string :returns: Camelized string @@ -56,7 +56,7 @@ The following functions are available: echo camelize('my_dog_spot'); // Prints 'myDogSpot' -.. function:: underscore($str) +.. php:function:: underscore($str) :param string $str: Input string :returns: String containing underscores instead of spaces @@ -67,7 +67,7 @@ The following functions are available: echo underscore('my dog spot'); // Prints 'my_dog_spot' -.. function:: humanize($str[, $separator = '_']) +.. php:function:: humanize($str[, $separator = '_']) :param string $str: Input string :param string $separator: Input separator @@ -85,7 +85,7 @@ The following functions are available: echo humanize('my-dog-spot', '-'); // Prints 'My Dog Spot' -.. function:: is_countable($word) +.. php:function:: is_countable($word) :param string $word: Input string :returns: TRUE if the word is countable or FALSE if not diff --git a/user_guide_src/source/helpers/language_helper.rst b/user_guide_src/source/helpers/language_helper.rst index e4d093725..cadf3c0ce 100644 --- a/user_guide_src/source/helpers/language_helper.rst +++ b/user_guide_src/source/helpers/language_helper.rst @@ -25,7 +25,7 @@ Available Functions The following functions are available: -.. function:: lang($line[, $for = ''[, $attributes = array()]]) +.. php:function:: lang($line[, $for = ''[, $attributes = array()]]) :param string $line: Language line key :param string $for: HTML "for" attribute (ID of the element we're creating a label for) diff --git a/user_guide_src/source/helpers/number_helper.rst b/user_guide_src/source/helpers/number_helper.rst index 2de4457d9..9d5e98cfb 100644 --- a/user_guide_src/source/helpers/number_helper.rst +++ b/user_guide_src/source/helpers/number_helper.rst @@ -25,7 +25,7 @@ Available Functions The following functions are available: -.. function:: byte_format($num[, $precision = 1]) +.. php:function:: byte_format($num[, $precision = 1]) :param mixed $num: Number of bytes :param int $precision: Floating point precision diff --git a/user_guide_src/source/helpers/path_helper.rst b/user_guide_src/source/helpers/path_helper.rst index 705ca23b9..f46cbad44 100644 --- a/user_guide_src/source/helpers/path_helper.rst +++ b/user_guide_src/source/helpers/path_helper.rst @@ -25,7 +25,7 @@ Available Functions The following functions are available: -.. function:: set_realpath($path[, $check_existance = FALSE]) +.. php:function:: set_realpath($path[, $check_existance = FALSE]) :param string $path: Path :param bool $check_existance: Whether to check if the path actually exists diff --git a/user_guide_src/source/helpers/security_helper.rst b/user_guide_src/source/helpers/security_helper.rst index 2e26890b0..103880cf9 100644 --- a/user_guide_src/source/helpers/security_helper.rst +++ b/user_guide_src/source/helpers/security_helper.rst @@ -24,7 +24,7 @@ Available Functions The following functions are available: -.. function:: xss_clean($str[, $is_image = FALSE]) +.. php:function:: xss_clean($str[, $is_image = FALSE]) :param string $str: Input data :param bool $is_image: Whether we're dealing with an image @@ -36,7 +36,7 @@ The following functions are available: This function is an alias for ``CI_Input::xss_clean()``. For more info, please see the :doc:`Input Library <../libraries/input>` documentation. -.. function:: sanitize_filename($filename) +.. php:function:: sanitize_filename($filename) :param string $filename: Filename :returns: Sanitized file name @@ -49,7 +49,7 @@ The following functions are available: documentation. -.. function:: do_hash($str[, $type = 'sha1']) +.. php:function:: do_hash($str[, $type = 'sha1']) :param string $str: Input :param string $type: Algorithm @@ -73,7 +73,7 @@ The following functions are available: .. note:: This function is DEPRECATED. Use the native ``hash()`` instead. -.. function:: strip_image_tags($str) +.. php:function:: strip_image_tags($str) :param string $str: Input string :returns: The input string with no image tags @@ -91,7 +91,7 @@ The following functions are available: documentation. -.. function:: encode_php_tags($str) +.. php:function:: encode_php_tags($str) :param string $str: Input string :returns: Safely formatted string @@ -99,7 +99,7 @@ The following functions are available: This is a security function that converts PHP tags to entities. - .. note:: :func:`xss_clean()` does this automatically, if you use it. + .. note:: :php:func:`xss_clean()` does this automatically, if you use it. Example:: diff --git a/user_guide_src/source/helpers/smiley_helper.rst b/user_guide_src/source/helpers/smiley_helper.rst index 5de1d83bb..978d11e5f 100644 --- a/user_guide_src/source/helpers/smiley_helper.rst +++ b/user_guide_src/source/helpers/smiley_helper.rst @@ -54,7 +54,7 @@ The Controller In your **application/controllers/** directory, create a file called Smileys.php and place the code below in it. -.. important:: Change the URL in the :func:`get_clickable_smileys()` +.. important:: Change the URL in the :php:func:`get_clickable_smileys()` function below so that it points to your smiley folder. You'll notice that in addition to the smiley helper, we are also using @@ -115,7 +115,7 @@ To map the alias to the field id, pass them both into the Available Functions =================== -.. function:: get_clickable_smileys($image_url[, $alias = ''[, $smileys = NULL]]) +.. php:function:: get_clickable_smileys($image_url[, $alias = ''[, $smileys = NULL]]) :param string $image_url: URL path to the smileys directory :param string $alias: Field alias @@ -130,7 +130,7 @@ Available Functions $image_array = get_clickable_smileys('http://example.com/images/smileys/', 'comment'); -.. function:: smiley_js([$alias = ''[, $field_id = ''[, $inline = TRUE]]]) +.. php:function:: smiley_js([$alias = ''[, $field_id = ''[, $inline = TRUE]]]) :param string $alias: Field alias :param string $field_id: Field ID @@ -148,7 +148,7 @@ Available Functions <?php echo smiley_js(); ?> -.. function:: parse_smileys([$str = ''[, $image_url = ''[, $smileys = NULL]]]) +.. php:function:: parse_smileys([$str = ''[, $image_url = ''[, $smileys = NULL]]]) :param string $str: Text containing smiley codes :param string $image_url: URL path to the smileys directory diff --git a/user_guide_src/source/helpers/string_helper.rst b/user_guide_src/source/helpers/string_helper.rst index 922bc6b8d..9d0d890b3 100644 --- a/user_guide_src/source/helpers/string_helper.rst +++ b/user_guide_src/source/helpers/string_helper.rst @@ -25,7 +25,7 @@ Available Functions The following functions are available: -.. function:: random_string([$type = 'alnum'[, $len = 8]]) +.. php:function:: random_string([$type = 'alnum'[, $len = 8]]) :param string $type: Randomization type :param int $len: Output string length @@ -53,7 +53,7 @@ The following functions are available: .. note:: Usage of the *unique* and *encrypt* types is DEPRECATED. They are just aliases for *md5* and *sha1* respectively. -.. function:: increment_string($str[, $separator = '_'[, $first = 1]]) +.. php:function:: increment_string($str[, $separator = '_'[, $first = 1]]) :param string $str: Input string :param string $separator: Separator to append a duplicate number with @@ -72,7 +72,7 @@ The following functions are available: echo increment_string('file_4'); // "file_5" -.. function:: alternator($args) +.. php:function:: alternator($args) :param mixed $args: A variable number of arguments :returns: Alternated string(s) @@ -99,7 +99,7 @@ The following functions are available: .. note:: To use multiple separate calls to this function simply call the function with no arguments to re-initialize. -.. function:: repeater($data[, $num = 1]) +.. php:function:: repeater($data[, $num = 1]) :param string $data: Input :param int $num: Number of times to repeat @@ -117,7 +117,7 @@ The following functions are available: instead. -.. function:: reduce_double_slashes($str) +.. php:function:: reduce_double_slashes($str) :param string $str: Input string :returns: A string with normalized slashes @@ -132,7 +132,7 @@ The following functions are available: echo reduce_double_slashes($string); // results in "http://example.com/index.php" -.. function:: strip_slashes($data) +.. php:function:: strip_slashes($data) :param mixed $data: Input string or an array of strings :returns: String(s) with stripped slashes @@ -160,7 +160,7 @@ The following functions are available: and handle string inputs. This however makes it just an alias for ``stripslashes()``. -.. function:: trim_slashes($str) +.. php:function:: trim_slashes($str) :param string $str: Input string :returns: Slash-trimmed string @@ -175,7 +175,7 @@ The following functions are available: | | trim($str, '/'); -.. function:: reduce_multiples($str[, $character = ''[, $trim = FALSE]]) +.. php:function:: reduce_multiples($str[, $character = ''[, $trim = FALSE]]) :param string $str: Text to search in :param string $character: Character to reduce @@ -195,7 +195,7 @@ The following functions are available: $string = ",Fred, Bill,, Joe, Jimmy,"; $string = reduce_multiples($string, ", ", TRUE); //results in "Fred, Bill, Joe, Jimmy" -.. function:: quotes_to_entities($str) +.. php:function:: quotes_to_entities($str) :param string $str: Input string :returns: String with quotes converted to HTML entities @@ -208,7 +208,7 @@ The following functions are available: $string = quotes_to_entities($string); //results in "Joe's "dinner"" -.. function:: strip_quotes($str) +.. php:function:: strip_quotes($str) :param string $str: Input string :returns: String with quotes stripped diff --git a/user_guide_src/source/helpers/text_helper.rst b/user_guide_src/source/helpers/text_helper.rst index 88a6d0658..d1723c58a 100644 --- a/user_guide_src/source/helpers/text_helper.rst +++ b/user_guide_src/source/helpers/text_helper.rst @@ -24,7 +24,7 @@ Available Functions The following functions are available: -.. function:: word_limiter($str[, $limit = 100[, $end_char = '…']]) +.. php:function:: word_limiter($str[, $limit = 100[, $end_char = '…']]) :param string $str: Input string :param int $limit: Limit @@ -42,7 +42,7 @@ The following functions are available: default it adds an ellipsis. -.. function:: character_limiter($str[, $n = 500[, $end_char = '…']]) +.. php:function:: character_limiter($str[, $n = 500[, $end_char = '…']]) :param string $str: Input string :param int $n: Number of characters @@ -64,9 +64,9 @@ The following functions are available: undeclared this helper uses an ellipsis. .. note:: If you need to truncate to an exact number of characters please - see the :func:`ellipsize()` function below. + see the :php:func:`ellipsize()` function below. -.. function:: ascii_to_entities($str) +.. php:function:: ascii_to_entities($str) :param string $str: Input string :returns: A string with ASCII values converted to entities @@ -84,17 +84,17 @@ The following functions are available: $string = ascii_to_entities($string); -.. function::entities_to_ascii($str[, $all = TRUE]) +.. php:function::entities_to_ascii($str[, $all = TRUE]) :param string $str: Input string :param bool $all: Whether to convert unsafe entities as well :returns: A string with HTML entities converted to ASCII characters :rtype: string - This function does the opposite of :func:`ascii_to_entities()`. + This function does the opposite of :php:func:`ascii_to_entities()`. It turns character entities back into ASCII. -.. function:: convert_accented_characters($str) +.. php:function:: convert_accented_characters($str) :param string $str: Input string :returns: A string with accented characters converted @@ -112,7 +112,7 @@ The following functions are available: `application/config/foreign_chars.php` to define the to and from array for transliteration. -.. function:: word_censor($str, $censored[, $replacement = '']) +.. php:function:: word_censor($str, $censored[, $replacement = '']) :param string $str: Input string :param array $censored: List of bad words to censor @@ -131,7 +131,7 @@ The following functions are available: $disallowed = array('darn', 'shucks', 'golly', 'phooey'); $string = word_censor($string, $disallowed, 'Beep!'); -.. function:: highlight_code($str) +.. php:function:: highlight_code($str) :param string $str: Input string :returns: String with code highlighted via HTML @@ -145,7 +145,7 @@ The following functions are available: colors used are the ones specified in your php.ini file. -.. function:: highlight_phrase($str, $phrase[, $tag_open = '<mark>'[, $tag_close = '</mark>']]) +.. php:function:: highlight_phrase($str, $phrase[, $tag_open = '<mark>'[, $tag_close = '</mark>']]) :param string $str: Input string :param string $phrase: Phrase to highlight @@ -178,7 +178,7 @@ The following functions are available: color: #000; }; -.. function:: word_wrap($str[, $charlim = 76]) +.. php:function:: word_wrap($str[, $charlim = 76]) :param string $str: Input string :param int $charlim: Character limit @@ -195,7 +195,7 @@ The following functions are available: // Would produce: Here is a simple string of text that will help us demonstrate this function -.. function:: ellipsize($str, $max_length[, $position = 1[, $ellipsis = '…']]) +.. php:function:: ellipsize($str, $max_length[, $position = 1[, $ellipsis = '…']]) :param string $str: Input string :param int $max_length: String length limit diff --git a/user_guide_src/source/helpers/typography_helper.rst b/user_guide_src/source/helpers/typography_helper.rst index deb3d164e..7eb4fceec 100644 --- a/user_guide_src/source/helpers/typography_helper.rst +++ b/user_guide_src/source/helpers/typography_helper.rst @@ -25,7 +25,7 @@ Available Functions The following functions are available: -.. function:: auto_typography($str[, $reduce_linebreaks = FALSE]) +.. php:function:: auto_typography($str[, $reduce_linebreaks = FALSE]) :param string $str: Input string :param bool $reduce_linebreaks: Whether to reduce multiple instances of double newlines to two @@ -49,7 +49,7 @@ The following functions are available: pages. -.. function:: nl2br_except_pre($str) +.. php:function:: nl2br_except_pre($str) :param string $str: Input string :returns: String with HTML-formatted line breaks @@ -63,7 +63,7 @@ The following functions are available: $string = nl2br_except_pre($string); -.. function:: entity_decode($str, $charset = NULL) +.. php:function:: entity_decode($str, $charset = NULL) :param string $str: Input string :param string $charset: Character set diff --git a/user_guide_src/source/helpers/url_helper.rst b/user_guide_src/source/helpers/url_helper.rst index 3bdcb8e17..83864d9d3 100644 --- a/user_guide_src/source/helpers/url_helper.rst +++ b/user_guide_src/source/helpers/url_helper.rst @@ -23,7 +23,7 @@ The following functions are available: Available Functions =================== -.. function:: site_url([$uri = ''[, $protocol = NULL]]) +.. php:function:: site_url([$uri = ''[, $protocol = NULL]]) :param string $uri: URI string :param string $protocol: Protocol, e.g. 'http' or 'https' @@ -55,7 +55,7 @@ Available Functions This function is an alias for ``CI_Config::site_url()``. For more info, please see the :doc:`Config Library <../libraries/config>` documentation. -.. function:: base_url($uri = '', $protocol = NULL) +.. php:function:: base_url($uri = '', $protocol = NULL) :param string $uri: URI string :param string $protocol: Protocol, e.g. 'http' or 'https' @@ -66,10 +66,10 @@ Available Functions echo base_url(); - This function returns the same thing as :func:`site_url()`, without + This function returns the same thing as :php:func:`site_url()`, without the *index_page* or *url_suffix* being appended. - Also like :func:`site_url()`, you can supply segments as a string or + Also like :php:func:`site_url()`, you can supply segments as a string or an array. Here is a string example:: echo base_url("blog/post/123"); @@ -77,7 +77,7 @@ Available Functions The above example would return something like: *http://example.com/blog/post/123* - This is useful because unlike :func:`site_url()`, you can supply a + This is useful because unlike :php:func:`site_url()`, you can supply a string to a file, such as an image or stylesheet. For example:: echo base_url("images/icons/edit.png"); @@ -88,7 +88,7 @@ Available Functions This function is an alias for ``CI_Config::base_url()``. For more info, please see the :doc:`Config Library <../libraries/config>` documentation. -.. function:: current_url() +.. php:function:: current_url() :returns: The current URL :rtype: string @@ -101,7 +101,7 @@ Available Functions | site_url(uri_string()); -.. function:: uri_string() +.. php:function:: uri_string() :returns: An URI string :rtype: string @@ -119,7 +119,7 @@ Available Functions please see the :doc:`Config Library <../libraries/config>` documentation. -.. function:: index_page() +.. php:function:: index_page() :returns: 'index_page' value :rtype: mixed @@ -129,7 +129,7 @@ Available Functions echo index_page(); -.. function:: anchor($uri = '', $title = '', $attributes = '') +.. php:function:: anchor($uri = '', $title = '', $attributes = '') :param string $uri: URI string :param string $title: Anchor title @@ -140,7 +140,7 @@ Available Functions Creates a standard HTML anchor link based on your local site URL. The first parameter can contain any segments you wish appended to the - URL. As with the :func:`site_url()` function above, segments can + URL. As with the :php:func:`site_url()` function above, segments can be a string or an array. .. note:: If you are building links that are internal to your application @@ -167,7 +167,7 @@ Available Functions // Prints: <a href="http://example.com">Click Here</a> -.. function:: anchor_popup($uri = '', $title = '', $attributes = FALSE) +.. php:function:: anchor_popup($uri = '', $title = '', $attributes = FALSE) :param string $uri: URI string :param string $title: Anchor title @@ -175,7 +175,7 @@ Available Functions :returns: Pop-up hyperlink :rtype: string - Nearly identical to the :func:`anchor()` function except that it + Nearly identical to the :php:func:`anchor()` function except that it opens the URL in a new window. You can specify JavaScript window attributes in the third parameter to control how the window is opened. If the third parameter is not set it will simply open a new window with @@ -211,7 +211,7 @@ Available Functions HTML attribute to the anchor tag. -.. function:: mailto($email, $title = '', $attributes = '') +.. php:function:: mailto($email, $title = '', $attributes = '') :param string $email: E-mail address :param string $title: Anchor title @@ -223,13 +223,13 @@ Available Functions echo mailto('me@my-site.com', 'Click Here to Contact Me'); - As with the :func:`anchor()` tab above, you can set attributes using the + As with the :php:func:`anchor()` tab above, you can set attributes using the third parameter:: $attributes = array('title' => 'Mail me'); echo mailto('me@my-site.com', 'Contact Me', $attributes); -.. function:: safe_mailto($email, $title = '', $attributes = '') +.. php:function:: safe_mailto($email, $title = '', $attributes = '') :param string $email: E-mail address :param string $title: Anchor title @@ -237,11 +237,11 @@ Available Functions :returns: A spam-safe "mail to" hyperlink :rtype: string - Identical to the :func:`mailto()` function except it writes an obfuscated + Identical to the :php:func:`mailto()` function except it writes an obfuscated version of the *mailto* tag using ordinal numbers written with JavaScript to help prevent the e-mail address from being harvested by spam bots. -.. function:: auto_link($str, $type = 'both', $popup = FALSE) +.. php:function:: auto_link($str, $type = 'both', $popup = FALSE) :param string $str: Input string :param string $type: Link type ('email', 'url' or 'both') @@ -256,7 +256,7 @@ Available Functions The second parameter determines whether URLs and e-mails are converted or just one or the other. Default behavior is both if the parameter is not - specified. E-mail links are encoded as :func:`safe_mailto()` as shown + specified. E-mail links are encoded as :php:func:`safe_mailto()` as shown above. Converts only URLs:: @@ -273,7 +273,7 @@ Available Functions $string = auto_link($string, 'both', TRUE); -.. function:: url_title($str, $separator = '-', $lowercase = FALSE) +.. php:function:: url_title($str, $separator = '-', $lowercase = FALSE) :param string $str: Input string :param string $separator: Word separator @@ -311,7 +311,7 @@ Available Functions // Produces: whats_wrong_with_css -.. function:: prep_url($str = '') +.. php:function:: prep_url($str = '') :param string $str: URL string :returns: Protocol-prefixed URL string @@ -325,7 +325,7 @@ Available Functions $url = prep_url('example.com'); -.. function:: redirect($uri = '', $method = 'auto', $code = NULL) +.. php:function:: redirect($uri = '', $method = 'auto', $code = NULL) :param string $uri: URI string :param string $method: Redirect method ('auto', 'location' or 'refresh') diff --git a/user_guide_src/source/helpers/xml_helper.rst b/user_guide_src/source/helpers/xml_helper.rst index a40ea9ad3..903e925c2 100644 --- a/user_guide_src/source/helpers/xml_helper.rst +++ b/user_guide_src/source/helpers/xml_helper.rst @@ -26,7 +26,7 @@ Available Functions The following functions are available: -.. function:: xml_convert($str[, $protect_all = FALSE]) +.. php:function:: xml_convert($str[, $protect_all = FALSE]) :param string $str: the text string to convert :param bool $protect_all: Whether to protect all content that looks like a potential entity instead of just numbered entities, e.g. &foo; diff --git a/user_guide_src/source/installation/downloads.rst b/user_guide_src/source/installation/downloads.rst index 63029856b..3b4ebe64b 100644 --- a/user_guide_src/source/installation/downloads.rst +++ b/user_guide_src/source/installation/downloads.rst @@ -2,40 +2,14 @@ Downloading CodeIgniter ####################### -- `CodeIgniter v3.0.0 (Current version) <http://ellislab.com/codeigniter/download>`_ -- `CodeIgniter v2.2.0 <http://ellislab.com/asset/ci_download_files/CodeIgniter_2.2.0.zip>`_ (MD5 Checksum: dbfddde4ec0b12027aee5156fbdd634b) -- `CodeIgniter v2.1.4 <http://ellislab.com/asset/ci_download_files/CodeIgniter_2.1.4.zip>`_ (MD5 Checksum: e74a296c1d412a855c025b9cd468a513) -- `CodeIgniter v2.1.3 <http://ellislab.com/asset/ci_download_files/CodeIgniter_2.1.3.zip>`_ (MD5 Checksum: 781d06be06eaa36f10759ef82c8594d5) -- `CodeIgniter v2.1.2 <http://ellislab.com/asset/ci_download_files/CodeIgniter_2.1.2.zip>`_ (MD5 Checksum: c7a2980dff2774c97bd38bfbf450d8d5) -- `CodeIgniter v2.1.1 <http://ellislab.com/asset/ci_download_files/CodeIgniter_2.1.1.zip>`_ (MD5 Checksum: c4aa5f188f4ff16f919607b46a16c76c) -- `CodeIgniter v2.1.0 <http://ellislab.com/asset/ci_download_files/CodeIgniter_2.1.0.zip>`_ (MD5 Checksum: 8cb676b0f831114935d7dd1ae2e0d490) -- `CodeIgniter v2.0.3 <http://ellislab.com/asset/ci_download_files/CodeIgniter_2.0.3.zip>`_ (MD5 Checksum: 910475d50daf088bdd949c3d35b444d9) -- `CodeIgniter v2.0.2 <http://ellislab.com/asset/ci_download_files/CodeIgniter_2.0.2.zip>`_ (MD5 Checksum: e75bab8cf27d2fb2483c5bb61b85a524) -- `CodeIgniter v2.0.1 <http://ellislab.com/asset/ci_download_files/CodeIgniter_2.0.1.zip>`_ (MD5 Checksum: 675aa95896bfb16467436c0484f15f1f) -- `CodeIgniter v2.0.0 <http://ellislab.com/asset/ci_download_files/CodeIgniter_2.0.0.zip>`_ (MD5 Checksum: bd657863de45dbb397f3b3dbc4f13abb) -- `CodeIgniter v1.7.3 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.7.3.zip>`_ (MD5 Checksum: 16f50e7df4f44c1defe18355131049e9) -- `CodeIgniter v1.7.2 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.7.2.zip>`_ (MD5 Checksum: ff2f4d1b3ab921f91e006f38b3ae6540) -- `CodeIgniter v1.7.1 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.7.1.zip>`_ (MD5 Checksum: deca9709cf21b26dc0e4ec040b37e866) -- `CodeIgniter v1.7.0 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.7.0.zip>`_ (MD5 Checksum: 28037f2071f940d8756864460d949045) -- `CodeIgniter v1.6.3 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.6.3.zip>`_ (MD5 Checksum: 5ffab52b39b235ed6bd08ee5dd64d2f6) -- `CodeIgniter v1.6.2 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.6.2.zip>`_ (MD5 Checksum: 0922830f96dfd40874b39ad018a49206) -- `CodeIgniter v1.6.1 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.6.1.zip>`_ (MD5 Checksum: cc3f0b566e3654d351fa067aeee9bced) -- `CodeIgniter v1.6.0 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.6.0.zip>`_ (MD5 Checksum: 89efabb8c1d57bb51071e6a20bb5590d) -- `CodeIgniter v1.5.4 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.5.4.zip>`_ (MD5 Checksum: 0d6cc66b01d5ddecde483b3d5f51e4f8) -- `CodeIgniter v1.5.3 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.5.3.zip>`_ (MD5 Checksum: f44dd21d34a2842bd052879ca5de6630) -- `CodeIgniter v1.5.2 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.5.2.zip>`_ (MD5 Checksum: 78e7106b271f75af48e626f6e923c1aa) -- `CodeIgniter v1.5.1 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.5.1.zip>`_ (MD5 Checksum: 9dfd0dbed4f283a42a817e1e88f97481) -- `CodeIgniter v1.5.0 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.5.0.zip>`_ (MD5 Checksum: 116b805eae4b7e78ddd43a8aee733632) -- `CodeIgniter v1.4.1 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.4.1.zip>`_ (MD5 Checksum: 470005a83772e9d2e99dec2b4058e584) -- `CodeIgniter v1.4.0 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.4.0.zip>`_ (MD5 Checksum: 43ca6ff3447d6b5681f98a328b386338) -- `CodeIgniter v1.3.3 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.3.3.zip>`_ (MD5 Checksum: 55692ba4b55b53b58e4514e310288981) -- `CodeIgniter v1.3.2 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.3.2.zip>`_ (MD5 Checksum: 7dace6e1d6245b569943e8df952c7637) -- `CodeIgniter v1.3.1 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.3.1.zip>`_ (MD5 Checksum: f6c6f00830c60d7f98b948269ee81069) -- `CodeIgniter v1.3 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.3.zip>`_ (MD5 Checksum: 03b2f796df6af808ecff3a18b6000477) -- `CodeIgniter v1.2 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.2.zip>`_ (MD5 Checksum: f9289814fabe102bc35beb791d0c0f62) -- `CodeIgniter v1.1 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.1b.zip>`_ (MD5 Checksum: bf4cabb6a3ea3122a974270b8044befb) -- `CodeIgniter v1.0 <http://ellislab.com/asset/ci_download_files/CodeIgniter_1.0b.zip>`_ (MD5 Checksum: 427ca4255e2bdaacee976de1aa143ea0) - +- `CodeIgniter v3.0.0 (Current version) <https://github.com/bcit-ci/CodeIgniter/archive/develop.zip>`_ +- `CodeIgniter v2.2.1 <https://github.com/bcit-ci/CodeIgniter/archive/2.2.1.zip>`_ +- `CodeIgniter v2.2.0 <https://github.com/bcit-ci/CodeIgniter/archive/2.2.0.zip>`_ +- `CodeIgniter v2.1.4 <https://github.com/bcit-ci/CodeIgniter/archive/2.1.4.zip>`_ +- `CodeIgniter v2.1.3 <https://github.com/bcit-ci/CodeIgniter/archive/2.1.3.zip>`_ +- `CodeIgniter v2.1.2 <https://github.com/bcit-ci/CodeIgniter/archive/2.1.2.zip>`_ +- `CodeIgniter v2.1.1 <https://github.com/bcit-ci/CodeIgniter/archive/2.1.1.zip>`_ +- `CodeIgniter v2.1.0 <https://github.com/bcit-ci/CodeIgniter/archive/v2.1.0.zip>`_ ****** GitHub diff --git a/user_guide_src/source/installation/upgrade_220.rst b/user_guide_src/source/installation/upgrade_220.rst index beb7bd7d7..b2e943223 100644 --- a/user_guide_src/source/installation/upgrade_220.rst +++ b/user_guide_src/source/installation/upgrade_220.rst @@ -2,7 +2,7 @@ Upgrading from 2.1.4 to 2.2.0 ############################# -.. note:: The :doc:`Encrypt Class <libraries/encrypt>` now requires the +.. note:: The :doc:`Encrypt Class </libraries/encrypt>` now requires the Mcrypt extension. If you were previously using the Encrypt Class without Mcrypt, then this is a breaking change. You must install the Mcrypt extension in order to upgrade. For information on diff --git a/user_guide_src/source/installation/upgrade_221.rst b/user_guide_src/source/installation/upgrade_221.rst new file mode 100644 index 000000000..4af73867e --- /dev/null +++ b/user_guide_src/source/installation/upgrade_221.rst @@ -0,0 +1,14 @@ +############################# +Upgrading from 2.2.0 to 2.2.1 +############################# + +Before performing an update you should take your site offline by +replacing the index.php file with a static one. + +Step 1: Update your CodeIgniter files +===================================== + +Replace all files and directories in your "system" folder. + +.. note:: If you have any custom developed files in these folders please + make copies of them first.
\ No newline at end of file diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index c84d16b31..8983f3d18 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -1,5 +1,5 @@ ############################# -Upgrading from 2.2.0 to 3.0.0 +Upgrading from 2.2.1 to 3.0.0 ############################# .. note:: These upgrade notes are for a version that is yet to be released. @@ -83,37 +83,117 @@ or extensions to work, you need to move them to **application/core/**:: application/libraries/Log.php -> application/core/Log.php application/libraries/MY_Log.php -> application/core/MY_Log.php -********************************************************* -Step 6: Convert your Session usage from library to driver -********************************************************* +***************************************** +Step 6: Update your Session library usage +***************************************** -When you load (or autoload) the Session library, you must now load it as a driver instead of a library. This means -calling ``$this->load->driver('session')`` instead of ``$this->load->library('session')`` and/or listing 'session' -in ``$autoload['drivers']`` instead of ``$autoload['libraries']``. +The :doc:`Session Library </libraries/sessions>` has been completely +re-written in CodeIgniter 3 and now comes with a bunch of new features, +but that also means that there are changes that you should make ... -With the change from a single Session Library to the new Session Driver, two new config items have been added: +Most notably, the library now uses separate storage drivers instead of +always relying on (encrypted) cookies. +In fact, cookies as storage have now been removed and you must always use +some kind of server-side storage engine, with the file-system being the +default option. - - ``$config['sess_driver']`` selects which driver to initially load. Options are: - - 'cookie' (the default) for classic CodeIgniter cookie-based sessions - - 'native' for native PHP Session support - - the name of a custom driver you have provided (see :doc:`Session Driver <../libraries/sessions>` for more info) - - ``$config['sess_valid_drivers']`` provides an array of additional custom drivers to make available for loading +The Session Class now utilizes PHP's own mechanisms for building custom +session handlers, which also means that your session data is now +accessible via the ``$_SESSION`` superglobal (though, we've kept the +possibility to use it as "userdata", like you've done until now). -As the new Session Driver library loads the classic Cookie driver by default and always makes 'cookie' and 'native' -available as valid drivers, neither of these configuration items are required. However, it is recommended that you -add them for clarity and ease of configuration in the future. +A few configuration options have been removed and a few have been added. +You should really read the whole :doc:`Session library manual +</libraries/sessions>` for the details, but here's a short list of changes +that you should make: -If you have written a Session extension, you must move it into a 'Session' sub-directory of 'libraries', following the -standard for Drivers. Also beware that some functions which are not part of the external Session API have moved into -the drivers, so your extension may have to be broken down into separate library and driver class extensions. + - Set your ``$config['sess_driver']`` value + + It will default to 'files', unles you've previously used + ``$config['sess_use_database']``, in which case it will be set to + 'database'. + + - Set a ``$config['sess_save_path']`` value + + For the 'database' driver, a fallback to ``$config['sess_table_name']`` + is in place, but otherwise requires you to read the manual for the + specific driver of your choice. + + - Update your ``ci_sessions`` table ('database' driver only) + + The table structure has changed a bit, and more specifically: + + - ``session_id`` field is renamed to ``id`` + - ``user_agent`` field is dropped + - ``user_data`` field is renamed to ``data`` and under MySQL is now of type BLOB + - ``last_activity`` field is renamed to ``timestamp`` + + This is accompanied by a slight change in the table indexes too, so + please read the manual about the `Session Database Driver + <../libraries/sessions.html#database-driver>`_ for more information. + + .. important:: Only MySQL and PostgreSQL are officially supported + now. Other databases may still work, but due to lack of advisory + locking features, they are unsafe for concurrent requests and + you should consider using another driver instead. + + - Remove ``$config['sess_match_useragent']`` + + The user-agent string is input supplied by the user's browser, or in + other words: client side input. As such, it is an ineffective feature + and hence why it has been removed. + + - Remove ``$config['sess_encrypt_cookie']`` + + As already noted, the library no longer uses cookies as a storage + mechanism, which renders this option useless. + + - Remove ``$config['sess_expire_on_close']`` + + This option is still usable, but only for backwards compatibility + purposes and it should be otherwise removed. The same effect is + achieved by setting ``$config['sess_expiration']`` to 0. + + - Check "flashdata" for collisions with "userdata" + + Flashdata is now just regular "userdata", only marked for deletion on + the next request. In other words: you can't have both "userdata" and + "flashdata" with the same name, because it's the same thing. + + - Check usage of session metadata + + Previously, you could access the 'session_id', 'ip_address', + 'user_agent' and 'last_activity' metadata items as userdata. + This is no longer possible, and you should read the notes about + `Session Metadata <../libraries/sessions.html#accessing-session-metadata>`_ + if your application relies on those values. + + - Check ``unset_userdata()`` usage + + Previously, this method used to accept an associative array of + ``'key' => 'dummy value'`` pairs for unsetting multiple keys. That + however makes no sense and you now have to pass *only* the keys, as + the elements of an array. + + :: + + // Old + $this->session->unset_userdata(array('item' => '', 'item2' => '')); + + // New + $this->session->unset_userdata(array('item', 'item2')); + +Finally, if you have written a Session extension, you must now move it to +the *application/libraries/Session/* directory, although chances are that +it will now also have to be re-factored. *************************************** Step 7: Update your config/database.php *************************************** -Due to 3.0.0's renaming of Active Record to Query Builder, inside your `config/database.php`, you will -need to rename the `$active_record` variable to `$query_builder` -:: +Due to 3.0.0's renaming of Active Record to Query Builder, inside your +**config/database.php**, you will need to rename the ``$active_record`` +variable to ``$query_builder``:: $active_group = 'default'; // $active_record = TRUE; @@ -217,7 +297,7 @@ Otherwise however, please review your usage of the following functions: - input->server() - input->input_stream() - - :doc:`Cookie Helper <../helpers/cookie_helper>` :func:`get_cookie()` + - :doc:`Cookie Helper <../helpers/cookie_helper>` :php:func:`get_cookie()` .. important:: Another related change is that the ``$_GET``, ``$_POST``, ``$_COOKIE`` and ``$_SERVER`` superglobals are no longer @@ -447,7 +527,7 @@ CodeIgniter 3.1+. String helper repeater() ======================== -:doc:`String Helper <../helpers/string_helper>` function :func:`repeater()` is now just an alias for +:doc:`String Helper <../helpers/string_helper>` function :php:func:`repeater()` is now just an alias for PHP's native ``str_repeat()`` function. It is deprecated and scheduled for removal in CodeIgniter 3.1+. .. note:: This function is still available, but you're strongly encouraged to remove its usage sooner @@ -456,20 +536,32 @@ PHP's native ``str_repeat()`` function. It is deprecated and scheduled for remov String helper trim_slashes() ============================ -:doc:`String Helper <../helpers/string_helper>` function :func:`trim_slashes()` is now just an alias +:doc:`String Helper <../helpers/string_helper>` function :php:func:`trim_slashes()` is now just an alias for PHP's native ``trim()`` function (with a slash passed as its second argument). It is deprecated and scheduled for removal in CodeIgniter 3.1+. .. note:: This function is still available, but you're strongly encouraged to remove its usage sooner rather than later. +Form helper form_prep() +======================= + +:doc:`Form Helper <../helpers/form_helper>` function :php:func:`form_prep()` +is now just an alias for :doc:`common function </general/common_functions>` +:func:`html_escape()`. It is deprecated and will be removed in the future. + +Please use :php:func:`html_escape()` instead. + +.. note:: This function is still available, but you're strongly encouraged + to remove its usage sooner rather than later. + Email helper functions ====================== :doc:`Email Helper <../helpers/email_helper>` only has two functions - - :func:`valid_email()` - - :func:`send_email()` + - :php:func:`valid_email()` + - :php:func:`send_email()` Both of them are now aliases for PHP's native ``filter_var()`` and ``mail()`` functions, respectively. Therefore the :doc:`Email Helper <../helpers/email_helper>` altogether is being deprecated and @@ -531,7 +623,7 @@ CodeIgniter 3.1+. String helper random_string() types 'unique' and 'encrypt' ========================================================== -When using the :doc:`String Helper <../helpers/string_helper>` function :func:`random_string()`, +When using the :doc:`String Helper <../helpers/string_helper>` function :php:func:`random_string()`, you should no longer pass the **unique** and **encrypt** randomization types. They are only aliases for **md5** and **sha1** respectively and are now deprecated and scheduled for removal in CodeIgniter 3.1+. @@ -542,7 +634,7 @@ in CodeIgniter 3.1+. URL helper url_title() separators 'dash' and 'underscore' ========================================================= -When using the :doc:`URL Helper <../helpers/url_helper>` function :func:`url_title()`, you +When using the :doc:`URL Helper <../helpers/url_helper>` function :php:func:`url_title()`, you should no longer pass **dash** or **underscore** as the word separator. This function will now accept any character and you should just pass the chosen character directly, so you should write '-' instead of 'dash' and '_' instead of 'underscore'. @@ -622,7 +714,7 @@ Input library method is_cli_request() Calls to the ``CI_Input::is_cli_request()`` method are necessary at many places in the CodeIgniter internals and this is often before the :doc:`Input Library <../libraries/input>` is loaded. Because of that, it is being replaced by a common -function named :func:`is_cli()` and this method is now just an alias. +function named :php:func:`is_cli()` and this method is now just an alias. The new function is both available at all times for you to use and shorter to type. diff --git a/user_guide_src/source/installation/upgrading.rst b/user_guide_src/source/installation/upgrading.rst index 366aa13f7..ab36e9bfd 100644 --- a/user_guide_src/source/installation/upgrading.rst +++ b/user_guide_src/source/installation/upgrading.rst @@ -8,7 +8,9 @@ upgrading from. .. toctree:: :titlesonly: - Upgrading from 2.1.4 to 3.0.0 <upgrade_300> + Upgrading from 2.2.1 to 3.0.0 <upgrade_300> + Upgrading from 2.2.0 to 2.2.1 <upgrade_221> + Upgrading from 2.1.4 to 2.2.0 <upgrade_220> Upgrading from 2.1.3 to 2.1.4 <upgrade_214> Upgrading from 2.1.2 to 2.1.3 <upgrade_213> Upgrading from 2.1.1 to 2.1.2 <upgrade_212> 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 |