Exemple #1
0
 private function getCategoryOption($id_category = 1, $id_lang = false, $id_shop = false, $recursive = true)
 {
     $html = '';
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $category = new Category((int) $id_category, (int) $id_lang, (int) $id_shop);
     if (is_null($category->id)) {
         return;
     }
     if ($recursive) {
         $children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
         $spacer = '';
         if ($category->level_depth > 0) {
             $spacer = str_repeat('-', 2 * ((int) $category->level_depth - 1));
         }
     }
     $shop = (object) Shop::getShop((int) $category->getShopID());
     if ($category->id != Configuration::get('PS_ROOT_CATEGORY')) {
         $html .= '<option value="' . (int) $category->id . '">' . $spacer . $category->name . '</option>';
     }
     if (isset($children) && count($children)) {
         foreach ($children as $child) {
             $html .= $this->getCategoryOption((int) $child['id_category'], (int) $id_lang, (int) $child['id_shop'], $recursive);
         }
     }
     return $html;
 }
Exemple #2
0
 public function __construct()
 {
     global $cookie;
     $this->table = 'category';
     $this->className = 'Category';
     $this->lang = true;
     $this->edit = true;
     $this->view = true;
     $this->delete = true;
     $this->fieldImageSettings = array('name' => 'image', 'dir' => 'c');
     $this->fieldsDisplay = array('id_category' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 30), 'name' => array('title' => $this->l('Name'), 'width' => 100, 'callback' => 'hideCategoryPosition'), 'description' => array('title' => $this->l('Description'), 'width' => 480, 'maxlength' => 90, 'orderby' => false), 'physical_products_quantity' => array('title' => $this->l('In stock Products'), 'align' => 'center', 'width' => 50), 'active' => array('title' => $this->l('Displayed'), 'active' => 'status', 'align' => 'center', 'type' => 'bool', 'orderby' => false));
     $this->_category = AdminCatalog::getCurrentCategory();
     $this->_filter = 'AND `id_parent` = ' . intval($this->_category->id);
     $children = Category::getChildren($this->_category->id, $cookie->id_lang);
     foreach ($children as &$child) {
         $tmp_list = $this->_category->id . ',';
         $obj = new Category($child['id_category']);
         $parents = $obj->getParentsCategories();
         foreach ($parents as $parent) {
             $tmp_list .= $parent['id_category'] . ',';
         }
         $child['parent_id_list'] = rtrim($tmp_list, ',');
     }
     parent::__construct();
 }
 public function getData()
 {
     if (!isset($this->_data)) {
         $shop = $this->getShop();
         $lang = $this->getLang();
         if (empty($this->_root_category)) {
             $root_category = Category::getRootCategory($lang, new Shop((int) Configuration::get('PS_SHOP_DEFAULT')))->id;
         }
         $categories = $new_selected_categories = array();
         $selected_categories = Category::getAllCategoriesName($root_category, $lang, false, null, false);
         $categories[$root_category] = Category::getChildren($root_category, $lang, false, (int) Configuration::get('PS_SHOP_DEFAULT'));
         foreach ($selected_categories as $selected_category) {
             $category = new Category($selected_category['id_category'], $lang, (int) Configuration::get('PS_SHOP_DEFAULT'));
             $new_selected_categories[] = $selected_category['id_category'];
             $parents = $category->getParentsCategories($lang);
             foreach ($parents as $value) {
                 $new_selected_categories[] = $value['id_category'];
             }
         }
         $new_selected_categories = array_unique($new_selected_categories);
         foreach ($new_selected_categories as $selected_category) {
             $current_category = Category::getChildren($selected_category, $lang, false, (int) Configuration::get('PS_SHOP_DEFAULT'));
             if (!empty($current_category)) {
                 $categories[$selected_category] = $current_category;
             }
         }
         $tree = $this->fillTree($categories, $root_category);
         if (!empty($children)) {
             $tree[$root_category]['children'] = $children;
         }
         $this->setData($tree);
     }
     return $this->_data;
 }
Exemple #4
0
 function ischildren($id_parent)
 {
     global $cookie;
     $categories = Category::getChildren($id_parent, intval($cookie->id_lang), true);
     $nb_children = count($categories);
     if ($nb_children > 1) {
         return $nb_children;
     } else {
         return false;
     }
 }
 public function getData()
 {
     if (!isset($this->_data)) {
         $shop = $this->getShop();
         $lang = $this->getLang();
         $root_category = (int) $this->getRootCategory();
         if ($this->_full_tree) {
             $this->setData(Category::getNestedCategories($root_category, $lang, false, null, $this->useShopRestriction()));
             $this->setDataSearch(Category::getAllCategoriesName($root_category, $lang, false, null, $this->useShopRestriction()));
         } elseif ($this->_children_only) {
             if (empty($root_category)) {
                 $root_category = Category::getRootCategory()->id;
             }
             $categories[$root_category] = Category::getChildren($root_category, $lang, false, $shop->id);
             $children = $this->fillTree($categories, $root_category);
             $this->setData($children);
         } else {
             if (empty($root_category)) {
                 $root_category = Category::getRootCategory()->id;
             }
             $new_selected_categories = array();
             $selected_categories = $this->getSelectedCategories();
             $categories[$root_category] = Category::getChildren($root_category, $lang, false, $shop->id);
             foreach ($selected_categories as $selected_category) {
                 $category = new Category($selected_category, $lang, $shop->id);
                 $new_selected_categories[] = $selected_category;
                 $parents = $category->getParentsCategories($lang);
                 foreach ($parents as $value) {
                     $new_selected_categories[] = $value['id_category'];
                 }
             }
             $new_selected_categories = array_unique($new_selected_categories);
             foreach ($new_selected_categories as $selected_category) {
                 $current_category = Category::getChildren($selected_category, $lang, false, $shop->id);
                 if (!empty($current_category)) {
                     $categories[$selected_category] = $current_category;
                 }
             }
             $tree = Category::getCategoryInformations(array($root_category), $lang);
             $children = $this->fillTree($categories, $root_category);
             if (!empty($children)) {
                 $tree[$root_category]['children'] = $children;
             }
             $this->setData($tree);
             $this->setDataSearch(Category::getAllCategoriesName($root_category, $lang, false, null, $this->useShopRestriction()));
         }
     }
     return $this->_data;
 }
 /**
 * Make the index view
 */
 public function get_index()
 {
     $fname = "";
     if (Auth::check()) {
         $fname = User::getFirstName(Auth::user()->get()->cid);
     }
     //Pull category data
     $publicCategories = Category::where('hidden', '!=', 1)->get();
     $categories = Category::all();
     //Figure out which categories have children
     $categoryChildren = array();
     foreach ($categories as $categoryParent) {
         if (Category::isParent($categoryParent->id)) {
             $categoryChildren[$categoryParent->id] = Category::getChildren($categoryParent->id);
         }
     }
     //Get our news
     $news = News::where("visible", "=", 1)->orderBy("updated_at", "DESC")->get();
     return View::make('index')->with(array('fname' => $fname, 'categories' => $categories, 'categoryChildren' => $categoryChildren, 'publicCategories' => $publicCategories, 'news' => $news));
 }
Exemple #7
0
 private function getCategory($id_category, $id_lang)
 {
     global $page_name;
     $categorie = new Category($id_category, $id_lang);
     if (is_null($categorie->id)) {
         return;
     }
     $selected = $page_name == 'category' && (int) Tools::getValue('id_category') == $id_category ? ' class="sfHoverForce"' : '';
     $this->_menu .= '<li' . $selected . '>';
     if (count(explode('.', $categorie->name)) > 1) {
         $name = str_replace('.', '', strstr($categorie->name, '.'));
     } else {
         $name = $categorie->name;
     }
     $this->_menu .= '<a href="' . $categorie->getLink() . '">' . $name . '</a>';
     $childrens = Category::getChildren($id_category, $id_lang);
     if (count($childrens)) {
         $this->_menu .= '<ul>';
         foreach ($childrens as $children) {
             $this->getCategory($children['id_category'], $id_lang);
         }
         $this->_menu .= '</ul>';
     }
     $this->_menu .= '</li>';
 }
 /**
  * Get musicinfo rows for browse list by filters and limit.
  */
 public function getMusicRange($cat, $start, $num, $orderby, $maxage = -1, $excludedcats = array())
 {
     $db = new DB();
     $browseby = $this->getBrowseBy();
     if ($start === false) {
         $limit = "";
     } else {
         $limit = " LIMIT " . $start . "," . $num;
     }
     $catsrch = "";
     if (count($cat) > 0 && $cat[0] != -1) {
         $catsrch = " (";
         foreach ($cat as $category) {
             if ($category != -1) {
                 $categ = new Category();
                 if ($categ->isParent($category)) {
                     $children = $categ->getChildren($category);
                     $chlist = "-99";
                     foreach ($children as $child) {
                         $chlist .= ", " . $child["ID"];
                     }
                     if ($chlist != "-99") {
                         $catsrch .= " r.categoryID in (" . $chlist . ") or ";
                     }
                 } else {
                     $catsrch .= sprintf(" r.categoryID = %d or ", $category);
                 }
             }
         }
         $catsrch .= "1=2 )";
     }
     $maxagesql = "";
     if ($maxage > 0) {
         $maxagesql = sprintf(" and r.postdate > now() - interval %d day ", $maxage);
     }
     $exccatlist = "";
     if (count($excludedcats) > 0) {
         $exccatlist = " and r.categoryID not in (" . implode(",", $excludedcats) . ")";
     }
     $order = $this->getMusicOrder($orderby);
     // query modified to join to musicinfo after limiting releases as performance issue prevented sane sql.
     $sql = sprintf(" SELECT r.*, r.ID as releaseID, m.*, g.title as genre, groups.name as group_name, concat(cp.title, ' > ', c.title) as category_name, concat(cp.ID, ',', c.ID) as category_ids, rn.ID as nfoID from releases r left outer join groups on groups.ID = r.groupID inner join musicinfo m on m.ID = r.musicinfoID and m.title != '' left outer join releasenfo rn on rn.releaseID = r.ID and rn.nfo is not null left outer join category c on c.ID = r.categoryID left outer join category cp on cp.ID = c.parentID left outer join genres g on g.ID = m.genreID inner join (select r.ID from releases r inner join musicinfo m ON m.ID = r.musicinfoID and m.title != '' where r.musicinfoID > 0 and r.passwordstatus <= (select value from site where setting='showpasswordedrelease') and %s %s %s %s order by %s %s %s) x on x.ID = r.ID order by %s %s", $browseby, $catsrch, $maxagesql, $exccatlist, $order[0], $order[1], $limit, $order[0], $order[1]);
     return $db->query($sql, true);
 }
Exemple #9
0
 /**
  * Creates part of a query for searches requiring the categoryid's.
  *
  * @param array $categories
  *
  * @return string
  */
 public function categorySQL($categories)
 {
     $sql = '';
     if (count($categories) > 0 && $categories[0] != -1) {
         $Category = new \Category(['Settings' => $this->pdo]);
         $sql = ' AND (';
         foreach ($categories as $category) {
             if ($category != -1) {
                 if ($Category->isParent($category)) {
                     $children = $Category->getChildren($category);
                     $childList = '-99';
                     foreach ($children as $child) {
                         $childList .= ', ' . $child['id'];
                     }
                     if ($childList != '-99') {
                         $sql .= ' r.categoryid IN (' . $childList . ') OR ';
                     }
                 } else {
                     $sql .= sprintf(' r.categoryid = %d OR ', $category);
                 }
             }
         }
         $sql .= '1=2 )';
     }
     return $sql;
 }
Exemple #10
0
<?php

require_once WWW_DIR . "/lib/movie.php";
require_once WWW_DIR . "/lib/category.php";
$movie = new Movie();
$cat = new Category();
if (!$users->isLoggedIn()) {
    $page->show403();
}
$moviecats = $cat->getChildren(Category::CAT_PARENT_MOVIE);
$mtmp = array();
foreach ($moviecats as $mcat) {
    $mtmp[$mcat['ID']] = $mcat;
}
$category = Category::CAT_PARENT_MOVIE;
if (isset($_REQUEST["t"]) && array_key_exists($_REQUEST['t'], $mtmp)) {
    $category = $_REQUEST["t"] + 0;
}
$catarray = array();
$catarray[] = $category;
$page->smarty->assign('catlist', $mtmp);
$page->smarty->assign('category', $category);
$browsecount = $movie->getMovieCount($catarray, -1, $page->userdata["categoryexclusions"]);
$offset = isset($_REQUEST["offset"]) && ctype_digit($_REQUEST['offset']) ? $_REQUEST["offset"] : 0;
$ordering = $movie->getMovieOrdering();
$orderby = isset($_REQUEST["ob"]) && in_array($_REQUEST['ob'], $ordering) ? $_REQUEST["ob"] : '';
$results = $movies = array();
$results = $movie->getMovieRange($catarray, $offset, ITEMS_PER_PAGE, $orderby, -1, $page->userdata["categoryexclusions"]);
foreach ($results as $result) {
    $result['genre'] = $movie->makeFieldLinks($result, 'genre');
    $result['actors'] = $movie->makeFieldLinks($result, 'actors');
Exemple #11
0
 public function getMovieRange($cat, $start, $num, $orderby, $maxage = -1, $excludedcats = array())
 {
     $db = new DB();
     $browseby = $this->getBrowseBy();
     if ($start === false) {
         $limit = "";
     } else {
         $limit = " LIMIT " . $start . "," . $num;
     }
     $catsrch = "";
     if (count($cat) > 0 && $cat[0] != -1) {
         $catsrch = " (";
         foreach ($cat as $category) {
             if ($category != -1) {
                 $categ = new Category();
                 if ($categ->isParent($category)) {
                     $children = $categ->getChildren($category);
                     $chlist = "-99";
                     foreach ($children as $child) {
                         $chlist .= ", " . $child["ID"];
                     }
                     if ($chlist != "-99") {
                         $catsrch .= " r.categoryID in (" . $chlist . ") or ";
                     }
                 } else {
                     $catsrch .= sprintf(" r.categoryID = %d or ", $category);
                 }
             }
         }
         $catsrch .= "1=2 )";
     }
     $maxage = "";
     if ($maxage > 0) {
         $maxage = sprintf(" and r.postdate > now() - interval %d day ", $maxage);
     }
     $exccatlist = "";
     if (count($excludedcats) > 0) {
         $exccatlist = " and r.categoryID not in (" . implode(",", $excludedcats) . ")";
     }
     $order = $this->getMovieOrder($orderby);
     $sql = sprintf(" SELECT GROUP_CONCAT(r.ID ORDER BY r.postdate desc SEPARATOR ',') as grp_release_id, GROUP_CONCAT(r.guid ORDER BY r.postdate desc SEPARATOR ',') as grp_release_guid, GROUP_CONCAT(rn.ID ORDER BY r.postdate desc SEPARATOR ',') as grp_release_nfoID, GROUP_CONCAT(groups.name ORDER BY r.postdate desc SEPARATOR ',') as grp_release_grpname, GROUP_CONCAT(r.searchname ORDER BY r.postdate desc SEPARATOR '#') as grp_release_name, GROUP_CONCAT(r.postdate ORDER BY r.postdate desc SEPARATOR ',') as grp_release_postdate, GROUP_CONCAT(r.size ORDER BY r.postdate desc SEPARATOR ',') as grp_release_size, GROUP_CONCAT(r.totalpart ORDER BY r.postdate desc SEPARATOR ',') as grp_release_totalparts, GROUP_CONCAT(r.comments ORDER BY r.postdate desc SEPARATOR ',') as grp_release_comments, GROUP_CONCAT(r.grabs ORDER BY r.postdate desc SEPARATOR ',') as grp_release_grabs, m.*, groups.name as group_name, rn.ID as nfoID from releases r left outer join groups on groups.ID = r.groupID inner join movieinfo m on m.imdbID = r.imdbID and m.title != '' left outer join releasenfo rn on rn.releaseID = r.ID and rn.nfo is not null where r.passwordstatus <= (select value from site where setting='showpasswordedrelease') and %s %s %s %s group by m.imdbID order by %s %s" . $limit, $browseby, $catsrch, $maxage, $exccatlist, $order[0], $order[1]);
     return $db->query($sql);
 }
 public function displayAjaxGetCategoriesFromRootCategory()
 {
     if (Tools::isSubmit('id_category')) {
         $selected_cat = array((int) Tools::getValue('id_category'));
         $children = Category::getChildren((int) Tools::getValue('id_category'), $this->context->language->id);
         foreach ($children as $child) {
             $selected_cat[] = $child['id_category'];
         }
         $helper = new HelperTreeCategories('categories-tree', null, (int) Tools::getValue('id_category'), null, false);
         $this->content = $helper->setSelectedCategories($selected_cat)->setUseSearch(true)->setUseCheckBox(true)->render();
     }
     parent::displayAjax();
 }
Exemple #13
0
 public function getCategoryList($id)
 {
     return Category::getChildren($id);
 }
Exemple #14
0
 /**
  * Get range of consoleinfo rows for browse list.
  */
 public function getConsoleRange($cat, $start, $num, $orderby, $maxage = -1, $excludedcats = [])
 {
     $browseby = $this->getBrowseBy();
     if ($start === false) {
         $limit = "";
     } else {
         $limit = " LIMIT " . $start . "," . $num;
     }
     $catsrch = "";
     if (count($cat) > 0 && $cat[0] != -1) {
         $catsrch = " (";
         foreach ($cat as $category) {
             if ($category != -1) {
                 $categ = new Category();
                 if ($categ->isParent($category)) {
                     $children = $categ->getChildren($category);
                     $chlist = "-99";
                     foreach ($children as $child) {
                         $chlist .= ", " . $child["id"];
                     }
                     if ($chlist != "-99") {
                         $catsrch .= " r.categoryid in (" . $chlist . ") or ";
                     }
                 } else {
                     $catsrch .= sprintf(" r.categoryid = %d or ", $category);
                 }
             }
         }
         $catsrch .= "1=2 )";
     }
     $maxagesql = "";
     if ($maxage > 0) {
         $maxagesql = sprintf(" and r.postdate > now() - interval %d day ", $maxage);
     }
     $exccatlist = "";
     if (count($excludedcats) > 0) {
         $exccatlist = " and r.categoryid not in (" . implode(",", $excludedcats) . ")";
     }
     $order = $this->getConsoleOrder($orderby);
     $sql = sprintf(" SELECT r.*, r.id as releaseid, con.*, g.title as genre, groups.name as group_name, concat(cp.title, ' > ', c.title) as category_name, concat(cp.id, ',', c.id) as category_ids, rn.id as nfoid from releases r left outer join groups on groups.id = r.groupid inner join consoleinfo con on con.id = r.consoleinfoid left outer join releasenfo rn on rn.releaseid = r.id and rn.nfo is not null left outer join category c on c.id = r.categoryid left outer join category cp on cp.id = c.parentid left outer join genres g on g.id = con.genreid where r.passwordstatus <= (select value from settings where setting='showpasswordedrelease') and %s %s %s %s order by %s %s" . $limit, $browseby, $catsrch, $maxagesql, $exccatlist, $order[0], $order[1]);
     return $this->pdo->query($sql, true);
 }
 public function displayAjaxGetCategoriesFromRootCategory()
 {
     if (Tools::isSubmit('id_category')) {
         $root_category = new Category((int) Tools::getValue('id_category'));
         $root_category = array('id_category' => $root_category->id_category, 'name' => $root_category->name[$this->context->language->id]);
         $selected_cat = array($root_category['id_category']);
         $children = Category::getChildren($root_category['id_category'], $this->context->language->id);
         foreach ($children as $child) {
             $selected_cat[] = $child['id_category'];
         }
         $helper = new Helper();
         $this->content = $helper->renderCategoryTree($root_category, $selected_cat);
     }
     parent::displayAjax();
 }
 private function getCategoryOption($id_category = 1, $id_lang = false, $id_shop = false, $recursive = true)
 {
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $category = new Category((int) $id_category, (int) $id_lang, (int) $id_shop);
     if (is_null($category->id)) {
         return;
     }
     if ($recursive) {
         $children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
         if ($category->level_depth == '1') {
             $spacer = '';
         } else {
             $spacer = str_repeat('-', $this->spacer_size * (int) $category->level_depth);
         }
     }
     $shop = (object) Shop::getShop((int) $category->getShopID());
     if ($category->name != 'Root' && $category->name != 'Home') {
         $this->_html .= '<option value="' . (int) $category->id . '">' . (isset($spacer) ? $spacer : '') . $category->name . ' </option>';
     }
     if (isset($children) && count($children)) {
         foreach ($children as $child) {
             $this->getCategoryOption((int) $child['id_category'], (int) $id_lang, (int) $child['id_shop']);
         }
     }
     return $this->_html;
 }
 /**
  * Constructs a SphinxQL query.
  *
  * @param   array   $search
  * @param   array   $cat
  * @param   int     $offset
  * @param   int     $limit
  * @param   array   $order
  * @param   int     $maxage
  * @param   array   $excludedcats
  * @param   array   $grp
  * @param   array   $indexes
  * @param   boolean $lookup
  * @param   array   $where
  * @param   string  $lookupQuery
  *
  */
 public function buildQuery($search, $cat = array(), $offset = 0, $limit = 100, $order = array("postdate", "desc"), $maxage = -1, $excludedcats = array(), $grp = array(), $indexes = array(), $lookup = true, $where = array(), &$lookupQuery = "")
 {
     $ndb = new DB();
     $offset = intval($offset);
     $limit = intval($limit);
     if ($lookup) {
         // Since we're going to look up the data from MySQL, we don't need
         // to get all the fields from Sphinx.
         $select = "ID, name ";
     } else {
         $select = "* ";
     }
     // Create a comma separated string of indexes, but only of enabled
     // indexes
     $searchIndexes = array();
     foreach ($indexes as $index) {
         if ($this->isIndexEnabled($index)) {
             $searchIndexes[] = $index;
         }
     }
     if (count($searchIndexes) == 0) {
         $searchIndexes = array_reverse($this->getAllEnabledIndexes(true));
     }
     $from = implode(", ", $searchIndexes);
     // Check to see if this is an extended query.  If it is, remove the
     // leading "!" and don't touch the rest of the query.
     if (count($search) > 0) {
         if (substr($search[0], 0, 2) == "! ") {
             /*
                Extended Query
             */
             $search[0] = substr($search[0], 2, strlen($search[0]) - 2);
         } else {
             /*
                Basic Query
             */
             // Check to see if the the query contains any field specifiers like:
             // "@(field1,field2)"--if not, add in the default search fields.
             foreach ($search as $i => $q) {
                 if ($q && !preg_match('/@\\(?\\w+/i', $q)) {
                     // No field specifiers were found, so use the site-defaults.  This
                     // turns the query for "ubuntu" into something like:
                     //  "@(name,searchname) ubuntu"
                     $fields = str_replace(" ", "", $this->site->sphinxsearchfields);
                     // Remove single "-" so that Sphinx doesn't use it as an
                     // exclusion modifier
                     $q = preg_replace('/([^\\-])\\-/', '\\1 ', $q);
                     // "basic" search syntax allows a "--" exclusion modifier,
                     // but Sphinx uses "-" as a the exclusion modifier
                     $q = str_replace("--", "-", $q);
                     // always add on * to Season based searches
                     $q = preg_replace('/([\\. ]S\\d{2})( |$)/i', '\\1*\\2', $q);
                     // Construct the basic query
                     $search[$i] = sprintf("@(%s) ", $fields) . $q;
                 }
             }
         }
     }
     // Create the actual MATCH() query.  Per the Sphinx docs, each query
     // can only have one MATCH() statement.
     if (count($search) > 0) {
         if (!(count($search) == 1 && $search[0] == "")) {
             // If we are searching across multiple indexes, it is safer to prepend
             // "@@relaxed" to the query to ensure that Sphinx doesn't choke on
             // differences in schemas.  See:
             //      http://sphinxsearch.com/docs/2.0.2/extended-syntax.html
             if (count($searchIndexes) > 1 && strpos($search[0], "@@relaxed") !== 0) {
                 // We are searching across multiple indexes and the term
                 // "@@relaxed" wasn't found at the beginning,
                 $search[0] = "@@relaxed " . $search[0];
             }
             $where[] = sprintf("MATCH(%s)", $ndb->escapeString(implode(' ', $search)));
         }
     }
     // Build the category query.  If any of the categories are a "parent"
     // then we need to explicitly include their children as well.
     $categoryIDs = array();
     if (count($cat) > 0 && $cat[0] != -1) {
         foreach ($cat as $category) {
             if ($category != -1) {
                 if (!in_array($category, $categoryIDs)) {
                     $categoryIDs[] = $category;
                 }
                 $categ = new Category();
                 if ($categ->isParent($category)) {
                     // Inlcude all children
                     $children = $categ->getChildren($category);
                     foreach ($children as $child) {
                         if (!in_array($child["ID"], $categoryIDs)) {
                             $categoryIDs[] = $child["ID"];
                         }
                     }
                 }
             }
         }
     }
     // Only include the category filter if we created one.
     if ($categoryIDs) {
         $where[] = sprintf("categoryID IN (%s)", implode(",", $categoryIDs));
     }
     // Filter on postdate.
     if ($maxage > 0) {
         // TODO: This probably isn't the best way to do this...
         $where[] = sprintf("postdate >= %d", time() - $maxage * 86400);
     }
     // Categories to exclude.
     if (count($excludedcats) > 0) {
         $where[] = sprintf("categoryID NOT IN (%s)", implode(",", $excludedcats));
     }
     // Usenet groups to include.
     if ($grp) {
         foreach ($grp as $i => $g) {
             if (strpos($g, "a.b.") !== false) {
                 $sql = sprintf("SELECT ID FROM groups " . "WHERE name = %s", $ndb->escapeString(str_replace("a.b.", "alt.binaries.", $g)));
                 $row = $ndb->queryOneRow($sql);
                 $grp[$i] = $row["ID"];
             }
         }
         $where[] = sprintf("groupID IN (%s)", implode(",", $grp));
     }
     // Order the results.
     // TODO: implement better default ordering behavior.
     $orderby = "";
     if (count($order) == 2) {
         $orderby = sprintf("ORDER BY %s %s", $order[0], $order[1]);
         // Add in the ORDER BY parameters if there is a $lookupQuery
         if ($lookupQuery) {
             $lookupQuery = $lookupQuery . " " . $orderby;
         }
     }
     // Build the full query.
     $q = sprintf("SELECT %s FROM %s " . (!empty($where) ? "WHERE " : "") . " %s %s LIMIT %d,%d", $select, $from, implode(" AND ", $where), $orderby, $offset, $limit);
     // Sphinx imposes a 1000 result limit (max_matches) by default, so in
     // order to access results beyond this, we need to tell it to do so
     if ($offset >= 1000) {
         $q .= sprintf(" OPTION max_matches=%d", $offset + $limit);
     }
     return $q;
 }
Exemple #18
0
 public function getCategoryOption($id_category = 1, $selected = null, $id_lang = false, $id_shop = false, $recursive = true, $link = false)
 {
     $html = '';
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $category = new Category((int) $id_category, (int) $id_lang, (int) $id_shop);
     if (is_null($category->id)) {
         return;
     }
     if ($recursive) {
         $children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
         $spacer = str_repeat('&nbsp;', 5 * (int) $category->level_depth);
     }
     $shop = (object) Shop::getShop((int) $category->getShopID());
     if ($category->id != 1) {
         if ($link) {
             $html .= '<option ' . ($selected == $category->id ? 'selected="selected" ' : '') . 'value="' . $this->context->link->getCategoryLink($category->id) . '">' . (isset($spacer) ? $spacer : '') . $category->name . '</option>';
         } else {
             $html .= '<option ' . ($selected == $category->id ? 'selected="selected" ' : '') . 'value="' . (int) $category->id . '">' . (isset($spacer) ? $spacer : '') . $category->name . '</option>';
         }
     }
     if (isset($children) && count($children)) {
         foreach ($children as $child) {
             $html .= $this->getCategoryOption((int) $child['id_category'], $selected, (int) $id_lang, (int) $child['id_shop'], $recursive, $link);
         }
     }
     return $html;
 }
Exemple #19
0
     foreach ($ordering as $ordertype) {
         $page->smarty->assign('orderby' . $ordertype, WWW_TOP . "/myshows/browse?ob=" . $ordertype . "&amp;offset=0");
     }
     $page->smarty->assign('lastvisit', $page->userdata['lastlogin']);
     $page->smarty->assign('results', $results);
     $page->smarty->assign('shows', true);
     $page->content = $page->smarty->fetch('browse.tpl');
     $page->render();
     break;
 default:
     $page->title = "My Shows";
     $page->meta_title = "My Shows";
     $page->meta_keywords = "search,add,to,cart,nzb,description,details";
     $page->meta_description = "Manage Your Shows";
     $cat = new Category(['Settings' => $page->settings]);
     $tmpcats = $cat->getChildren(Category::CAT_PARENT_TV);
     $categories = array();
     foreach ($tmpcats as $c) {
         $categories[$c['id']] = $c['title'];
     }
     $shows = $us->getShows($page->users->currentUserId());
     $results = array();
     foreach ($shows as $showk => $show) {
         $showcats = explode('|', $show['categoryid']);
         if (is_array($showcats) && sizeof($showcats) > 0) {
             $catarr = array();
             foreach ($showcats as $scat) {
                 if (!empty($scat)) {
                     $catarr[] = $categories[$scat];
                 }
             }
 private function getCategory(&$menu, $id_category, $id_lang = false, $id_shop = false, $is_child_item = false)
 {
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $category = new Category((int) $id_category, (int) $id_lang);
     if ($category->level_depth > 1) {
         $category_link = $category->getLink();
     } else {
         $category_link = $this->context->link->getPageLink('index');
     }
     if (is_null($category->id)) {
         return;
     }
     $children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
     $selected = $this->page_name == 'category' && (int) Tools::getValue('id_category') == $id_category ? 'active ' : '';
     $is_intersected = array_intersect($category->getGroups(), $this->user_groups);
     $class = $selected . ($is_child_item ? $this->_subItemClass : $this->_itemClass);
     $head = $is_child_item ? $this->_subItemHead : $this->_itemHead;
     $tail = $is_child_item ? $this->_subItemTail : $this->_itemTail;
     // filter the categories that the user is allowed to see and browse
     if (!empty($is_intersected)) {
         $menu .= $head . '<li class="' . $class . '">';
         $menu .= '<a href="' . $category_link . '"><span>' . $category->name . '</span></a>';
         if (count($children) && ($this->_showAll !== 'one level' || $this->_showAllResponsive !== 'one level')) {
             $menu .= $this->_subMenuHead . '<ul class="' . $this->_subMenuClass . '">';
             foreach ($children as $child) {
                 $this->getCategory($menu, (int) $child['id_category'], (int) $id_lang, (int) $child['id_shop'], true);
             }
             $menu .= '</ul>' . $this->_subMenuTail;
         }
         $menu .= '</li>' . $tail;
     }
 }
Exemple #21
0
 private function getCategoryOption($id_category = 1, $id_lang = false, $id_shop = false, $recursive = true, $link = false)
 {
     $html = '';
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $category = new Category((int) $id_category, (int) $id_lang, (int) $id_shop);
     if (is_null($category->id)) {
         return;
     }
     if ($recursive) {
         $children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
         $spacer = str_repeat('&nbsp;', 3 * (int) $category->level_depth);
     }
     $shop = (object) Shop::getShop((int) $category->getShopID());
     if (!in_array($category->id, array(Configuration::get('PS_HOME_CATEGORY'), Configuration::get('PS_ROOT_CATEGORY')))) {
         if ($link) {
             $html .= '<option value="' . $this->context->link->getCategoryLink($category->id) . '">' . (isset($spacer) ? $spacer : '') . str_repeat('&nbsp;', 3 * (int) $category->level_depth) . $category->name . '</option>';
         } else {
             $html .= '<option value="CAT' . (int) $category->id . '">' . str_repeat('&nbsp;', 3 * (int) $category->level_depth) . $category->name . '</option>';
         }
     } elseif ($category->id != Configuration::get('PS_ROOT_CATEGORY')) {
         $html .= '<optgroup label="' . str_repeat('&nbsp;', 3 * (int) $category->level_depth) . $category->name . '">';
     }
     if (isset($children) && count($children)) {
         foreach ($children as $child) {
             $html .= $this->getCategoryOption((int) $child['id_category'], (int) $id_lang, (int) $child['id_shop'], $recursive, $link);
         }
     }
     return $html;
 }
Exemple #22
0
<?php

if (!$page->users->isLoggedIn()) {
    $page->show403();
}
$console = new Konsole(['Settings' => $page->settings]);
$cat = new Category(['Settings' => $page->settings]);
$gen = new Genres(['Settings' => $page->settings]);
$concats = $cat->getChildren(Category::CAT_PARENT_GAME);
$ctmp = [];
foreach ($concats as $ccat) {
    $ctmp[$ccat['id']] = $ccat;
}
$category = Category::CAT_PARENT_GAME;
if (isset($_REQUEST["t"]) && array_key_exists($_REQUEST['t'], $ctmp)) {
    $category = $_REQUEST["t"] + 0;
}
$catarray = [];
$catarray[] = $category;
$page->smarty->assign('catlist', $ctmp);
$page->smarty->assign('category', $category);
$browsecount = $console->getConsoleCount($catarray, -1, $page->userdata["categoryexclusions"]);
$offset = isset($_REQUEST["offset"]) && ctype_digit($_REQUEST['offset']) ? $_REQUEST["offset"] : 0;
$ordering = $console->getConsoleOrdering();
$orderby = isset($_REQUEST["ob"]) && in_array($_REQUEST['ob'], $ordering) ? $_REQUEST["ob"] : '';
$results = $consoles = [];
$results = $console->getConsoleRange($catarray, $offset, ITEMS_PER_COVER_PAGE, $orderby, $page->userdata["categoryexclusions"]);
$maxwords = 50;
foreach ($results as $result) {
    if (!empty($result['review'])) {
        $words = explode(' ', $result['review']);
Exemple #23
0
 private function getCategory($id_category, $id_lang = false, $id_shop = false)
 {
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $category = new Category((int) $id_category, (int) $id_lang);
     if ($category->level_depth > 1) {
         $category_link = $category->getLink();
     } else {
         $category_link = $this->context->link->getPageLink('index');
     }
     if (is_null($category->id)) {
         return;
     }
     $children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
     $selected = $this->page_name == 'category' && (int) Tools::getValue('id_category') == $id_category ? ' class="sfHoverForce"' : '';
     $is_intersected = array_intersect($category->getGroups(), $this->user_groups);
     // filter the categories that the user is allowed to see and browse
     if (!empty($is_intersected)) {
         $this->_menu .= '<li ' . $selected . '>';
         $this->_menu .= '<a href="' . Tools::HtmlEntitiesUTF8($category_link) . '" title="' . $category->name . '">' . $category->name . '</a>';
         if (count($children)) {
             $this->_menu .= '<ul>';
             foreach ($children as $child) {
                 $this->getCategory((int) $child['id_category'], (int) $id_lang, (int) $child['id_shop']);
             }
             if ($category->level_depth == 2) {
                 $files = scandir(_PS_CAT_IMG_DIR_);
                 $this->_menu .= '<li id="category-thumbnail">';
                 foreach ($files as $file) {
                     if (preg_match('/' . $category->id . '-([0-9])?_thumb.jpg/i', $file) === 1) {
                         $this->_menu .= '<div><img src="' . Tools::getShopDomain(true, true) . __PS_BASE_URI__ . basename(_PS_IMG_DIR_) . '/' . basename(_PS_CAT_IMG_DIR_) . '/' . $file . '" alt="' . $category->name . '" class="imgm" /></div>';
                     }
                 }
                 $this->_menu .= '</li>';
             }
             $this->_menu .= '</ul>';
         }
         $this->_menu .= '</li>';
     }
 }
 private function getCategory($id_category, $id_lang = false, $id_shop = false)
 {
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $category = new Category((int) $id_category, (int) $id_lang);
     if ($category->level_depth > 1) {
         $category_link = $category->getLink();
     } else {
         $category_link = $this->context->link->getPageLink('index');
     }
     if (is_null($category->id)) {
         return;
     }
     $children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
     $selected = $this->page_name == 'category' && (int) Tools::getValue('id_category') == $id_category ? ' class="sfHoverForce"' : '';
     $is_intersected = array_intersect($category->getGroups(), $this->user_groups);
     // filter the categories that the user is allowed to see and browse
     if (!empty($is_intersected)) {
         $this->_menu .= '<li ' . $selected . '>';
         $this->_menu .= '<a href="' . $category_link . '">' . $category->name . '</a>';
         if (count($children)) {
             $this->_menu .= '<ul>';
             foreach ($children as $child) {
                 $this->getCategory((int) $child['id_category'], (int) $id_lang, (int) $child['id_shop']);
             }
             $this->_menu .= '</ul>';
         }
         $this->_menu .= '</li>';
     }
 }
Exemple #25
0
     foreach ($ordering as $ordertype) {
         $page->smarty->assign('orderby' . $ordertype, WWW_TOP . "/myshows/browse?ob=" . $ordertype . "&amp;offset=0");
     }
     $page->smarty->assign('lastvisit', $page->userdata['lastlogin']);
     $page->smarty->assign('results', $results);
     $page->smarty->assign('shows', true);
     $page->content = $page->smarty->fetch('browse.tpl');
     $page->render();
     break;
 default:
     $page->title = "My Shows";
     $page->meta_title = "My Shows";
     $page->meta_keywords = "search,add,to,cart,nzb,description,details";
     $page->meta_description = "Manage Your Shows";
     $cat = new Category();
     $tmpcats = $cat->getChildren(Category::CAT_PARENT_TV, true, $page->userdata["categoryexclusions"]);
     $categories = array();
     foreach ($tmpcats as $c) {
         $categories[$c['ID']] = $c['title'];
     }
     $shows = $us->getShows($users->currentUserId());
     $results = array();
     foreach ($shows as $showk => $show) {
         $showcats = explode('|', $show['categoryID']);
         if (is_array($showcats) && sizeof($showcats) > 0) {
             $catarr = array();
             foreach ($showcats as $scat) {
                 if (!empty($scat)) {
                     $catarr[] = $categories[$scat];
                 }
             }
Exemple #26
0
 public function getCategoryOption($selected = null, $id_category = 1, $id_lang = false, $id_shop = false, $recursive = true)
 {
     $html = '';
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $category = new Category((int) $id_category, (int) $id_lang, (int) $id_shop);
     if (is_null($category->id)) {
         return;
     }
     if ($recursive) {
         $children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
     }
     $shop = (object) Shop::getShop((int) $category->getShopID());
     if ($category->id != 1) {
         $html .= '<option ' . ($selected == $category->id ? 'selected="selected"' : '') . ' value="' . (int) $category->id . '">' . $category->name . '</option>';
     }
     if (isset($children) && count($children)) {
         foreach ($children as $child) {
             $html .= $this->getCategoryOption($selected, (int) $child['id_category'], (int) $id_lang, (int) $child['id_shop']);
         }
     }
     return $html;
 }
 public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
 {
     $alias = 'sa';
     parent::getList($id_lang, $alias . '.position', $order_way, $start, $limit, Context::getContext()->shop->id);
     // Check each row to see if there are combinations and get the correct action in consequence
     $nb_items = count($this->_list);
     for ($i = 0; $i < $nb_items; $i++) {
         $item =& $this->_list[$i];
         $category_tree = Category::getChildren((int) $item['id_category'], $this->context->language->id);
         if (!count($category_tree)) {
             $this->addRowActionSkipList('view', array($item['id_category']));
         }
     }
 }
Exemple #28
0
 private function getCatMobileOption($id_category, $id_lang = false, $id_shop = false, $child = false)
 {
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $category = new Category((int) $id_category, (int) $id_lang);
     if ($category->level_depth > 1) {
         $category_link = $category->getLink();
     } else {
         $category_link = $this->context->link->getPageLink('index');
     }
     if (is_null($category->id)) {
         return;
     }
     $children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
     $selected = $this->page_name == 'category' && (int) Tools::getValue('id_category') == $id_category ? ' class="active"' : '';
     /*
               $is_intersected = array_intersect($category->getGroups(), $this->user_groups);
               // filter the categories that the user is allowed to see and browse
               if (!empty($is_intersected))
               { */
     $this->_mmenu .= '<option value="' . htmlentities($category_link) . '">';
     if ($child == 1) {
         $this->_mmenu .= ' – ';
     }
     $this->_mmenu .= $category->name;
     $this->_mmenu .= '</option>';
     if (count($children)) {
         foreach ($children as $child) {
             $this->getCatMobileOption((int) $child['id_category'], (int) $id_lang, (int) $child['id_shop'], $child = 1);
         }
     }
     //}
 }
Exemple #29
0
 private function _displayForm()
 {
     /* Gets Slides */
     $id_lang = $this->context->cookie->id_lang;
     $root_cate_id = Configuration::get('ROOT_CATEGORY');
     $id_category = Tools::getValue('id_category', $root_cate_id);
     $current_cate = new Category($id_category, $id_lang);
     $parent_cate = new Category($current_cate->id_parent, $id_lang);
     $categories = Category::getChildren($id_category, $id_lang);
     $displayList = false;
     $slides = array();
     if (Tools::getValue('id_category') && $id_category > $root_cate_id) {
         $displayList = true;
         $slides = $this->getSlides(null, $id_category);
     }
     //category tree
     // Generate category selection tree
     $tree = new HelperTreeCategories('categories-tree', $this->l('Filter by category'));
     $tree->setAttribute('is_category_filter', (bool) $id_category)->setAttribute('base_url', preg_replace('#&id_category=[0-9]*#', '', AdminController::$currentIndex) . '&token=' . Tools::getAdminTokenLite('AdminModules'))->setInputName('id-category')->setSelectedCategories(array((int) $id_category));
     $categoryTree = $tree->render();
     $this->context->smarty->assign(array('slide_width' => Configuration::get('CATESLIDER_WIDTH'), 'slide_height' => Configuration::get('CATESLIDER_HEIGHT'), 'slide_speed' => Configuration::get('CATESLIDER_SPEED'), 'slide_pause' => Configuration::get('CATESLIDER_PAUSE'), 'slide_loop' => Configuration::get('CATESLIDER_LOOP'), 'categoryTree' => $categoryTree, 'displayList' => $displayList, 'current_cate' => $current_cate, 'slides' => $slides));
     return $this->display(__FILE__, 'views/templates/admin/main.tpl');
 }
        $lang = $_POST['language'];
    } else {
        $lang = $LANGCODE;
    }
    $currentLink = $_SERVER['PHP_SELF'] . $linkext;
    $tree = new Category($lang);
    $tree->buildTree();
    foreach ($tree->catTree as $cat) {
        $indent = '';
        for ($i = 0; $i < $cat['indent']; $i++) {
            $indent .= '&nbsp;&nbsp;&nbsp;';
        }
        printf("%s<strong style=\"vertical-align: top;\">&middot; %s</strong> ", $indent, $cat["name"]);
        printf('<a href="%s&amp;aktion=addcategory&amp;cat=%s" title="%s"><img src="images/add.gif" width="17" height="18" alt="%s" title="%s" border="0" /></a>', $currentLink, $cat['id'], $PMF_LANG['ad_kateg_add'], $PMF_LANG['ad_kateg_add'], $PMF_LANG['ad_kateg_add']);
        printf('<a href="%s&amp;aktion=editcategory&amp;cat=%s" title="%s"><img src="images/edit.gif" width="18" height="18" border="0" title="%s" alt="%s" /></a>', $currentLink, $cat['id'], $PMF_LANG['ad_kateg_rename'], $PMF_LANG['ad_kateg_rename'], $PMF_LANG['ad_kateg_rename']);
        if (count($tree->getChildren($cat['id'])) == 0) {
            printf('<a href="%s&amp;aktion=deletecategory&amp;cat=%s&amp;lang=%s" title="%s"><img src="images/delete.gif" width="17" height="18" alt="%s" title="%s" border="0" /></a>', $currentLink, $cat['id'], $cat['lang'], $PMF_LANG['ad_categ_delete'], $PMF_LANG['ad_categ_delete'], $PMF_LANG['ad_categ_delete']);
        }
        printf('<a href="%s&amp;aktion=cutcategory&amp;cat=%s" title="%s"><img src="images/cut.gif" width="16" height="16" alt="%s" border="0" title="%s" /></a>', $currentLink, $cat['id'], $PMF_LANG['ad_categ_cut'], $PMF_LANG['ad_categ_cut'], $PMF_LANG['ad_categ_cut']);
        printf('<a href="%s&amp;aktion=movecategory&amp;cat=%s&amp;parent_id=%s" title="%s"><img src="images/move.gif" width="16" height="16" alt="%s" border="0" title="%s" /></a>', $currentLink, $cat['id'], $cat['parent_id'], $PMF_LANG['ad_categ_move'], $PMF_LANG['ad_categ_move'], $PMF_LANG['ad_categ_move']);
        print "<br />";
    }
    ?>
	<p><img src="images/arrow.gif" width="11" height="11" alt="" border="0" /> <a href="<?php 
    print $currentLink . '&amp;aktion=addcategory';
    ?>
"><?php 
    print $PMF_LANG['ad_kateg_add'];
    ?>
</a></p>
	<p><?php