本文整理汇总了PHP中Category::getChildren方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::getChildren方法的具体用法?PHP Category::getChildren怎么用?PHP Category::getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category
的用法示例。
在下文中一共展示了Category::getChildren方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCategoryOption
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;
}
示例2: __construct
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();
}
示例3: getData
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;
}
示例4: ischildren
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;
}
}
示例5: getData
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;
}
示例6: get_index
/**
* 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));
}
示例7: getCategory
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>';
}
示例8: getMusicRange
/**
* 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);
}
示例9: categorySQL
/**
* 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;
}
示例10: Movie
<?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');
示例11: getMovieRange
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);
}
示例12: displayAjaxGetCategoriesFromRootCategory
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();
}
示例13: getCategoryList
public function getCategoryList($id)
{
return Category::getChildren($id);
}
示例14: getConsoleRange
/**
* 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);
}
示例15: displayAjaxGetCategoriesFromRootCategory
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();
}