本文整理汇总了PHP中JString::str_ireplace方法的典型用法代码示例。如果您正苦于以下问题:PHP JString::str_ireplace方法的具体用法?PHP JString::str_ireplace怎么用?PHP JString::str_ireplace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JString
的用法示例。
在下文中一共展示了JString::str_ireplace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInput
protected function getInput()
{
$db = JFactory::getDBO();
$query = "SELECT * FROM #__k2_categories WHERE trash = 0 ORDER BY parent, ordering";
$db->setQuery($query);
$rows = $db->loadObjectList();
$children = array();
if ($rows) {
foreach ($rows as $row) {
$row->title = $row->name;
$row->parent_id = $row->parent;
$pt = $row->parent;
$list = @$children[$pt] ? $children[$pt] : array();
array_push($list, $row);
$children[$pt] = $list;
}
}
$list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
$rows = array();
$rows[] = JHTML::_('select.option', '0', JText::_('K2_NONE_ONSELECTLISTS'));
foreach ($list as $item) {
$item->treename = JString::str_ireplace(' ', ' -', $item->treename);
$rows[] = JHTML::_('select.option', $item->id, $item->treename);
}
return JHTML::_('select.genericlist', $rows, $this->name, '', 'value', 'text', $this->value);
}
示例2: fetchElement
function fetchElement($name, $value, &$node, $control_name)
{
$db = JFactory::getDBO();
$query = 'SELECT m.* FROM #__k2_categories m WHERE trash = 0 ORDER BY parent, ordering';
$db->setQuery($query);
$mitems = $db->loadObjectList();
$children = array();
if ($mitems) {
foreach ($mitems as $v) {
if (K2_JVERSION != '15') {
$v->title = $v->name;
$v->parent_id = $v->parent;
}
$pt = $v->parent;
$list = @$children[$pt] ? $children[$pt] : array();
array_push($list, $v);
$children[$pt] = $list;
}
}
$list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
$mitems = array();
foreach ($list as $item) {
$item->treename = JString::str_ireplace(' ', '- ', $item->treename);
@($mitems[] = JHTML::_('select.option', $item->id, $item->treename));
}
if (K2_JVERSION != '15') {
$fieldName = $name;
} else {
$fieldName = $control_name . '[' . $name . ']';
}
return JHTML::_('select.genericlist', $mitems, $fieldName, ' class="inputbox" size="15"', 'value', 'text', $value);
}
示例3: onAfterRender
public function onAfterRender()
{
$fbml = '<html xmlns:fb="http://ogp.me/ns/fb#" ';
$html = JResponse::getBody();
$html = JString::str_ireplace('<html', $fbml, $html);
JResponse::setBody($html);
}
示例4: replace
public static function replace($tmp, $text)
{
$config = DiscussHelper::getConfig();
$pattern = '@(?i)\\b((?:https?://|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'".,<>?«»“”‘’]))@';
preg_match_all($pattern, $tmp, $matches);
$targetBlank = $config->get('main_link_new_window') ? ' target="_blank"' : '';
if (!isset($matches[0]) || !is_array($matches[0])) {
return;
}
// to avoid infinite loop, unique the matches
$links = $matches[0];
foreach ($links as &$link) {
$link = JString::strtolower($link);
}
$uniques = array_unique($links);
foreach ($uniques as $match) {
$matchProtocol = $match;
if (stristr($matchProtocol, 'http://') === false && stristr($matchProtocol, 'https://') === false && stristr($matchProtocol, 'ftp://') === false) {
$matchProtocol = 'http://' . $matchProtocol;
}
$text = JString::str_ireplace($match, '<a href="' . $matchProtocol . '"' . $targetBlank . '>' . $match . '</a>', $text);
}
$text = JString::str_ireplace('"', '"', $text);
return $text;
}
示例5: stripExtensions
function stripExtensions($title)
{
// Remove known extensions from title
$extensions = array('jpg', 'png', 'gif');
$title = JString::str_ireplace($extensions, '', $title);
return $title;
}
示例6: preplace
/**
* Unwrap placeholder text from possible <p> tags
*
* @param array $match preg matched {fabrik} tag
*
* @return string
*/
protected function preplace($match)
{
$match = $match[0];
$match = JString::str_ireplace('<p>', '<div>', $match);
$match = JString::str_ireplace('</p>', '</div>', $match);
return $match;
}
示例7: fetchElement
function fetchElement($name, $value, &$node, $control_name)
{
$db =& JFactory::getDBO();
$query = 'SELECT m.* FROM #__k2_categories m WHERE published=1 AND trash = 0 ORDER BY parent, ordering';
$db->setQuery($query);
$mitems = $db->loadObjectList();
$fieldName = $name . '[]';
if (count($mitems)) {
$children = array();
if ($mitems) {
foreach ($mitems as $v) {
$v->title = $v->name;
$v->parent_id = $v->parent;
$pt = $v->parent;
$list = @$children[$pt] ? $children[$pt] : array();
array_push($list, $v);
$children[$pt] = $list;
}
}
$list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
$mitems = array();
foreach ($list as $item) {
$item->treename = JString::str_ireplace(' ', '- ', $item->treename);
$mitems[] = JHTML::_('select.option', $item->id, ' ' . $item->treename);
}
$output = JHTML::_('select.genericlist', $mitems, $fieldName, 'class="inputbox" multiple="multiple" size="10"', 'value', 'text', $value);
} else {
$mitems[] = JHTML::_('select.option', 0, 'K2 is not installed or there is no K2 category available.');
$output = JHtml::_('select.genericlist', $mitems, $fieldName, 'class="inputbox" disabled="disabled" multiple="multiple" style="width:160px" size="5"', 'value', 'text', $value);
}
return $output;
}
示例8: getInput
protected function getInput()
{
$output = '';
if (!file_exists(JPATH_SITE . '/components/com_k2/helpers/utilities.php')) {
$output .= JHTML::_('select.genericlist', array(), $this->name, 'class="inputbox" style="display:none" multiple="multiple" size="10"', 'value', 'text', $this->value, $this->id);
$output .= JText::_('<p>Please install com_k2</p>');
return $output;
}
$db = JFactory::getDBO();
$query = 'SELECT m.* FROM #__k2_categories m WHERE trash = 0 ORDER BY parent, ordering';
$db->setQuery($query);
$mitems = $db->loadObjectList();
$children = array();
if ($mitems) {
foreach ($mitems as $v) {
$v->title = $v->name;
$v->parent_id = $v->parent;
$pt = $v->parent;
$list = @$children[$pt] ? $children[$pt] : array();
array_push($list, $v);
$children[$pt] = $list;
}
}
$list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
$mitems = array();
foreach ($list as $item) {
$item->treename = JString::str_ireplace(' ', '- ', $item->treename);
$mitems[] = JHTML::_('select.option', $item->id, ' ' . $item->treename);
}
$output = JHTML::_('select.genericlist', $mitems, $this->name, 'class="inputbox" multiple="multiple" size="10"', 'value', 'text', $this->value, $this->id);
return $output;
}
示例9: store
function store()
{
$table =& $this->getTable();
$post = JRequest::get('post');
// Fix HTML
$post['htmltext'] = JRequest::getString('htmltext', '', 'post', JREQUEST_ALLOWRAW);
$post['htmltext'] = JString::str_ireplace('&amp;', '&', $post['htmltext']);
$post['htmlsmall'] = JRequest::getString('htmlsmall', '', 'post', JREQUEST_ALLOWRAW);
$post['htmlsmall'] = JString::str_ireplace('&amp;', '&', $post['htmlsmall']);
$post['htmllarge'] = JRequest::getString('htmllarge', '', 'post', JREQUEST_ALLOWRAW);
$post['htmllarge'] = JString::str_ireplace('&amp;', '&', $post['htmllarge']);
$post['htmlbutton'] = JRequest::getString('htmlbutton', '', 'post', JREQUEST_ALLOWRAW);
$post['htmlbutton'] = JString::str_ireplace('&amp;', '&', $post['htmlbutton']);
$post['htmlcustom'] = JRequest::getString('htmlcustom', '', 'post', JREQUEST_ALLOWRAW);
$post['htmlcustom'] = JString::str_ireplace('&amp;', '&', $post['htmlcustom']);
// Bind form data to table fields
if (!$table->bind($post)) {
$this->setError($table->getError());
return false;
}
// Make sure the record is a valid one
if (!$table->check()) {
$this->setError($table->getError());
return false;
}
// Save bookmark
if (!$table->store()) {
$this->setError($table->getError());
return false;
}
return $table->get('id');
}
示例10: onProfileCreate
function onProfileCreate($user)
{
// Upon registering, users should get 4 default photo albums:
// Fiskeplasser, Fangstrapporter, Turer, and Klekker (Spots/Catches/Trips/Hatches)
$config = CFactory::getConfig();
CFactory::load('models', 'photos');
$albumNames = array('Fiskeplasser', 'Fangstrapporter', 'Turer', 'Klekker');
foreach ($albumNames as $album_name) {
$album =& JTable::getInstance('Album', 'CTable');
$album->creator = $user->id;
$album->name = $album_name;
$album->description = "";
$album->type = "user";
$album->created = gmdate('Y-m-d H:i:s');
$params = $user->getParams();
$album->permissions = $params->get('privacyPhotoView');
$album->permanent = 1;
// don't let users delete default albums
$storage = JPATH_ROOT . DS . $config->getString('photofolder');
$albumPath = $storage . DS . 'photos' . DS . $user->id . DS;
$albumPath = JString::str_ireplace(JPATH_ROOT . DS, '', $albumPath);
$albumPath = JString::str_ireplace('\\', '/', $albumPath);
$album->path = $albumPath;
$album->store();
}
}
示例11: check
public function check()
{
if (trim($this->title) == '') {
$this->setError(JText::_('COM_JUDOWNLOAD_TITLE_MUST_NOT_BE_EMPTY'));
return false;
}
if (trim($this->alias) == '') {
$this->alias = $this->title;
}
$this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') {
$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
}
if (trim(str_replace(' ', '', $this->description)) == '') {
$this->description = '';
}
if (!empty($this->metakeyword)) {
$bad_characters = array("\n", "\r", "\"", "<", ">");
$after_clean = JString::str_ireplace($bad_characters, "", $this->metakeyword);
$keys = explode(',', $after_clean);
$clean_keys = array();
foreach ($keys as $key) {
if (trim($key)) {
$clean_keys[] = trim($key);
}
}
$this->metakeyword = implode(", ", $clean_keys);
}
return true;
}
示例12: ejaxPostToArray
public static function ejaxPostToArray($params)
{
$post = array();
foreach($params as $item)
{
$pair = explode('=', $item);
if( isset( $pair[ 0 ] ) && isset( $pair[ 1 ] ) )
{
$key = $pair[0];
$value = KomentoStringHelper::ejaxUrlDecode( $pair[ 1 ] );
if( JString::stristr( $key , '[]' ) !== false )
{
$key = JString::str_ireplace( '[]' , '' , $key );
$post[ $key ][] = $value;
}
else
{
$post[ $key ] = $value;
}
}
}
return $post;
}
示例13: setImage
public function setImage($path, $type = 'thumb')
{
CError::assert($path, '', '!empty', __FILE__, __LINE__);
$db =& $this->getDBO();
// Fix the back quotes
$path = JString::str_ireplace('\\', '/', $path);
$type = JString::strtolower($type);
// Test if the record exists.
$oldFile = $this->{$type};
if ($db->getErrorNum()) {
JError::raiseError(500, $db->stderr());
}
if ($oldFile) {
// File exists, try to remove old files first.
$oldFile = JString::str_ireplace('/', DS, $oldFile);
// If old file is default_thumb or default, we should not remove it.
// Need proper way to test it
if (!JString::stristr($oldFile, 'user.png') && !JString::stristr($oldFile, 'user_thumb.png')) {
jimport('joomla.filesystem.file');
JFile::delete($oldFile);
}
}
$this->{$type} = $path;
$this->store();
}
示例14: send
/**
* Do a batch send
*/
function send($total = 100)
{
$mailqModel = CFactory::getModel('mailq');
$userModel = CFactory::getModel('user');
$mails = $mailqModel->get($total);
$jconfig = JFactory::getConfig();
$mailer = JFactory::getMailer();
$config = CFactory::getConfig();
$senderEmail = $jconfig->getValue('mailfrom');
$senderName = $jconfig->getValue('fromname');
if (empty($mails)) {
return;
}
CFactory::load('helpers', 'string');
foreach ($mails as $row) {
// @rule: only send emails that is valid.
// @rule: make sure recipient is not blocked!
$userid = $userModel->getUserFromEmail($row->recipient);
$user = CFactory::getUser($userid);
if (!$user->isBlocked() && !JString::stristr($row->recipient, 'foo.bar')) {
$mailer->setSender(array($senderEmail, $senderName));
$mailer->addRecipient($row->recipient);
$mailer->setSubject($row->subject);
$tmpl = new CTemplate();
$raw = isset($row->params) ? $row->params : '';
$params = new JParameter($row->params);
$base = $config->get('htmlemail') ? 'email.html' : 'email.text';
if ($config->get('htmlemail')) {
$row->body = JString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $row->body);
$mailer->IsHTML(true);
} else {
//@rule: Some content might contain 'html' tags. Strip them out since this mail should never contain html tags.
$row->body = CStringHelper::escape(strip_tags($row->body));
}
$tmpl->set('content', $row->body);
$tmpl->set('template', rtrim(JURI::root(), '/') . '/components/com_community/templates/' . $config->get('template'));
$tmpl->set('sitename', $config->get('sitename'));
$row->body = $tmpl->fetch($base);
// Replace any occurences of custom variables within the braces scoe { }
if (!empty($row->body)) {
preg_match_all("/{(.*?)}/", $row->body, $matches, PREG_SET_ORDER);
foreach ($matches as $val) {
$replaceWith = $params->get($val[1], null);
//if the replacement start with 'index.php', we can CRoute it
if (strpos($replaceWith, 'index.php') === 0) {
$replaceWith = CRoute::getExternalURL($replaceWith);
}
if (!is_null($replaceWith)) {
$row->body = JString::str_ireplace($val[0], $replaceWith, $row->body);
}
}
}
unset($tmpl);
$mailer->setBody($row->body);
$mailer->send();
}
$mailqModel->markSent($row->id);
$mailer->ClearAllRecipients();
}
}
示例15: getCategoryOptionsPerLanguage
public static function getCategoryOptionsPerLanguage($config = array('filter.published' => array(0, 1), 'filter.languages' => array()))
{
$hash = md5(serialize($config));
if (!isset(self::$_categoriesOptionsPerLanguage[$hash]))
{
$config = (array)$config;
// read categories from db
$items = self::getCategoriesPerLanguage($config);
// B/C compat.
foreach ($items as &$item)
{
$item->title = $item->name;
$item->parent_id = $item->parent;
}
// indent cat list, for easier reading
$items = self::indentCategories($items);
self::$_categoriesOptionsPerLanguage[$hash] = array();
foreach ($items as &$item)
{
self::$_categoriesOptionsPerLanguage[$hash][] = JHtml::_('select.option', $item->id, JString::str_ireplace('<sup>|_</sup>', '', $item->treename));
}
}
return self::$_categoriesOptionsPerLanguage[$hash];
}