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


PHP K2HelperUtilities::characterLimit方法代码示例

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


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

示例1: display


//.........这里部分代码省略.........
             $params->set('page_title', $title);
         }
     } else {
         $params->set('page_title', $title);
     }
     // We're adding a new variable here which won't get the appended/prepended site title,
     // when enabled via Joomla!'s SEO/SEF settings
     $params->set('page_title_clean', $title);
     if (K2_JVERSION != '15') {
         if ($mainframe->getCfg('sitename_pagetitles', 0) == 1) {
             $tmpTitle = JText::sprintf('JPAGETITLE', $mainframe->getCfg('sitename'), $params->get('page_title'));
             $params->set('page_title', $tmpTitle);
         } elseif ($mainframe->getCfg('sitename_pagetitles', 0) == 2) {
             $tmpTitle = JText::sprintf('JPAGETITLE', $params->get('page_title'), $mainframe->getCfg('sitename'));
             $params->set('page_title', $tmpTitle);
         }
     }
     $document->setTitle($params->get('page_title'));
     // Search - Update the Google Search results container (K2 v2.6.6+)
     if ($task == 'search') {
         $googleSearchContainerID = trim($params->get('googleSearchContainer', 'k2GoogleSearchContainer'));
         if ($googleSearchContainerID == 'k2Container') {
             $googleSearchContainerID = 'k2GoogleSearchContainer';
         }
         $params->set('googleSearchContainer', $googleSearchContainerID);
     }
     // Set metadata for category
     if ($task == 'category') {
         if ($category->metaDescription) {
             $document->setDescription($category->metaDescription);
         } else {
             $metaDescItem = preg_replace("#{(.*?)}(.*?){/(.*?)}#s", '', $this->category->description);
             $metaDescItem = strip_tags($metaDescItem);
             $metaDescItem = K2HelperUtilities::characterLimit($metaDescItem, $params->get('metaDescLimit', 150));
             $metaDescItem = htmlspecialchars($metaDescItem, ENT_QUOTES, 'UTF-8');
             $document->setDescription($metaDescItem);
         }
         if ($category->metaKeywords) {
             $document->setMetadata('keywords', $category->metaKeywords);
         }
         if ($category->metaRobots) {
             $document->setMetadata('robots', $category->metaRobots);
         }
         if ($category->metaAuthor) {
             $document->setMetadata('author', $category->metaAuthor);
         }
     }
     if (K2_JVERSION != '15') {
         // Menu metadata options
         if ($params->get('menu-meta_description')) {
             $document->setDescription($params->get('menu-meta_description'));
         }
         if ($params->get('menu-meta_keywords')) {
             $document->setMetadata('keywords', $params->get('menu-meta_keywords'));
         }
         if ($params->get('robots')) {
             $document->setMetadata('robots', $params->get('robots'));
         }
         // Menu page display options
         if ($params->get('page_heading')) {
             $params->set('page_title', $params->get('page_heading'));
         }
         $params->set('show_page_title', $params->get('show_page_heading'));
     }
     // Pathway
     $pathway = $mainframe->getPathWay();
开发者ID:GitIPFire,项目名称:Homeworks,代码行数:67,代码来源:view.html.php

示例2: display


//.........这里部分代码省略.........
            if (!$menu_params->get('page_title')) {
                $params->set('page_title', $item->cleanTitle);
            }
        } else {
            $params->set('page_title', $item->cleanTitle);
        }
        if (K2_JVERSION == '16') {
            if ($mainframe->getCfg('sitename_pagetitles', 0) == 1) {
                $title = JText::sprintf('JPAGETITLE', $mainframe->getCfg('sitename'), $params->get('page_title'));
                $params->set('page_title', $title);
            } elseif ($mainframe->getCfg('sitename_pagetitles', 0) == 2) {
                $title = JText::sprintf('JPAGETITLE', $params->get('page_title'), $mainframe->getCfg('sitename'));
                $params->set('page_title', $title);
            }
        }
        $document->setTitle($params->get('page_title'));
        // Set pathway
        $menus =& JSite::getMenu();
        $menu = $menus->getActive();
        $pathway =& $mainframe->getPathWay();
        if ($menu) {
            if ($menu->query['view'] != 'item' || $menu->query['id'] != $item->id) {
                if (!isset($menu->query['task']) || $menu->query['task'] != 'category' || $menu->query['id'] != $item->catid) {
                    $pathway->addItem($item->category->name, $item->category->link);
                }
                $pathway->addItem($item->cleanTitle, '');
            }
        }
        // Set metadata
        if ($item->metadesc) {
            $document->setDescription($item->metadesc);
        } else {
            $metaDescItem = preg_replace("#{(.*?)}(.*?){/(.*?)}#s", '', $item->introtext . ' ' . $item->fulltext);
            $metaDescItem = K2HelperUtilities::characterLimit($metaDescItem, $params->get('metaDescLimit', 150));
            $metaDescItem = htmlentities($metaDescItem, ENT_QUOTES, 'utf-8');
            $document->setDescription($metaDescItem);
        }
        if ($item->metakey) {
            $document->setMetadata('keywords', $item->metakey);
        } else {
            if (isset($item->tags) && count($item->tags)) {
                $tmp = array();
                foreach ($item->tags as $tag) {
                    $tmp[] = $tag->name;
                }
                $document->setMetadata('keywords', implode(',', $tmp));
            }
        }
        // Menu metadata for Joomla! 1.6/1.7 (Overrides the current metadata if set)
        if (K2_JVERSION == '16') {
            if ($params->get('menu-meta_description')) {
                $document->setDescription($params->get('menu-meta_description'));
            }
            if ($params->get('menu-meta_keywords')) {
                $document->setMetadata('keywords', $params->get('menu-meta_keywords'));
            }
            if ($params->get('robots')) {
                $document->setMetadata('robots', $params->get('robots'));
            }
            // Menu page display options
            if ($params->get('page_heading')) {
                $params->set('page_title', $params->get('page_heading'));
            }
            $params->set('show_page_title', $params->get('show_page_heading'));
        }
        if ($mainframe->getCfg('MetaTitle') == '1') {
开发者ID:vuchannguyen,项目名称:dayhoc,代码行数:67,代码来源:view.html.php

示例3: display


//.........这里部分代码省略.........
                $params->set('page_title', $item->cleanTitle);
            }
        } else {
            $params->set('page_title', $item->cleanTitle);
        }
        if (K2_JVERSION != '15') {
            if ($mainframe->getCfg('sitename_pagetitles', 0) == 1) {
                $title = JText::sprintf('JPAGETITLE', $mainframe->getCfg('sitename'), $params->get('page_title'));
                $params->set('page_title', $title);
            } elseif ($mainframe->getCfg('sitename_pagetitles', 0) == 2) {
                $title = JText::sprintf('JPAGETITLE', $params->get('page_title'), $mainframe->getCfg('sitename'));
                $params->set('page_title', $title);
            }
        }
        $document->setTitle($params->get('page_title'));
        // Set pathway
        $menus = $mainframe->getMenu();
        $menu = $menus->getActive();
        $pathway = $mainframe->getPathWay();
        if ($menu) {
            if (isset($menu->query['view']) && ($menu->query['view'] != 'item' || $menu->query['id'] != $item->id)) {
                if (!isset($menu->query['task']) || $menu->query['task'] != 'category' || $menu->query['id'] != $item->catid) {
                    $pathway->addItem($item->category->name, $item->category->link);
                }
                $pathway->addItem($item->cleanTitle, '');
            }
        }
        // Set metadata
        if ($item->metadesc) {
            $document->setDescription(K2_JVERSION == '15' ? htmlspecialchars($item->metadesc, ENT_QUOTES, 'UTF-8') : $item->metadesc);
        } else {
            $metaDescItem = preg_replace("#{(.*?)}(.*?){/(.*?)}#s", '', $item->introtext . ' ' . $item->fulltext);
            $metaDescItem = strip_tags($metaDescItem);
            $metaDescItem = K2HelperUtilities::characterLimit($metaDescItem, $params->get('metaDescLimit', 150));
            $document->setDescription(K2_JVERSION == '15' ? $metaDescItem : html_entity_decode($metaDescItem));
        }
        if ($item->metakey) {
            $document->setMetadata('keywords', $item->metakey);
        } else {
            if (isset($item->tags) && count($item->tags)) {
                $tmp = array();
                foreach ($item->tags as $tag) {
                    $tmp[] = $tag->name;
                }
                $document->setMetadata('keywords', implode(',', $tmp));
            }
        }
        // Menu metadata for Joomla! 2.5+ (overrides the current metadata if set)
        if (K2_JVERSION != '15') {
            if ($params->get('menu-meta_description')) {
                $document->setDescription($params->get('menu-meta_description'));
            }
            if ($params->get('menu-meta_keywords')) {
                $document->setMetadata('keywords', $params->get('menu-meta_keywords'));
            }
            if ($params->get('robots')) {
                $document->setMetadata('robots', $params->get('robots'));
            }
            // Menu page display options
            if ($params->get('page_heading')) {
                $params->set('page_title', $params->get('page_heading'));
            }
            $params->set('show_page_title', $params->get('show_page_heading'));
        }
        if ($mainframe->getCfg('MetaTitle') == '1') {
            $document->setMetadata('title', $item->cleanTitle);
开发者ID:emavro,项目名称:k2,代码行数:67,代码来源:view.html.php

示例4: onBeforeRender

 /**
  * This method is to load neccessary access
  * for PageBuilder need
  *
  * @return void
  */
 public function onBeforeRender()
 {
     // Check if JoomlaShine extension framework is enabled?
     $framework = JTable::getInstance('Extension');
     $framework->load(array('element' => 'jsnframework', 'type' => 'plugin', 'folder' => 'system'));
     // Do nothing if JSN Extension framework not found.
     if (!$framework->extension_id) {
         return;
     }
     $app = JFactory::getApplication();
     $tpl = $app->input->getInt('tp', 0);
     if ($app->isAdmin() || $tpl) {
         return;
     }
     // Get requested component, view and task
     $option = $app->input->getCmd('option', '');
     $view = $app->input->getCmd('view', '');
     $layout = $app->input->getCmd('layout', '');
     $user = JFactory::getUser();
     if ($app->isSite() && $option == 'com_content' && $view == 'form' && $layout == 'edit' && $user->get('id') > 0) {
         return;
     }
     $doc = JFactory::getDocument();
     if (get_class($doc) != "JDocumentHTML") {
         return;
     }
     if ($app->isSite() && $option == 'com_k2' && $view == 'item' && $app->input->getInt('id', 0)) {
         if (file_exists(JPATH_ROOT . '/administrator/components/com_pagebuilder/helpers/shortcode.php')) {
             if (class_exists('K2HelperUtilities')) {
                 include_once JPATH_ROOT . '/administrator/components/com_pagebuilder/helpers/shortcode.php';
                 $shortCodeRegex = JSNPagebuilderHelpersShortcode::getShortcodeRegex();
                 JModelLegacy::addIncludePath(JPATH_ROOT . '/components/com_k2/models');
                 $K2ModelItem = JModelLegacy::getInstance('k2modelitem');
                 $k2Item = $K2ModelItem->getData();
                 if (count($k2Item)) {
                     $metaDescItem = preg_replace("#{(.*?)}(.*?){/(.*?)}#s", '', $k2Item->introtext . ' ' . $k2Item->fulltext);
                     $metaDescItem = strip_tags($metaDescItem);
                     $k2params = K2HelperUtilities::getParams('com_k2');
                     $metaDescItem = self::removeShortCode($metaDescItem, $shortCodeRegex);
                     $metaDescItem = K2HelperUtilities::characterLimit($metaDescItem, $k2params->get('metaDescLimit', 150));
                     if ($doc->getMetaData('og:description') != null) {
                         $doc->setMetaData('og:description', $metaDescItem);
                     }
                     if ($doc->getDescription() != '') {
                         $doc->setDescription($metaDescItem);
                     }
                 }
             }
         }
     }
     // Get PageBuilder configuration.
     $params = JSNConfigHelper::get('com_pagebuilder');
     // Check if it's enabled or not.
     $isEnabled = $params->get('enable_pagebuilder', 1);
     // Do nothing if PageBuilder not enabled;
     if (!$isEnabled) {
     }
     // Register autoloaded classes
     JSN_Loader::register(JSNPB_ADMIN_ROOT . '/helpers', 'JSNPagebuilderHelpers');
     JSN_Loader::register(JSNPB_ADMIN_ROOT . '/helpers/shortcode', 'JSNPBShortcode');
     //JSN_Loader::register(JPATH_ROOT . '/plugins/pagebuilder/' , 'JSNPBShortcode');
     //JSN_Loader::register(JPATH_ROOT . '/administrator/components/com_pagebuilder/elements/' , 'JSNPBShortcode');
     JSN_Loader::register(JPATH_ROOT . '/plugins/jsnpagebuilder/defaultelements/', 'JSNPBShortcode');
     //load ElementAssets
     self::loadElementAssets();
     /*
      * Move all css files of PageBuilder
      * to the end of css list
      *
      */
     $data = $doc->getHeadData();
     $styleSheetList = $data['styleSheets'];
     $_tmpList = array();
     if (count($styleSheetList)) {
         foreach ($styleSheetList as $cssUrl => $css) {
             // Check if the file belongs to PageBuilder
             if (strpos($cssUrl, 'plugins/pagebuilder/') !== false || strpos($cssUrl, 'com_pagebuilder') !== false) {
                 $_tmpList[$cssUrl] = $css;
                 unset($styleSheetList[$cssUrl]);
             }
         }
     }
     $styleSheetList = array_merge($styleSheetList, $_tmpList);
     $data['styleSheets'] = $styleSheetList;
     $doc->setHeadData($data);
 }
开发者ID:jovielarmario,项目名称:albay_cms,代码行数:92,代码来源:pagebuilder.php

示例5: display


//.........这里部分代码省略.........
                $item->nextTitle = $nextItem->title;
            }
            $previousItem = $model->getPreviousItem($item->id, $item->catid, $item->ordering);
            if (!is_null($previousItem)) {
                $item->previousLink = urldecode(JRoute::_(K2HelperRoute::getItemRoute($previousItem->id . ':' . urlencode($previousItem->alias), $previousItem->catid . ':' . urlencode($item->category->alias))));
                $item->previousTitle = $previousItem->title;
            }
        }
        //Absolute URL
        $uri =& JURI::getInstance();
        $item->absoluteURL = $uri->_uri;
        //Email link
        $item->emailLink = JRoute::_('index.php?option=com_mailto&tmpl=component&link=' . base64_encode($item->absoluteURL));
        //Twitter link
        if ($params->get('itemTwitterLink') && $params->get('twitterUsername')) {
            $itemURLForTwitter = $params->get('tinyURL') ? @file_get_contents('http://tinyurl.com/api-create.php?url=' . $item->absoluteURL) : $item->absoluteURL;
            $item->twitterURL = 'http://twitter.com/home/?status=' . urlencode('Reading @' . $params->get('twitterUsername') . ' ' . $item->title . ' ' . $itemURLForTwitter);
        }
        //Social link
        $item->socialLink = urlencode($item->absoluteURL);
        //Set page title
        $menus =& JSite::getMenu();
        $menu = $menus->getActive();
        if (is_object($menu) && isset($menu->query['view']) && $menu->query['view'] == 'item' && isset($menu->query['id']) && $menu->query['id'] == $item->id) {
            $menu_params = new JParameter($menu->params);
            if (!$menu_params->get('page_title')) {
                $params->set('page_title', $item->cleanTitle);
            }
        } else {
            $params->set('page_title', $item->cleanTitle);
        }
        $document->setTitle($params->get('page_title'));
        //Set pathway
        $menus =& JSite::getMenu();
        $menu = $menus->getActive();
        $pathway =& $mainframe->getPathWay();
        if ($menu) {
            if ($menu->query['view'] != 'item' || $menu->query['id'] != $item->id) {
                if (!isset($menu->query['task']) || $menu->query['task'] != 'category' || $menu->query['id'] != $item->catid) {
                    $pathway->addItem($item->category->name, $item->category->link);
                }
                $pathway->addItem($item->title, '');
            }
        }
        //Set metadata
        if ($item->metadesc) {
            $document->setDescription($item->metadesc);
        } else {
            $metaDescItem = preg_replace("#{(.*?)}(.*?){/(.*?)}#s", '', $item->introtext . ' ' . $item->fulltext);
            $metaDescItem = K2HelperUtilities::characterLimit($metaDescItem, $params->get('metaDescLimit', 150));
            $document->setDescription($metaDescItem);
        }
        if ($item->metakey) {
            $document->setMetadata('keywords', $item->metakey);
        } else {
            if (isset($item->tags) && count($item->tags)) {
                $tmp = array();
                foreach ($item->tags as $tag) {
                    $tmp[] = $tag->name;
                }
                $document->setMetadata('keywords', implode(',', $tmp));
            }
        }
        if ($mainframe->getCfg('MetaTitle') == '1') {
            $mainframe->addMetaTag('title', $item->title);
        }
        if ($mainframe->getCfg('MetaAuthor') == '1' && isset($item->author->name)) {
            $mainframe->addMetaTag('author', $item->author->name);
        }
        $mdata = new JParameter($item->metadata);
        $mdata = $mdata->toArray();
        foreach ($mdata as $k => $v) {
            if ($k == 'robots' || $k == 'author') {
                if ($v) {
                    $document->setMetadata($k, $v);
                }
            }
        }
        //Look for template files in component folders
        $this->_addPath('template', JPATH_COMPONENT . DS . 'templates');
        $this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . 'default');
        //Look for overrides in template folder (K2 template structure)
        $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates');
        $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . 'default');
        //Look for overrides in template folder (Joomla! template structure)
        $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'default');
        $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2');
        //Look for specific K2 theme files
        if ($item->params->get('theme')) {
            $this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . $item->params->get('theme'));
            $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . $item->params->get('theme'));
            $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . $item->params->get('theme'));
        }
        //Assign data
        $this->assignRef('item', $item);
        $this->assignRef('user', $user);
        $this->assignRef('params', $item->params);
        $this->assignRef('pagination', $pagination);
        parent::display($tpl);
    }
开发者ID:rlee1962,项目名称:diylegalcenter,代码行数:101,代码来源:view.html.php

示例6: setMetadata

 protected function setMetadata($resource)
 {
     $params = JComponentHelper::getParams('com_k2');
     if (!$this->isActive) {
         // Detect title
         $title = isset($resource->title) ? $resource->title : $resource->name;
         // Set the browser title according to the settings
         $this->setTitle($title);
         // Hide page heading since the current menu item is inherited
         $this->params->set('show_page_heading', false);
         // Update pathway
         $application = JFactory::getApplication();
         $pathway = $application->getPathWay();
         $pathway->addItem($title, '');
     }
     // Detect and set metadata
     if (isset($resource->metadata) && ($metadata = $resource->metadata)) {
         if ($metadata->get('description')) {
             $this->document->setDescription($metadata->get('description'));
         }
         if ($metadata->get('kewords')) {
             $this->document->setMetadata('keywords', $metadata->get('kewords'));
         }
         if ($metadata->get('robots')) {
             $this->document->setMetadata('robots', $metadata->get('robots'));
         }
         if ($metadata->get('author')) {
             $this->document->setMetadata('author', $metadata->get('author'));
         }
     }
     // If meta description is empty ( this means it was not set in the menu or item/category form ) then use the content of the resource
     if (!$this->document->getDescription()) {
         $resourceType = get_class($resource);
         if ($resourceType == 'K2Items') {
             $description = $resource->introtext . ' ' . $resource->fulltext;
         } else {
             if ($resourceType == 'K2Categories') {
                 $description = $resource->description;
             } else {
                 if ($resourceType == 'K2Users') {
                     $description = $resource->description;
                 }
             }
         }
         if (isset($description)) {
             $description = strip_tags($description);
             $description = K2HelperUtilities::characterLimit($description, $params->get('metaDescLimit', 150));
             $this->document->setDescription($description);
         }
     }
 }
开发者ID:Naldo100,项目名称:k2-v3-dev-build,代码行数:51,代码来源:view.php


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