Skip to content

Commit 3bb853d

Browse files
authored
Restore deprecated functions that were removed in 3.2.0-dev (for backward compatibility).
* fix: restore form_prep() removed in 3.2.0-dev. * fix: restore do_hash() removed in 3.2.0-dev. * fix: restore br() and nbs() removed in 3.2.0-dev. * fix: restore trim_slashes() and repeater() removed in 3.2.0-dev. * fix: restore standard_date() and nice_date() removed in 3.2.0-dev. * fix: restore is_cli_request() removed in 3.2.0-dev. * fix: restore prep_for_form() removed in 3.2.0-dev. * fix: restore system_url() removed in 3.2.0-dev. * docs: rework upgrade guide and README for the 3.2+ maintenance fork. * fix: restore 'unique' and 'encrypt' aliases in random_string() removed in 3.2.0-dev. * fix: restore 'dash' and 'underscore' aliases in url_title() removed in 3.2.0-dev. * fix: restore 'anchor_class' option in Pagination removed in 3.2.0-dev. * fix: restore $_after parameter in add_column() removed in 3.2.0-dev. * docs: remove restored items from 3.2+ upgrade removal list. * fix: restore Smiley Helper removed in 3.2.0-dev. * fix: restore Javascript Library removed in 3.2.0-dev. * docs: remove restored items from 3.2+ upgrade removal list.
1 parent 17ea1c6 commit 3bb853d

18 files changed

Lines changed: 2616 additions & 54 deletions

File tree

application/config/smileys.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
defined('BASEPATH') OR exit('No direct script access allowed');
3+
4+
/*
5+
| -------------------------------------------------------------------
6+
| SMILEYS
7+
| -------------------------------------------------------------------
8+
| This file contains an array of smileys for use with the emoticon helper.
9+
| Individual images can be used to replace multiple smileys. For example:
10+
| :-) and :) use the same image replacement.
11+
|
12+
| Please see user guide for more info:
13+
| https://codeigniter.com/user_guide/helpers/smiley_helper.html
14+
|
15+
*/
16+
$smileys = array(
17+
18+
// smiley image name width height alt
19+
20+
':-)' => array('grin.gif', '19', '19', 'grin'),
21+
':lol:' => array('lol.gif', '19', '19', 'LOL'),
22+
':cheese:' => array('cheese.gif', '19', '19', 'cheese'),
23+
':)' => array('smile.gif', '19', '19', 'smile'),
24+
';-)' => array('wink.gif', '19', '19', 'wink'),
25+
';)' => array('wink.gif', '19', '19', 'wink'),
26+
':smirk:' => array('smirk.gif', '19', '19', 'smirk'),
27+
':roll:' => array('rolleyes.gif', '19', '19', 'rolleyes'),
28+
':-S' => array('confused.gif', '19', '19', 'confused'),
29+
':wow:' => array('surprise.gif', '19', '19', 'surprised'),
30+
':bug:' => array('bigsurprise.gif', '19', '19', 'big surprise'),
31+
':-P' => array('tongue_laugh.gif', '19', '19', 'tongue laugh'),
32+
'%-P' => array('tongue_rolleye.gif', '19', '19', 'tongue rolleye'),
33+
';-P' => array('tongue_wink.gif', '19', '19', 'tongue wink'),
34+
':P' => array('raspberry.gif', '19', '19', 'raspberry'),
35+
':blank:' => array('blank.gif', '19', '19', 'blank stare'),
36+
':long:' => array('longface.gif', '19', '19', 'long face'),
37+
':ohh:' => array('ohh.gif', '19', '19', 'ohh'),
38+
':grrr:' => array('grrr.gif', '19', '19', 'grrr'),
39+
':gulp:' => array('gulp.gif', '19', '19', 'gulp'),
40+
'8-/' => array('ohoh.gif', '19', '19', 'oh oh'),
41+
':down:' => array('downer.gif', '19', '19', 'downer'),
42+
':red:' => array('embarrassed.gif', '19', '19', 'red face'),
43+
':sick:' => array('sick.gif', '19', '19', 'sick'),
44+
':shut:' => array('shuteye.gif', '19', '19', 'shut eye'),
45+
':-/' => array('hmm.gif', '19', '19', 'hmmm'),
46+
'>:(' => array('mad.gif', '19', '19', 'mad'),
47+
':mad:' => array('mad.gif', '19', '19', 'mad'),
48+
'>:-(' => array('angry.gif', '19', '19', 'angry'),
49+
':angry:' => array('angry.gif', '19', '19', 'angry'),
50+
':zip:' => array('zip.gif', '19', '19', 'zipper'),
51+
':kiss:' => array('kiss.gif', '19', '19', 'kiss'),
52+
':ahhh:' => array('shock.gif', '19', '19', 'shock'),
53+
':coolsmile:' => array('shade_smile.gif', '19', '19', 'cool smile'),
54+
':coolsmirk:' => array('shade_smirk.gif', '19', '19', 'cool smirk'),
55+
':coolgrin:' => array('shade_grin.gif', '19', '19', 'cool grin'),
56+
':coolhmm:' => array('shade_hmm.gif', '19', '19', 'cool hmm'),
57+
':coolmad:' => array('shade_mad.gif', '19', '19', 'cool mad'),
58+
':coolcheese:' => array('shade_cheese.gif', '19', '19', 'cool cheese'),
59+
':vampire:' => array('vampire.gif', '19', '19', 'vampire'),
60+
':snake:' => array('snake.gif', '19', '19', 'snake'),
61+
':exclaim:' => array('exclaim.gif', '19', '19', 'exclaim'),
62+
':question:' => array('question.gif', '19', '19', 'question')
63+
64+
);

readme.rst

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,9 @@ If you prefer the traditional approach of replacing the system directory:
9393

9494
**Upgrading from Original CI3**
9595

96-
⚠️ **Important:** This fork is based on the unreleased CodeIgniter 3.2.0-dev version, not the stable 3.1.13. If you're upgrading from CI 3.1.x, please read the upgrade guide for any changes that may affect your application.
96+
This fork is based on the unreleased CodeIgniter 3.2.0-dev. For most
97+
applications the upgrade is straightforward: install via Composer,
98+
update your `$system_path`, and review the upgrade guide.
9799

98-
**Please review the upgrade guide:** `upgrade_320.rst <user_guide_src/source/installation/upgrade_320.rst>`_
99-
100-
Note: The upgrade guide has been updated to reflect functionality we've restored for backward compatibility (Cart library, Email helper, etc.).
101-
102-
Steps to upgrade:
103-
104-
1. Review the upgrade guide for breaking changes between 3.1.x and 3.2.0
105-
2. Install via Composer as shown above
106-
3. Update the `$system_path` in your `index.php`
107-
4. Apply any necessary changes from the upgrade guide to your application
108-
5. Your existing `application/` directory remains mostly unchanged (except for items noted in the upgrade guide)
109-
6. Test thoroughly with your PHP version (especially if using PHP 8.2+)
100+
The upgrade guide covers both 3.1.x and 3.2-dev users:
101+
`upgrade_320.rst <user_guide_src/source/installation/upgrade_320.rst>`_

system/core/Config.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,20 @@ public function base_url($uri = '', $protocol = NULL)
325325

326326
// -------------------------------------------------------------
327327

328+
/**
329+
* System URL
330+
*
331+
* @deprecated 3.0.0
332+
* @return string
333+
*/
334+
public function system_url()
335+
{
336+
$x = explode('/', preg_replace('|/*(.+?)/*$|', '\\1', BASEPATH));
337+
return $this->slash_item('base_url').end($x).'/';
338+
}
339+
340+
// -------------------------------------------------------------
341+
328342
/**
329343
* Build URI string
330344
*

system/core/Input.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,22 @@ public function is_ajax_request()
662662

663663
// --------------------------------------------------------------------
664664

665+
/**
666+
* Is CLI request?
667+
*
668+
* Test to see if a request was made from the command line.
669+
*
670+
* @deprecated 3.0.0 Use is_cli() instead
671+
* @see is_cli()
672+
* @return bool
673+
*/
674+
public function is_cli_request()
675+
{
676+
return is_cli();
677+
}
678+
679+
// --------------------------------------------------------------------
680+
665681
/**
666682
* Get Request Method
667683
*

system/database/DB_forge.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,13 +561,18 @@ public function rename_table($table_name, $new_table_name)
561561
* @param array $field Column definition
562562
* @return bool
563563
*/
564-
public function add_column($table, $field)
564+
public function add_column($table, $field, $_after = NULL)
565565
{
566566
// Work-around for literal column definitions
567567
is_array($field) OR $field = array($field);
568568

569569
foreach (array_keys($field) as $k)
570570
{
571+
if ($_after !== NULL && is_array($field[$k]) && ! isset($field[$k]['after']))
572+
{
573+
$field[$k]['after'] = $_after;
574+
}
575+
571576
$this->add_field(array($k => $field[$k]));
572577
}
573578

system/helpers/date_helper.php

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,42 @@ function mdate($datestr = '', $time = '')
123123

124124
// ------------------------------------------------------------------------
125125

126+
if ( ! function_exists('standard_date'))
127+
{
128+
/**
129+
* Standard Date
130+
*
131+
* Returns a date formatted according to the submitted standard.
132+
*
133+
* As of PHP 5.2, the DateTime extension provides constants that
134+
* serve for the exact same purpose and are used internally by
135+
* date() as well.
136+
*
137+
* @deprecated 3.1.3 Use PHP's native date() with DateTime constants
138+
*
139+
* @param string $fmt = 'DATE_RFC822' the chosen format
140+
* @param int $time = NULL Unix timestamp
141+
* @return string
142+
*/
143+
function standard_date($fmt = 'DATE_RFC822', $time = NULL)
144+
{
145+
if (empty($time))
146+
{
147+
$time = now();
148+
}
149+
150+
// Procedural style pre-defined constants from the DateTime extension
151+
if (strpos($fmt, 'DATE_') !== 0 OR defined($fmt) === FALSE)
152+
{
153+
return FALSE;
154+
}
155+
156+
return date(constant($fmt), $time);
157+
}
158+
}
159+
160+
// ------------------------------------------------------------------------
161+
126162
if ( ! function_exists('timespan'))
127163
{
128164
/**
@@ -451,6 +487,72 @@ function human_to_unix($datestr = '')
451487

452488
// ------------------------------------------------------------------------
453489

490+
if ( ! function_exists('nice_date'))
491+
{
492+
/**
493+
* Turns many "reasonably-date-like" strings into something
494+
* that is actually useful. This only works for dates after unix epoch.
495+
*
496+
* @deprecated 3.1.3 Use DateTime::createFromFormat($input_format, $input)->format($output_format);
497+
* @param string The terribly formatted date-like string
498+
* @param string Date format to return (same as php date function)
499+
* @return string
500+
*/
501+
function nice_date($bad_date = '', $format = FALSE)
502+
{
503+
if (empty($bad_date))
504+
{
505+
return 'Unknown';
506+
}
507+
elseif (empty($format))
508+
{
509+
$format = 'U';
510+
}
511+
512+
// Date like: YYYYMM
513+
if (preg_match('/^\d{6}$/i', $bad_date))
514+
{
515+
if (in_array(substr($bad_date, 0, 2), array('19', '20')))
516+
{
517+
$year = substr($bad_date, 0, 4);
518+
$month = substr($bad_date, 4, 2);
519+
}
520+
else
521+
{
522+
$month = substr($bad_date, 0, 2);
523+
$year = substr($bad_date, 2, 4);
524+
}
525+
526+
return date($format, strtotime($year.'-'.$month.'-01'));
527+
}
528+
529+
// Date Like: YYYYMMDD
530+
if (preg_match('/^\d{8}$/i', $bad_date, $matches))
531+
{
532+
return DateTime::createFromFormat('Ymd', $bad_date)->format($format);
533+
}
534+
535+
// Date Like: MM-DD-YYYY __or__ M-D-YYYY (or anything in between)
536+
if (preg_match('/^(\d{1,2})-(\d{1,2})-(\d{4})$/i', $bad_date, $matches))
537+
{
538+
return date($format, strtotime($matches[3].'-'.$matches[1].'-'.$matches[2]));
539+
}
540+
541+
// Any other kind of string, when converted into UNIX time,
542+
// produces "0 seconds after epoc..." is probably bad...
543+
// return "Invalid Date".
544+
if (date('U', strtotime($bad_date)) === '0')
545+
{
546+
return 'Invalid Date';
547+
}
548+
549+
// It's probably a valid-ish date format already
550+
return date($format, strtotime($bad_date));
551+
}
552+
}
553+
554+
// ------------------------------------------------------------------------
555+
454556
if ( ! function_exists('timezone_menu'))
455557
{
456558
/**

system/helpers/form_helper.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,25 @@ function form_close($extra = '')
676676

677677
// ------------------------------------------------------------------------
678678

679+
if ( ! function_exists('form_prep'))
680+
{
681+
/**
682+
* Form Prep
683+
*
684+
* Formats text so that it can be safely placed in a form field in the event it has HTML tags.
685+
*
686+
* @deprecated 3.0.0 An alias for html_escape()
687+
* @param string|string[] $str Value to escape
688+
* @return string|string[] Escaped values
689+
*/
690+
function form_prep($str)
691+
{
692+
return html_escape($str, TRUE);
693+
}
694+
}
695+
696+
// ------------------------------------------------------------------------
697+
679698
if ( ! function_exists('set_value'))
680699
{
681700
/**

system/helpers/html_helper.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,3 +389,37 @@ function meta($name = '', $content = '', $type = 'name', $newline = "\n")
389389
return $str;
390390
}
391391
}
392+
393+
// ------------------------------------------------------------------------
394+
395+
if ( ! function_exists('br'))
396+
{
397+
/**
398+
* Generates HTML BR tags based on number supplied
399+
*
400+
* @deprecated 3.0.0 Use str_repeat() instead
401+
* @param int $count Number of times to repeat the tag
402+
* @return string
403+
*/
404+
function br($count = 1)
405+
{
406+
return str_repeat('<br />', $count);
407+
}
408+
}
409+
410+
// ------------------------------------------------------------------------
411+
412+
if ( ! function_exists('nbs'))
413+
{
414+
/**
415+
* Generates non-breaking space entities based on number supplied
416+
*
417+
* @deprecated 3.0.0 Use str_repeat() instead
418+
* @param int
419+
* @return string
420+
*/
421+
function nbs($num = 1)
422+
{
423+
return str_repeat('&nbsp;', $num);
424+
}
425+
}

system/helpers/security_helper.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,29 @@ function sanitize_filename($filename)
8383

8484
// ------------------------------------------------------------------------
8585

86+
if ( ! function_exists('do_hash'))
87+
{
88+
/**
89+
* Hash encode a string
90+
*
91+
* @deprecated 3.0.0 Use PHP's native hash() instead.
92+
* @param string $str
93+
* @param string $type = 'sha1'
94+
* @return string
95+
*/
96+
function do_hash($str, $type = 'sha1')
97+
{
98+
if ( ! in_array(strtolower($type), hash_algos()))
99+
{
100+
$type = 'md5';
101+
}
102+
103+
return hash($type, $str);
104+
}
105+
}
106+
107+
// ------------------------------------------------------------------------
108+
86109
if ( ! function_exists('strip_image_tags'))
87110
{
88111
/**

0 commit comments

Comments
 (0)