當前位置: 首頁>>代碼示例>>PHP>>正文


PHP flexicontent_db::_getOrderByClause方法代碼示例

本文整理匯總了PHP中flexicontent_db::_getOrderByClause方法的典型用法代碼示例。如果您正苦於以下問題:PHP flexicontent_db::_getOrderByClause方法的具體用法?PHP flexicontent_db::_getOrderByClause怎麽用?PHP flexicontent_db::_getOrderByClause使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flexicontent_db的用法示例。


在下文中一共展示了flexicontent_db::_getOrderByClause方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: buildItemOrderBy

 /**
  * Build the order clause of item listings
  * precedence: $request_var ==> $order ==> $config_param ==> $default_order_col (& $default_order_dir)
  * @access private
  * @return string
  */
 static function buildItemOrderBy(&$params = null, &$order = '', $request_var = 'orderby', $config_param = 'orderby', $i_as = 'i', $rel_as = 'rel', $default_order_col_1st = '', $default_order_dir_1st = '', $sfx = '', $support_2nd_lvl = false)
 {
     // Use global params ordering if parameters were not given
     if (!$params) {
         $params = JComponentHelper::getParams('com_flexicontent');
     }
     $order_fallback = 'rdate';
     // Use as default or when an invalid ordering is requested
     $orderbycustomfield = (int) $params->get('orderbycustomfield' . $sfx, 1);
     // Backwards compatibility, defaults to enabled *
     $orderbycustomfieldid = (int) $params->get('orderbycustomfieldid' . $sfx, 0);
     // * but this needs to be set in order for field ordering to be used
     // 1. If a FORCED -ORDER- is not given, then use ordering parameters from configuration. NOTE: custom field ordering takes priority
     if (!$order) {
         $order = $orderbycustomfield && $orderbycustomfieldid ? 'field' : $params->get($config_param . $sfx, $order_fallback);
     }
     // 2. If allowing user ordering override, then get ordering from HTTP request variable
     $order = $params->get('orderby_override') && ($request_order = JRequest::getVar($request_var . $sfx)) ? $request_order : $order;
     // 3. Check various cases of invalid order, print warning, and reset ordering to default
     if ($order == 'field' && !$orderbycustomfieldid) {
         // This can occur only if field ordering was requested explicitly, otherwise an not set 'orderbycustomfieldid' will prevent 'field' ordering
         echo "Custom field ordering was selected, but no custom field is selected to be used for ordering<br/>";
         $order = $order_fallback;
     }
     if ($order == 'commented') {
         if (!file_exists(JPATH_SITE . DS . 'components' . DS . 'com_jcomments' . DS . 'jcomments.php')) {
             echo "jcomments not installed, you need jcomments to use 'Most commented' ordering OR display comments information.<br/>\n";
             $order = $order_fallback;
         }
     }
     $order_col_1st = $default_order_col_1st;
     $order_dir_1st = $default_order_dir_1st;
     flexicontent_db::_getOrderByClause($params, $order, $i_as, $rel_as, $order_col_1st, $order_dir_1st, $sfx);
     $order_arr[1] = $order;
     $orderby = ' ORDER BY ' . $order_col_1st . ' ' . $order_dir_1st;
     // ****************************************************************
     // 2nd level ordering, (currently only supported when no SFX given)
     // ****************************************************************
     if ($sfx != '' || !$support_2nd_lvl) {
         $orderby .= $order_col_1st != $i_as . '.title' ? ', ' . $i_as . '.title' : '';
         $order_arr[2] = '';
         $order = $order_arr;
         return $orderby;
     }
     $order = '';
     // Clear this, thus force retrieval from parameters (below)
     $sfx = '_2nd';
     // Set suffix of second level ordering
     $order_fallback = 'alpha';
     // Use as default or when an invalid ordering is requested
     $orderbycustomfield = (int) $params->get('orderbycustomfield' . $sfx, 1);
     // Backwards compatibility, defaults to enabled *
     $orderbycustomfieldid = (int) $params->get('orderbycustomfieldid' . $sfx, 0);
     // * but this needs to be set in order for field ordering to be used
     // 1. If a FORCED -ORDER- is not given, then use ordering parameters from configuration. NOTE: custom field ordering takes priority
     if (!$order) {
         $order = $orderbycustomfield && $orderbycustomfieldid ? 'field' : $params->get($config_param . $sfx, $order_fallback);
     }
     // 2. If allowing user ordering override, then get ordering from HTTP request variable
     $order = $request_var && ($request_order = JRequest::getVar($request_var . $sfx)) ? $request_order : $order;
     // 3. Check various cases of invalid order, print warning, and reset ordering to default
     if ($order == 'field' && !$orderbycustomfieldid) {
         // This can occur only if field ordering was requested explicitly, otherwise an not set 'orderbycustomfieldid' will prevent 'field' ordering
         echo "Custom field ordering was selected, but no custom field is selected to be used for ordering<br/>";
         $order = $order_fallback;
     }
     if ($order == 'commented') {
         if (!file_exists(JPATH_SITE . DS . 'components' . DS . 'com_jcomments' . DS . 'jcomments.php')) {
             echo "jcomments not installed, you need jcomments to use 'Most commented' ordering OR display comments information.<br/>\n";
             $order = $order_fallback;
         }
     }
     $order_col_2nd = '';
     $order_dir_2nd = '';
     if ($order != 'default') {
         flexicontent_db::_getOrderByClause($params, $order, $i_as, $rel_as, $order_col_2nd, $order_dir_2nd, $sfx);
         $order_arr[2] = $order;
         $orderby .= ', ' . $order_col_2nd . ' ' . $order_dir_2nd;
     }
     // Order by title after default ordering
     $orderby .= $order_col_1st != $i_as . '.title' && $order_col_2nd != $i_as . '.title' ? ', ' . $i_as . '.title' : '';
     $order = $order_arr;
     return $orderby;
 }
開發者ID:nettdotkomm,項目名稱:flexicontent-cck,代碼行數:90,代碼來源:flexicontent.helper.php


注:本文中的flexicontent_db::_getOrderByClause方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。