From d2e4ccfe3bba903227c3686b9390d8b9525b197d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 12 Dec 2016 15:15:39 +0200 Subject: Remove previously deprecated Smiley Helper --- application/config/smileys.php | 64 ------ system/helpers/smiley_helper.php | 255 --------------------- user_guide_src/source/changelog.rst | 9 +- user_guide_src/source/helpers/smiley_helper.rst | 169 -------------- user_guide_src/source/images/smile.gif | Bin 1156 -> 0 bytes user_guide_src/source/installation/upgrade_300.rst | 12 +- user_guide_src/source/installation/upgrade_320.rst | 4 +- 7 files changed, 14 insertions(+), 499 deletions(-) delete mode 100644 application/config/smileys.php delete mode 100644 system/helpers/smiley_helper.php delete mode 100644 user_guide_src/source/helpers/smiley_helper.rst delete mode 100644 user_guide_src/source/images/smile.gif diff --git a/application/config/smileys.php b/application/config/smileys.php deleted file mode 100644 index abf9a898d..000000000 --- a/application/config/smileys.php +++ /dev/null @@ -1,64 +0,0 @@ - array('grin.gif', '19', '19', 'grin'), - ':lol:' => array('lol.gif', '19', '19', 'LOL'), - ':cheese:' => array('cheese.gif', '19', '19', 'cheese'), - ':)' => array('smile.gif', '19', '19', 'smile'), - ';-)' => array('wink.gif', '19', '19', 'wink'), - ';)' => array('wink.gif', '19', '19', 'wink'), - ':smirk:' => array('smirk.gif', '19', '19', 'smirk'), - ':roll:' => array('rolleyes.gif', '19', '19', 'rolleyes'), - ':-S' => array('confused.gif', '19', '19', 'confused'), - ':wow:' => array('surprise.gif', '19', '19', 'surprised'), - ':bug:' => array('bigsurprise.gif', '19', '19', 'big surprise'), - ':-P' => array('tongue_laugh.gif', '19', '19', 'tongue laugh'), - '%-P' => array('tongue_rolleye.gif', '19', '19', 'tongue rolleye'), - ';-P' => array('tongue_wink.gif', '19', '19', 'tongue wink'), - ':P' => array('raspberry.gif', '19', '19', 'raspberry'), - ':blank:' => array('blank.gif', '19', '19', 'blank stare'), - ':long:' => array('longface.gif', '19', '19', 'long face'), - ':ohh:' => array('ohh.gif', '19', '19', 'ohh'), - ':grrr:' => array('grrr.gif', '19', '19', 'grrr'), - ':gulp:' => array('gulp.gif', '19', '19', 'gulp'), - '8-/' => array('ohoh.gif', '19', '19', 'oh oh'), - ':down:' => array('downer.gif', '19', '19', 'downer'), - ':red:' => array('embarrassed.gif', '19', '19', 'red face'), - ':sick:' => array('sick.gif', '19', '19', 'sick'), - ':shut:' => array('shuteye.gif', '19', '19', 'shut eye'), - ':-/' => array('hmm.gif', '19', '19', 'hmmm'), - '>:(' => array('mad.gif', '19', '19', 'mad'), - ':mad:' => array('mad.gif', '19', '19', 'mad'), - '>:-(' => array('angry.gif', '19', '19', 'angry'), - ':angry:' => array('angry.gif', '19', '19', 'angry'), - ':zip:' => array('zip.gif', '19', '19', 'zipper'), - ':kiss:' => array('kiss.gif', '19', '19', 'kiss'), - ':ahhh:' => array('shock.gif', '19', '19', 'shock'), - ':coolsmile:' => array('shade_smile.gif', '19', '19', 'cool smile'), - ':coolsmirk:' => array('shade_smirk.gif', '19', '19', 'cool smirk'), - ':coolgrin:' => array('shade_grin.gif', '19', '19', 'cool grin'), - ':coolhmm:' => array('shade_hmm.gif', '19', '19', 'cool hmm'), - ':coolmad:' => array('shade_mad.gif', '19', '19', 'cool mad'), - ':coolcheese:' => array('shade_cheese.gif', '19', '19', 'cool cheese'), - ':vampire:' => array('vampire.gif', '19', '19', 'vampire'), - ':snake:' => array('snake.gif', '19', '19', 'snake'), - ':exclaim:' => array('exclaim.gif', '19', '19', 'exclaim'), - ':question:' => array('question.gif', '19', '19', 'question') - -); diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php deleted file mode 100644 index 688ca24c2..000000000 --- a/system/helpers/smiley_helper.php +++ /dev/null @@ -1,255 +0,0 @@ -field_id pairs - * @param string field_id if alias name was passed in - * @param bool - * @return array - */ - function smiley_js($alias = '', $field_id = '', $inline = TRUE) - { - static $do_setup = TRUE; - $r = ''; - - if ($alias !== '' && ! is_array($alias)) - { - $alias = array($alias => $field_id); - } - - if ($do_setup === TRUE) - { - $do_setup = FALSE; - $m = array(); - - if (is_array($alias)) - { - foreach ($alias as $name => $id) - { - $m[] = '"'.$name.'" : "'.$id.'"'; - } - } - - $m = '{'.implode(',', $m).'}'; - - $r .= << $id) - { - $r .= 'smiley_map["'.$name.'"] = "'.$id."\";\n"; - } - } - - return ($inline) - ? '' - : $r; - } -} - -// ------------------------------------------------------------------------ - -if ( ! function_exists('get_clickable_smileys')) -{ - /** - * Get Clickable Smileys - * - * Returns an array of image tag links that can be clicked to be inserted - * into a form field. - * - * @param string the URL to the folder containing the smiley images - * @param array - * @return array - */ - function get_clickable_smileys($image_url, $alias = '') - { - // For backward compatibility with js_insert_smiley - if (is_array($alias)) - { - $smileys = $alias; - } - elseif (FALSE === ($smileys = _get_smiley_array())) - { - return FALSE; - } - - // Add a trailing slash to the file path if needed - $image_url = rtrim($image_url, '/').'/'; - - $used = array(); - foreach ($smileys as $key => $val) - { - // Keep duplicates from being used, which can happen if the - // mapping array contains multiple identical replacements. For example: - // :-) and :) might be replaced with the same image so both smileys - // will be in the array. - if (isset($used[$smileys[$key][0]])) - { - continue; - } - - $link[] = ''.$smileys[$key][3].''; - $used[$smileys[$key][0]] = TRUE; - } - - return $link; - } -} - -// ------------------------------------------------------------------------ - -if ( ! function_exists('parse_smileys')) -{ - /** - * Parse Smileys - * - * Takes a string as input and swaps any contained smileys for the actual image - * - * @param string the text to be parsed - * @param string the URL to the folder containing the smiley images - * @param array - * @return string - */ - function parse_smileys($str = '', $image_url = '', $smileys = NULL) - { - if ($image_url === '' OR ( ! is_array($smileys) && FALSE === ($smileys = _get_smiley_array()))) - { - return $str; - } - - // Add a trailing slash to the file path if needed - $image_url = rtrim($image_url, '/').'/'; - - foreach ($smileys as $key => $val) - { - $str = str_replace($key, ''.$smileys[$key][3].'', $str); - } - - return $str; - } -} - -// ------------------------------------------------------------------------ - -if ( ! function_exists('_get_smiley_array')) -{ - /** - * Get Smiley Array - * - * Fetches the config/smiley.php file - * - * @return mixed - */ - function _get_smiley_array() - { - static $_smileys; - - if ( ! is_array($_smileys)) - { - if (file_exists(APPPATH.'config/smileys.php')) - { - include(APPPATH.'config/smileys.php'); - } - - if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php')) - { - include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'); - } - - if (empty($smileys) OR ! is_array($smileys)) - { - $_smileys = array(); - return FALSE; - } - - $_smileys = $smileys; - } - - return $_smileys; - } -} diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index a61ad164b..4d0b4cf4d 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -21,6 +21,7 @@ Release Date: Not Released - Removed previously deprecated :doc:`File Helper ` function ``read_file()`` (use PHP's native ``file_get_contents()`` instead). - Removed previously deprecated :doc:`Form Helper ` function ``form_prep()`` (use :php:func:`html_escape()` instead). - Removed previously deprecated *Email Helper* (had only two functions, aliases for PHP's native ``filter_var()`` and ``mail()``). + - Removed previously deprecated *Smiley Helper*. - Removed previously deprecated *Javascript Library* (it was always experimental in the first place). - Libraries @@ -561,7 +562,7 @@ Release Date: March 30, 2015 - ``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 `. - - :doc:`Smiley Helper ` changes include: + - *Smiley Helper* changes include: - Deprecated the whole helper as too specific for CodeIgniter. - Removed previously deprecated function ``js_insert_smiley()``. @@ -1850,7 +1851,7 @@ Hg Tag: v2.0.0 string already has a scheme. - Modified get_file_info in the file helper, changing filectime() to filemtime() for dates. - - Modified smiley_js() to add optional third parameter to return + - Modified ``smiley_js()`` to add optional third parameter to return only the javascript with no script tags. - The img() function of the :doc:`HTML helper <./helpers/html_helper>` will now generate an empty @@ -2005,7 +2006,7 @@ Hg Tag: v1.7.2 - Modified directory_map() in the :doc:`Directory helper ` to allow the inclusion of hidden files, and to return FALSE on failure to read directory. - - Modified the :doc:`Smiley helper ` to work + - Modified the *Smiley helper* to work with multiple fields and insert the smiley at the last known cursor position. @@ -3112,7 +3113,7 @@ Release Date: October 30, 2006 - Added :doc:`$this->db->platform() <./database/helpers>` function - Added new :doc:`File Helper <./helpers/file_helper>`: get_filenames() -- Added new helper: :doc:`Smiley Helper <./helpers/smiley_helper>` +- Added new helper: *Smiley Helper* - Added support for
    and
      lists in the :doc:`HTML Helper <./helpers/html_helper>` - Added the ability to rewrite :doc:`short diff --git a/user_guide_src/source/helpers/smiley_helper.rst b/user_guide_src/source/helpers/smiley_helper.rst deleted file mode 100644 index 3e7669942..000000000 --- a/user_guide_src/source/helpers/smiley_helper.rst +++ /dev/null @@ -1,169 +0,0 @@ -############# -Smiley Helper -############# - -The Smiley Helper file contains functions that let you manage smileys -(emoticons). - -.. important:: The Smiley helper is DEPRECATED and should not be used. - It is currently only kept for backwards compatibility. - -.. contents:: - :local: - -.. raw:: html - -
      - -Loading this Helper -=================== - -This helper is loaded using the following code:: - - $this->load->helper('smiley'); - -Overview -======== - -The Smiley helper has a renderer that takes plain text smileys, like -:-) and turns them into a image representation, like |smile!| - -It also lets you display a set of smiley images that when clicked will -be inserted into a form field. For example, if you have a blog that -allows user commenting you can show the smileys next to the comment -form. Your users can click a desired smiley and with the help of some -JavaScript it will be placed into the form field. - -Clickable Smileys Tutorial -========================== - -Here is an example demonstrating how you might create a set of clickable -smileys next to a form field. This example requires that you first -download and install the smiley images, then create a controller and the -View as described. - -.. important:: Before you begin, please `download the smiley images - `_ - and put them in a publicly accessible place on your server. - This helper also assumes you have the smiley replacement array - located at `application/config/smileys.php` - -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 :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 -the :doc:`Table Class <../libraries/table>`:: - - load->helper('smiley'); - $this->load->library('table'); - - $image_array = get_clickable_smileys('http://example.com/images/smileys/', 'comments'); - $col_array = $this->table->make_columns($image_array, 8); - - $data['smiley_table'] = $this->table->generate($col_array); - $this->load->view('smiley_view', $data); - } - - } - -In your **application/views/** directory, create a file called **smiley_view.php** -and place this code in it:: - - - - Smileys - - - -
      - -
      -

      Click to insert a smiley!

      - - When you have created the above controller and view, load it by visiting http://www.example.com/index.php/smileys/ - - - -Field Aliases -------------- - -When making changes to a view it can be inconvenient to have the field -id in the controller. To work around this, you can give your smiley -links a generic name that will be tied to a specific id in your view. - -:: - - $image_array = get_smiley_links("http://example.com/images/smileys/", "comment_textarea_alias"); - -To map the alias to the field id, pass them both into the -:func:`smiley_js()` function:: - - $image_array = smiley_js("comment_textarea_alias", "comments"); - -Available Functions -=================== - -.. 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 - :returns: An array of ready to use smileys - :rtype: array - - Returns an array containing your smiley images wrapped in a clickable - link. You must supply the URL to your smiley folder and a field id or - field alias. - - Example:: - - $image_array = get_clickable_smileys('http://example.com/images/smileys/', 'comment'); - -.. php:function:: smiley_js([$alias = ''[, $field_id = ''[, $inline = TRUE]]]) - - :param string $alias: Field alias - :param string $field_id: Field ID - :param bool $inline: Whether we're inserting an inline smiley - :returns: Smiley-enabling JavaScript code - :rtype: string - - Generates the JavaScript that allows the images to be clicked and - inserted into a form field. If you supplied an alias instead of an id - when generating your smiley links, you need to pass the alias and - corresponding form id into the function. This function is designed to be - placed into the area of your web page. - - Example:: - - - -.. 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 - :param array $smileys: An array of smileys - :returns: Parsed smileys - :rtype: string - - Takes a string of text as input and replaces any contained plain text - smileys into the image equivalent. The first parameter must contain your - string, the second must contain the URL to your smiley folder - - Example:: - - $str = 'Here are some smileys: :-) ;-)'; - $str = parse_smileys($str, 'http://example.com/images/smileys/'); - echo $str; - -.. |smile!| image:: ../images/smile.gif \ No newline at end of file diff --git a/user_guide_src/source/images/smile.gif b/user_guide_src/source/images/smile.gif deleted file mode 100644 index bf0922504..000000000 Binary files a/user_guide_src/source/images/smile.gif and /dev/null differ diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index f00a69512..54f635cc0 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -532,9 +532,9 @@ the ``EXT`` constant has been removed. Use just '.php' instead. Smiley helper ============= -The :doc:`Smiley Helper <../helpers/smiley_helper>` is a legacy feature from EllisLab's -ExpressionEngine product. However, it is too specific for a general purpose framework like -CodeIgniter and as such it is now deprecated. +The *Smiley Helper* is a legacy feature from EllisLab's ExpressionEngine product. +However, it is too specific for a general purpose framework like CodeIgniter +and as such it is now deprecated. Also, the previously deprecated ``js_insert_smiley()`` (since version 1.7.2) is now removed. @@ -559,9 +559,9 @@ implemented cryptographic functions. The Cart library ================ -The :doc:`Cart Library <../libraries/cart>`, similarly to the :doc:`Smiley Helper -<../helpers/smiley_helper>` is too specific for CodeIgniter. It is now deprecated -and scheduled for removal in CodeIgniter 3.1+. +The :doc:`Cart Library <../libraries/cart>`, similarly to the *Smiley Helper* +is too specific for CodeIgniter. It is now deprecated and scheduled for +removal in CodeIgniter 3.1+. .. note:: The library is still available, but you're strongly encouraged to remove its usage sooner rather than later. diff --git a/user_guide_src/source/installation/upgrade_320.rst b/user_guide_src/source/installation/upgrade_320.rst index 4e4a73b67..597e1ecf2 100644 --- a/user_guide_src/source/installation/upgrade_320.rst +++ b/user_guide_src/source/installation/upgrade_320.rst @@ -132,7 +132,7 @@ The following is a list of functionalities deprecated in CodeIgniter version 3.0.x, that have been removed in 3.2.0: - ``CI_Input::is_cli_request()`` (use :php:func:`is_cli()` instead) -- ``CI_Router::fetch_directory()`` (use ``CI_Router::$directory instead) +- ``CI_Router::fetch_directory()`` (use ``CI_Router::$directory`` instead) - ``CI_Router::fetch_class()`` (use ``CI_Router::$class`` instead) - ``CI_Router::fetch_method()`` (use ``CI_Router::$method`` instead) - ``CI_Config::system_url()`` (encourages insecure practices) @@ -153,3 +153,5 @@ version 3.0.x, that have been removed in 3.2.0: - ``valid_email()`` (use ``filter_var($email, FILTER_VALIDATE_EMAIL)`` instead) - ``send_email()`` (use ``mail()`` instead) + +- The entire *Smiley Helper* (an archived version is available on GitHub: `bcit-ci/ci3-smiley-helper `_) -- cgit v1.2.3-24-g4f1b