/**
  * Return all categories.
  *
  * @author Kuldeep Dangi <*****@*****.**>
  */
 public function actionGetALLCategories()
 {
     $this->result['success'] = true;
     $model = new Category();
     $this->result['data'] = $model->findAll();
     $this->sendResponse($this->result);
 }
Example #2
0
 public function getTree()
 {
     $criteria = new CDbCriteria();
     $criteria->order = 't.lft';
     $catRoot = new Category();
     return $catRoot->findAll($criteria);
 }
Example #3
0
 public static function getcat($pid)
 {
     $model = new Category();
     $criteria = new CDbCriteria();
     $criteria->addCondition("is_show=1 and pid={$pid}");
     $criteria->order = 'orderid ASC';
     $cat = $model->findAll($criteria);
     return $cat;
 }
 /**
  * Get a list of categories
  *
  * @param Request $request
  * @param string $params
  * @return void
  */
 protected static function get($request, $params)
 {
     try {
         $categories = Category::query($request->get('queryParams'), $request->include);
     } catch (OutOfBoundsException $e) {
         $categories = Category::findAll($request->include);
     }
     static::response($categories, 200);
 }
 public function __construct()
 {
     AuthUser::load();
     if (!AuthUser::isLoggedIn()) {
         echo 'Please Login';
         header('location:index.php?job=login');
     }
     //首页最近文章
     //$this->recent_post = Article::getPost(5, true);
     //侧栏分类
     $this->categories = Category::findAll();
     if (is_array($this->categories) && count($this->categories) > 0) {
         $temp = array();
         foreach ($this->categories as $k => $v) {
             $temp[$v->id] = get_object_vars($v);
         }
         $this->cahce_categories = $temp;
         $temp = array();
     }
     //Tags 后期改进为热词形式
     $hot_tags = Tag::findAll(20);
     //mprint_r($hot_tags, '$hot_tags');
     if (count($hot_tags) > 0) {
         $first = current($hot_tags);
         $last = end($hot_tags);
         foreach ($hot_tags as $k => $v) {
             $tags_list[$k]['word'] = $v->name;
             $tags_list[$k]['size'] = tagClouds($v->count, $first->count, $last->count);
         }
     }
     $this->tags_list = $tags_list;
     $tags = Tag::findAll();
     //var_dump($tags);
     $content_tag = Record::findAllFrom('ContentTag');
     //var_dump($content_tag);
     //关系表中存在的文章ID以及tag集合到一个数组中tag_cache  避免在遍历生成文章静态页时重复读取数据库
     //遍历所有tag 组合出方便调用的形式
     if (is_array($tags) && count($tags) > 0) {
         $temp_tags = array();
         foreach ($tags as $k => $v) {
             $temp_tags[$v->id] = $v->name;
         }
     }
     //遍历关系表
     if (is_array($content_tag) && count($content_tag) > 0) {
         $this->cahce_tags = array();
         foreach ($content_tag as $k => $v) {
             if (isset($temp_tags[$v->tag_id])) {
                 $this->cahce_tags[$v->content_id][] = $temp_tags[$v->tag_id];
             }
         }
     }
     //清空临时数据
     $tags = $content_tag = $temp_tags = array();
 }
 public function index($category_id)
 {
     //var_dump($_GET['search']);
     // Blogクラスから$Blogインスタンス生成
     $Blog = new Blog($this->plural_resource);
     if (isset($_GET['search'])) {
         $sql = $Blog->findAll($category_id, $_GET['search']);
     } else {
         $sql = $Blog->findAll($category_id);
         // 'SELECT * FROM blogs'という文字列が返ってくる
     }
     //var_dump($sql);
     $blogs = mysqli_query($this->db, $sql) or die(mysqli_error($this->db));
     //var_dump($blogs);
     //var_dump('test');
     $Category = new Category('categories');
     $cat_sql = $Category->findAll();
     //var_dump($cat_sql);
     $categories = mysqli_query($this->db, $cat_sql) or die(mysqli_error($this->db));
     //var_dump($categories);
     $return['blogs'] = $blogs;
     $return['categories'] = $categories;
     return $return;
 }
        </tr>
      </thead>
    
      <tbody id="alter_rows">
       <?php 
$count_record = Category::countCategory(0);
if (!isset($_REQUEST['page'])) {
    $page = 1;
} else {
    $page = $_GET[page];
}
$pagination = new Pagination();
//for display
$pg = $pagination->page_pagination(20, $count_record, $page, 20);
//$result_prod = mysql_query($query_Recordset2.$pg[1]);
$category = Category::findAll($pg[1], 0);
?>
		  	<? if($count_record == 0) { ?>
            	  <tr>
                  	<td colspan="3" align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#F00; font-weight:bold">No Record Found</td>
                  </tr>
            <? } else { 
					foreach($category as $categories) { 
					
			?>		
                <tr>
                  <td> <?php 
echo $categories->fldCategoryID;
?>
 </td>
                  
Example #8
0
<?php

// create category list
$category = new Category();
$categoryList = $category->findAll($connect);
$connect->close();
?>
<form action='' id="productForm" method=post>
    <input type="hidden" name="id" id="id" value="<?php 
echo empty($product) ? '' : $product->id;
?>
"/>
    <label> 
        <span class="span">Product name</span>
        <input type='text' name='title' id='title' value="<?php 
echo empty($product) ? '' : $product->title;
?>
"/>
        <span>*<?php 
echo !isset($validateResult['fieldsErrors']['title']['errorMsg']) ? '' : $validateResult['fieldsErrors']['title']['errorMsg'];
?>
</span>
    </label>
    <br/>
    <label>
        <span class="span">Price</span>
        <input type='text' name='price' id='price' value="<?php 
echo empty($product) ? '' : $product->price;
?>
"/>
        <span>*<?php 
Example #9
0
 public static function getDropList($pid)
 {
     $model = new Category();
     $criteria = new CDbCriteria();
     $criteria->addCondition("pid={$pid}");
     $criteria->order = 'orderid ASC';
     $data = $model->findAll($criteria);
     if ($data) {
         foreach ($data as $key => $row) {
             $dropList[$row['id']] = $row['name'];
         }
     }
     return $dropList;
 }
Example #10
0
 public function __construct()
 {
     /*
             $cache = new FileCache();
             $cache->cachePath = DATA_DIR.'cache/';
     
             //侧栏分类
             $categories = $cache->get('categories');
             if($categories === false) {
                 $categories = array();
                 //获得所有分类
                 $categories[0] = Category::findAll();
                 if(is_array($categories[0]) && count($categories[0]) > 0) {
                     foreach($categories[0] as $k => $v) {
                         //$this->categories[$v->id] = get_object_vars($v);
                         $categories[1][$v->id] = $v;
                         $categories[1][$v->slug] = $v;
                     }
                 }
     
                 $cache->set('categories', $categories, 7200);//缓存2小时
                 del_cache();
             }
     
             //Tags 热词
             $hot_tags = $cache->get('hot_tags');
             if($hot_tags === false) {
                 $hot_tags = Tag::findAll(30);
                 $cache->set('hot_tags', $hot_tags, 7200);
             }
     */
     //--------------------------------
     //首页最近文章
     $this->recent_post = Article::getPost(5, true);
     //侧栏分类
     $this->categories = Category::findAll();
     if (is_array($this->categories) && count($this->categories) > 0) {
         $temp = array();
         foreach ($this->categories as $k => $v) {
             $temp[$v->id] = get_object_vars($v);
         }
         $this->cahce_categories = $temp;
         $temp = array();
     }
     //Tags 后期改进为热词形式
     $this->tags_list = Tag::findAll(30);
     $tags = Tag::findAll();
     $content_tag = Record::findAllFrom('ContentTag');
     //遍历所有tag 组合出方便调用的形式
     if (is_array($tags) && count($tags) > 0) {
         $temp_tags = array();
         foreach ($tags as $k => $v) {
             $temp_tags[$v->id] = $v->name;
         }
     }
     //遍历关系表
     if (is_array($content_tag) && count($content_tag) > 0) {
         $this->cahce_tags = array();
         foreach ($content_tag as $k => $v) {
             if (isset($temp_tags[$v->tag_id])) {
                 $this->cahce_tags[$v->content_id][] = $temp_tags[$v->tag_id];
             }
         }
     }
     //清空临时数据
     $tags = $content_tag = $temp_tags = array();
 }
Example #11
0
      </div>  
      <?php 
}
?>
    
      
    </div>
  </nav>
  <div class="wrapper wrapper--dropdownmenu">
    <div class="container">
        <ul class="header-menu-primary__dropdownmenu__container">
          <li class="dropdownmenu__item">
            <ul class="dropdownmenu__item__list">
          <?php 
$data_cat = new Category();
$list = $data_cat->findAll();
$i = 1;
foreach ($list as $k => $v) {
    //if($i%8==0) {
    //    echo '</ul></li>';
    //    echo '      <li class="dropdownmenu__item">
    //            <ul class="dropdownmenu__item__list">';
    //}
    echo '<li class="dropdownmenu__item__list__item"><h3 class="dropdownmenu__item__list__item__title">' . $v->name . '</h3></li>';
    $model = new Occupation();
    $list1 = $model->localized('ru')->findAll('cat_id=:cid', array(':cid' => $v->id));
    $i = 1;
    foreach ($list1 as $k1 => $v1) {
        //echo '<li class="dropdownmenu__item__list__item"><a href="" class="dropdownmenu__item__list__item__link">Воздушные акробаты<span class="dropdown__link__col">&nbsp;(25)</span></a></li>';
        if ($v1->alias != '') {
            $alias = $v1->alias;
 public function createPostHtml($obj = null)
 {
     global $tpl;
     if (is_object($obj) && DEBUG === false) {
         $post = clone $obj;
         $post->content = processContent($post->content);
         //上一篇文章
         $previous = $obj->previous();
         //下一篇文章
         $next = $obj->next();
         //首页最近文章
         $recent_post = Article::getPost(5, false);
         //侧栏分类
         $categories = Category::findAll();
         //Tags
         $hot_tags = Tag::findAll(30);
         //mprint_r($hot_tags, '$hot_tags');
         if (count($hot_tags) > 0) {
             $first = current($hot_tags);
             $last = end($hot_tags);
             foreach ($hot_tags as $k => $v) {
                 $tags_list[$k]['word'] = $v->name;
                 $tags_list[$k]['size'] = tagClouds($v->count, $first->count, $last->count);
             }
         }
         //smarty
         $tpl->assign('post', $post);
         $tpl->assign('next', $next);
         $tpl->assign('previous', $previous);
         $tpl->assign('recent_post', $recent_post);
         $tpl->assign('categories', $categories);
         $tpl->assign('tag_list', $tags_list);
         $filetpl = SYSTEM_ROOT . 'templates/' . DEFAULT_TEMPLATE . '/post.html';
         $path = SYSTEM_ROOT . 'post/';
         //$filename = !empty($obj->slug) ? str_replace(' ', '-', trim($obj->slug)) : $obj->id;
         $filename = $obj->id;
         $file = $path . $filename . '.html';
         file_put_contents($file, $tpl->fetch($filetpl));
         @chmod($file, 0777);
     }
 }
Example #13
0
 public function run()
 {
     $model = new Category();
     $info = $model->findAll();
     $this->render('menu', array('info' => $info));
 }
Example #14
0
 public function __construct()
 {
     global $tpl, $app;
     $app->refresh();
     $this->cache = new FileCache();
     $this->cache->cachePath = DATA_DIR . 'cache/';
     //侧栏分类
     $categories = $this->cache->get('categories');
     if ($categories === false) {
         $categories = array();
         //获得所有分类
         $categories[0] = Category::findAll();
         if (is_array($categories[0]) && count($categories[0]) > 0) {
             foreach ($categories[0] as $k => $v) {
                 $categories[0][$k]->url = SITE_URL . 'category/' . $v->slug . '/';
                 //$this->categories[$v->id] = get_object_vars($v);
                 $categories[1][$v->id] = $v;
                 $categories[1][$v->slug] = $v;
             }
         }
         if (DEBUG === false) {
             $this->cache->set('categories', $categories, 7200);
             //缓存2小时
             del_cache();
         }
     }
     //mprint_r($categories[0], 'a');
     //分别以ID, slug为键值的分类组合
     $this->categories = $categories[1];
     //Tags 热词
     $tags_list = $this->cache->get('hot_tags');
     if ($tags_list === false) {
         $hot_tags = Tag::findAll(20);
         //mprint_r($hot_tags, '$hot_tags');
         if (count($hot_tags) > 0) {
             $first = current($hot_tags);
             $last = end($hot_tags);
             foreach ($hot_tags as $k => $v) {
                 $tags_list[$k]['word'] = $v->name;
                 $tags_list[$k]['size'] = tagClouds($v->count, $first->count, $last->count);
                 $tags_list[$k]['url'] = SITE_URL . 'tag/' . strtolower($v->name) . '/';
             }
         }
         if (DEBUG === false) {
             $this->cache->set('hot_tags', $tags_list, 7200);
         }
     }
     //首页最近文章
     $recent_post = $this->cache->get('recent_post');
     if ($recent_post === false) {
         $recent_post = Article::getPost(5);
         if (is_array($recent_post) && count($recent_post) > 0) {
             foreach ($recent_post as $key => $val) {
                 $recent_post[$key]->url = SITE_URL . 'post/' . $val->id . '.html';
             }
         }
         if (DEBUG === false) {
             $this->cache->set('recent_post', $recent_post, 7200);
             //缓存2小时
             del_cache();
         }
     }
     //mprint_r($recent_post, '$recent_post');
     $tpl->assign('recent_post', $recent_post);
     $tpl->assign('categories', $categories[0]);
     $tpl->assign('tag_list', $tags_list);
 }
 public function editAction($args = null)
 {
     global $tpl;
     $data = isset($_POST['cat']) ? $_POST['cat'] : array();
     if (isset($_POST['submit'])) {
         //var_dump($data);
         $category = new Category('id', $date['id']);
         //更新当前分类
         $pid = (int) $data['pid'];
         if ($pid == 0) {
             //顶级分类, path为0,本身ID
             $category->path = '0,' . $category->id;
             $category->pid = 0;
         } elseif ($pid > 0) {
             //查询父ID的path
             $parent_category = new Category('id', $pid);
             $category->pid = $parent_category->id;
             $category->path = $parent_category->path . ',' . $category->id;
         }
         $category->save('category');
         $_POST = array();
         header('location:index.php?job=admin_category');
     } else {
         $id = isset($args['id']) ? (int) $args['id'] : '';
         $category = new Category('id', $id);
         //参数改进
         //$category = get_object_vars($category);
         $tpl->assign('cat', $category);
         //查出所有分类
         //$result = Category::findAll();
         $result = Category::findAll();
         //var_dump($result);
         $tpl->assign('cats', $result);
         $tpl->display('admin/categroy_edit.html');
     }
 }