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


PHP CategoriesHelper类代码示例

本文整理汇总了PHP中CategoriesHelper的典型用法代码示例。如果您正苦于以下问题:PHP CategoriesHelper类的具体用法?PHP CategoriesHelper怎么用?PHP CategoriesHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: display

 /**
  * Method to display a view.
  *
  * @param	boolean			If true, the view output will be cached
  * @param	array			An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  * @since	1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     // Get the document object.
     $document = JFactory::getDocument();
     // Set the default view name and format from the Request.
     $vName = JRequest::getCmd('view', 'categories');
     $vFormat = $document->getType();
     $lName = JRequest::getCmd('layout', 'default');
     $id = JRequest::getInt('id');
     // Check for edit form.
     if ($vName == 'category' && $lName == 'edit' && !$this->checkEditId('com_categories.edit.category', $id)) {
         // Somehow the person just went to the form - we don't allow that.
         $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
         $this->setMessage($this->getError(), 'error');
         $this->setRedirect(JRoute::_('index.php?option=com_categories&view=categories&extension=' . $this->extension, false));
         return false;
     }
     // Get and render the view.
     if ($view = $this->getView($vName, $vFormat)) {
         // Get the model for the view.
         $model = $this->getModel($vName, 'CategoriesModel', array('name' => $vName . '.' . substr($this->extension, 4)));
         // Push the model into the view (as default).
         $view->setModel($model, true);
         $view->setLayout($lName);
         // Push document object into the view.
         $view->assignRef('document', $document);
         // Load the submenu.
         require_once JPATH_COMPONENT . '/helpers/categories.php';
         CategoriesHelper::addSubmenu($model->getState('filter.extension'));
         $view->display();
     }
     return $this;
 }
开发者ID:exntu,项目名称:joomla-cms,代码行数:42,代码来源:controller.php

示例2: association

 /**
  * Render the list of associated items
  *
  * @param   integer  $catid      Category identifier to search its associations
  * @param   string   $extension  Category Extension
  *
  * @return  string   The language HTML
  *
  * @since   3.2
  * @throws  Exception
  */
 public static function association($catid, $extension = 'com_content')
 {
     // Defaults
     $html = '';
     // Get the associations
     if ($associations = CategoriesHelper::getAssociations($catid, $extension)) {
         $associations = ArrayHelper::toInteger($associations);
         // Get the associated categories
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('c.id, c.title')->select('l.sef as lang_sef')->select('l.lang_code')->from('#__categories as c')->where('c.id IN (' . implode(',', array_values($associations)) . ')')->join('LEFT', '#__languages as l ON c.language=l.lang_code')->select('l.image')->select('l.title as language_title');
         $db->setQuery($query);
         try {
             $items = $db->loadObjectList('id');
         } catch (RuntimeException $e) {
             throw new Exception($e->getMessage(), 500, $e);
         }
         if ($items) {
             foreach ($items as &$item) {
                 $text = $item->lang_sef ? strtoupper($item->lang_sef) : 'XX';
                 $url = JRoute::_('index.php?option=com_categories&task=category.edit&id=' . (int) $item->id . '&extension=' . $extension);
                 $classes = 'hasPopover label label-association label-' . $item->lang_sef;
                 $item->link = '<a href="' . $url . '" title="' . $item->language_title . '" class="' . $classes . '" data-content="' . $item->title . '" data-placement="top">' . $text . '</a>';
             }
         }
         JHtml::_('bootstrap.popover');
         $html = JLayoutHelper::render('joomla.content.associations', $items);
     }
     return $html;
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:40,代码来源:categoriesadministrator.php

示例3: association

 /**
  * @param	int $articleid	The article item id
  */
 public static function association($catid)
 {
     // Get the associations
     $associations = CategoriesHelper::getAssociations($catid);
     JArrayHelper::toInteger($associations);
     // Get the associated menu items
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('c.*');
     $query->from('#__categories as c');
     $query->where('c.id IN (' . implode(',', array_values($associations)) . ')');
     $query->leftJoin('#__languages as l ON c.language=l.lang_code');
     $query->select('l.image');
     $query->select('l.title as language_title');
     $db->setQuery($query);
     $items = $db->loadObjectList('id');
     // Check for a database error.
     if ($error = $db->getErrorMsg()) {
         JError::raiseWarning(500, $error);
         return false;
     }
     // Construct html
     $text = array();
     foreach ($associations as $tag => $associated) {
         if ($associated != $catid) {
             $text[] = JText::sprintf('COM_CATEGORIES_TIP_ASSOCIATED_LANGUAGE', JHtml::_('image', 'mod_languages/' . $items[$associated]->image . '.gif', $items[$associated]->language_title, array('title' => $items[$associated]->language_title), true), $items[$associated]->title);
         }
     }
     return JHtml::_('tooltip', implode('<br />', $text), JText::_('COM_CATEGORIES_TIP_ASSOCIATION'), 'admin/icon-16-links.png');
 }
开发者ID:ngxuanmui,项目名称:thongtinonline.net,代码行数:33,代码来源:categoriesadministrator.php

示例4: association

 /**
  * Render the list of associated items
  *
  * @param   integer  $catid      Category identifier to search its associations
  * @param   string   $extension  Category Extension
  *
  * @return  string   The language HTML
  */
 public static function association($catid, $extension = 'com_content')
 {
     // Defaults
     $html = '';
     // Get the associations
     if ($associations = CategoriesHelper::getAssociations($catid, $extension)) {
         JArrayHelper::toInteger($associations);
         // Get the associated categories
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('c.id, c.title')->select('l.sef as lang_sef')->from('#__categories as c')->where('c.id IN (' . implode(',', array_values($associations)) . ')')->join('LEFT', '#__languages as l ON c.language=l.lang_code')->select('l.image')->select('l.title as language_title');
         $db->setQuery($query);
         try {
             $items = $db->loadObjectList('id');
         } catch (RuntimeException $e) {
             throw new Exception($e->getMessage(), 500);
         }
         if ($items) {
             foreach ($items as &$item) {
                 $text = strtoupper($item->lang_sef);
                 $url = JRoute::_('index.php?option=com_categories&task=category.edit&id=' . (int) $item->id . '&extension=' . $extension);
                 $tooltipParts = array(JHtml::_('image', 'mod_languages/' . $item->image . '.gif', $item->language_title, array('title' => $item->language_title), true), $item->title);
                 $item->link = JHtml::_('tooltip', implode(' ', $tooltipParts), null, null, $text, $url, null, ' label label-association label-' . $item->lang_sef);
             }
         }
         $html = JLayoutHelper::render('joomla.content.associations', $items);
     }
     return $html;
 }
开发者ID:unrealprojects,项目名称:journal,代码行数:36,代码来源:categoriesadministrator.php

示例5: getCategoryAssociations

 /**
  * Method to get the associations for a given category
  *
  * @param   integer  $id         Id of the item
  * @param   string   $extension  Name of the component
  *
  * @return  array   Array of associations for the component categories
  *
  * @since  3.0
  */
 public static function getCategoryAssociations($id = 0, $extension = 'com_content')
 {
     $return = array();
     if ($id) {
         $associations = CategoriesHelper::getAssociations($id, $extension);
         foreach ($associations as $tag => $item) {
             $return[$tag] = ContentHelperRoute::getCategoryRoute($item, $tag);
         }
     }
     return $return;
 }
开发者ID:ngxuanmui,项目名称:thongtinonline.net,代码行数:21,代码来源:association.php

示例6: getAssociationsForm

 public static function getAssociationsForm($id, $name, $config = array())
 {
     if (!self::hasAssociations()) {
         return '';
     }
     $app = JFactory::getApplication();
     $addform = new SimpleXMLElement('<form />');
     $extension = $app->input->getString('extension', 'com_content');
     $fields = $addform->addChild('fields');
     $fields->addAttribute('name', $name);
     $fieldset = $fields->addChild('fieldset');
     $fieldset->addAttribute('name', 'item_associations');
     $fieldset->addAttribute('description', 'COM_CATEGORIES_ITEM_ASSOCIATIONS_FIELDSET_DESC');
     $fieldset->addAttribute('addfieldpath', '/administrator/components/com_categories/models/fields');
     $hasForm = false;
     $languages = JLanguageHelper::getLanguages('lang_code');
     foreach ($languages as $tag => $language) {
         if (empty($config['language']) || $tag != $config['language']) {
             $hasForm = true;
             $f = $fieldset->addChild('field');
             $f->addAttribute('name', $tag);
             $f->addAttribute('type', 'modal_category');
             $f->addAttribute('language', $tag);
             $f->addAttribute('label', $language->title);
             $f->addAttribute('translate_label', 'false');
             $f->addAttribute('extension', $extension);
         }
     }
     $form = JForm::getInstance($id, $addform->asXML());
     if ($hasForm) {
         $form->load($addform, false);
         $associations = CategoriesHelper::getAssociations($config['pk'], $extension);
         if (count($associations)) {
             foreach ($associations as $tag => $association_id) {
                 $form->setValue($tag, $name, $association_id);
             }
         }
         if ($config['translate_id'] && isset($config['translate'])) {
             $form->setValue($config['translate'], $name, $config['translate_id']);
         }
     }
     // Render Form
     $fields = $form->getFieldset('item_associations');
     $form = '';
     foreach ($fields as $f) {
         $form .= '<div class="control-group"><div class="control-label">' . $f->label . '</div><div class="controls">' . $f->input . '</div></div>';
     }
     return $form;
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:49,代码来源:helper.php

示例7: display

 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     $JSNMedia = JSNFactory::getMedia();
     $JSNMedia->addStyleSheet(JSN_POWERADMIN_STYLE_URI . 'content.css');
     JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.content.js');
     //Load language
     JFactory::getLanguage()->load('com_categories');
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $this->canDo = CategoriesHelper::getActions($this->state->get('category.component'));
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     parent::display($tpl);
 }
开发者ID:kleinhelmi,项目名称:tus03_j3_2015_01,代码行数:21,代码来源:view.html.php

示例8: getCategoryAssociations

 /**
  * Method to get the associations for a given category
  *
  * @param   integer  $id         Id of the item
  * @param   string   $extension  Name of the component
  *
  * @return  array    Array of associations for the component categories
  *
  * @since  3.0
  */
 public static function getCategoryAssociations($id = 0, $extension = 'com_content')
 {
     $return = array();
     if ($id) {
         // Load route helper
         jimport('helper.route', JPATH_COMPONENT_SITE);
         $helperClassname = ucfirst(substr($extension, 4)) . 'HelperRoute';
         $associations = CategoriesHelper::getAssociations($id, $extension);
         foreach ($associations as $tag => $item) {
             if (class_exists($helperClassname) && is_callable(array($helperClassname, 'getCategoryRoute'))) {
                 $return[$tag] = $helperClassname::getCategoryRoute($item, $tag);
             } else {
                 $return[$tag] = 'index.php?option=' . $extension . '&view=category&id=' . $item;
             }
         }
     }
     return $return;
 }
开发者ID:WineWorld,项目名称:joomlatrialcmbg,代码行数:28,代码来源:association.php

示例9: display

 /**
  * Method to display a view.
  *
  * @return	void
  */
 function display()
 {
     // Get the document object.
     $document =& JFactory::getDocument();
     // Set the default view name and format from the Request.
     $vName = JRequest::getWord('view', 'categories');
     $vFormat = $document->getType();
     $lName = JRequest::getWord('layout', 'default');
     // Get and render the view.
     if ($view =& $this->getView($vName, $vFormat)) {
         // Get the model for the view.
         $model =& $this->getModel($vName);
         // Push the model into the view (as default).
         $view->setModel($model, true);
         $view->setLayout($lName);
         // Push document object into the view.
         $view->assignRef('document', $document);
         $view->display();
         // Load the submenu.
         require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'categories.php';
         CategoriesHelper::addSubmenu($model->getState('filter.extension'));
     }
 }
开发者ID:joebushi,项目名称:joomla,代码行数:28,代码来源:controller.php

示例10: getCategoryAssociations

 /**
  * Method to get the associations for a given category
  *
  * @param   integer  $id         Id of the item
  * @param   string   $extension  Name of the component
  *
  * @return  array    Array of associations for the component categories
  *
  * @since  3.0
  */
 public static function getCategoryAssociations($id = 0, $extension = 'com_content', $view = '')
 {
     $return = array();
     if ($id) {
         //            if(!is_array($id)){
         // Load route helper
         jimport('helper.route', JPATH_COMPONENT_SITE);
         $helperClassname = 'TZ_PortfolioHelperRoute';
         $associations = CategoriesHelper::getAssociations($id, $extension);
         foreach ($associations as $tag => $item) {
             if (class_exists($helperClassname) && is_callable(array($helperClassname, 'getCategoryRoute'))) {
                 $return[$tag] = $helperClassname::getCategoryRoute($item, $tag);
             } else {
                 $return[$tag] = 'index.php?option=com_tz_portfolio&amp;view=category&id=' . $item;
             }
         }
         //            }else{
         //                $associations = CategoriesHelper::getAssociations($id, $extension);
         //                var_dump($associations);
         //            }
     }
     return $return;
 }
开发者ID:Glonum,项目名称:tz_portfolio,代码行数:33,代码来源:association.php

示例11: save

 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success.
  *
  * @since   3.0
  */
 public function save($data)
 {
     $input = JFactory::getApplication()->input;
     JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/categories.php');
     // Cast catid to integer for comparison
     $catid = (int) $data['catid'];
     // Check if New Category exists
     if ($catid > 0) {
         $catid = CategoriesHelper::validateCategoryId($data['catid'], 'com_contact');
     }
     // Save New Category
     if ($catid == 0 && $this->canCreateCategory()) {
         $table = array();
         $table['title'] = $data['catid'];
         $table['parent_id'] = 1;
         $table['extension'] = 'com_contact';
         $table['language'] = $data['language'];
         $table['published'] = 1;
         // Create new category and get catid back
         $data['catid'] = CategoriesHelper::createCategory($table);
     }
     // Alter the name for save as copy
     if ($input->get('task') == 'save2copy') {
         $origTable = clone $this->getTable();
         $origTable->load($input->getInt('id'));
         if ($data['name'] == $origTable->name) {
             list($name, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['name']);
             $data['name'] = $name;
             $data['alias'] = $alias;
         } else {
             if ($data['alias'] == $origTable->alias) {
                 $data['alias'] = '';
             }
         }
         $data['published'] = 0;
     }
     $links = array('linka', 'linkb', 'linkc', 'linkd', 'linke');
     foreach ($links as $link) {
         if ($data['params'][$link]) {
             $data['params'][$link] = JStringPunycode::urlToPunycode($data['params'][$link]);
         }
     }
     return parent::save($data);
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:53,代码来源:contact.php

示例12: save

 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success.
  *
  * @since	3.1
  */
 public function save($data)
 {
     $app = JFactory::getApplication();
     JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/categories.php');
     // Cast catid to integer for comparison
     $catid = (int) $data['catid'];
     // Check if New Category exists
     if ($catid > 0) {
         $catid = CategoriesHelper::validateCategoryId($data['catid'], 'com_weblinks');
     }
     // Save New Category
     if ($catid == 0 && $this->canCreateCategory()) {
         $table = array();
         $table['title'] = $data['catid'];
         $table['parent_id'] = 1;
         $table['extension'] = 'com_weblinks';
         $table['language'] = $data['language'];
         $table['published'] = 1;
         // Create new category and get catid back
         $data['catid'] = CategoriesHelper::createCategory($table);
     }
     // Alter the title for save as copy
     if ($app->input->get('task') == 'save2copy') {
         list($name, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['title']);
         $data['title'] = $name;
         $data['alias'] = $alias;
         $data['state'] = 0;
     }
     return parent::save($data);
 }
开发者ID:Bakual,项目名称:weblinks,代码行数:39,代码来源:weblink.php

示例13: defined

<?php

defined('_JEXEC') or die;
require_once __DIR__ . '/helper.php';
$categories = CategoriesHelper::getCategories();
if (!empty($categories)) {
    require JModuleHelper::getLayoutPath('mod_categories', $params->get('layout', 'default'));
}
开发者ID:baxri,项目名称:presents,代码行数:8,代码来源:mod_categories.php

示例14: save

 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success.
  *
  * @since   1.6
  */
 public function save($data)
 {
     $input = JFactory::getApplication()->input;
     JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/categories.php');
     // Cast catid to integer for comparison
     $catid = (int) $data['catid'];
     // Check if New Category exists
     if ($catid > 0) {
         $catid = CategoriesHelper::validateCategoryId($data['catid'], 'com_banners');
     }
     // Save New Category
     if ($catid == 0) {
         $table = array();
         $table['title'] = $data['catid'];
         $table['parent_id'] = 1;
         $table['extension'] = 'com_banners';
         $table['language'] = $data['language'];
         $table['published'] = 1;
         // Create new category and get catid back
         $data['catid'] = CategoriesHelper::createCategory($table);
     }
     // Alter the name for save as copy
     if ($input->get('task') == 'save2copy') {
         /** @var BannersTableBanner $origTable */
         $origTable = clone $this->getTable();
         $origTable->load($input->getInt('id'));
         if ($data['name'] == $origTable->name) {
             list($name, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['name']);
             $data['name'] = $name;
             $data['alias'] = $alias;
         } else {
             if ($data['alias'] == $origTable->alias) {
                 $data['alias'] = '';
             }
         }
         $data['state'] = 0;
     }
     return parent::save($data);
 }
开发者ID:ITPrism,项目名称:GamificationDistribution,代码行数:48,代码来源:banner.php

示例15:

        <p>
            <b>
                <?php 
echo $form->labelEx($model, 'categoryIds');
?>
            </b>
        </p>
        <input type="text" name="categoryFilter" class="filter span8"
               placeholder="<?php 
echo Yii::t('main', 'text.filter.placeholder');
?>
"/>

        <div>
            <?php 
echo $form->inlineCheckBoxList($model, 'categoryIds', CategoriesHelper::all(), ['template' => '{beginLabel}{input} {labelTitle}{endLabel}', 'separator' => '']);
?>
        </div>
    </div>
    <hr />
    <div class="control-group">
        <p>
            <b>
                <?php 
echo $form->labelEx($model, 'positionIds');
?>
            </b>
        </p
        <p>
            <?php 
echo Yii::t('main', 'vacancy.label.positionIds.ext');
开发者ID:asopin,项目名称:portal,代码行数:31,代码来源:_form.php


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