/** * @return ResourceModel\Category\Collection */ public function getCategories() { $ids = $this->getCategoryIds(); $ids[] = 0; $collection = $this->categoryFactory->create()->getCollection()->addAttributeToSelect(['name', 'url_key'])->addFieldToFilter('entity_id', $ids); return $collection; }
public function test_method_create_should_return_a_valid_category_instance() { $category = ["_id" => 1234, "_value" => "VALUE", "_remain" => 3]; $newCategory = CategoryFactory::create($category); $this->assertInstanceOf('Tufesa\\Service\\Type\\Category', $newCategory); $this->assertEquals($category["_id"], $newCategory->getId()); $this->assertEquals($category["_value"], $newCategory->getValue()); $this->assertEquals($category["_remain"], $newCategory->getRemain()); }
function loadAlternateCatergory($languageSuffix = '') { if ($languageSuffix == '') { $languageSuffix = CategoryInput::getVar('lsfx', ''); } if ($languageSuffix != '') { $config =& CategoryFactory::getConfig(); $config->set('lsfx', $languageSuffix); $language =& JFactory::getLanguage(); $language->load($languageSuffix); } }
/** * @param string $pathInfo * @return bool|DataObject */ public function match($pathInfo) { $identifier = trim($pathInfo, '/'); $parts = explode('/', $identifier); if (count($parts) >= 1) { $parts[count($parts) - 1] = $this->trimSuffix($parts[count($parts) - 1]); } if ($parts[0] != $this->config->getBaseRoute()) { return false; } if (count($parts) > 1) { unset($parts[0]); $parts = array_values($parts); $urlKey = implode('/', $parts); $urlKey = urldecode($urlKey); $urlKey = $this->trimSuffix($urlKey); } else { $urlKey = ''; } if ($urlKey == '') { return new DataObject(['module_name' => 'blog', 'controller_name' => 'category', 'action_name' => 'index', 'params' => []]); } if ($parts[0] == 'search') { return new DataObject(['module_name' => 'blog', 'controller_name' => 'search', 'action_name' => 'result', 'params' => []]); } if ($parts[0] == 'tag' && isset($parts[1])) { $tag = $this->tagFactory->create()->getCollection()->addFieldToFilter('url_key', $parts[1])->getFirstItem(); if ($tag->getId()) { return new DataObject(['module_name' => 'blog', 'controller_name' => 'tag', 'action_name' => 'view', 'params' => ['id' => $tag->getId()]]); } else { return false; } } if ($parts[0] == 'author' && isset($parts[1])) { $author = $this->authorFactory->create()->getCollection()->addFieldToFilter('user_id', $parts[1])->getFirstItem(); if ($author->getId()) { return new DataObject(['module_name' => 'blog', 'controller_name' => 'author', 'action_name' => 'view', 'params' => ['id' => $author->getId()]]); } else { return false; } } if ($parts[0] == 'rss' && isset($parts[1])) { $category = $this->categoryFactory->create()->getCollection()->addFieldToFilter('url_key', $parts[1])->getFirstItem(); if ($category->getId()) { return new DataObject(['module_name' => 'blog', 'controller_name' => 'category', 'action_name' => 'rss', 'params' => ['id' => $category->getId()]]); } else { return false; } } elseif ($parts[0] == 'rss') { return new DataObject(['module_name' => 'blog', 'controller_name' => 'category', 'action_name' => 'rss', 'params' => []]); } $post = $this->postFactory->create()->getCollection()->addAttributeToFilter('url_key', $urlKey)->getFirstItem(); if ($post->getId()) { return new DataObject(['module_name' => 'blog', 'controller_name' => 'post', 'action_name' => 'view', 'params' => ['id' => $post->getId()]]); } $category = $this->categoryFactory->create()->getCollection()->addAttributeToFilter('url_key', $urlKey)->getFirstItem(); if ($category->getId()) { return new DataObject(['module_name' => 'blog', 'controller_name' => 'category', 'action_name' => 'view', 'params' => ['id' => $category->getId()]]); } return false; }
public function AddCategory($categoryid) { array_push($this->Categories, CategoryFactory::GetCategory($categoryid)); }
public function executeSubpagination(sfWebRequest $request) { // eliminated subcategory route to prevent dup. content issues on page-1 $manuf_slug = $request->getParameter('manuf_slug'); $this->param = array(); $this->param['cat_id'] = LWS::getCategoryPk($request->getParameter('cat_slug')); $this->param['manuf'] = LWS::unslugify($manuf_slug, true); $this->param['category'] = LWS::getCategoryName($request->getParameter('cat_slug')); $this->param['subcategory'] = LWS::unslugify($request->getParameter('subcat_slug')); $this->param['section'] = LWS::getSectionName($this->param['subcategory'], $request->getParameter('section')); $this->param['current_page_num'] = LWS::extractPaginationNum($request->getParameter('page_num')); $category = CategoryFactory::make(array('cat_id' => $this->param['cat_id'], 'list_decorator_type' => 'basic')); $this->param['parts'] = $category->fetchSubcatListByManuf(LWS::getManufPk($manuf_slug), $this->param['section'], $this->param['current_page_num']); $this->forward404Unless($this->param['parts']); $this->param['part_count'] = $this->param['parts'][0]['part_count']; $this->param['next_page_num'] = $this->param['current_page_num'] + 1; $this->param['total_pages'] = ceil($this->param['part_count'] / intval(sfConfig::get('app_pagination_items_limit', 100))); $prefix = $this->param['current_page_num'] > 1 ? "Page {$this->param['current_page_num']} of {$this->param['total_pages']} : " : ''; $response = $this->getResponse(); $response->setSlot('body_id', str_replace('-', '_', $request->getParameter('cat_slug'))); $response->setSlot('body_class', 'pagination'); $response->addMeta('description', "{$this->param['manuf']} {$this->param['category']} {$this->param['section']} {$this->param['subcategory']} Catalog - {$prefix}"); $response->setTitle("{$prefix}{$this->param['section']} {$this->param['subcategory']} - {$this->param['manuf']} {$this->param['category']} - " . sfConfig::get('app_biz_name')); return sfView::SUCCESS; }
MySQLConnection::Close($GLOBALS['mysqli']); echo json_encode($retval); }); $app->get('/getcategorylist/', function () { require_once 'common/dbconnection.php'; $GLOBALS['mysqli'] = MySQLConnection::Open(); require_once 'category.php'; $retval = CategoryFactory::GetCategories(); MySQLConnection::Close($GLOBALS['mysqli']); echo json_encode($retval); }); $app->get('/getpublishedcategorylist/', function () { require_once 'common/dbconnection.php'; $GLOBALS['mysqli'] = MySQLConnection::Open(); require_once 'category.php'; $retval = CategoryFactory::GetPublishedCategories(); MySQLConnection::Close($GLOBALS['mysqli']); cors(); echo json_encode($retval); }); $app->get('/getcategoryblogs/:categoryid', function ($categoryid) { require_once 'common/dbconnection.php'; require_once 'category.php'; require_once 'post.php'; require_once 'posttype.php'; require_once 'userresponse.php'; require_once 'userreply.php'; $GLOBALS['mysqli'] = MySQLConnection::Open(); $retval = PostFactory::GetBlogsByCategory($categoryid); MySQLConnection::Close($GLOBALS['mysqli']); echo json_encode($retval);