From 48a8675c3a50beba5a22080ea11050287b5866bb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 8 Nov 2012 15:16:34 +0200 Subject: Polish docs for Array, CAPTCHA, Cookie, Date, Directory and Download helpers --- user_guide_src/source/helpers/array_helper.rst | 66 ++--- user_guide_src/source/helpers/captcha_helper.rst | 99 +++---- user_guide_src/source/helpers/cookie_helper.rst | 65 ++--- user_guide_src/source/helpers/date_helper.rst | 339 ++++++++++------------ user_guide_src/source/helpers/download_helper.rst | 32 +- 5 files changed, 275 insertions(+), 326 deletions(-) diff --git a/user_guide_src/source/helpers/array_helper.rst b/user_guide_src/source/helpers/array_helper.rst index 15b5e17c4..9435b3ac7 100644 --- a/user_guide_src/source/helpers/array_helper.rst +++ b/user_guide_src/source/helpers/array_helper.rst @@ -10,9 +10,7 @@ arrays. Loading this Helper =================== -This helper is loaded using the following code - -:: +This helper is loaded using the following code:: $this->load->helper('array'); @@ -21,20 +19,19 @@ The following functions are available: element() ========= -.. php:method:: element($item, $array, $default = NULL) - - :param string $item: Item to fetch from the array - :param array $array: Input array - :param boolean $default: What to return if the array isn't valid - :returns: NULL on failure or the array item. +.. php:function:: element($item, $array, $default = NULL) + :param string $item: Item to fetch from the array + :param array $array: Input array + :param bool $default: What to return if the array isn't valid + :returns: NULL on failure or the array item. Lets you fetch an item from an array. The function tests whether the array index is set and whether it has a value. If a value exists it is returned. If a value does not exist it returns NULL, or whatever you've -specified as the default value via the third parameter. Example +specified as the default value via the third parameter. -:: +Example:: $array = array( 'color' => 'red', @@ -48,21 +45,19 @@ specified as the default value via the third parameter. Example elements() ========== +.. php:function:: elements($items, $array, $default = NULL) + + :param string $item: Item to fetch from the array + :param array $array: Input array + :param bool $default: What to return if the array isn't valid + :returns: NULL on failure or the array item. + Lets you fetch a number of items from an array. The function tests whether each of the array indices is set. If an index does not exist it is set to NULL, or whatever you've specified as the default value via the third parameter. -.. php:method:: elements($items, $array, $default = NULL) - - :param string $item: Item to fetch from the array - :param array $array: Input array - :param boolean $default: What to return if the array isn't valid - :returns: NULL on failure or the array item. - -Example - -:: +Example:: $array = array( 'color' => 'red', @@ -73,9 +68,7 @@ Example $my_shape = elements(array('color', 'shape', 'height'), $array); -The above will return the following array - -:: +The above will return the following array:: array( 'color' => 'red', @@ -83,15 +76,12 @@ The above will return the following array 'height' => NULL ); -You can set the third parameter to any default value you like - +You can set the third parameter to any default value you like. :: $my_shape = elements(array('color', 'shape', 'height'), $array, 'foobar'); -The above will return the following array - -:: +The above will return the following array:: array(      'color' => 'red', @@ -99,9 +89,9 @@ The above will return the following array 'height' => 'foobar' ); -This is useful when sending the $_POST array to one of your Models. +This is useful when sending the ``$_POST`` array to one of your Models. This prevents users from sending additional POST data to be entered into -your tables +your tables. :: @@ -116,15 +106,14 @@ updated. random_element() ================ -Takes an array as input and returns a random element from it. Usage -example +.. php:function:: random_element($array) -.. php:method:: random_element($array) + :param array $array: Input array + :returns: string (a random element from the array) - :param array $array: Input array - :returns: String - Random element from the array. +Takes an array as input and returns a random element from it. -:: +Usage example:: $quotes = array( "I find that the harder I work, the more luck I seem to have. - Thomas Jefferson", @@ -135,5 +124,4 @@ example "Chance favors the prepared mind - Louis Pasteur" ); - echo random_element($quotes); - + echo random_element($quotes); \ No newline at end of file diff --git a/user_guide_src/source/helpers/captcha_helper.rst b/user_guide_src/source/helpers/captcha_helper.rst index 90244739b..17462a8de 100644 --- a/user_guide_src/source/helpers/captcha_helper.rst +++ b/user_guide_src/source/helpers/captcha_helper.rst @@ -11,78 +11,72 @@ Loading this Helper =================== This helper is loaded using the following code - :: $this->load->helper('captcha'); The following functions are available: -create_captcha($data) -===================== +create_captcha() +================ + +.. php:function:: 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 + :param string $img_url: URL to the CAPTCHA image folder + :param string $font_path: Server path to font + :returns: array('word' => $word, 'time' => $now, 'image' => $img) Takes an array of information to generate the CAPTCHA as input and creates the image to your specifications, returning an array of associative data about the image. -.. php:method:: 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 - :param string $img_url: URL to the CAPTCHA image folder - :param string $font_path: server path to font - :returns: array('word' => $word, 'time' => $now, 'image' => $img) - - :: - [array] ( - 'image' => IMAGE TAG    - 'time' => TIMESTAMP (in microtime)    - 'word' => CAPTCHA WORD ) + array( + 'image' => IMAGE TAG + 'time' => TIMESTAMP (in microtime) + 'word' => CAPTCHA WORD + ) -The "image" is the actual image tag: - -:: +The **image** is the actual image tag:: - -The "time" is the micro timestamp used as the image name without the +The **time** is the micro timestamp used as the image name without the file extension. It will be a number like this: 1139612155.3422 -The "word" is the word that appears in the captcha image, which if not +The **word** is the word that appears in the captcha image, which if not supplied to the function, will be a random string. Using the CAPTCHA helper ------------------------ -Once loaded you can generate a captcha like this - -:: +Once loaded you can generate a captcha like this:: - $vals = array(      - 'word' => 'Random word',      - 'img_path' => './captcha/',      - 'img_url' => 'http://example.com/captcha/',      - 'font_path' => './path/to/fonts/texb.ttf',      - 'img_width' => '150',      - 'img_height' => 30,      - 'expiration' => 7200      + $vals = array( + 'word' => 'Random word', + 'img_path' => './captcha/', + 'img_url' => 'http://example.com/captcha/', + 'font_path' => './path/to/fonts/texb.ttf', + 'img_width' => '150', + 'img_height' => 30, + 'expiration' => 7200 ); - $cap = create_captcha($vals); echo $cap['image']; - + $cap = create_captcha($vals); + echo $cap['image']; - The captcha function requires the GD image library. -- Only the img_path and img_url are required. -- If a "word" is not supplied, the function will generate a random +- Only the **img_path** and **img_url** are required. +- If a **word** is not supplied, the function will generate a random ASCII string. You might put together your own word library that you can draw randomly from. - If you do not specify a path to a TRUE TYPE font, the native ugly GD font will be used. - The "captcha" folder must be writable (666, or 777) -- The "expiration" (in seconds) signifies how long an image will remain +- The **expiration** (in seconds) signifies how long an image will remain in the captcha folder before it will be deleted. The default is two hours. @@ -90,14 +84,12 @@ Adding a Database ----------------- In order for the captcha function to prevent someone from submitting, -you will need to add the information returned from create_captcha() -function to your database. Then, when the data from the form is -submitted by the user you will need to verify that the data exists in -the database and has not expired. +you will need to add the information returned from ``create_captcha()`` +to your database. Then, when the data from the form is submitted by +the user you will need to verify that the data exists in the database +and has not expired. -Here is a table prototype - -:: +Here is a table prototype:: CREATE TABLE captcha (   captcha_id bigint(13) unsigned NOT NULL auto_increment,   @@ -109,9 +101,7 @@ Here is a table prototype ); Here is an example of usage with a database. On the page where the -CAPTCHA will be shown you'll have something like this - -:: +CAPTCHA will be shown you'll have something like this:: $this->load->helper('captcha'); $vals = array(      @@ -134,23 +124,20 @@ CAPTCHA will be shown you'll have something like this echo ''; Then, on the page that accepts the submission you'll have something like -this - -:: +this:: // First, delete old captchas $expiration = time() - 7200; // Two hour limit $this->db->where('captcha_time < ', $expiration) - ->delete('captcha'); + ->delete('captcha'); // Then see if a captcha exists: - $sql = "SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND captcha_time > ?"; + $sql = 'SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND captcha_time > ?'; $binds = array($_POST['captcha'], $this->input->ip_address(), $expiration); $query = $this->db->query($sql, $binds); $row = $query->row(); if ($row->count == 0) {      - echo "You must submit the word that appears in the image"; - } - + echo 'You must submit the word that appears in the image.'; + } \ No newline at end of file diff --git a/user_guide_src/source/helpers/cookie_helper.rst b/user_guide_src/source/helpers/cookie_helper.rst index 30e601c32..c41193c3c 100644 --- a/user_guide_src/source/helpers/cookie_helper.rst +++ b/user_guide_src/source/helpers/cookie_helper.rst @@ -10,9 +10,7 @@ cookies. Loading this Helper =================== -This helper is loaded using the following code - -:: +This helper is loaded using the following code:: $this->load->helper('cookie'); @@ -21,52 +19,53 @@ The following functions are available: set_cookie() ============ +.. php:function:: set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE) + + :param string $name: Cookie name + :param string $value: Cookie value + :param int $expire: Number of seconds until expiration + :param string $domain: Cookie domain (usually: .yourdomain.com) + :param string $path: Cookie path + :param string $prefix: Cookie name prefix + :param bool $secure: Whether to only send the cookie through HTTPS + :param bool $httponly: Whether to hide the cookie from JavaScript + :returns: void + This helper function gives you view file friendly syntax to set browser -cookies. Refer to the :doc:`Input class <../libraries/input>` for a -description of use, as this function is an alias to -`$this->input->set_cookie()`. - -.. php:method:: set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE) - - :param string $name: the name of the cookie - :param string $value: the value of the cookie - :param string $expire: the number of seconds until expiration - :param string $domain: the cookie domain. Usually: .yourdomain.com - :param string $path: the cookie path - :param string $prefix: the cookie prefix - :param boolean $secure: secure cookie or not. - :returns: void +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()``. get_cookie() ============ -This helper function gives you view file friendly syntax to get browser -cookies. Refer to the :doc:`Input class <../libraries/input>` for a -description of use, as this function is an alias to `$this->input->cookie()`. +.. php:function:: get_cookie($index = '', $xss_clean = FALSE) -.. php:method:: get_cookie($index = '', $xss_clean = FALSE) + :param string $index: Cookie name + :param bool $xss_clean: Whether to apply XSS filtering to the returned value + :returns: mixed - :param string $index: the name of the cookie - :param boolean $xss_clean: If the resulting value should be xss_cleaned or not - :returns: 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 itsuse, as this function is an alias for ``CI_Input::cookie()``. delete_cookie() =============== -Lets you delete a cookie. Unless you've set a custom path or other -values, only the name of the cookie is needed - -.. php:method:: delete_cookie($name = '', $domain = '', $path = '/', $prefix = '') +.. php:function:: delete_cookie($name = '', $domain = '', $path = '/', $prefix = '') - :param string $name: the name of the cookie - :param string $domain: cookie domain (ususally .example.com) - :param string $path: cookie path - :param string $prefix: cookie prefix + :param string $name: Cookie name + :param string $domain: Cookie domain (usually: .yourdomain.com) + :param string $path: Cookie path + :param string $prefix: Cookie name prefix :returns: void +Lets you delete a cookie. Unless you've set a custom path or other +values, only the name of the cookie is needed. + :: - delete_cookie("name"); + delete_cookie('name'); This function is otherwise identical to ``set_cookie()``, except that it does not have the value and expiration parameters. You can submit an diff --git a/user_guide_src/source/helpers/date_helper.rst b/user_guide_src/source/helpers/date_helper.rst index 9de925ba7..3a3454edc 100644 --- a/user_guide_src/source/helpers/date_helper.rst +++ b/user_guide_src/source/helpers/date_helper.rst @@ -9,9 +9,7 @@ The Date Helper file contains functions that help you work with dates. Loading this Helper =================== -This helper is loaded using the following code - -:: +This helper is loaded using the following code:: $this->load->helper('date'); @@ -20,44 +18,45 @@ The following functions are available: now() ===== -Returns the current time as a Unix timestamp, referenced either to your -server's local time or any PHP suported timezone, based on the "time reference" -setting in your config file. If you do not intend to set your master time reference -to any other PHP suported timezone (which you'll typically do if you run a site that -lets each user set their own timezone settings) there is no benefit to using this -function over PHP's time() function. +.. php:function:: now($timezone = NULL) -.. php:method:: now($timezone = NULL) + :param string $timezone: Timezone + :returns: int - :param string $timezone: The timezone you want to be returned - :returns: integer +Returns the current time as a UNIX timestamp, referenced either to your server's +local time or any PHP suported timezone, based on the "time reference" setting +in your config file. If you do not intend to set your master time reference to +any other PHP supported timezone (which you'll typically do if you run a site +that lets each user set their own timezone settings) there is no benefit to using +this function over PHP's ``time()`` function. :: - echo now("Australia/Victoria"); -If a timezone is not provided, it will return time() based on "time_reference" setting. + echo now('Australia/Victoria'); + +If a timezone is not provided, it will return ``time()`` based on the +**time_reference** setting. mdate() ======= +.. php:function:: mdate($datestr = '', $time = '') + + :param string $datestr: Date string + :param int $time: UNIX timestamp + :returns: int + This function is identical to PHP's `date() `_ function, except that it lets you use MySQL style date codes, where each -code letter is preceded with a percent sign: %Y %m %d etc. +code letter is preceded with a percent sign, e.g. `%Y %m %d` The benefit of doing dates this way is that you don't have to worry about escaping any characters that are not date codes, as you would -normally have to do with the date() function. Example - -.. php:method:: mdate($datestr = '', $time = '') +normally have to do with the ``date()`` function. - :param string $datestr: Date String - :param integer $time: time - :returns: integer +Example:: - -:: - - $datestring = "Year: %Y Month: %m Day: %d - %h:%i %a"; + $datestring = 'Year: %Y Month: %m Day: %d - %h:%i %a'; $time = time(); echo mdate($datestring, $time); @@ -67,32 +66,30 @@ will be used. standard_date() =============== -Lets you generate a date string in one of several standardized formats. -Example +.. php:function:: standard_date($fmt = 'DATE_RFC822', $time = NULL) -.. php:method:: standard_date($fmt = 'DATE_RFC822', $time = '') + :param string $fmt: Date format + :param int $time: UNIX timestamp + :returns: string - :param string $fmt: the chosen format - :param string $time: Unix timestamp - :returns: string +Lets you generate a date string in one of several standardized formats. -:: +Example:: $format = 'DATE_RFC822'; $time = time(); echo standard_date($format, $time); -The first parameter must contain the format, the second parameter must -contain the date as a Unix timestamp. - -.. note:: This function is DEPRECATED. Use the native ``date()`` combined - with `DateTime's format constants `_ +.. note:: This function is DEPRECATED.Use the native ``date()`` combined with + `DateTime's format constants + `_ instead: | | echo date(DATE_RFC822, time()); -Supported formats: +Supported formats +----------------- =============== ======================= ====================================== Constant Description Example @@ -112,39 +109,34 @@ DATE_W3C W3C 2005-08-14T16:13:03+0000 local_to_gmt() ============== -Takes a Unix timestamp as input and returns it as GMT. +.. php:function:: local_to_gmt($time = '') -.. php:method:: local_to_gmt($time = '') + :param int $time: UNIX timestamp + :returns: string - :param integer $time: Unix timestamp - :returns: string +Takes a UNIX timestamp as input and returns it as GMT. -Example: +Example:: -:: - - $now = time(); - $gmt = local_to_gmt($now); + $gmt = local_to_gmt(time()); gmt_to_local() ============== -Takes a Unix timestamp (referenced to GMT) as input, and converts it to -a localized timestamp based on the timezone and Daylight Saving time -submitted. - -.. php:method:: gmt_to_local($time = '', $timezone = 'UTC', $dst = FALSE) +.. php:function:: gmt_to_local($time = '', $timezone = 'UTC', $dst = FALSE) - :param integer $time: Unix timestamp - :param string $timezone: timezone - :param boolean $dst: whether DST is active - :returns: integer + :param int $time: UNIX timestamp + :param string $timezone: Timezone + :param bool $dst: Whether DST is active + :returns: int -Example +Takes a UNIX timestamp (referenced to GMT) as input, and converts it to +a localized timestamp based on the timezone and Daylight Saving Time +submitted. -:: +Example:: - $timestamp = '1140153693'; + $timestamp = 1140153693; $timezone = 'UM8'; $daylight_saving = TRUE; echo gmt_to_local($timestamp, $timezone, $daylight_saving); @@ -152,40 +144,32 @@ Example .. note:: For a list of timezones see the reference at the bottom of this page. - mysql_to_unix() =============== -Takes a MySQL Timestamp as input and returns it as Unix. +.. php:function:: mysql_to_unix($time = '') -.. php:method:: mysql_to_unix($time = '') + :param int $time: UNIX timestamp + :returns: int - :param integer $time: Unix timestamp - :returns: integer - -Example +Takes a MySQL Timestamp as input and returns it as a UNIX timestamp. -:: +Example:: - $mysql = '20061124092345'; - $unix = mysql_to_unix($mysql); + $unix = mysql_to_unix('20061124092345'); unix_to_human() =============== -Takes a Unix timestamp as input and returns it in a human readable -format with this prototype +.. php:function:: unix_to_human($time = '', $seconds = FALSE, $fmt = 'us') -.. php:method:: unix_to_human($time = '', $seconds = FALSE, $fmt = 'us') - - :param integer $time: Unix timestamp - :param boolean $seconds: whether to show seconds - :param string $fmt: format: us or euro + :param int $time: UNIX timestamp + :param bool $seconds: Whether to show seconds + :param string $fmt: format (us or euro) :returns: integer -Example - -:: +Takes a UNIX timestamp as input and returns it in a human readable +format with this prototype:: YYYY-MM-DD HH:MM:SS AM/PM @@ -194,9 +178,9 @@ submission. The time can be formatted with or without seconds, and it can be set to European or US format. If only the timestamp is submitted it will return -the time without seconds formatted for the U.S. Examples +the time without seconds formatted for the U.S. -:: +Examples:: $now = time(); echo unix_to_human($now); // U.S. time, no seconds @@ -206,19 +190,17 @@ the time without seconds formatted for the U.S. Examples human_to_unix() =============== -The opposite of the above function. Takes a "human" time as input and -returns it as Unix. This function is useful if you accept "human" -formatted dates submitted via a form. Returns FALSE (boolean) if the -date string passed to it is not formatted as indicated above. +.. php:function:: human_to_unix($datestr = '') -.. php:method:: human_to_unix($datestr = '') - - :param integer $datestr: Date String - :returns: integer + :param int $datestr: Date string + :returns: int UNIX timestamp or FALSE on failure -Example: +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. -:: +Example:: $now = time(); $human = unix_to_human($now); @@ -227,22 +209,20 @@ Example: nice_date() =========== -This function can take a number poorly-formed date formats and convert -them into something useful. It also accepts well-formed dates. - -The function will return a Unix timestamp by default. You can, -optionally, pass a format string (the same type as the PHP date function -accepts) as the second parameter. +.. php:function:: nice_date($bad_date = '', $format = FALSE) -.. php:method:: 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) + :returns: string - :param integer $bad_date: The terribly formatted date-like string - :param string $format: Date format to return (same as php date function) - :returns: string +This function can take a number poorly-formed date formats and convert +them into something useful. It also accepts well-formed dates. -Example +The function will return a UNIX timestamp by default. You can, optionally, +pass a format string (the same type as the PHP ``date()`` function accepts) +as the second parameter. -:: +Example:: $bad_date = '199605'; // Should Produce: 1996-05-01 @@ -255,28 +235,28 @@ Example timespan() ========== -Formats a unix timestamp so that is appears similar to this -:: +.. php:function:: timespan($seconds = 1, $time = '', $units = '') - 1 Year, 10 Months, 2 Weeks, 5 Days, 10 Hours, 16 Minutes + :param int $seconds: Number of seconds + :param string $time: UNIX timestamp + :param int $units: Number of time units to display + :returns: string -The first parameter must contain a Unix timestamp. The second parameter -must contain a timestamp that is greater that the first timestamp. If -the second parameter empty, the current time will be used. The third -parameter is optional and limits the number of time units to display. -The most common purpose for this function is to show how much time has -elapsed from some point in time in the past to now. +Formats a UNIX timestamp so that is appears similar to this:: -.. php:method:: timespan($seconds = 1, $time = '', $units = '') + 1 Year, 10 Months, 2 Weeks, 5 Days, 10 Hours, 16 Minutes - :param integer $seconds: a number of seconds - :param string $time: Unix timestamp - :param integer $units: a number of time units to display - :returns: string +The first parameter must contain a UNIX timestamp. +The second parameter must contain a timestamp that is greater that the +first timestamp. +The thirdparameter is optional and limits the number of time units to display. -Example +If the second parameter empty, the current time will be used. -:: +The most common purpose for this function is to show how much time has +elapsed from some point in time in the past to now. + +Example:: $post_date = '1079621429'; $now = time(); @@ -284,23 +264,21 @@ Example echo timespan($post_date, $now, $units); .. note:: The text generated by this function is found in the following language - file: language//date_lang.php + file: `language//date_lang.php` days_in_month() =============== -Returns the number of days in a given month/year. Takes leap years into -account. +.. php:function:: days_in_month($month = 0, $year = '') -.. php:method:: days_in_month($month = 0, $year = '') + :param int $month: a numeric month + :param int $year: a numeric year + :returns: int - :param integer $month: a numeric month - :param integer $year: a numeric year - :returns: integer - -Example +Returns the number of days in a given month/year. Takes leap years into +account. -:: +Example:: echo days_in_month(06, 2005); @@ -309,19 +287,17 @@ If the second parameter is empty, the current year will be used. date_range() ============ -Returns a list of dates within a specified period. - -.. php:method:: 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 integer $unix_start: UNIX timestamp of the range start date - :param integer $mixed: UNIX timestamp of the range end date or interval in days - :param boolean $is_unix: set to FALSE if $mixed is not a timestamp - :param string $format: output date format, same as in date() - :returns: array + :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 + :param bool $is_unix: set to FALSE if $mixed is not a timestamp + :param string $format: Output date format, same as in ``date()`` + :returns: array -Example +Returns a list of dates within a specified period. -:: +Example:: $range = date_range('2012-01-01', '2012-01-15'); echo "First 15 days of 2012:"; @@ -333,29 +309,34 @@ Example timezones() =========== +.. php:function:: timezones($tz = '') + + :param string $tz: a numeric timezone + :returns: string + Takes a timezone reference (for a list of valid timezones, see the "Timezone Reference" below) and returns the number of hours offset from UTC. -.. php:method:: timezones($tz = '') - - :param string $tz: a numeric timezone - :returns: string - -Example - -:: +Example:: echo timezones('UM5'); -This function is useful when used with `timezone_menu()`. +This function is useful when used with :php:func:`timezone_menu()`. timezone_menu() =============== -Generates a pull-down menu of timezones, like this one: +.. php:function:: timezone_menu($default = 'UTC', $class = '', $name = 'timezones', $attributes = '') + :param string $default: Timezone + :param string $class: Class name + :param string $name: Menu name + :param mixed $attributes: HTML attributes + :returns: string + +Generates a pull-down menu of timezones, like this one: .. raw:: html @@ -409,19 +390,7 @@ This menu is useful if you run a membership site in which your users are allowed to set their local timezone value. The first parameter lets you set the "selected" state of the menu. For -example, to set Pacific time as the default you will do this - -.. php:method:: timezone_menu($default = 'UTC', $class = '', $name = 'timezones', $attributes = '') - - :param string $default: timezone - :param string $class: classname - :param string $name: menu name - :param mixed $attributes: attributes - :returns: string - -Example: - -:: +example, to set Pacific time as the default you will do this:: echo timezone_menu('UM8'); @@ -445,37 +414,37 @@ Note some of the location lists have been abridged for clarity and formatting. =========== ===================================================================== Time Zone Location =========== ===================================================================== -UM2 (UTC - 12:00) Baker/Howland Island -UM1 (UTC - 11:00) Samoa Time Zone, Niue -UM0 (UTC - 10:00) Hawaii-Aleutian Standard Time, Cook Islands +UM2 (UTC - 12:00) Baker/Howland Island +UM1 (UTC - 11:00) Samoa Time Zone, Niue +UM0 (UTC - 10:00) Hawaii-Aleutian Standard Time, Cook Islands UM95 (UTC - 09:30) Marquesas Islands -UM9 (UTC - 09:00) Alaska Standard Time, Gambier Islands -UM8 (UTC - 08:00) Pacific Standard Time, Clipperton Island -UM7 (UTC - 11:00) Mountain Standard Time -UM6 (UTC - 06:00) Central Standard Time -UM5 (UTC - 05:00) Eastern Standard Time, Western Caribbean +UM9 (UTC - 09:00) Alaska Standard Time, Gambier Islands +UM8 (UTC - 08:00) Pacific Standard Time, Clipperton Island +UM7 (UTC - 11:00) Mountain Standard Time +UM6 (UTC - 06:00) Central Standard Time +UM5 (UTC - 05:00) Eastern Standard Time, Western Caribbean UM45 (UTC - 04:30) Venezuelan Standard Time -UM4 (UTC - 04:00) Atlantic Standard Time, Eastern Caribbean +UM4 (UTC - 04:00) Atlantic Standard Time, Eastern Caribbean UM35 (UTC - 03:30) Newfoundland Standard Time -UM3 (UTC - 03:00) Argentina, Brazil, French Guiana, Uruguay -UM2 (UTC - 02:00) South Georgia/South Sandwich Islands -UM (UTC -1:00) Azores, Cape Verde Islands -UTC (UTC) Greenwich Mean Time, Western European Time -UP1 (UTC +1:00) Central European Time, West Africa Time -UP2 (UTC +2:00) Central Africa Time, Eastern European Time -UP3 (UTC +3:00) Moscow Time, East Africa Time +UM3 (UTC - 03:00) Argentina, Brazil, French Guiana, Uruguay +UM2 (UTC - 02:00) South Georgia/South Sandwich Islands +UM (UTC -1:00) Azores, Cape Verde Islands +UTC (UTC) Greenwich Mean Time, Western European Time +UP1 (UTC +1:00) Central European Time, West Africa Time +UP2 (UTC +2:00) Central Africa Time, Eastern European Time +UP3 (UTC +3:00) Moscow Time, East Africa Time UP35 (UTC +3:30) Iran Standard Time -UP4 (UTC +4:00) Azerbaijan Standard Time, Samara Time +UP4 (UTC +4:00) Azerbaijan Standard Time, Samara Time UP45 (UTC +4:30) Afghanistan -UP5 (UTC +5:00) Pakistan Standard Time, Yekaterinburg Time +UP5 (UTC +5:00) Pakistan Standard Time, Yekaterinburg Time UP55 (UTC +5:30) Indian Standard Time, Sri Lanka Time UP575 (UTC +5:45) Nepal Time -UP6 (UTC +6:00) Bangladesh Standard Time, Bhutan Time, Omsk Time +UP6 (UTC +6:00) Bangladesh Standard Time, Bhutan Time, Omsk Time UP65 (UTC +6:30) Cocos Islands, Myanmar -UP7 (UTC +7:00) Krasnoyarsk Time, Cambodia, Laos, Thailand, Vietnam -UP8 (UTC +8:00) Australian Western Standard Time, Beijing Time +UP7 (UTC +7:00) Krasnoyarsk Time, Cambodia, Laos, Thailand, Vietnam +UP8 (UTC +8:00) Australian Western Standard Time, Beijing Time UP875 (UTC +8:45) Australian Central Western Standard Time -UP9 (UTC +9:00) Japan Standard Time, Korea Standard Time, Yakutsk +UP9 (UTC +9:00) Japan Standard Time, Korea Standard Time, Yakutsk UP95 (UTC +9:30) Australian Central Standard Time UP10 (UTC +10:00) Australian Eastern Standard Time, Vladivostok Time UP105 (UTC +10:30) Lord Howe Island @@ -483,6 +452,6 @@ UP11 (UTC +11:00) Magadan Time, Solomon Islands, Vanuatu UP115 (UTC +11:30) Norfolk Island UP12 (UTC +12:00) Fiji, Gilbert Islands, Kamchatka, New Zealand UP1275 (UTC +12:45) Chatham Islands Standard Time -UP1 (UTC +13:00) Phoenix Islands Time, Tonga +UP1 (UTC +13:00) Phoenix Islands Time, Tonga UP14 (UTC +14:00) Line Islands =========== ===================================================================== \ No newline at end of file diff --git a/user_guide_src/source/helpers/download_helper.rst b/user_guide_src/source/helpers/download_helper.rst index e6094dc6b..1e9ec21ea 100644 --- a/user_guide_src/source/helpers/download_helper.rst +++ b/user_guide_src/source/helpers/download_helper.rst @@ -9,34 +9,40 @@ The Download Helper lets you download data to your desktop. Loading this Helper =================== -This helper is loaded using the following code - -:: +This helper is loaded using the following code:: $this->load->helper('download'); The following functions are available: -force_download('filename', 'data') -================================== +force_download() +================ + +.. php:function:: force_download($filename = '', $data = '', $set_mime = FALSE) + + :param string $filename: Filename + :param string $data: File contents + :param bool $set_mime: Whether to try to send the actual MIME type + :returns: void Generates server headers which force data to be downloaded to your desktop. Useful with file downloads. The first parameter is the **name you want the downloaded file to be named**, the second parameter is the -file data. Example +file data. + +If you set the third parameter to boolean TRUE, then the actual file MIME type +(based on the filename extension) will be sent, so that if your browser has a +handler for that type - it can use it. -:: +Example:: $data = 'Here is some text!'; $name = 'mytext.txt'; force_download($name, $data); If you want to download an existing file from your server you'll need to -read the file into a string +read the file into a string:: -:: - - $data = file_get_contents("/path/to/photo.jpg"); // Read the file's contents + $data = file_get_contents('/path/to/photo.jpg'); // Read the file's contents $name = 'myphoto.jpg'; - force_download($name, $data); - + force_download($name, $data); \ No newline at end of file -- cgit v1.2.3-24-g4f1b