当前位置: 首页>>代码示例>>PHP>>正文


PHP JString::substr方法代码示例

本文整理汇总了PHP中JString::substr方法的典型用法代码示例。如果您正苦于以下问题:PHP JString::substr方法的具体用法?PHP JString::substr怎么用?PHP JString::substr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JString的用法示例。


在下文中一共展示了JString::substr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: check

 function check()
 {
     //initialize
     $this->_error = null;
     $this->newurl = JString::trim($this->newurl);
     $this->metadesc = JString::trim($this->metadesc);
     $this->metakey = JString::trim($this->metakey);
     $this->metatitle = JString::trim($this->metatitle);
     $this->metalang = JString::trim($this->metalang);
     $this->metarobots = JString::trim($this->metarobots);
     // check for valid URLs
     if ($this->newurl == '') {
         $this->_error .= JText::_('COM_SH404SEF_EMPTYURL');
         return false;
     }
     if (JString::substr($this->newurl, 0, 9) != 'index.php') {
         $this->_error .= JText::_('COM_SH404SEF_BADURL');
     }
     if (is_null($this->_error)) {
         // check for existing URLS
         $this->_db->setQuery("SELECT id FROM #__sh404sef_metas WHERE `newurl` LIKE " . $this->_db->Quote($this->newurl));
         $xid = intval($this->_db->loadResult());
         if ($xid && $xid != intval($this->id)) {
             $this->_error = JText::_('COM_SH404SEF_URLEXIST');
             return false;
         }
         return true;
     } else {
         return false;
     }
 }
开发者ID:lautarodragan,项目名称:ideary,代码行数:31,代码来源:sh404SEFMeta.class.php

示例2: genericordering

 /**
  * Returns an array of options
  *
  * @param   string   $sql		SQL with ordering As value and 'name field' AS text
  * @param   integer  $chop	The length of the truncated headline
  *
  * @return  array  An array of objects formatted for JHtml list processing
  * @since   11.1
  */
 public static function genericordering($sql, $chop = '30')
 {
     $db = JFactory::getDbo();
     $options = array();
     $db->setQuery($sql);
     $items = $db->loadObjectList();
     // Check for a database error.
     if ($db->getErrorNum()) {
         JError::raiseNotice(500, $db->getErrorMsg());
         return false;
     }
     if (empty($items)) {
         $options[] = JHtml::_('select.option', 1, JText::_('JOPTION_ORDER_FIRST'));
         return $options;
     }
     $options[] = JHtml::_('select.option', 0, '0 ' . JText::_('JOPTION_ORDER_FIRST'));
     for ($i = 0, $n = count($items); $i < $n; $i++) {
         $items[$i]->text = JText::_($items[$i]->text);
         if (JString::strlen($items[$i]->text) > $chop) {
             $text = JString::substr($items[$i]->text, 0, $chop) . "...";
         } else {
             $text = $items[$i]->text;
         }
         $options[] = JHtml::_('select.option', $items[$i]->value, $items[$i]->value . '. ' . $text);
     }
     $options[] = JHtml::_('select.option', $items[$i - 1]->value + 1, $items[$i - 1]->value + 1 . ' ' . JText::_('JOPTION_ORDER_LAST'));
     return $options;
 }
开发者ID:nibra,项目名称:joomla-platform,代码行数:37,代码来源:list.php

示例3: addCard

 public static function addCard(&$blog, $rawIntroText)
 {
     $cfg = EasyBlogHelper::getConfig();
     // @rule: Check if user really wants to append the opengraph tags on the headers.
     if (!$cfg->get('main_twitter_cards')) {
         return false;
     }
     // Get the absolute permalink for this blog item.
     $url = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true);
     // Get the image of the blog post.
     $image = self::getImage($blog, $rawIntroText);
     // @task: Get Joomla's document object.
     $doc = JFactory::getDocument();
     // Add card definition.
     $doc->addCustomTag('<meta property="twitter:card" content="summary" />');
     $doc->addCustomTag('<meta property="twitter:url" content="' . $url . '" />');
     $doc->addCustomTag('<meta property="twitter:title" content="' . $blog->title . '" />');
     $text = EasyBlogHelper::stripEmbedTags($rawIntroText);
     $text = strip_tags($text);
     $text = str_ireplace("\r\n", "", $text);
     // Remove any " in the content as this would mess up the headers.
     $text = str_ireplace('"', '', $text);
     $maxLength = 137;
     if (!empty($maxLength)) {
         $text = JString::strlen($text) > $maxLength ? JString::substr($text, 0, $maxLength) . '...' : $text;
     }
     $text = EasyBlogStringHelper::escape($text);
     $doc->addCustomTag('<meta property="twitter:description" content="' . $text . '" />');
     if ($image) {
         $doc->addCustomTag('<meta property="twitter:image" content="' . $image . '"/> ');
     }
     return true;
 }
开发者ID:alexinteam,项目名称:joomla3,代码行数:33,代码来源:twitter.php

示例4: generate

 /**
  * Generates the captcha image
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return	
  */
 public function generate()
 {
     $id = $this->input->get('id', '', 'int');
     // Load up the captcha object
     $captcha = EB::table('Captcha');
     // Clear outdated keys
     $captcha->clear();
     // load the captcha records.
     $captcha->load($id);
     if (!$captcha->id) {
         return false;
     }
     // @task: Generate a very random integer and take only 5 chars max.
     $hash = JString::substr(md5(rand(0, 9999)), 0, 5);
     $captcha->response = $hash;
     $captcha->store();
     // Captcha width and height
     $width = 100;
     $height = 20;
     $image = ImageCreate($width, $height);
     $white = ImageColorAllocate($image, 255, 255, 255);
     $black = ImageColorAllocate($image, 0, 0, 0);
     $gray = ImageColorAllocate($image, 204, 204, 204);
     ImageFill($image, 0, 0, $white);
     ImageString($image, 5, 30, 3, $hash, $black);
     ImageRectangle($image, 0, 0, $width - 1, $height - 1, $gray);
     imageline($image, 0, $height / 2, $width, $height / 2, $gray);
     imageline($image, $width / 2, 0, $width / 2, $height, $gray);
     header('Content-type: image/jpeg');
     ImageJpeg($image);
     ImageDestroy($image);
     exit;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:41,代码来源:captcha.php

示例5: _sanitize

 /**
  * Sanitize a value
  *
  * @param   mixed   Value to be sanitized
  * @return  string
  */
 protected function _sanitize($value)
 {
     $value = parent::_sanitize($value);
     $search_ignore = array();
     // Limit term to 20 characters
     if (JString::strlen($value) > 20) {
         $value = JString::substr($value, 0, 19);
     }
     // Term must contain a minimum of 3 characters
     if ($value && JString::strlen($value) < 3) {
         $value = '';
     }
     //Filter out search terms that are too small
     $words = explode(' ', JString::strtolower($value));
     foreach ($words as $word) {
         if (JString::strlen($word) < 3) {
             $search_ignore[] = $word;
         }
     }
     if (count($words) > 1) {
         $pruned = array_diff($words, $search_ignore);
         $value = implode(' ', $pruned);
     }
     return $value;
 }
开发者ID:JSWebdesign,项目名称:intranet-platform,代码行数:31,代码来源:term.php

示例6: html

 /**
  * Outputs the html code for Twitter button
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function html()
 {
     // If this is a frontpage, ensure that show in frontpage is enabled
     if ($this->frontpage && !$this->config->get('main_twitter_button_frontpage', $this->config->get('social_show_frontpage'))) {
         return;
     }
     // Get the button size
     $size = $this->getButtonSize();
     // Get the via text
     $via = $this->config->get('main_twitter_button_via_screen_name', '');
     if ($via) {
         $via = JString::substr($via, 1);
     }
     // Get the absolute url to this blog post
     $url = $this->getUrl();
     // Ge the formatted title to this blog post
     $title = $this->getTitle();
     // Twitter's sharing shouldn't have urlencoded values
     $title = urldecode($title);
     // Remove unwanted character inside url to avoid incorrect url sharing
     $title = str_replace('"', '', $title);
     // Determines if we should track with analytics
     $tracking = $this->config->get('main_twitter_analytics');
     $placeholder = $this->getPlaceholderId();
     $theme = EB::template();
     $theme->set('tracking', $tracking);
     $theme->set('size', $size);
     $theme->set('via', $via);
     $theme->set('placeholder', $placeholder);
     $theme->set('url', $url);
     $theme->set('title', $title);
     $output = $theme->output('site/socialbuttons/twitter');
     return $output;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:42,代码来源:twitter.php

示例7: DefaultViewEventCatRowNew

function DefaultViewEventCatRowNew($view, $row, $args = "")
{
    // I choost not to use $row->fgcolor()
    $fgcolor = "inherit";
    $router = JRouter::getInstance("site");
    $vars = $router->getVars();
    $vars["catids"] = $row->catid();
    if (array_key_exists("Itemid", $vars) && is_null($vars["Itemid"])) {
        $vars["Itemid"] = JRequest::getInt("Itemid", 0);
    }
    $eventlink = "index.php?";
    foreach ($vars as $key => $val) {
        $eventlink .= $key . "=" . $val . "&";
    }
    $eventlink = JString::substr($eventlink, 0, JString::strlen($eventlink) - 1);
    $eventlink = JRoute::_($eventlink);
    ?>
		<a class="ev_link_cat" href="<?php 
    echo $eventlink;
    ?>
"  style="color:<?php 
    echo $fgcolor;
    ?>
;" title="<?php 
    echo JEventsHTML::special($row->catname());
    ?>
"><?php 
    echo $row->catname();
    ?>
</a>
		<?php 
}
开发者ID:poorgeek,项目名称:JEvents,代码行数:32,代码来源:defaultvieweventcatrownew.php

示例8: execute

 public function execute($item)
 {
     $model = FD::model('comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     $users[] = $item->actor_id;
     $users = array_values(array_unique(array_diff($users, array(FD::user()->id))));
     $names = FD::string()->namesToNotifications($users);
     $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR';
     $content = '';
     if (count($users) == 1 && !empty($item->content)) {
         $content = JString::substr(strip_tags($item->content), 0, 30);
         if (JString::strlen($item->content) > 30) {
             $content .= JText::_('COM_EASYSOCIAL_ELLIPSES');
         }
     }
     $item->content = $content;
     list($element, $group, $verb) = explode('.', $item->context_type);
     $streamItem = FD::table('streamitem');
     $state = $streamItem->load(array('context_type' => $element, 'actor_type' => $group, 'verb' => $verb, 'context_id' => $item->uid));
     if (!$state) {
         return;
     }
     $owner = $streamItem->actor_id;
     if ($item->target_type === SOCIAL_TYPE_USER && $item->target_id == $owner) {
         $item->title = JText::sprintf('APP_USER_ARTICLE_USER_COMMENTED_ON_YOUR_ITEM' . $plurality, $names);
         return $item;
     }
     if ($item->actor_id == $owner && count($users) == 1) {
         $item->title = JText::sprintf('APP_USER_ARTICLE_OWNER_COMMENTED_ON_ITEM' . FD::user($owner)->getGenderLang(), $names);
         return $item;
     }
     $item->title = JText::sprintf('APP_USER_ARTICLE_USER_COMMENTED_ON_USER_ITEM' . $plurality, $names, FD::user($owner)->getName());
     return $item;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:34,代码来源:notification.comments.php

示例9: listDirectories

 function listDirectories($path, $regex = '.', $recurse = false)
 {
     $dirs = array();
     // Make sure path is valid
     jimport('joomla.filesystem.path');
     $path = JPath::clean($path);
     $root = strlen(JPATH_ROOT) ? JPATH_ROOT : DS;
     if (empty($path) || JString::strpos($path, $root) !== 0) {
         return $dirs;
     }
     // Find folders
     jimport('joomla.filesystem.folder');
     $list = JFolder::folders($path, $regex, $recurse, true);
     if (empty($list)) {
         return $dirs;
     }
     // Create list of directories and the names
     foreach ($list as $path) {
         //$folder	= JString::str_ireplace(JPATH_ROOT, '', $path);
         $folder = JString::substr($path, JString::strlen($root));
         $folder = substr(str_replace(DS, '/', $folder), 1);
         $name = @explode('/', $folder);
         $name = array_pop($name);
         $dirs[] = array('folder' => $folder, 'name' => $name, 'path' => $path, 'path.64' => base64_encode($path));
     }
     return $dirs;
 }
开发者ID:jtresca,项目名称:nysurveyor,代码行数:27,代码来源:helper.php

示例10: html

 /**
  * Outputs the html code for Twitter button
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function html()
 {
     if (!$this->isEnabled()) {
         return;
     }
     $this->addScript();
     // Get the pinterest button style from the configuration
     $size = $this->getButtonSize();
     $url = EBR::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $this->post->id, false, true);
     // Combine the introtext and the content
     $content = $this->post->intro . $this->post->content;
     // Get the media
     $media = $this->getMedia();
     $contentLength = 350;
     $text = $this->post->intro . $this->post->content;
     $text = nl2br($text);
     $text = strip_tags($text);
     $text = trim(preg_replace('/\\s+/', ' ', $text));
     $text = JString::strlen($text) > $contentLength ? JString::substr($text, 0, $contentLength) . '...' : $text;
     $title = $this->post->title;
     // Urlencode all the necessary properties.
     $url = urlencode($url);
     $text = urlencode($text);
     $media = urlencode($media);
     $placeholder = $this->getPlaceholderId();
     $theme = EB::template();
     $theme->set('size', $size);
     $theme->set('placeholder', $placeholder);
     $theme->set('url', $url);
     $theme->set('title', $title);
     $theme->set('media', $media);
     $theme->set('text', $text);
     $output = $theme->output('site/socialbuttons/pinterest');
     return $output;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:43,代码来源:pinterest.php

示例11: cutText

 function cutText($text, $limit_value, $limit_type, $at_end)
 {
     // solved problem from: https://www.gavick.com/support/forums/47/12309.html?p=57464#p57464
     $cck_path = JPATH_BASE . DS . 'components' . DS . 'com_cck';
     if (file_exists($cck_path)) {
         if (JComponentHelper::isEnabled('com_cck', true)) {
             // Force parsing plugin if SEBLOD is used
             if ($this->config['parse_plugins'] == FALSE) {
                 $text = JHtml::_('content.prepare', $text);
             }
             $text = trim(substr(strip_tags($text, "<br /><br><strong></strong><p></p><i></i><b></b><span></span><ul></ul><li></li><blockquote></blockquote>"), 0));
         }
     }
     if ($limit_type == 'words' && $limit_value > 0) {
         $temp = explode(' ', $text);
         if (count($temp) > $limit_value) {
             for ($i = 0; $i < $limit_value; $i++) {
                 $cutted[$i] = $temp[$i];
             }
             $cutted = implode(' ', $cutted);
             $text = $cutted . $at_end;
         }
     } elseif ($limit_type == 'words' && $limit_value == 0) {
         return '';
     } else {
         if (JString::strlen($text) > $limit_value) {
             $text = JString::substr($text, 0, $limit_value) . $at_end;
         }
     }
     // replace unnecessary entities at end of the cutted text
     $toReplace = array('&&', '&a&', '&am&', '&amp&', '&q&', '&qu&', '&quo&', '&quot&', '&ap&', '&apo&', '&apos&');
     $text = str_replace($toReplace, '&', $text);
     //
     return $text;
 }
开发者ID:Gskflute,项目名称:joomla25,代码行数:35,代码来源:gk.utils.php

示例12: links

    function links($rows, $team)
    {
        ?>
		<ul class="eblog_entry_links_list">
		<?php 
        for ($i = 1; $i < count($rows); $i++) {
            ?>
			<?php 
            $item = $rows[$i];
            ?>
			<li>
				<a href="<?php 
            echo EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $item->id);
            ?>
">
					<?php 
            echo JString::strlen($item->title) > 30 ? JString::substr(strip_tags($item->title), 0, 30) . '...' : strip_tags($item->title);
            ?>
				</a>
				<span><?php 
            echo JString::strlen($item->content) > 100 ? JString::substr(strip_tags($item->content), 0, 100) . '...' : strip_tags($item->content);
            ?>
</span>
			</li>
		<?php 
        }
        //end for
        ?>
		</ul>
<?php 
    }
开发者ID:Tommar,项目名称:vino2,代码行数:31,代码来源:layout.php

示例13: modChrome_ztxhtml

function modChrome_ztxhtml($module, &$params, &$attribs)
{
    $titles = JString::strpos($module->title, ' ');
    $title = $titles !== false ? JString::substr($module->title, 0, $titles) . '<span>' . JString::substr($module->title, $titles) . '</span>' : $module->title;
    if (!empty($module->content)) {
        ?>
		<div class="moduletable<?php 
        echo $params->get('moduleclass_sfx');
        ?>
">
			<div class="ztmodule">
				<?php 
        if ($module->showtitle != 0) {
            ?>
					<h3 class="moduletitle"><span class="title"><?php 
            echo $title;
            ?>
</span></h3>
				<?php 
        }
        ?>
				<div class="modulecontent">
					<?php 
        echo $module->content;
        ?>
				</div>
			</div>
		</div>
	<?php 
    }
}
开发者ID:romuland,项目名称:khparts,代码行数:31,代码来源:modules.php

示例14: __construct

 public function __construct(&$subject, $config)
 {
     parent::__construct($subject, $config);
     // Ensure that constructor is called one time
     self::$cookie = SID == '';
     if (!self::$default_lang) {
         $app = JFactory::getApplication();
         $router = $app->getRouter();
         if ($app->isSite()) {
             // setup language data
             self::$mode_sef = $router->getMode() == JROUTER_MODE_SEF ? true : false;
             self::$sefs = JLanguageHelper::getLanguages('sef');
             self::$lang_codes = JLanguageHelper::getLanguages('lang_code');
             self::$default_lang = JComponentHelper::getParams('com_languages')->get('site', 'en-GB');
             self::$default_sef = self::$lang_codes[self::$default_lang]->sef;
             $user = JFactory::getUser();
             $levels = $user->getAuthorisedViewLevels();
             foreach (self::$sefs as $sef => &$language) {
                 if (isset($language->access) && $language->access && !in_array($language->access, $levels)) {
                     unset(self::$sefs[$sef]);
                 }
             }
             $app->setLanguageFilter(true);
             jimport('joomla.environment.uri');
             $uri = JURI::getInstance();
             if (self::$mode_sef) {
                 // Get the route path from the request.
                 $path = JString::substr($uri->toString(), JString::strlen($uri->base()));
                 // Apache mod_rewrite is Off
                 $path = JFactory::getConfig()->get('sef_rewrite') ? $path : JString::substr($path, 10);
                 // Trim any spaces or slashes from the ends of the path and explode into segments.
                 $path = JString::trim($path, '/ ');
                 $parts = explode('/', $path);
                 // The language segment is always at the beginning of the route path if it exists.
                 $sef = $uri->getVar('lang');
                 if (!empty($parts) && empty($sef)) {
                     $sef = reset($parts);
                 }
             } else {
                 $sef = $uri->getVar('lang');
             }
             if (isset(self::$sefs[$sef])) {
                 $lang_code = self::$sefs[$sef]->lang_code;
                 // Create a cookie
                 $conf = JFactory::getConfig();
                 $cookie_domain = $conf->get('config.cookie_domain', '');
                 $cookie_path = $conf->get('config.cookie_path', '/');
                 setcookie(JApplication::getHash('language'), $lang_code, $this->getLangCookieTime(), $cookie_path, $cookie_domain);
                 $app->input->cookie->set(JApplication::getHash('language'), $lang_code);
                 // set the request var
                 $app->input->set('language', $lang_code);
             }
         }
         parent::__construct($subject, $config);
         // 	Detect browser feature
         if ($app->isSite()) {
             $app->setDetectBrowser($this->params->get('detect_browser', '1') == '1');
         }
     }
 }
开发者ID:GitIPFire,项目名称:Homeworks,代码行数:60,代码来源:languagefilter.php

示例15: fetchElement

 function fetchElement($name, $value, &$node, $control_name)
 {
     $db =& JFactory::getDBO();
     $db->setQuery('SELECT * FROM #__mt_customfields WHERE published = 1');
     $fields = $db->loadObjectList();
     if (!is_array($value)) {
         $value = array($value);
     }
     $html = '';
     foreach ($fields as $field) {
         $html .= '<div style="width:125px;float:left;padding: 4px 3px"><input type="checkbox"';
         $html .= ' name="' . $control_name . '[' . $name . '][]' . '"';
         $html .= ' id="' . $control_name . $name . $field->cf_id . '"';
         $html .= ' value="' . $field->cf_id . '"';
         if (in_array($field->cf_id, $value)) {
             $html .= ' checked';
         }
         $html .= ' />';
         $field->caption = stripslashes($field->caption);
         $html .= '&nbsp;<label for="' . $control_name . $name . $field->cf_id . '" title="' . $field->caption . '">';
         if (JString::strlen($field->caption) > $this->_max_caption_length - 3) {
             $html .= JString::substr($field->caption, 0, $this->_max_caption_length - 3);
             $html .= '...';
         } else {
             $html .= $field->caption;
         }
         $html .= '</label>';
         $html .= '</div>';
     }
     return $html;
 }
开发者ID:rsemedo,项目名称:Apply-Within,代码行数:31,代码来源:fields.php


注:本文中的JString::substr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。