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


PHP flexicontent_db::getAccessNames方法代码示例

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


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

示例1: calculateItemMarkups

 static function calculateItemMarkups($items, $params)
 {
     global $globalcats;
     global $globalnoroute;
     $globalnoroute = !is_array($globalnoroute) ? array() : $globalnoroute;
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $aids = JAccess::getAuthorisedViewLevels($user->id);
     // **************************************
     // Get configuration about markups to add
     // **************************************
     // Get addcss parameters
     $mu_addcss_cats = $params->get('mu_addcss_cats', array('featured'));
     $mu_addcss_cats = FLEXIUtilities::paramToArray($mu_addcss_cats);
     $mu_addcss_acclvl = $params->get('mu_addcss_acclvl', array('needed_acc', 'obtained_acc'));
     $mu_addcss_acclvl = FLEXIUtilities::paramToArray($mu_addcss_acclvl);
     $mu_addcss_radded = $params->get('mu_addcss_radded', 0);
     $mu_addcss_rupdated = $params->get('mu_addcss_rupdated', 0);
     // Calculate addcss flags
     $add_featured_cats = in_array('featured', $mu_addcss_cats);
     $add_other_cats = in_array('other', $mu_addcss_cats);
     $add_no_acc = in_array('no_acc', $mu_addcss_acclvl);
     $add_free_acc = in_array('free_acc', $mu_addcss_acclvl);
     $add_needed_acc = in_array('needed_acc', $mu_addcss_acclvl);
     $add_obtained_acc = in_array('obtained_acc', $mu_addcss_acclvl);
     // Get addtext parameters
     $mu_addtext_cats = $params->get('mu_addtext_cats', 1);
     $mu_addtext_acclvl = $params->get('mu_addtext_acclvl', array('no_acc', 'free_acc', 'needed_acc', 'obtained_acc'));
     $mu_addtext_acclvl = FLEXIUtilities::paramToArray($mu_addtext_acclvl);
     $mu_addtext_radded = $params->get('mu_addtext_radded', 1);
     $mu_addtext_rupdated = $params->get('mu_addtext_rupdated', 1);
     // Calculate addtext flags
     $add_txt_no_acc = in_array('no_acc', $mu_addtext_acclvl);
     $add_txt_free_acc = in_array('free_acc', $mu_addtext_acclvl);
     $add_txt_needed_acc = in_array('needed_acc', $mu_addtext_acclvl);
     $add_txt_obtained_acc = in_array('obtained_acc', $mu_addtext_acclvl);
     $mu_add_condition_obtainded_acc = $params->get('mu_add_condition_obtainded_acc', 1);
     $mu_no_acc_text = JText::_($params->get('mu_no_acc_text', 'FLEXI_MU_NO_ACC'));
     $mu_free_acc_text = JText::_($params->get('mu_free_acc_text', 'FLEXI_MU_NO_ACC'));
     // *******************************
     // Prepare data needed for markups
     // *******************************
     // a. Get Featured categories and language filter their titles
     $featured_cats_parent = $params->get('featured_cats_parent', 0);
     $disabled_cats = $params->get('featured_cats_parent_disable', 1) ? array($featured_cats_parent) : array();
     $featured_cats = array();
     if ($add_featured_cats && $featured_cats_parent) {
         $where[] = isset($globalcats[$featured_cats_parent]) ? 'id IN (' . $globalcats[$featured_cats_parent]->descendants . ')' : 'parent_id = ' . $featured_cats_parent;
         if (!empty($disabled_cats)) {
             $where[] = 'id NOT IN (' . implode(", ", $disabled_cats) . ')';
         }
         // optionally exclude category root of featured subtree
         $query = 'SELECT c.id' . ' FROM #__categories AS c' . (count($where) ? ' WHERE ' . implode(' AND ', $where) : '');
         $db->setQuery($query);
         $featured_cats = $db->loadColumn();
         $featured_cats = $featured_cats ? array_flip($featured_cats) : array();
         foreach ($featured_cats as $featured_cat => $i) {
             $featured_cats_titles[$featured_cat] = JText::_($globalcats[$featured_cat]->title);
         }
     }
     // b. Get Access Level names (language filter them)
     if ($add_needed_acc || $add_obtained_acc) {
         $access_names = flexicontent_db::getAccessNames();
     }
     // c. Calculate creation time intervals
     if ($mu_addcss_radded) {
         $nowdate_secs = time();
         $ra_timeframes = trim($params->get('mu_ra_timeframe_intervals', '24h,2d,7d,1m,3m,1y,3y'));
         $ra_timeframes = preg_split("/\\s*,\\s*/u", $ra_timeframes);
         $ra_names = trim($params->get('mu_ra_timeframe_names', 'FLEXI_24H_RA , FLEXI_2D_RA , FLEXI_7D_RA , FLEXI_1M_RA , FLEXI_3M_RA , FLEXI_1Y_RA , FLEXI_3Y_RA'));
         $ra_names = preg_split("/\\s*,\\s*/u", $ra_names);
         $unit_hour_map = array('h' => 1, 'd' => 24, 'm' => 24 * 30, 'y' => 24 * 365);
         $unit_word_map = array('h' => 'hours', 'd' => 'days', 'm' => 'months', 'y' => 'years');
         $unit_text_map = array('h' => 'FLEXI_MU_HOURS', 'd' => 'FLEXI_MU_DAYS', 'm' => 'FLEXI_MU_MONTHS', 'y' => 'FLEXI_MU_YEARS');
         foreach ($ra_timeframes as $i => $timeframe) {
             $unit = substr($timeframe, -1);
             if (!isset($unit_hour_map[$unit])) {
                 echo "Improper timeframe ': " . $timeframe . "' for recently added content, please fix in configuration";
                 continue;
             }
             $timeframe = (int) $timeframe;
             $ra_css_classes[$i] = '_item_added_within_' . $timeframe . $unit_word_map[$unit];
             $ra_timeframe_secs[$i] = $timeframe * $unit_hour_map[$unit] * 3600;
             $ra_timeframe_text[$i] = @$ra_names[$i] ? JText::_($ra_names[$i]) : JText::_('FLEXI_MU_ADDED') . JText::sprintf($unit_text_map[$unit], $timeframe);
         }
     }
     // d. Calculate updated time intervals
     if ($mu_addcss_rupdated) {
         $nowdate_secs = time();
         $ru_timeframes = trim($params->get('mu_ru_timeframe_intervals', '24h,2d,7d,1m,3m,1y,3y'));
         $ru_timeframes = preg_split("/\\s*,\\s*/u", $ru_timeframes);
         $ru_names = trim($params->get('mu_ru_timeframe_names', 'FLEXI_24H_RU , FLEXI_2D_RU , FLEXI_7D_RU , FLEXI_1M_RU , FLEXI_3M_RU , FLEXI_1Y_RU , FLEXI_3Y_RU'));
         $ru_names = preg_split("/\\s*,\\s*/u", $ru_names);
         $unit_hour_map = array('h' => 1, 'd' => 24, 'm' => 24 * 30, 'y' => 24 * 365);
         $unit_word_map = array('h' => 'hours', 'd' => 'days', 'm' => 'months', 'y' => 'years');
         $unit_text_map = array('h' => 'FLEXI_MU_HOURS', 'd' => 'FLEXI_MU_DAYS', 'm' => 'FLEXI_MU_MONTHS', 'y' => 'FLEXI_MU_YEARS');
         foreach ($ru_timeframes as $i => $timeframe) {
             $unit = substr($timeframe, -1);
             if (!isset($unit_hour_map[$unit])) {
                 echo "Improper timeframe ': " . $timeframe . "' for recently updated content, please fix in configuration";
//.........这里部分代码省略.........
开发者ID:khetsothea,项目名称:flexicontent-cck,代码行数:101,代码来源:flexicontent.helper.php

示例2: onDisplayFieldValue

 public function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display')
 {
     if (!in_array($field->field_type, self::$field_types)) {
         return;
     }
     static $all_langs = null;
     static $cat_links = array();
     static $acclvl_names = null;
     $remove_space = $field->parameters->get('remove_space', 0);
     $pretext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('pretext', ''), 'pretext');
     $posttext = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('posttext', ''), 'posttext');
     $separatorf = $field->parameters->get('separatorf', 1);
     $opentag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('opentag', ''), 'opentag');
     $closetag = FlexicontentFields::replaceFieldValue($field, $item, $field->parameters->get('closetag', ''), 'closetag');
     // Microdata (classify the field values for search engines)
     $itemprop = $field->parameters->get('microdata_itemprop');
     if ($pretext) {
         $pretext = $remove_space ? $pretext : $pretext . ' ';
     }
     if ($posttext) {
         $posttext = $remove_space ? $posttext : ' ' . $posttext;
     }
     switch ($separatorf) {
         case 0:
             $separatorf = ' ';
             break;
         case 1:
             $separatorf = '<br />';
             break;
         case 2:
             $separatorf = '&nbsp;|&nbsp;';
             break;
         case 3:
             $separatorf = ',&nbsp;';
             break;
         case 4:
             $separatorf = $closetag . $opentag;
             break;
         case 5:
             $separatorf = '';
             break;
         default:
             $separatorf = '&nbsp;';
             break;
     }
     $props_type = $field->parameters->get('props_type');
     switch ($props_type) {
         case 'language':
             if ($all_langs === null) {
                 $all_langs = FLEXIUtilities::getLanguages($hash = 'code');
             }
             $lang_data = $all_langs->{$item->language};
             $field->{$prop} = @$lang_data->title_native ? $lang_data->title_native : $lang_data->name;
             break;
         case 'alias':
             $field->{$prop} = $item->{$props_type};
             break;
         case 'category':
             $link_maincat = $field->parameters->get('link_maincat', 1);
             if ($link_maincat) {
                 $maincatid = isset($item->maincatid) ? $item->maincatid : $item->catid;
                 // maincatid is used by item view
                 if (!isset($cat_links[$maincatid])) {
                     $maincat_slug = $item->maincatid ? $item->maincatid . ':' . $item->maincat_alias : $item->catid;
                     $cat_links[$maincatid] = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($maincat_slug));
                 }
             }
             $maincat_title = !empty($item->maincat_title) ? $item->maincat_title : 'catid: ' . $item->catid;
             $field->{$prop} = $link_maincat ? '<a class="fc_coreprop fc_maincat link_' . $field->name . '" href="' . $cat_links[$maincatid] . '">' . $maincat_title . '</a>' : $maincat_title;
             break;
         case 'access':
             if ($acclvl_names === null) {
                 $acclvl_names = flexicontent_db::getAccessNames();
             }
             $field->{$prop} = isset($acclvl_names[$item->access]) ? $acclvl_names[$item->access] : 'unknown access level id: ' . $item->access;
             break;
         default:
             $field->{$prop} = $props_type;
             break;
     }
     if (strlen($field->{$prop})) {
         $field->{$prop} = $opentag . $pretext . $field->{$prop} . $posttext . $closetag;
     }
 }
开发者ID:khetsothea,项目名称:flexicontent-cck,代码行数:84,代码来源:coreprops.php


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