Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin app - JString -> StringHelper #12056

Merged
merged 1 commit into from
Sep 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions administrator/components/com_admin/models/help.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

defined('_JEXEC') or die;

use Joomla\String\StringHelper;

/**
* Admin Component Help Model
*
Expand Down Expand Up @@ -173,8 +175,7 @@ public function &getToc()
// Strip the extension
$file = preg_replace('#\.xml$|\.html$#', '', $file);

if ($help_search
&& JString::strpos(JString::strtolower(strip_tags($buffer)), JString::strtolower($help_search)) === false)
if ($help_search && StringHelper::strpos(StringHelper::strtolower(strip_tags($buffer)), StringHelper::strtolower($help_search)) === false)
{
continue;
}
Expand Down
5 changes: 3 additions & 2 deletions administrator/components/com_categories/models/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
defined('_JEXEC') or die;

use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;

/**
Expand Down Expand Up @@ -1238,8 +1239,8 @@ protected function generateNewTitle($parent_id, $alias, $title)

while ($table->load(array('alias' => $alias, 'parent_id' => $parent_id)))
{
$title = JString::increment($title);
$alias = JString::increment($alias, 'dash');
$title = StringHelper::increment($title);
$alias = StringHelper::increment($alias, 'dash');
}

return array($title, $alias);
Expand Down
5 changes: 3 additions & 2 deletions administrator/components/com_contact/models/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
defined('_JEXEC') or die;

use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;

JLoader::register('ContactHelper', JPATH_ADMINISTRATOR . '/components/com_contact/helpers/contact.php');
Expand Down Expand Up @@ -647,10 +648,10 @@ protected function generateNewTitle($category_id, $alias, $name)
{
if ($name == $table->name)
{
$name = JString::increment($name);
$name = StringHelper::increment($name);
}

$alias = JString::increment($alias, 'dash');
$alias = StringHelper::increment($alias, 'dash');
}

return array($name, $alias);
Expand Down
5 changes: 3 additions & 2 deletions administrator/components/com_contact/tables/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
defined('_JEXEC') or die;

use Joomla\Registry\Registry;
use Joomla\String\StringHelper;

/**
* Contact Table class.
Expand Down Expand Up @@ -185,7 +186,7 @@ public function check()
$bad_characters = array("\n", "\r", "\"", "<", ">");

// Remove bad characters.
$after_clean = JString::str_ireplace($bad_characters, "", $this->metakey);
$after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey);

// Create array using commas as delimiter.
$keys = explode(',', $after_clean);
Expand All @@ -209,7 +210,7 @@ public function check()
{
// Only process if not empty
$bad_characters = array("\"", "<", ">");
$this->metadesc = JString::str_ireplace($bad_characters, "", $this->metadesc);
$this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc);
}

return true;
Expand Down
17 changes: 9 additions & 8 deletions administrator/components/com_finder/helpers/indexer/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
defined('_JEXEC') or die;

use Joomla\Registry\Registry;
use Joomla\String\StringHelper;

JLoader::register('FinderIndexerParser', __DIR__ . '/parser.php');
JLoader::register('FinderIndexerStemmer', __DIR__ . '/stemmer.php');
Expand Down Expand Up @@ -62,7 +63,7 @@ public static function parse($input, $format = 'html')
public static function tokenize($input, $lang, $phrase = false)
{
static $cache;
$store = JString::strlen($input) < 128 ? md5($input . '::' . $lang . '::' . $phrase) : null;
$store = StringHelper::strlen($input) < 128 ? md5($input . '::' . $lang . '::' . $phrase) : null;

// Check if the string has been tokenized already.
if ($store && isset($cache[$store]))
Expand All @@ -89,7 +90,7 @@ public static function tokenize($input, $lang, $phrase = false)
* 7. Replace the assorted single quotation marks with the ASCII standard single quotation.
* 8. Remove multiple space characters and replaces with a single space.
*/
$input = JString::strtolower($input);
$input = StringHelper::strtolower($input);
$input = preg_replace('#[^\pL\pM\pN\p{Pi}\p{Pf}\'+-.,]+#mui', ' ', $input);
$input = preg_replace('#(^|\s)[+-.,]+([\pL\pM]+)#mui', ' $1', $input);
$input = preg_replace('#([\pL\pM\pN]+)[+-.,]+(\s|$)#mui', '$1 ', $input);
Expand All @@ -98,7 +99,7 @@ public static function tokenize($input, $lang, $phrase = false)
$input = preg_replace('#(^|\s)[\p{Pi}\p{Pf}]+(\s|$)#mui', ' ', $input);
$input = preg_replace('#[' . $quotes . ']+#mui', '\'', $input);
$input = preg_replace('#\s+#mui', ' ', $input);
$input = JString::trim($input);
$input = StringHelper::trim($input);

// Explode the normalized string to get the terms.
$terms = explode(' ', $input);
Expand All @@ -120,7 +121,7 @@ public static function tokenize($input, $lang, $phrase = false)
// Split apart any groups of Chinese characters.
for ($j = 0; $j < $charCount; $j++)
{
$tSplit = JString::str_ireplace($charMatches[0][$j], '', $terms[$i], false);
$tSplit = StringHelper::str_ireplace($charMatches[0][$j], '', $terms[$i], false);

if (!empty($tSplit))
{
Expand Down Expand Up @@ -215,12 +216,12 @@ public static function tokenize($input, $lang, $phrase = false)
public static function stem($token, $lang)
{
// Trim apostrophes at either end of the token.
$token = JString::trim($token, '\'');
$token = StringHelper::trim($token, '\'');

// Trim everything after any apostrophe in the token.
if (($pos = JString::strpos($token, '\'')) !== false)
if (($pos = StringHelper::strpos($token, '\'')) !== false)
{
$token = JString::substr($token, 0, $pos);
$token = StringHelper::substr($token, 0, $pos);
}

// Stem the token if we have a valid stemmer to use.
Expand Down Expand Up @@ -374,7 +375,7 @@ public static function getPrimaryLanguage($lang)
else
{
// Get the language key using string position.
$data[$lang] = JString::substr($lang, 0, JString::strpos($lang, '-'));
$data[$lang] = StringHelper::substr($lang, 0, StringHelper::strpos($lang, '-'));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

defined('_JEXEC') or die;

use Joomla\String\StringHelper;

JLoader::register('FinderIndexerHelper', __DIR__ . '/helper.php');
JLoader::register('FinderIndexerParser', __DIR__ . '/parser.php');
JLoader::register('FinderIndexerStemmer', __DIR__ . '/stemmer.php');
Expand Down Expand Up @@ -338,7 +340,7 @@ protected function tokenizeToDb($input, $context, $lang, $format)
$string = substr($buffer, 0, $ls);

// Adjust the buffer based on the last space for the next iteration and trim.
$buffer = JString::trim(substr($buffer, $ls));
$buffer = StringHelper::trim(substr($buffer, $ls));
}
// No space character was found.
else
Expand Down
43 changes: 22 additions & 21 deletions administrator/components/com_finder/helpers/indexer/query.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
defined('_JEXEC') or die;

use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;

JLoader::register('FinderIndexerHelper', __DIR__ . '/helper.php');
Expand Down Expand Up @@ -665,10 +666,10 @@ protected function processDynamicTaxonomy($filters)
protected function processDates($date1, $date2, $when1, $when2)
{
// Clean up the inputs.
$date1 = JString::trim(JString::strtolower($date1));
$date2 = JString::trim(JString::strtolower($date2));
$when1 = JString::trim(JString::strtolower($when1));
$when2 = JString::trim(JString::strtolower($when2));
$date1 = StringHelper::trim(StringHelper::strtolower($date1));
$date2 = StringHelper::trim(StringHelper::strtolower($date2));
$when1 = StringHelper::trim(StringHelper::strtolower($when1));
$when2 = StringHelper::trim(StringHelper::strtolower($when2));

// Get the time offset.
$offset = JFactory::getApplication()->get('offset');
Expand All @@ -677,7 +678,7 @@ protected function processDates($date1, $date2, $when1, $when2)
$whens = array('before', 'after', 'exact');

// The value of 'today' is a special case that we need to handle.
if ($date1 === JString::strtolower(JText::_('COM_FINDER_QUERY_FILTER_TODAY')))
if ($date1 === StringHelper::strtolower(JText::_('COM_FINDER_QUERY_FILTER_TODAY')))
{
$date1 = JFactory::getDate('now', $offset)->format('%Y-%m-%d');
}
Expand All @@ -694,7 +695,7 @@ protected function processDates($date1, $date2, $when1, $when2)
}

// The value of 'today' is a special case that we need to handle.
if ($date2 === JString::strtolower(JText::_('COM_FINDER_QUERY_FILTER_TODAY')))
if ($date2 === StringHelper::strtolower(JText::_('COM_FINDER_QUERY_FILTER_TODAY')))
{
$date2 = JFactory::getDate('now', $offset)->format('%Y-%m-%d');
}
Expand Down Expand Up @@ -730,9 +731,9 @@ protected function processString($input, $lang, $mode)
{
// Clean up the input string.
$input = html_entity_decode($input, ENT_QUOTES, 'UTF-8');
$input = JString::strtolower($input);
$input = StringHelper::strtolower($input);
$input = preg_replace('#\s+#mi', ' ', $input);
$input = JString::trim($input);
$input = StringHelper::trim($input);
$debug = JFactory::getConfig()->get('debug_lang');

/*
Expand All @@ -749,7 +750,7 @@ protected function processString($input, $lang, $mode)
foreach (FinderIndexerTaxonomy::getBranchTitles() as $branch)
{
// Add the pattern.
$patterns[$branch] = JString::strtolower(JText::_(FinderHelperLanguage::branchSingular($branch)));
$patterns[$branch] = StringHelper::strtolower(JText::_(FinderHelperLanguage::branchSingular($branch)));
}

// Container for search terms and phrases.
Expand Down Expand Up @@ -801,7 +802,7 @@ protected function processString($input, $lang, $mode)
$whens = array('before', 'after', 'exact');

// The value of 'today' is a special case that we need to handle.
if ($value === JString::strtolower(JText::_('COM_FINDER_QUERY_FILTER_TODAY')))
if ($value === StringHelper::strtolower(JText::_('COM_FINDER_QUERY_FILTER_TODAY')))
{
$value = JFactory::getDate('now', $offset)->format('%Y-%m-%d');
}
Expand Down Expand Up @@ -850,15 +851,15 @@ protected function processString($input, $lang, $mode)
// Clean up the input string again.
$input = str_replace($matches[0], '', $input);
$input = preg_replace('#\s+#mi', ' ', $input);
$input = JString::trim($input);
$input = StringHelper::trim($input);
}
}

/*
* Extract the tokens enclosed in double quotes so that we can handle
* them as phrases.
*/
if (JString::strpos($input, '"') !== false)
if (StringHelper::strpos($input, '"') !== false)
{
$matches = array();

Expand All @@ -873,21 +874,21 @@ protected function processString($input, $lang, $mode)
foreach ($matches[1] as $key => $match)
{
// Find the complete phrase in the input string.
$pos = JString::strpos($input, $matches[0][$key]);
$len = JString::strlen($matches[0][$key]);
$pos = StringHelper::strpos($input, $matches[0][$key]);
$len = StringHelper::strlen($matches[0][$key]);

// Add any terms that are before this phrase to the stack.
if (JString::trim(JString::substr($input, 0, $pos)))
if (StringHelper::trim(StringHelper::substr($input, 0, $pos)))
{
$terms = array_merge($terms, explode(' ', JString::trim(JString::substr($input, 0, $pos))));
$terms = array_merge($terms, explode(' ', StringHelper::trim(StringHelper::substr($input, 0, $pos))));
}

// Strip out everything up to and including the phrase.
$input = JString::substr($input, $pos + $len);
$input = StringHelper::substr($input, $pos + $len);

// Clean up the input string again.
$input = preg_replace('#\s+#mi', ' ', $input);
$input = JString::trim($input);
$input = StringHelper::trim($input);

// Get the number of words in the phrase.
$parts = explode(' ', $match);
Expand Down Expand Up @@ -963,9 +964,9 @@ protected function processString($input, $lang, $mode)

// An array of our boolean operators. $operator => $translation
$operators = array(
'AND' => JString::strtolower(JText::_('COM_FINDER_QUERY_OPERATOR_AND')),
'OR' => JString::strtolower(JText::_('COM_FINDER_QUERY_OPERATOR_OR')),
'NOT' => JString::strtolower(JText::_('COM_FINDER_QUERY_OPERATOR_NOT'))
'AND' => StringHelper::strtolower(JText::_('COM_FINDER_QUERY_OPERATOR_AND')),
'OR' => StringHelper::strtolower(JText::_('COM_FINDER_QUERY_OPERATOR_OR')),
'NOT' => StringHelper::strtolower(JText::_('COM_FINDER_QUERY_OPERATOR_NOT'))
);

// If language debugging is enabled you need to ignore the debug strings in matching.
Expand Down
6 changes: 4 additions & 2 deletions administrator/components/com_finder/helpers/indexer/token.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

defined('_JEXEC') or die;

use Joomla\String\StringHelper;

/**
* Token class for the Finder indexer package.
*
Expand Down Expand Up @@ -107,7 +109,7 @@ public function __construct($term, $lang, $spacer = ' ')
$this->numeric = false;
$this->common = false;
$this->phrase = true;
$this->length = JString::strlen($this->term);
$this->length = StringHelper::strlen($this->term);

/*
* Calculate the weight of the token.
Expand All @@ -126,7 +128,7 @@ public function __construct($term, $lang, $spacer = ' ')
$this->numeric = (is_numeric($this->term) || (bool) preg_match('#^[0-9,.\-\+]+$#', $this->term));
$this->common = $this->numeric ? false : FinderIndexerHelper::isCommon($this->term, $lang);
$this->phrase = false;
$this->length = JString::strlen($this->term);
$this->length = StringHelper::strlen($this->term);

/*
* Calculate the weight of the token.
Expand Down
5 changes: 3 additions & 2 deletions administrator/components/com_menus/models/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
defined('_JEXEC') or die;

use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;

jimport('joomla.filesystem.path');
Expand Down Expand Up @@ -1664,10 +1665,10 @@ protected function generateNewTitle($parent_id, $alias, $title)
{
if ($title == $table->title)
{
$title = JString::increment($title);
$title = StringHelper::increment($title);
}

$alias = JString::increment($alias, 'dash');
$alias = StringHelper::increment($alias, 'dash');
}

return array($title, $alias);
Expand Down
3 changes: 2 additions & 1 deletion administrator/components/com_modules/models/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
defined('_JEXEC') or die;

use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;

/**
Expand Down Expand Up @@ -483,7 +484,7 @@ protected function generateNewTitle($category_id, $title, $position)

while ($table->load(array('position' => $position, 'title' => $title)))
{
$title = JString::increment($title);
$title = StringHelper::increment($title);
}

return array($title);
Expand Down
5 changes: 3 additions & 2 deletions administrator/components/com_newsfeeds/models/newsfeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
defined('_JEXEC') or die;

use Joomla\Registry\Registry;
use Joomla\String\StringHelper;

JLoader::register('NewsfeedsHelper', JPATH_ADMINISTRATOR . '/components/com_newsfeeds/helpers/newsfeeds.php');

Expand Down Expand Up @@ -568,9 +569,9 @@ protected function generateNewTitle($category_id, $alias, $name)
{
if ($name == $table->name)
{
$name = JString::increment($name);
$name = StringHelper::increment($name);
}
$alias = JString::increment($alias, 'dash');
$alias = StringHelper::increment($alias, 'dash');
}

return array($name, $alias);
Expand Down
Loading