public function actionIndex() { $this->pageTitle = 'App哥伦部 - 发现好玩的App'; $ua = $_SERVER['HTTP_USER_AGENT']; $categoryModel = new Category(); $systemCategory = $categoryModel->getCategory(); if (stripos($ua, 'Mobile') > 0) { $isFollow = 0; $userId = Yii::app()->user->id; if ($userId) { $aUser = User::model()->findByPk($userId); if ($aUser) { $isFollow = $aUser->IsFollow; } } $this->render('app', array('userId' => $userId, 'isFollow' => $isFollow, 'systemCategory' => $systemCategory)); return; } $order = isset($_GET['order']) ? $_GET['order'] : 1; $order = CommonFunc::checkIntParam($order, 4, ''); $type = isset($_GET['type']) ? $_GET['type'] : ''; $type = CommonFunc::checkIntParam($type, 2, ''); $search = isset($_GET['search']) ? $_GET['search'] : ''; $category = isset($_GET['category']) ? $_GET['category'] : ''; $category = CommonFunc::checkIntParam($category, Category::getMaxCategory(), ''); if (!isset($systemCategory[$category])) { $category = 0; } $maxId = AppInfoList::getMaxId(); $appsInfo = AppInfoList::getData($order, $type, $search, $category); $this->render('app', array('data' => $appsInfo['data'], 'pagecount' => $appsInfo['pageCount'], 'maxid' => $maxId, 'order' => $order, 'category' => $category, 'type' => $type, 'search' => $search, 'systemCategory' => $systemCategory)); }
public function projectcreationAction() { $this->_helper->layout()->setLayout('business'); $categoryProject = new Category(); $selectCategories = $categoryProject->getCategory(); $this->view->categoryProject = $selectCategories; }
function view($id = null, $name = null) { $this->set('title', $name . ' - GJboard View App'); $post = $this->Post->getPost("*", array("id" => $id)); $user = new User(); $post['user_name'] = $user->getUser("name", array('user_id' => $post["user_id"])); $category = new Category(); $post['category'] = $category->getCategory("*", array('id' => $post['category_id'])); $this->set('post', $post); }
public function addAction() { $Category = new Category(); $this->view->data = $Category->getCategory(); $marka = $this->request->getPost('category'); if ($marka == NULL) { $this->view->display('add_cat'); } else { $Category->saveCategory($marka); header('location: ' . Url::getUrl('category', 'list', array('status' => 9))); } }
public function actionIndex() { $ua = $_SERVER['HTTP_USER_AGENT']; // $SERVER 是包含诸如头信息,路径,脚本位置等信息的数组 HTTP_USER_AGENT 该字符串表明访问该页面的用户代理的信息(浏览器信息) $categoryModel = new Category(); $systemCategory = $categoryModel->getCategory(); // var_dump($systemCategory);exit; // $ua 取得浏览器信息,stripos() 匹配字符串信息,此处匹配成功则为移动设备访问 if (stripos($ua, 'Mobile') > 0) { //stripos() 查找字符串首次出现的位置(不区分大小写); strpos() 功能相同,区分大小写 $isFollow = 0; $userId = Yii::app()->user->id; if ($userId) { $aUser = User::model()->findByPk($userId); if ($aUser) { $isFollow = $aUser->IsFollow; // user IsFollow 用户表是否粉丝标志位 } } $this->render('app', array('userId' => $userId, 'isFollow' => $isFollow, 'systemCategory' => $systemCategory)); return; } $order = isset($_GET['order']) ? $_GET['order'] : 1; $order = CommonFunc::checkIntParam($order, 4, ''); $type = isset($_GET['type']) ? $_GET['type'] : ''; $type = CommonFunc::checkIntParam($type, 2, ''); $search = isset($_GET['search']) ? $_GET['search'] : ''; $category = isset($_GET['category']) ? $_GET['category'] : ''; $category = CommonFunc::checkIntParam($category, Category::getMaxCategory(), ''); if (!isset($systemCategory[$category])) { $category = 0; } $maxId = AppInfoList::getMaxId(); $appsInfo = AppInfoList::getData($order, $type, $search, $category); $this->render('app', array('data' => $appsInfo['data'], 'pagecount' => $appsInfo['pageCount'], 'maxid' => $maxId, 'order' => $order, 'category' => $category, 'type' => $type, 'search' => $search, 'systemCategory' => $systemCategory)); }
/** * Delete the current loaded download * * @return boolean */ public function delete($categoryId = null) { global $objDatabase, $_ARRAYLANG, $_LANGID; $objFWUser = \FWUser::getFWUserObject(); if (!\Permission::checkAccess(143, 'static', true) && (!$objFWUser->objUser->login() || $this->owner_id != $objFWUser->objUser->getId()) && (empty($categoryId) || ($objCategory = Category::getCategory($categoryId)) === false || $objCategory->getManageFilesAccessId() && !\Permission::checkAccess($objCategory->getManageFilesAccessId(), 'dynamic', true) && (!$objFWUser->objUser->login() || $objCategory->getOwnerId() != $objFWUser->objUser->getId()))) { $this->error_msg[] = sprintf($_ARRAYLANG['TXT_DOWNLOADS_NO_PERM_DEL_DOWNLOAD'], htmlentities($this->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET)); return false; } \Permission::removeAccess($this->access_id, 'dynamic'); if ($objDatabase->Execute('DELETE tblD, tblL, tblRC, tblR FROM `' . DBPREFIX . 'module_downloads_download` AS tblD LEFT JOIN `' . DBPREFIX . 'module_downloads_download_locale` AS tblL ON tblL.`download_id` = tblD.`id` LEFT JOIN `' . DBPREFIX . 'module_downloads_rel_download_category` AS tblRC ON tblRC.`download_id` = tblD.`id` LEFT JOIN `' . DBPREFIX . 'module_downloads_rel_download_download` AS tblR ON (tblR.`id1` = tblD.`id` OR tblR.`id2` = tblD.`id`) WHERE tblD.`id` = ' . $this->id) !== false) { return true; } else { $this->error_msg[] = sprintf($_ARRAYLANG['TXT_DOWNLOADS_DOWNLOAD_DELETE_FAILED'], htmlentities($this->name, ENT_QUOTES, CONTREXX_CHARSET)); } return false; }
public function admin_edit_category($admin) { if (!Visitor::current()->group()->can("manage_categorize")) { show_403(__("Access Denied"), __("You do not have sufficient privileges to manage categories.", "categorize")); } if (empty($_REQUEST['id'])) { error(__("No ID Specified"), __("An ID is required to edit a category.", "categorize")); } if (isset($_POST['update'])) { if (!empty($_POST['name'])) { Category::updateCategory($_POST); Flash::notice(__("Category updated.", "categorize"), "/admin/?action=manage_category"); } else { $fields["categorize"] = array("name" => $_POST['name'], "show_on_home" => $_POST['show_on_home']); } } else { $fields["categorize"] = Category::getCategory($_REQUEST['id']); } $admin->display("edit_category", $fields, "Edit category"); }
private function parseRelatedDownloads($objDownload, $currentCategoryId) { global $_LANGID, $_ARRAYLANG; if (!$this->objTemplate->blockExists('downloads_related_file_list')) { return; } $sortOrder = $this->downloadsSortingOptions[$this->arrConfig['downloads_sorting_order']]; $objRelatedDownload = $objDownload->getDownloads(array('download_id' => $objDownload->getId()), null, $sortOrder); if ($objRelatedDownload) { $row = 1; while (!$objRelatedDownload->EOF) { $description = $objRelatedDownload->getDescription($_LANGID); if (strlen($description) > 100) { $shortDescription = substr($description, 0, 97) . '...'; } else { $shortDescription = $description; } $imageSrc = $objRelatedDownload->getImage(); if (!empty($imageSrc) && file_exists(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteDocumentRootPath() . $imageSrc)) { $thumb_name = \ImageManager::getThumbnailFilename($imageSrc); if (file_exists(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteDocumentRootPath() . $thumb_name)) { $thumbnailSrc = $thumb_name; } else { $thumbnailSrc = \ImageManager::getThumbnailFilename($this->defaultCategoryImage['src']); } $image = $this->getHtmlImageTag($imageSrc, htmlentities($objRelatedDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET)); $thumbnail = $this->getHtmlImageTag($thumbnailSrc, htmlentities($objRelatedDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET)); } else { $imageSrc = $this->defaultCategoryImage['src']; $thumbnailSrc = \ImageManager::getThumbnailFilename($this->defaultCategoryImage['src']); $image = ''; $thumbnail = ''; } $arrAssociatedCategories = $objRelatedDownload->getAssociatedCategoryIds(); if (in_array($currentCategoryId, $arrAssociatedCategories)) { $categoryId = $currentCategoryId; } else { $arrPublicCategories = array(); $arrProtectedCategories = array(); foreach ($arrAssociatedCategories as $categoryId) { $objCategory = Category::getCategory($categoryId); if (!$objCategory->EOF) { if ($objCategory->getVisibility() || \Permission::checkAccess($objCategory->getReadAccessId(), 'dynamic', true) || $objCategory->getOwnerId() == $this->userId) { $arrPublicCategories[] = $categoryId; break; } else { $arrProtectedCategories[] = $categoryId; } } } if (count($arrPublicCategories)) { $categoryId = $arrPublicCategories[0]; } elseif (count($arrProtectedCategories)) { $categoryId = $arrProtectedCategories[0]; } else { $objRelatedDownload->next(); continue; } } $this->objTemplate->setVariable(array('DOWNLOADS_RELATED_FILE_ID' => $objRelatedDownload->getId(), 'DOWNLOADS_RELATED_FILE_DETAIL_SRC' => CONTREXX_SCRIPT_PATH . $this->moduleParamsHtml . '&category=' . $categoryId . '&id=' . $objRelatedDownload->getId(), 'DOWNLOADS_RELATED_FILE_NAME' => htmlentities($objRelatedDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_RELATED_FILE_DESCRIPTION' => nl2br(htmlentities($description, ENT_QUOTES, CONTREXX_CHARSET)), 'DOWNLOADS_RELATED_FILE_SHORT_DESCRIPTION' => htmlentities($shortDescription, ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_RELATED_FILE_IMAGE' => $image, 'DOWNLOADS_RELATED_FILE_IMAGE_SRC' => $imageSrc, 'DOWNLOADS_RELATED_FILE_THUMBNAIL' => $thumbnail, 'DOWNLOADS_RELATED_FILE_THUMBNAIL_SRC' => $thumbnailSrc, 'DOWNLOADS_RELATED_FILE_ICON' => $this->getHtmlImageTag($objRelatedDownload->getIcon(), htmlentities($objRelatedDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET)), 'DOWNLOADS_RELATED_FILE_ROW_CLASS' => 'row' . ($row++ % 2 + 1))); $this->objTemplate->parse('downloads_related_file'); $objRelatedDownload->next(); } $this->objTemplate->setVariable('TXT_DOWNLOADS_RELATED_DOWNLOADS', $_ARRAYLANG['TXT_DOWNLOADS_RELATED_DOWNLOADS']); $this->objTemplate->parse('downloads_related_file_list'); } else { $this->objTemplate->hideBlock('downloads_related_file_list'); } }
public function actionList() { $categoryModel = new Category(); $systemCategory = $categoryModel->getCategory(); echo new ReturnInfo(RET_SUC, $systemCategory); }
<?php /** * categorydelete.php * * Delete for the Categories table * * @version 1.2 2011-02-03 * @package Smithside Auctions * @copyright Copyright (c) 2011 Smithside Auctions * @license GNU General Public License * @since Since Release 1.0 */ $id = (int) $_GET['cat_id']; // Get the existing information for an existing item $item = Category::getCategory($id); ?> <h1>Category Deletion</h1> <form action="index.php?content=categories" method="post" name="maint" id="maint"> <fieldset class="maintform"> <legend><?php echo 'ID: ' . $id; ?> </legend> <ul> <li><strong>Category:</strong> <?php echo htmlspecialchars($item->getCat_name()); ?>
echo "true"; } else { if (isset($_POST['catIds']) && $_POST['catIds'] != "" && isset($_POST['menuId']) && $_POST['menuId'] != "" && isset($_POST['isCategory']) && $_POST['isCategory'] == "true") { // add pages to the menu $menuId = $database->escapeString($_POST['menuId']); $appearName = $database->escapeString($_POST['appearName']); $links->setMenuId($menuId); $links->setIsCustomLink(0); $links->setHttp(""); $links->setPageId(0); $startPos = $links->numByMenu($database) + 1; foreach ($_POST['catIds'] as $id) { if ($appearName == "") { $category->setCategoryId($database->escapeString($id)); $category->getById($database); $links->setAppearName($category->getCategory()); } else { $links->setAppearName($appearName); } $links->setCategoryId($database->escapeString($id)); $links->setPosition($startPos); $links->create($database); $startPos++; } echo "true"; } else { if (isset($_POST['menuId']) && $_POST['menuId'] != "" && isset($_POST['isCategory']) && $_POST['isCategory'] == "false" && isset($_POST['isCustomLink']) && $_POST['isCustomLink'] == "true") { // add pages to the menu $menuId = $database->escapeString($_POST['menuId']); $appearName = $database->escapeString($_POST['appearName']); $links->setMenuId($menuId);
<?php /** * lots.php * * Content for Lots pages * * @version 1.2 2011-02-03 * @package Smithside Auctions * @copyright Copyright (c) 2011 Smithside Auctions * @license GNU General Public License * @since Since Release 1.0 */ // Get the Category $cat_id_in = (int) $_GET['cat_id']; $category = Category::getCategory($cat_id_in); // Get the lot information $lots = Lot::getLots($cat_id_in); if (empty($lots)) { $lots = array(); } ?> <h1>Product Category: <?php echo $category->getCat_name(); ?> <a class="button" href="index.php?content=lotmaint&cat_id=<?php echo $cat_id_in; ?> &lot_id=0"> Add</a>
require_once './config.php'; require_once './lib/alert.class.php'; require_once './lib/user.class.php'; require_once './lib/category.class.php'; $db = new MySQLi($config['database']['host'], $config['database']['username'], $config['database']['password'], $config['database']['database']); if ($db->connect_errno) { die('Ei tietokantayhteyttä.'); } $alertClass = new Alert(); $userClass = new User($db); if (!$userClass->isLoggedIn()) { $alertClass->addAlert('Sinun täytyy olla kirjautuneen sisään poistaaksesi kategorioita', 'error'); $alertClass->redirect('/login.php'); } if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { $alertClass->addAlert('Kategorian ID oli tyhjä', 'error'); $alertClass->redirect('/list_categories.php'); } $user = $userClass->getCurrentUser(); $categoryClass = new Category($db); $category = $categoryClass->getCategory($_GET['id']); if ($category === null) { $alertClass->addAlert('Kategoriaa ei löytynyt'); $alertClass->redirect('/list_categories.php'); } if ($category['userID'] !== $user['id']) { $alertClass->addAlert('Sinulla ei ole oikeuksia tähän kategoriaan', 'error'); $alertClass->redirect('/list_categories.php'); } $categoryClass->removeCategory($_GET['id']); header('Location: /list_categories.php');
* Delete for the Lots * * @version 1.2 2011-02-03 * @package Smithside Auctions * @copyright Copyright (c) 2011 Smithside Auctions * @license GNU General Public License * @since Since Release 1.0 */ // Save the category so you return to the right lots page $cat_id_in = (int) $_GET['cat_id']; // Get the lot id. If it doesn't exist or is 0, then this is a new lot $id = (int) $_GET['lot_id']; // Get the existing information for an existing item $item = Lot::getLot($id); // get the Category name for the lot $cat_name = Category::getCategory($item->getCat_id())->getCat_name(); ?> <h1>Lot Delete</h1> <form action="index.php?content=lots&cat_id=<?php echo $cat_id_in; ?> &sidebar=catnav" method="post" name="maint" id="maint"> <fieldset class="maintform"> <legend><?php echo 'ID: ' . $id; ?> </legend> <ul>
/** * categories list * @global array * @global integer * @global array * @global object * @global object */ private function categories() { global $_ARRAYLANG, $_LANGID, $_CONFIG, $objInit; $objCategory = Category::getCategory($this->parentCategoryId); $objFWUser = \FWUser::getFWUserObject(); $this->_pageTitle = $_ARRAYLANG['TXT_DOWNLOADS_CATEGORIES']; $this->objTemplate->addBlockFile('DOWNLOADS_CATEGORY_TEMPLATE', 'module_downloads_categories', 'module_downloads_categories.html'); // check access permission if (!\Permission::checkAccess(143, 'static', true) && $objCategory->getReadAccessId() && !\Permission::checkAccess($objCategory->getReadAccessId(), 'dynamic', true) && $objCategory->getOwnerId() != $objFWUser->objUser->getId()) { return \Permission::noAccess(); } // get passed parameters $pos = isset($_GET['pos']) ? intval($_GET['pos']) : 0; $categoryLimitOffset = isset($_GET['category_pos']) ? intval($_GET['category_pos']) : $pos; $categoryOrderDirection = !empty($_GET['category_sort']) ? $_GET['category_sort'] : 'asc'; $categoryOrderBy = !empty($_GET['category_by']) ? $_GET['category_by'] : ''; $downloadLimitOffset = isset($_GET['download_pos']) ? intval($_GET['download_pos']) : $pos; $downloadOrderDirection = !empty($_GET['download_sort']) ? $_GET['download_sort'] : 'asc'; $downloadOrderBy = !empty($_GET['download_by']) ? $_GET['download_by'] : ''; $searchTerm = !empty($_GET['search_term']) ? $_GET['search_term'] : ''; $searchTerm = $searchTerm == $_ARRAYLANG['TXT_DOWNLOADS_SEARCH_DOWNLOAD'] ? '' : $searchTerm; // parse categories multi action if (isset($_POST['downloads_category_select_action'])) { switch ($_POST['downloads_category_select_action']) { case 'order': $this->updateCategoryOrder(isset($_POST['downloads_category_order']) && is_array($_POST['downloads_category_order']) ? $_POST['downloads_category_order'] : array()); break; case 'delete': $this->deleteCategories(isset($_POST['downloads_category_id']) && is_array($_POST['downloads_category_id']) ? $_POST['downloads_category_id'] : array(), isset($_POST['downloads_category_delete_recursive']) && $_POST['downloads_category_delete_recursive']); break; } } // process downloads multi action if (isset($_POST['downloads_download_select_action'])) { if (!\Permission::checkAccess(143, 'static', true) && $objCategory->getManageFilesAccessId() && !\Permission::checkAccess($objCategory->getManageFilesAccessId(), 'dynamic', true) && $objCategory->getOwnerId() != $objFWUser->objUser->getId()) { return \Permission::noAccess(); } switch ($_POST['downloads_download_select_action']) { case 'order': if ($objCategory->updateDownloadOrder(isset($_POST['downloads_download_order']) && is_array($_POST['downloads_download_order']) ? $_POST['downloads_download_order'] : array())) { $this->arrStatusMsg['ok'][] = $_ARRAYLANG['TXT_DOWNLOADS_DOWNLOAD_ORDER_SET_SUCCESS']; } else { $this->arrStatusMsg['error'] = array_merge($this->arrStatusMsg['error'], $objCategory->getErrorMsg()); } break; case 'unlink': $this->unlinkDownloadsFromCategory($objCategory, isset($_POST['downloads_download_id']) && is_array($_POST['downloads_download_id']) ? $_POST['downloads_download_id'] : array()); break; } } $this->objTemplate->setGlobalVariable(array('TXT_DOWNLOADS_EDIT' => $_ARRAYLANG['TXT_DOWNLOADS_EDIT'], 'TXT_DOWNLOADS_DELETE' => $_ARRAYLANG['TXT_DOWNLOADS_DELETE'])); // // check if user is allowed to add a subcategory // if (// managers are allowed to add subcategories // \Permission::checkAccess(143, 'static', true) // // the selected category must be valid to proceed future permission checks. // // this is required to protect the overview section from non-admins // || $objCategory->getId() && ( // // the category isn't protected => everyone is allowed to add subcategories // !$objCategory->getAddSubcategoriesAccessId() // // the category is protected => only those who have the sufficent permissions are allowed to add subcategories // || \Permission::checkAccess($objCategory->getAddSubcategoriesAccessId(), 'dynamic', true) // // the owner is allowed to add subcategories // || ($objFWUser = \FWUser::getFWUserObject()) && $objFWUser->objUser->login() && $objCategory->getOwnerId() == $objFWUser->objUser->getId() // ) // ) { // $this->objTemplate->setVariable(array( // 'DOWNLOADS_CATEGORY_ID' => $objCategory->getId(), // // TODO: rename // //'TXT_ADD_CATEGORY' => $_ARRAYLANG['TXT_ADD_CATEGORY'] // )); // $this->objTemplate->parse('downloads_category_add_buttom'); // } else { // $this->objTemplate->hideBlock('downloads_category_add_buttom'); // } // parse categories $this->parseCategories($objCategory, $downloadOrderBy, $downloadOrderDirection, $downloadLimitOffset, $categoryOrderBy, $categoryOrderDirection, $categoryLimitOffset); if (!$objCategory->getId()) { $this->objTemplate->setVariable('TXT_DOWNLOADS_ALL_CATEGORIES', $_ARRAYLANG['TXT_DOWNLOADS_ALL_CATEGORIES']); } // parse frontend preview link if ($objCategory->getId()) { $categoryFrontendURI = ASCMS_PATH_OFFSET . '/' . \FWLanguage::getLanguageCodeById(FRONTEND_LANG_ID) . '/' . CONTREXX_DIRECTORY_INDEX . '?section=Downloads&category=' . $objCategory->getId(); $this->objTemplate->setVariable(array('TXT_DOWNLOADS_OPEN_CATEGORY_FRONTEND' => $_ARRAYLANG['TXT_DOWNLOADS_OPEN_CATEGORY_FRONTEND'], 'DOWNLOADS_CATEGORY_FRONTEND_URI' => $categoryFrontendURI)); $this->objTemplate->parse('downloads_category_frontend_link'); } else { $this->objTemplate->hideBlock('downloads_category_frontend_link'); } // parse downloads $this->parseCategoryDownloads($objCategory, $downloadOrderBy, $downloadOrderDirection, $downloadLimitOffset, $categoryOrderBy, $categoryOrderDirection, $categoryLimitOffset, $searchTerm); $this->objTemplate->setVariable(array('DOWNLOADS_CONFIRM_UNLINK_DOWNLOAD_TXT' => preg_replace('#\\n#', '\\n', addslashes($_ARRAYLANG['TXT_DOWNLOADS_CONFIRM_UNLINK_DOWNLOAD'])))); // parse add downloads buttons if ($objCategory->getId() && (\Permission::checkAccess(143, 'static', true) || !$objCategory->getAddFilesAccessId() || \Permission::checkAccess($objCategory->getAddFilesAccessId(), 'dynamic', true))) { $this->objTemplate->setVariable(array('DOWNLOADS_CATEGORY_ID' => $objCategory->getId(), 'TXT_DOWNLOADS_ADD_NEW_DOWNLOAD_TO_CATEGORY' => sprintf($_ARRAYLANG['TXT_DOWNLOADS_ADD_NEW_DOWNLOAD_TO_CATEGORY'], htmlentities($objCategory->getName(LANG_ID), ENT_QUOTES, CONTREXX_CHARSET)), 'TXT_DOWNLOADS_ADD_DOWNLOADS_TO_CATEGORY' => sprintf($_ARRAYLANG['TXT_DOWNLOADS_ADD_DOWNLOADS_TO_CATEGORY'], htmlentities($objCategory->getName(LANG_ID), ENT_QUOTES, CONTREXX_CHARSET)), 'DOWNLOADS_DOWNLOAD_CATEGORY_SORT' => $categoryOrderDirection, 'DOWNLOADS_DOWNLOAD_CATEGORY_SORT_BY' => $categoryOrderBy, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_SORT' => $downloadOrderDirection, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_BY' => $downloadOrderBy, 'DOWNLOADS_DOWNLOAD_CATEGORY_OFFSET' => $categoryLimitOffset, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_OFFSET' => $downloadLimitOffset)); $this->objTemplate->parse('downloads_add_downloads_button'); } else { $this->objTemplate->hideBlock('downloads_add_downloads_button'); } // parse category menu // parse category id (will be used as the parent_id when creating a new directory $this->objTemplate->setVariable(array('TXT_DOWNLOADS_CATEGORY' => $_ARRAYLANG['TXT_DOWNLOADS_CATEGORY'], 'DOWNLOADS_CATEGORY_ID' => $objCategory->getId(), 'DOWNLOADS_CATEGORY_MENU' => $this->getCategoryMenu('read', $objCategory->getId(), $_ARRAYLANG['TXT_DOWNLOADS_ALL_CATEGORIES']), 'DOWNLOADS_SEARCH_TERM' => !empty($_GET['search_term']) ? $_GET['search_term'] : $_ARRAYLANG['TXT_DOWNLOADS_SEARCH_DOWNLOAD'], 'TXT_DOWNLOADS_SEARCH_DOWNLOAD' => $_ARRAYLANG['TXT_DOWNLOADS_SEARCH_DOWNLOAD'], 'TXT_DOWNLOADS_FILTER' => $_ARRAYLANG['TXT_DOWNLOADS_FILTER'], 'TXT_DOWNLOADS_SEARCH' => $_ARRAYLANG['TXT_DOWNLOADS_SEARCH'])); return true; }
/** * content() - handles displaying a content * @param string $path - The path column of the category assigned to this content * @param mixed $content - XXX-title, XXX corresponds to the ID of the content, * and title is... the title + added -t at the end * @return View */ public function content($path, $content) { // We need to separate the ID from the title in order to find the exact content from the database $id = explode('-', $content)[0]; try { $this->data['content'] = Content::select('id', 'title', 'slug', 'introtext', 'fullcontent', 'catid', 'created_by', 'created_by_alias', 'hits', 'created_at')->where('state', 1)->findOrFail($id); } catch (Exception $e) { App::abort(404); } // Increasing the amount of views for this content $this->data['content']->hits += 1; $this->data['content']->save(); // Join videos $this->data['videos'] = $this->data['content']->videos; // Display a link to the forum topic $this->data['topic_url'] = null; if ($id_msg = $this->data['content']->getForumId($this->data['content']->id)) { $this->data['topic_url'] = URL::route('home') . '/forum/index.php/topic,' . $id_msg . '.0.html'; } // Additional information - the score of this content $this->data['content_rating'] = $this->data['content']->rating; if ($this->data['content_rating']) { $this->data['content_rating']['rate'] = round($this->data['content_rating']['rating_sum'] / $this->data['content_rating']['rating_count']); } $this->data['rate_tooltip'] = array(1 => '1 - много зле', '2 - зле', '3 - средно', '4 - добре', '5 - отлично'); // Additional information - the exact location of the content in the tree structure $node = Category::getCategory($this->data['content']->catid); $this->data['ancestors'] = $node->ancestorsOf($this->data['content']->catid)->get(); // First item is always root, but 'Начало' looks better, doesn't it? $this->data['ancestors'][0]->title = 'Начало'; // Just to make the active highlight for the menus $this->data['active'] = $this->data['content']->catid; // Prepare data intended to go within the head tags $this->data['page_title'] = ucfirst($this->data['content']->title); $this->data['page_desc'] = $this->data['content']->title; foreach ($this->data['ancestors'] as $k => $v) { // first key (0) will generate the keyword 'начало', nobody needs this! if ($k != 0) { $this->data['page_keywords'] .= $v->title . ', '; } } return View::make('home.content', $this->data); }
public function setParentId($parentId) { global $_ARRAYLANG, $_LANGID; if ($this->parent_id == $parentId) { return true; } // check if the user is allowed to change the parent id if ($this->parent_id) { $objParentCategory = Category::getCategory($this->parent_id); if (!\Permission::checkAccess(143, 'static', true) && $objParentCategory->getManageSubcategoriesAccessId() && !\Permission::checkAccess($objParentCategory->getManageSubcategoriesAccessId(), 'dynamic', true) && (($objFWUser = \FWUser::getFWUserObject()) == false || !$objFWUser->objUser->login() || $objParentCategory->getOwnerId() != $objFWUser->objUser->getId())) { $this->error_msg[] = $_ARRAYLANG['TXT_DOWNLOADS_CHANGE_PARENT_CATEGORY_PROHIBITED']; return false; } } // check if the user is allowed to use the desired category as a parent id $objParentCategory = Category::getCategory($parentId); if (!$objParentCategory->EOF || \Permission::checkAccess(143, 'static', true)) { if (!\Permission::checkAccess(143, 'static', true) && $objParentCategory->getAddSubcategoriesAccessId() && !\Permission::checkAccess($objParentCategory->getAddSubcategoriesAccessId(), 'dynamic', true) && (($objFWUser = \FWUser::getFWUserObject()) == false || !$objFWUser->objUser->login() || $objParentCategory->getOwnerId() != $objFWUser->objUser->getId())) { $this->error_msg[] = sprintf($_ARRAYLANG['TXT_DOWNLOADS_ADD_SUBCATEGORY_TO_CATEGORY_PROHIBITED'], htmlentities($objParentCategory->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET)); return false; } } else { $this->error_msg[] = $_ARRAYLANG['TXT_DOWNLOADS_ADD_MAIN_CATEGORY_PROHIBITED']; return false; } if ($objParentCategory->check4Subcategory($this->getId())) { return false; } $this->parent_id = $parentId; return true; }
include_once './includes/init.php'; //获取分类ID if (empty($_GET["id"])) { $c_id = 0; } else { $c_id = $_GET['id']; } //获取商城id if (empty($_GET["mall_id"])) { $mall_id = 0; } else { $mall_id = $_GET['mall_id']; } //查看所有商品分类并显示 $category = new Category(); $categories = $category->getCategory(); $categoryStr = ""; if ($c_id == 0) { //没有选择分类,则默认全部分类被选中 $categoryStr .= "<a href=\"./index.php?mall_id=" . $mall_id . "\" class=\"curcateitem\">\\<span class=\"curcateitemword\">全部</span></a>"; } else { $categoryStr .= "<a href=\"./index.php?mall_id=" . $mall_id . "\" class=\"cateitem\"><span class=\"cateitemword\">全部</span></a>"; } for ($i = 0; $i < count($categories); $i++) { if ($c_id == $i + 1) { //分类id对应则显示该分类被选中 $categoryStr .= "<a href=\"./index.php?mall_id=" . $mall_id . "&id=" . ($i + 1) . "\" class=\"curcateitem\"><span class=\"curcateitemword\">" . $categories[$i]['c_name'] . "</span></a>"; } else { $categoryStr .= "<a href=\"./index.php?mall_id=" . $mall_id . "&id=" . ($i + 1) . "\" class=\"cateitem\"><span class=\"cateitemword\">" . $categories[$i]['c_name'] . "</span></a>"; } }
<?php $root = new Category('root'); $category = $root->getCategory('test'); $articles = $root->getArticlesFrom($category);
echo "データが存在しません。"; return; } $latest = new LatestPages(); $category = new Category(); $archive = new Archive(); foreach (array_reverse($data) as $page) { $main[] = array('title' => $page->title, 'date' => $page->date, 'text' => mb_substr($page->text, 0, mb_strpos($page->text, "<br />")), 'pagenum' => $page->pagenum); } $smarty->assign('title', 'アーカイブ:' . $_GET['archive']); } else { $blog = new ActiveRecord(); $blog->connectPdo('blogdb', 'blog', 'readonly', 'readonly'); $data = $blog->find($blog->size()); if (!isset($data->pagenum)) { echo "データが存在しません。"; return; } $latest = new LatestPages(); $category = new Category(); $archive = new Archive(); $main[] = array('title' => $data->title, 'date' => $data->date, 'text' => $data->text); $smarty->assign('prev', $blog->find($blog->size() - 1)); } } } $smarty->assign('main', $main); $smarty->assign('latest', $latest->getPages()); $smarty->assign('category', $category->getCategory()); $smarty->assign('archive', $archive->getArchive()); $smarty->display('blog.tpl');