本文整理汇总了PHP中JString::stristr方法的典型用法代码示例。如果您正苦于以下问题:PHP JString::stristr方法的具体用法?PHP JString::stristr怎么用?PHP JString::stristr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JString
的用法示例。
在下文中一共展示了JString::stristr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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();
}
}
示例3: toFormat
public function toFormat( $format='%Y-%m-%d %H:%M:%S' )
{
if( Komento::joomlaVersion() >= '3.0' )
{
if( JString::stristr( $format, '%' ) !== false )
{
Komento::import( 'helper', 'date' );
$format = KomentoDateHelper::strftimeToDate( $format );
}
return $this->date->format( $format, true );
}
else
{
// There is no way to have cross version working, except for detecting % in the format
if( JString::stristr( $format , '%' ) === false )
{
if( Komento::isJoomla15() )
{
// forced fallback for Joomla 15 if format doesn't have %
$format = '%c';
}
else
{
return $this->date->format( $format , true );
}
}
return $this->date->toFormat( $format, true );
}
}
示例4: setImage
public function setImage($path, $type = 'thumb')
{
CError::assert($path, '', '!empty', __FILE__, __LINE__);
$db = $this->getDBO();
// Fix the back quotes
$path = CString::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 = CString::str_ireplace('/', '/', $oldFile);
// If old file is default_thumb or default, we should not remove it.
//
// Need proper way to test it
if (!JString::stristr($oldFile, 'group.jpg') && !JString::stristr($oldFile, 'group_thumb.jpg') && !JString::stristr($oldFile, 'default.jpg') && !JString::stristr($oldFile, 'default_thumb.jpg')) {
jimport('joomla.filesystem.file');
JFile::delete($oldFile);
}
}
$this->{$type} = $path;
$this->store();
}
示例5: ajaxChangeTemplate
public function ajaxChangeTemplate($templateName)
{
$response = new JAXResponse();
if ($templateName == 'none') {
// Previously user might already selected a template, hide the files
$response->addScriptCall('azcommunity.resetTemplateFiles();');
// Close all files if it is already editing
$response->addScriptCall('azcommunity.resetTemplateForm();');
} else {
$html = '<div id="template-files">';
$html .= '<h3>' . JText::_('COM_COMMUNITY_SELECT_FILE') . '</h3>';
$templatePath = COMMUNITY_BASE_PATH . '/templates/' . JString::strtolower($templateName);
$files = array();
if ($handle = @opendir($templatePath)) {
while (false !== ($file = readdir($handle))) {
$filePath = $templatePath . '/' . $file;
// Do not get '.' or '..' or '.svn' since we only want folders.
if ($file != '.' && $file != '..' && $file != '.svn' && !JString::stristr($file, '.js') && !is_dir($filePath)) {
$files[] = $file;
}
}
}
sort($files);
$html .= '<select name="file" onchange="azcommunity.editTemplate(\'' . $templateName . '\',this.value);">';
$html .= '<option value="none" selected="true">' . JText::_('COM_COMMUNITY_SELECT_FILE') . '</option>';
for ($i = 0; $i < count($files); $i++) {
$html .= '<option value="' . $files[$i] . '">' . $files[$i] . '</option>';
}
$html .= '</select>';
$html .= '</div>';
$response->addAssign('templates-files-container', 'innerHTML', $html);
}
return $response->sendResponse();
}
示例6: Quick2cartParseRoute
function Quick2cartParseRoute($segments)
{
$site = JFactory::getApplication();
$vars = array();
$menu = $site->getMenu();
$selectedMenu = $menu->getActive();
$storeURL_text = JText::_('QTC_VANITY_PAGE');
// We need to grab the store id first see if the first segment is a store
$count = count($segments);
if (!empty($count)) {
$alias = $segments[0];
$storeid = '';
if (!empty($alias)) {
// Check if this store exists in the alias
$storeid = Quick2cartGetStoreId($alias);
// Joomla converts ':' to '-' when encoding and during decoding,
// it converts '-' to ':' back for the query string which will break things
// if the alias has '-'. So we do not have any choice apart from
// testing both this values until Joomla tries to fix this
if (!$storeid && JString::stristr($alias, ':')) {
$storeid = Quick2cartGetStoreId($alias);
//CString::str_ireplace(':', '-', $alias));
}
}
if (!$storeid) {
if (isset($segments[1]) && $segments[1] == $storeURL_text) {
return JError::raiseError(404, JText::_('QTC_STORE_NOT_FOUND'));
}
}
if ($storeid != 0) {
array_shift($segments);
$vars['store_id'] = $storeid;
// if empty, we should display the user's profile
if (empty($segments)) {
$vars['view'] = 'vendor';
$vars['layout'] = 'store';
}
}
}
$count = count($segments);
if ($storeid != 0 && isset($selectedMenu) && $selectedMenu->query['view'] == 'category') {
// We know this is a frontpage view in the menu, try to get the
// view from the segments instead.
if ($count > 0) {
$vars['view'] = 'vendor';
if ($segments[0] == $storeURL_text) {
$vars['layout'] = 'store';
} else {
$vars['layout'] = $selectedMenu->query['layout'];
}
if (!empty($segments[1])) {
$vars['task'] = $segments[1];
}
}
}
return $vars;
}
示例7: test
/**
* Method to test for a valid color in hexadecimal.
*
* @param SimpleXMLElement &$element The SimpleXMLElement object representing the <field /> tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
* @param object &$input An optional JRegistry object with the entire data set to validate against the entire form.
* @param object &$form The form object for which the field is being tested.
*
* @return boolean True if the value is valid, false otherwise.
*/
public function test(&$element, $value, $group = null, &$input = null, &$form = null)
{
$params = JComponentHelper::getParams('com_contact');
$banned = $params->get('banned_subject');
foreach (explode(';', $banned) as $item) {
if (JString::stristr($item, $value) !== false) {
return false;
}
}
return true;
}
示例8: toFormat
public function toFormat($format = '%Y-%m-%d %H:%M:%S')
{
if (DiscussHelper::getJoomlaVersion() >= '1.6') {
if (JString::stristr($format, '%') !== false) {
$format = DiscussHelper::getHelper('date')->strftimeToDate($format);
}
return $this->date->format($format);
} else {
return $this->date->toFormat($format);
}
}
示例9: getInstance
public static function getInstance()
{
$suffix = JString::stristr(XiptHelperJomsocial::get_js_version(), 2.0) ? "Js20" : "Js18";
$classname = "XiptFieldsTemplates" . JString::ucfirst($suffix);
if (class_exists($classname, true) === false) {
XiptError::raiseError(__CLASS__ . '.' . __LINE__, XiptText::_("{$className} : CLASS_NOT_FOUND"));
return false;
}
$instance = new $classname();
return $instance;
}
示例10: test
/**
* Method to test for a banned subject
*
* @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
* @param JRegistry $input An optional JRegistry object with the entire data set to validate against the entire form.
* @param JForm $form The form object for which the field is being tested.
*
* @return boolean True if the value is valid, false otherwise
*/
public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null)
{
$params = JComponentHelper::getParams('com_contact');
$banned = $params->get('banned_subject');
if ($banned) {
foreach (explode(';', $banned) as $item) {
if ($item != '' && JString::stristr($value, $item) !== false) {
return false;
}
}
}
return true;
}
示例11: checkAclApplicable
function checkAclApplicable(&$data)
{
$session = JFactory::getSession();
$permission = $this->aclparams->get('upload_avatar_at_registration', false);
$post = JRequest::get('post');
// When user login then force to upload avatar
$userId = JFactory::getUser()->id;
if (!empty($userId) && $data['task'] === 'logout') {
$session->clear('uploadAvatar', 'XIPT');
return false;
}
if (!empty($userId) && $data['task'] !== 'uploadavatar') {
//get login user avatar
$userAvatar = CFactory::getUser($userId)->_avatar;
//if avatar is deafaul then force to upload avatar
if (JString::stristr($userAvatar, 'components/com_community/assets/default.jpg') || empty($userAvatar)) {
$session->set('uploadAvatar', true, 'XIPT');
return true;
} else {
return false;
}
}
if ($permission && $session->get('uploadAvatar', false, 'XIPT') && isset($post['action']) && $post['action'] === 'doUpload') {
$session->clear('uploadAvatar', 'XIPT');
$session->clear('sessionpt', 'XIPT');
}
//if user login and have a avatar then not apply
if ($userId && $permission) {
return false;
}
//On Registeration Time:: if user come to uoload avatr then all link are disable untill user not upload avatar
if ($permission && $session->get('uploadAvatar', false, 'XIPT') && $data['task'] !== 'registeravatar') {
return true;
}
// When not registered than dont follow this rule until reach at upload avatar page through ragistration
if ('com_community' != $data['option'] && 'community' != $data['option']) {
return false;
}
// Set session variable at registration time
if ('register' == $data['view'] && $data['task'] === 'registeravatar') {
if (!isset($post['action']) || isset($post['action']) && $post['action'] != 'doUpload') {
$session->set('uploadAvatar', true, 'XIPT');
}
//XiTODO::add javascript for Click on upload button with image path.(without image-path does nt submit form)
}
// if you click on "SKIP" url then apply rule and not redirect to success
if ($permission && 'register' == $data['view'] && $data['task'] == 'registersucess' && $session->get('uploadAvatar', false, 'XIPT')) {
return true;
}
return false;
}
示例12: test
public function test(&$element, $value, $group = null, &$input = null, &$form = null)
{
if (!parent::test($element, $value, $group, $input, $form)) {
return false;
}
$params = JComponentHelper::getParams('com_contact');
$banned = $params->get('banned_email');
foreach (explode(';', $banned) as $item) {
if ($item != '' && JString::stristr($value, $item) !== false) {
return false;
}
}
return true;
}
示例13: do_filter
protected function do_filter($var)
{
if (is_string($this->strings)) {
$this->strings = array($this->strings);
}
foreach ($this->strings as $word) {
// Check for custom replacement
$customReplacement = '';
if (JString::stristr($word, '=')) {
$tmp = explode('=', $word);
$customReplacement = JString::trim($tmp[1]);
$word = JString::trim($tmp[0]);
}
// $word = preg_replace('#[^A-Za-z0-9\*\$\^]#', '', JString::trim($word));
$replacement = '';
if (JString::stristr($word, '*') === false && JString::stristr($word, '$') === false && JString::stristr($word, '^') === false) {
$str = JString::strlen($word);
$first = $this->keep_first_last ? $word[0] : '';
$str = $this->keep_first_last ? $str - 2 : $str;
$last = $this->keep_first_last ? $word[JString::strlen($word) - 1] : '';
if ($customReplacement == '') {
$replacement = str_repeat('*', $str);
} else {
$replacement = $customReplacement;
}
if ($this->replace_matches_inside_words) {
$var = JString::str_replace($word, $first . $replacement . $last, $var);
} else {
$var = preg_replace('/\\b' . $word . '\\b/ui', $first . $replacement . $last, $var);
}
} else {
// Rebuiling the regex
$keySearch = array('/\\*/ms', '/\\$/ms');
$keyReplace = array('%', '#');
$word = preg_replace($keySearch, $keyReplace, $word);
$keySearch = array('/\\%/ms', '/\\#/ms');
$keyReplace = array('.?', '.*?');
$word = preg_replace($keySearch, $keyReplace, $word);
if ($customReplacement != '') {
$replacement = str_repeat('*', JString::strlen($word));
} else {
$replacement = $customReplacement;
}
$var = preg_replace('/\\b' . $word . '\\b/uims', $replacement, $var);
}
}
return $var;
}
示例14: test
/**
* Method to test for banned e-mail addresses
*
* @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
* @param Registry $input An optional Registry object with the entire data set to validate against the entire form.
* @param JForm $form The form object for which the field is being tested.
*
* @return boolean True if the value is valid, false otherwise.
*/
public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, JForm $form = null)
{
if (!parent::test($element, $value, $group, $input, $form)) {
return false;
}
$params = JComponentHelper::getParams('com_proveedor');
$banned = $params->get('banned_email');
if ($banned) {
foreach (explode(';', $banned) as $item) {
if ($item != '' && JString::stristr($value, $item) !== false) {
return false;
}
}
}
return true;
}
示例15: onDisplay
/**
* Display the button
*
* @return array A two element array of ( imageName, textToInsert )
*/
function onDisplay($name)
{
JHTML::_('behavior.modal');
$doc =& JFactory::getDocument();
$lang =& JFactory::getLanguage();
// Button image
$base = JURI::root();
$inAdmin = JString::stristr($base, 'administrator/') !== false;
$assets = $inAdmin ? 'components/com_linkr/assets/' : 'administrator/components/com_linkr/assets/';
$assets = $base . $assets;
$button = $lang->get('rtl', 0) == 1 ? $assets . 'button-rtl.png' : $assets . 'button.png';
$doc->addStyleDeclaration('.button2-left .linkr{background:url(' . $button . ') 100% 0 no-repeat;}');
$link = 'index.php?option=com_linkr&view=articles&tmpl=component&e_name=' . $name;
$button = new JObject();
$button->set('modal', true);
$button->set('link', $link);
$button->set('text', JText::_('Link Article'));
$button->set('name', 'linkr');
$button->set('options', "{handler:'iframe',size:{x:570,y:350}}");
return $button;
}