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


PHP mslib_fe::getSubcats方法代码示例

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


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

示例1: sortCatalog

 function sortCatalog($sortItem, $sortByField, $orderBy = 'asc')
 {
     set_time_limit(86400);
     ignore_user_abort(true);
     switch ($sortItem) {
         case 'manufacturers':
             switch ($sortByField) {
                 case 'manufacturers_name':
                     $query_array = array();
                     $query_array['select'][] = 'm.manufacturers_id';
                     $query_array['from'][] = 'tx_multishop_manufacturers m';
                     $query_array['where'][] = 'm.status=1';
                     //$query_array['order_by'][]='SUBSTRING_INDEX(m.manufacturers_name, " ", 1) ASC, CAST(SUBSTRING_INDEX(m.manufacturers_name, " ", -1) AS SIGNED) '.$orderBy;
                     $query_array['order_by'][] = 'm.manufacturers_name ' . $orderBy;
                     $str = $GLOBALS['TYPO3_DB']->SELECTquery(is_array($query_array['select']) ? implode(",", $query_array['select']) : '', is_array($query_array['from']) ? implode(",", $query_array['from']) : '', is_array($query_array['where']) ? implode(" and ", $query_array['where']) : '', is_array($query_array['group_by']) ? implode(",", $query_array['group_by']) : '', is_array($query_array['order_by']) ? implode(",", $query_array['order_by']) : '', is_array($query_array['limit']) ? implode(",", $query_array['limit']) : '');
                     $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
                     $counter = 0;
                     $content .= '<div class="main-heading"><h2>Sorting Manufacturers on alphabet ' . $orderBy . ' done</h2></div>';
                     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) {
                         $updateArray = array();
                         $updateArray['sort_order'] = $counter;
                         $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_manufacturers', 'manufacturers_id=' . $row['manufacturers_id'], $updateArray);
                         $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                         $counter++;
                     }
                     break;
             }
             break;
         case 'categories':
             switch ($sortByField) {
                 case 'categories_name':
                 case 'categories_name_natural':
                     $content .= '<div class="main-heading"><h2>Sorting categories on name ' . $orderBy . ' done</h2></div>';
                     $query_array = array();
                     $query_array['select'][] = 'c.categories_id,cd.categories_name';
                     $query_array['from'][] = 'tx_multishop_categories c, tx_multishop_categories_description cd';
                     //$query_array['where'][]='c.status=1 and c.parent_id=\''.$this->categoriesStartingPoint.'\' and c.page_uid=\''.$this->showCatalogFromPage.'\' and c.categories_id=cd.categories_id';
                     $query_array['where'][] = 'c.status=1 and c.page_uid=\'' . $this->showCatalogFromPage . '\' and c.categories_id=cd.categories_id';
                     $str = $GLOBALS['TYPO3_DB']->SELECTquery(is_array($query_array['select']) ? implode(",", $query_array['select']) : '', is_array($query_array['from']) ? implode(",", $query_array['from']) : '', is_array($query_array['where']) ? implode(" and ", $query_array['where']) : '', is_array($query_array['group_by']) ? implode(",", $query_array['group_by']) : '', is_array($query_array['order_by']) ? implode(",", $query_array['order_by']) : '', is_array($query_array['limit']) ? implode(",", $query_array['limit']) : '');
                     $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
                     $valuesArray = array();
                     while ($item = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) {
                         $values_name = $item['categories_name'];
                         // if the first char is not alphanumeric we cut it off, so we can sort much better
                         if ($values_name and !preg_match("/^[a-z0-9]/i", $values_name)) {
                             do {
                                 $values_name = substr($values_name, 1, strlen($values_name));
                             } while ($values_name and !preg_match("/^[a-z0-9]/i", $values_name));
                         }
                         // we now have a name that starts with alphanumeric
                         $valuesArray[$item['categories_id']] = $values_name;
                     }
                     // now let PHP sort the array
                     natcasesort($valuesArray);
                     switch ($orderBy) {
                         case 'desc':
                             $valuesArray = array_reverse($valuesArray);
                             break;
                     }
                     $sort = 1;
                     // iterate each value and save the new sort order number to DB
                     foreach ($valuesArray as $categories_id => $values_name) {
                         $updateArray = array();
                         $updateArray['sort_order'] = $sort;
                         $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_categories', 'categories_id=' . $categories_id, $updateArray);
                         $GLOBALS['TYPO3_DB']->sql_query($query);
                         $sort++;
                     }
                     break;
                 case 'categories_name_old':
                     $query_array = array();
                     $query_array['select'][] = 'c.categories_id';
                     $query_array['from'][] = 'tx_multishop_categories c, tx_multishop_categories_description cd';
                     $query_array['where'][] = 'c.status=1 and c.parent_id=\'0\' and c.page_uid=\'' . $this->showCatalogFromPage . '\' and c.categories_id=cd.categories_id';
                     $query_array['order_by'][] = 'SUBSTRING_INDEX(cd.categories_name, " ", 1) ASC, CAST(SUBSTRING_INDEX(cd.categories_name, " ", -1) AS SIGNED) ' . $orderBy;
                     $str = $GLOBALS['TYPO3_DB']->SELECTquery(is_array($query_array['select']) ? implode(",", $query_array['select']) : '', is_array($query_array['from']) ? implode(",", $query_array['from']) : '', is_array($query_array['where']) ? implode(" and ", $query_array['where']) : '', is_array($query_array['group_by']) ? implode(",", $query_array['group_by']) : '', is_array($query_array['order_by']) ? implode(",", $query_array['order_by']) : '', is_array($query_array['limit']) ? implode(",", $query_array['limit']) : '');
                     $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
                     $counter = 0;
                     $content .= '<div class="main-heading"><h2>Sorting categories on alphabet ' . $orderby . ' done</h2></div>';
                     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) {
                         $updateArray = array();
                         $updateArray['sort_order'] = $counter;
                         $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_categories', 'categories_id=' . $row['categories_id'], $updateArray);
                         $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                         $content .= $row['categories_id'] . '<br />';
                         $counter++;
                     }
                     $subcategories_array = array();
                     mslib_fe::getSubcats($subcategories_array, 0);
                     if (count($subcategories_array)) {
                         foreach ($subcategories_array as $item) {
                             // try to sort the subcats
                             $content .= $item . '<br />';
                             $query_array = array();
                             $query_array['select'][] = 'c.categories_id';
                             $query_array['from'][] = 'tx_multishop_categories c, tx_multishop_categories_description cd';
                             $query_array['where'][] = 'c.status=1 and c.parent_id=\'' . $item . '\' and c.page_uid=\'' . $this->showCatalogFromPage . '\' and c.categories_id=cd.categories_id';
                             $query_array['order_by'][] = 'SUBSTRING_INDEX(cd.categories_name, " ", 1) ASC, CAST(SUBSTRING_INDEX(cd.categories_name, " ", -1) AS SIGNED) ' . $orderBy;
                             $str = $GLOBALS['TYPO3_DB']->SELECTquery(is_array($query_array['select']) ? implode(",", $query_array['select']) : '', is_array($query_array['from']) ? implode(",", $query_array['from']) : '', is_array($query_array['where']) ? implode(" and ", $query_array['where']) : '', is_array($query_array['group_by']) ? implode(",", $query_array['group_by']) : '', is_array($query_array['order_by']) ? implode(",", $query_array['order_by']) : '', is_array($query_array['limit']) ? implode(",", $query_array['limit']) : '');
                             $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
//.........这里部分代码省略.........
开发者ID:bvbmedia,项目名称:multishop,代码行数:101,代码来源:class.tx_mslib_catalog.php

示例2: getSubcats

 public function getSubcats(&$subcategories_array, $parent_id = 0, $page_uid = '')
 {
     if (!is_numeric($page_uid)) {
         $page_uid = $this->showCatalogFromPage;
     }
     $qry = $GLOBALS['TYPO3_DB']->SELECTquery('categories_id', 'tx_multishop_categories', 'page_uid=\'' . $page_uid . '\' and status = \'1\' and parent_id = \'' . $parent_id . '\'', '', '', '');
     $subcategories_query = $GLOBALS['TYPO3_DB']->sql_query($qry);
     while ($subcategories = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($subcategories_query)) {
         $subcategories_array[sizeof($subcategories_array)] = $subcategories['categories_id'];
         if ($subcategories['categories_id'] != $parent_id) {
             mslib_fe::getSubcats($subcategories_array, $subcategories['categories_id']);
         }
     }
 }
开发者ID:bvbmedia,项目名称:multishop,代码行数:14,代码来源:class.mslib_fe.php

示例3: array

     if (!$this->cacheLifeTime) {
         $this->cacheLifeTime = $this->ms['MODULES']['CACHE_TIME_OUT_LISTING_PAGES'];
     }
     $options = array('caching' => true, 'cacheDir' => $this->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/cache/', 'lifeTime' => $this->cacheLifeTime);
     $Cache_Lite = new Cache_Lite($options);
     $string = $this->cObj->data['uid'] . '_' . $parent_id . '_' . $this->server['REQUEST_URI'] . $this->server['QUERY_STRING'];
 }
 if (!$this->ms['MODULES']['CACHE_FRONT_END'] or !($output_array = $Cache_Lite->get($string))) {
     $str = '';
     $filter = array();
     if ($parent_id) {
         if ($this->ms['MODULES']['FLAT_DATABASE']) {
             $filter[] = "(categories_id_0='" . $parent_id . "' or categories_id_1='" . $parent_id . "' or categories_id_2='" . $parent_id . "' or categories_id_3='" . $parent_id . "' or categories_id_4='" . $parent_id . "' or categories_id_5='" . $parent_id . "')";
         } else {
             $subcategories_array = array();
             mslib_fe::getSubcats($subcategories_array, $parent_id);
             if (count($subcategories_array) > 0) {
                 $where = '';
                 $filter[] = "p2c.categories_id IN (" . implode(",", $subcategories_array) . ")";
             } else {
                 $filter[] = "p2c.categories_id IN (" . $parent_id . ")";
             }
         }
     } elseif ($this->get['skeyword']) {
         if ($this->ms['MODULES']['FLAT_DATABASE']) {
             $tbl = '';
         } else {
             $tbl = 'pd.';
         }
         $filter[] = "(" . $tbl . "products_name like '%" . addslashes($this->get['skeyword']) . "%' or " . $tbl . "products_description like '%" . addslashes($this->get['skeyword']) . "%')";
     }
开发者ID:bvbmedia,项目名称:multishop,代码行数:31,代码来源:products_specials.php

示例4: array

<?php

// THIS CATEGORIES LISTING TYPE DIRECTLY PRINTS THE PRODUCTS
if (is_array($current) && $current['categories_id'] == $this->conf['categoriesStartingPoint']) {
    $categories_id = $current['categories_id'];
    $current['categories_name'] = '';
} else {
    $categories_id = $this->conf['categoriesStartingPoint'];
}
if (!is_numeric($categories_id)) {
    // FALLBACK TO NORMAL CATEGORIES LISTING
    require \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('multishop') . 'scripts/front_pages/includes/categories_listing/default.php';
} else {
    // get all subcategories
    $cats = array();
    mslib_fe::getSubcats($cats, $categories_id);
    if ($this->productsLimit) {
        $this->ms['MODULES']['PRODUCTS_LISTING_LIMIT'] = $this->productsLimit;
    }
    $default_limit_page = $this->ms['MODULES']['PRODUCTS_LISTING_LIMIT'];
    if ($this->get['tx_multishop_pi1']['limitsb']) {
        if ($this->get['tx_multishop_pi1']['limitsb'] and $this->get['tx_multishop_pi1']['limitsb'] != $this->cookie['limitsb']) {
            $this->cookie['limitsb'] = $this->get['tx_multishop_pi1']['limitsb'];
            $this->ms['MODULES']['PRODUCTS_LISTING_LIMIT'] = $this->cookie['limitsb'];
            $GLOBALS['TSFE']->fe_user->setKey('ses', 'tx_multishop_cookie', $this->cookie);
            $GLOBALS['TSFE']->storeSessionData();
        }
    }
    if ($this->get['tx_multishop_pi1']['sortbysb']) {
        if ($this->get['tx_multishop_pi1']['sortbysb'] and $this->get['tx_multishop_pi1']['sortbysb'] != $this->cookie['sortbysb']) {
            $this->cookie['sortbysb'] = $this->get['tx_multishop_pi1']['sortbysb'];
开发者ID:bvbmedia,项目名称:multishop,代码行数:31,代码来源:default_products.php


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