本文整理汇总了PHP中CategoryModel类的典型用法代码示例。如果您正苦于以下问题:PHP CategoryModel类的具体用法?PHP CategoryModel怎么用?PHP CategoryModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CategoryModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionActive
protected static function actionActive()
{
$category = new CategoryModel($_GET['id']);
$category->active = $category->active ? '0' : '1';
$category->save();
self::redirect(App::getLink('AdminCategories'));
}
示例2: indexAction
public function indexAction()
{
$categoryObj = new CategoryModel();
$list = $categoryObj->getCategoryList();
var_dump($list);
// exit;
}
示例3: addAction
public function addAction()
{
$model_category = new CategoryModel();
$category_list = $model_category->getTreeList(0);
$this->view->assign('category_list', $category_list);
$this->view->display('add.tpl');
}
示例4: index
public function index()
{
if (IS_POST) {
if (empty($_POST['catid'])) {
$this->error("请选择数据来源");
}
$map['catid'] = array('in', $_POST['catid']);
$map['status'] = array('eq', 1);
$article = M('Article');
$articlelist = $article->where($map)->order('create_time desc')->select();
$download = M('Download');
$downloadlist = $download->where($map)->order('create_time desc')->select();
$photo = M('Photo');
$photolist = $photo->where($map)->order('create_time desc')->select();
if (isset($_POST['sitemaptype'])) {
$type = $_POST['sitemaptype'];
}
$sitemapstr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
switch ($type) {
case 0:
$sitemapstr .= "<urlset>\r\n";
break;
case 1:
$sitemapstr .= "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\r\n";
break;
}
foreach ($articlelist as $value) {
$sitemapstr .= "<url>\r\n";
$sitemapstr .= "<loc>Article/show?id=" . $value['id'] . "</loc>\r\n";
$sitemapstr .= "<lastmod>" . toDate(NOW_TIME, 'Y-m-d') . "</lastmod>\r\n";
$sitemapstr .= "<changefreq>" . $_POST['changefreq'] . "</changefreq>\r\n";
$sitemapstr .= "<priority>" . $_POST['priority'] . "</priority>\r\n";
$sitemapstr .= "</url>\r\n\r\n";
}
foreach ($downloadlist as $value) {
$sitemapstr .= "<url>\r\n";
$sitemapstr .= "<loc>Download/show?id=" . $value['id'] . "</loc>\r\n";
$sitemapstr .= "<lastmod>" . toDate(NOW_TIME, 'Y-m-d') . "</lastmod>\r\n";
$sitemapstr .= "<changefreq>" . $_POST['changefreq'] . "</changefreq>\r\n";
$sitemapstr .= "<priority>" . $_POST['priority'] . "</priority>\r\n";
$sitemapstr .= "</url>\r\n\r\n";
}
foreach ($photolist as $value) {
$sitemapstr .= "<url>\r\n";
$sitemapstr .= "<loc>Photo/show?id=" . $value['id'] . "</loc>\r\n";
$sitemapstr .= "<lastmod>" . toDate(NOW_TIME, 'Y-m-d') . "</lastmod>\r\n";
$sitemapstr .= "<changefreq>" . $_POST['changefreq'] . "</changefreq>\r\n";
$sitemapstr .= "<priority>" . $_POST['priority'] . "</priority>\r\n";
$sitemapstr .= "</url>\r\n\r\n";
}
$sitemapstr .= "</urlset>";
file_put_contents("../sitemap.xml", $sitemapstr);
$this->success("sitemap在线生成完成");
} else {
$cate = new CategoryModel();
$this->list = $cate->getMyCategory();
//加载栏目
$this->display();
}
}
示例5: CategoryController_ToggleFollow_Create
/**
* ToggleFollow toggles the hidden/unhidden state of categories
*
* it has been adopted from function Follow in
* /applications/vanilla/controllers/class.categorycontroller.php
* Redirection had to be fixed
*/
public function CategoryController_ToggleFollow_Create($CategoryID, $Value, $TKey, $Target)
{
if (Gdn::Session()->ValidateTransientKey($TKey)) {
$CategoryModel = new CategoryModel();
$CategoryModel->SaveUserTree($CategoryID, array('Unfollow' => !(bool) $Value));
if (!(bool) $Value) {
// switch to "view only followed" when hiding a category
$this->CategoriesController_SetToggle_Create(1, $Target);
} else {
// and to "view all" when no category is hidden
$NoFollowing = TRUE;
$Categories = $CategoryModel::Categories();
foreach ($Categories as $Category) {
if ($Category['Following'] == '') {
$NoFollowing = FALSE;
break;
}
}
if ($NoFollowing) {
$this->CategoriesController_SetToggle_Create(0, $Target);
}
}
}
Redirect($Target);
}
示例6: addAction
/**
* 增加商品跳转动作
*/
public function addAction()
{
//得到所有分类
$model_category = new CategoryModel();
$cat_list = $model_category->getList();
require CURR_VIEW_DIR . 'goodsAdd.html';
}
示例7: _before_edit
public function _before_edit()
{
$cate = new CategoryModel();
$menu = $cate->getModelCategory('Article');
//加载栏目
$menu1 = arrToMenu($menu, 0);
$this->categorylist = $menu1;
}
示例8: detailAction
public function detailAction()
{
$Category = new CategoryModel((int) $this->_request->value);
$Category->load();
$View = new DetailView();
$View->setModel($Category);
$View->display();
}
示例9: Base_Render_Before
/**
* Hack the Base Render in order to achieve our goal
*
* @since 1.0
* @version 1.7.2
*/
public function Base_Render_Before(&$Sender)
{
// Attach the Plugin's CSS to the site
$Sender->AddCssFile($this->GetResource('categories2menu.css', FALSE, FALSE));
$Cat2MenuJQuerySource = '<script type="text/javascript">
var ddmenuitem = 0;
var menustyles = { "visibility":"visible", "display":"block", "z-index":"9"}
function Menu_close()
{ if(ddmenuitem) { ddmenuitem.css("visibility", "hidden"); } }
function Menu_open()
{ Menu_close();
ddmenuitem = $(this).find("ul").css(menustyles);
}
jQuery(document).ready(function()
{ $("ul#Menu > li").bind("mouseover", Menu_open);
$("ul#Menu > li").bind("mouseout", Menu_close);
});
document.onclick = Menu_close;</script>
';
// Add the jQuery JavaScript to the page
$Sender->Head->AddString($Cat2MenuJQuerySource);
if ($Sender->Menu) {
// Set this to FALSE|TRUE whether you want to display the Discussion-Counter next to each Category or not
$DisplayCounter = TRUE;
// Build the Categories Model & load Categories Data
$CategoryModel = new CategoryModel();
$_CategoryData = $CategoryModel->GetFull();
// If there are any Categories...
if ($_CategoryData != FALSE) {
// Add a link to the Category overview as first menuitem
$Sender->Menu->AddLink('Discussions', T('→ All Categories'), '/categories/all');
// If $DisplayCounter is set to TRUE, get Count discussions per Category separately
$CountDiscussions = 0;
foreach ($_CategoryData->Result() as $Category) {
// (will ignore root node)
if ($Category->Name != 'Root') {
$CountDiscussions = $CountDiscussions + $Category->CountDiscussions;
}
}
// Fetch every single Category...
foreach ($_CategoryData->Result() as $Category) {
if ($Category->Name != 'Root') {
if ($DisplayCounter == TRUE) {
// Build the Categories-Menu with Discussions-Counter
$Sender->Menu->AddLink('Discussions', $Category->Name . ' <span>' . $Category->CountDiscussions . '</span>', '/categories/' . $Category->UrlCode, FALSE);
} else {
// Build the Categories-Menu
$Sender->Menu->AddLink('Discussions', $Category->Name, '/categories/' . $Category->UrlCode, FALSE);
}
}
}
}
}
}
示例10: viewMainPage
public function viewMainPage()
{
$postmodel = new PostModel();
$categorymodel = new CategoryModel();
$categories = $categorymodel->getAllPublicCategories();
$page_title = 'Forums';
include BASE_URI . 'app/view/template/header.php';
include BASE_URI . 'app/view/main/public.php';
include BASE_URI . 'app/view/template/footer.php';
}
示例11: deleteUser
public function deleteUser($id)
{
$db = new Database();
$db->execute('DELETE FROM accounts WHERE id = ?', array($id));
$db->execute('DELETE FROM passwords WHERE account = ?', array($id));
$db->execute('DELETE FROM articlesfavoris WHERE account = ?', array($id));
$db->execute('DELETE FROM categories WHERE account = ?', array($id));
$categoryModel = new CategoryModel();
$categoryModel->deleteAllCategoriesByAccount($id);
}
示例12: deleteAction
public function deleteAction()
{
$category_model = new CategoryModel();
$result = $category_model->delByID($_GET['id']);
if (!$result) {
$this->redirect('category.php?act=list', $category_model->error_info, 3);
} else {
$this->redirect('category.php?act=list');
}
}
示例13: deleteAction
public function deleteAction()
{
$catmodel = new CategoryModel("category");
$catmodel = new CategoryModel("category");
$cat_id = $_GET["cat_id"];
if ($catmodel->delete($cat_id)) {
$this->jump("index.php?p=admin&c=Category&a=index", "删除成功", $wait = 1);
} else {
$this->jump("index.php?p=admin&c=Category&a=index", "删除失败", $wait = 1);
}
}
示例14: _before_edit
public function _before_edit()
{
$cate = new CategoryModel();
// $this->list=$cate->getMyCategory();//加载栏目
$menu = $cate->getMyCategory1();
//加载栏目
$menu = arrToMenu($menu, 0);
$this->list = $menu;
$this->mdldata = $cate->getMyModel();
//加载模型
}
示例15: menu
public function menu()
{
$this->checkUser();
if (isset($_SESSION[C('USER_AUTH_KEY')])) {
//显示菜单项
$menu = array();
if (isset($_SESSION['menu' . $_SESSION[C('USER_AUTH_KEY')]])) {
//如果已经缓存,直接读取缓存
$menu = $_SESSION['menu' . $_SESSION[C('USER_AUTH_KEY')]];
} else {
//读取数据库模块列表生成菜单项
$node = M("Node");
$map['level'] = 2;
$map['status'] = 1;
$list = $node->where($map)->field('id,name,pid,title')->order('sort asc')->select();
$accessList = $_SESSION['_ACCESS_LIST'];
foreach ($list as $key => $module) {
if (isset($accessList[strtoupper(APP_NAME)][strtoupper($module['name'])]) || $_SESSION['administrator']) {
//设置模块访问权限
$module['access'] = 1;
$menu[$key] = $module;
}
}
//缓存菜单访问
$_SESSION['menu' . $_SESSION[C('USER_AUTH_KEY')]] = $menu;
}
if (isset($_GET['tag'])) {
$tag = $_GET['tag'];
if (0 == $tag) {
$this->assign('menuTitle', '扩展功能');
} else {
$mapid['id'] = array('eq', $tag);
$node = M("Node");
$title = $list = $node->where($mapid)->getField('title');
$this->assign('menuTitle', $title);
}
$this->assign('menuTag', $tag);
} else {
$this->assign('menuTitle', '内容管理');
}
$this->assign('menu', $menu);
}
//显示站点栏目
$cate = new CategoryModel();
$this->cate = $list = $cate->getMyCategory();
//加载栏目
$menu = $cate->getMyCategory1();
//加载栏目
$menu = arrToTree($menu, 0);
$tree = outMenuNode($menu);
$this->assign('tree', $tree);
$this->display();
}