Example #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Category();
     $catlist = Category::getDropList(0);
     $model->orderid = 1;
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Category'])) {
         $model->attributes = $_POST['Category'];
         $model->create_uid = Yii::app()->user->id;
         $model->create_time = date('Y-m-d H:i:s');
         $model->orderid = 1;
         if ($model->save()) {
             $id = $model->attributes['id'];
             if ($model->pid == 0) {
                 $model->path = $id;
                 $model->level = 1;
                 $model->save();
             } else {
                 $parent = Category::getParent($model->pid);
                 $model->path = $parent->path . '/' . $id;
                 $model->level = $parent->level + 1;
                 $model->save();
             }
             //$this->redirect(array('view','id'=>$model->id));
             Yii::app()->user->setFlash('success', '信息提交成功!');
         } else {
             Yii::app()->user->setFlash('success', '信息提交失败!');
         }
     }
     $this->render('create', array('model' => $model, 'catlist' => $catlist));
 }
 public function index()
 {
     $data = D('BlogRelation')->relation(true)->where(array('id' => $_GET['id']))->select();
     $this->data = $data;
     // P($data);die;
     $cid = $data[0]['sortid'];
     // p($cid);die;
     import('Class.Category', APP_PATH);
     $cate = M('cate')->order('sort')->select();
     // p($cate);
     $this->parent = Category::getParent($cate, $cid);
     // p($parent);die;
     $this->display();
 }
 public function index()
 {
     $id = $_GET['id'];
     $cate = M('cate')->order('sort')->select();
     import('Class.Category', APP_PATH);
     $cid = Category::getChild($cate, $id);
     $cid[] = $id;
     //根据视图模型查找所有的文章
     $where = array('sortid' => array('IN', $cid));
     $count = M('user')->where($where)->count();
     import('ORG.Util.Page');
     $page = new Page($count, C('CATE_LIST_NUMS'));
     $limit = $page->firstRow . ',' . $page->listRows;
     $blog_list = D('BlogView')->getAll($where, $limit);
     //查找出上级分类
     $cid = $blog_list[0]['cid'];
     import('Class.Category', APP_PATH);
     $cate = M('cate')->order('sort')->select();
     $this->parentl = Category::getParent($cate, $cid);
     $this->page = $page->show();
     $this->blog_list = $blog_list;
     $this->display();
 }
}
//START TEMPLATE
$cat_id = tep_db_prepare_input($_GET['id']);
if ($cat_id == 'new') {
    $cat_id = '0';
    $cat = null;
    $parent_name = '';
    $cat_prefix = '';
    $ctid = tep_db_prepare_input($_GET['ctid']);
    $ct = new CategoryTop($ctid);
    $mod_title = 'Create New Category - ' . $ct->name;
} else {
    $cat = new Category($cat_id);
    $ct = $cat->getCategoryTop();
    $ctid = $ct->id;
    $parent = $cat->getParent();
    if ($parent === false) {
        $parent_name = '';
    } else {
        $parent_name = $parent->getName($default_lid);
    }
    $cat_prefix = $cat->getProductCodePrefix();
    $mod_title = 'Manage Category Detail - ' . $ct->name;
}
/* SUB CATEGORIES IS NO LONGER SUPPORTED
$categories_query  = "SELECT c.categories_id, c.parent_id, cd.categories_name, IF(c.parent_id=0, c.categories_id, c.parent_id) AS parent_grouping FROM categories c";
$categories_query .= " LEFT JOIN categories_description cd ON cd.categories_id=c.categories_id AND cd.language_id=$default_lid";
$categories_query .= " ORDER BY parent_grouping, c.parent_id";
$categories_result = tep_db_query($categories_query);
$categories = array();
while ($row = tep_db_fetch_array($categories_result)) {
Example #5
0
 function remove($id = null)
 {
     // attachment & category is own your risk!
     global $database, $gCacheStorage;
     $this->init();
     if (!empty($id)) {
         $this->id = $id;
     }
     // step 0. Get Information
     if (!isset($this->id) || !Validator::number($this->id, 1)) {
         return $this->_error('id');
     }
     if (!($query = $this->_buildQuery())) {
         return false;
     }
     if (!($entry = $query->getRow('category, visibility'))) {
         return $this->_error('id');
     }
     // step 1. Check Syndication
     if ($entry['visibility'] == 3) {
         requireComponent('Eolin.API.Syndication');
         Syndication::leave($this->getLink());
     }
     CacheControl::flushEntry($this->id);
     CacheControl::flushDBCache('entry');
     CacheControl::flushDBCache('comment');
     CacheControl::flushDBCache('trackback');
     $gCacheStorage->purge();
     // step 2. Delete Entry
     $sql = "DELETE FROM " . $database['prefix'] . "Entries WHERE blogid = " . $this->blogid . " AND id = " . $this->id;
     if (POD::queryCount($sql)) {
         // step 3. Delete Comment
         POD::execute("DELETE FROM {$database['prefix']}Comments WHERE blogid = " . $this->blogid . " AND entry = " . $this->id);
         // step 4. Delete Trackback
         POD::execute("DELETE FROM {$database['prefix']}RemoteResponses WHERE blogid = " . $this->blogid . " AND entry = " . $this->id);
         // step 5. Delete Trackback Logs
         POD::execute("DELETE FROM {$database['prefix']}RemoteResponseLogs WHERE blogid = " . $this->blogid . " AND entry = " . $this->id);
         // step 6. update Category
         if (isset($entry['category'])) {
             $target = ($parentCategory = Category::getParent($entry['category'])) ? '(id = ' . $entry['category'] . ' OR id = ' . $parentCategory . ')' : 'id = ' . $entry['category'];
             if (isset($entry['visibility']) && $entry['visibility'] != 1) {
                 POD::query("UPDATE {$database['prefix']}Categories SET entries = entries - 1, entriesinlogin = entriesinlogin - 1 WHERE blogid = " . $this->blogid . " AND " . $target);
             } else {
                 POD::query("UPDATE {$database['prefix']}Categories SET entriesinlogin = entriesinlogin - 1 WHERE blogid = " . $this->blogid . " AND " . $target);
             }
         }
         // step 7. Delete Attachment
         $attachNames = POD::queryColumn("SELECT name FROM {$database['prefix']}Attachments\n\t\t\t\tWHERE blogid = " . getBlogId() . " AND parent = " . $this->id);
         if (POD::execute("DELETE FROM {$database['prefix']}Attachments WHERE blogid = " . getBlogId() . " AND parent = " . $this->id)) {
             foreach ($attachNames as $attachName) {
                 if (file_exists(__TEXTCUBE_ATTACH_DIR__ . "/" . getBlogId() . "/{$attachName}")) {
                     @unlink(__TEXTCUBE_ATTACH_DIR__ . "/" . getBlogId() . "/{$attachName}");
                 }
             }
         }
         // step 8. Delete Tags
         $this->deleteTags();
         // step 9. Clear RSS
         requireComponent('Textcube.Control.RSS');
         RSS::refresh();
         return true;
     }
     return false;
 }
Example #6
0
          <div id="list<?php 
    echo $Category->ID;
    ?>
" class="glassListRow listRow listHover">
            <div class="col-md-1 col-sm-1 col-xs-12">
              <img src="<?php 
    echo $Category->Data['image'];
    ?>
" class="img-responsive">
            </div>
            <div class="col-md-3 col-sm-2 col-xs-12"><p><?php 
    echo $Category->Data['title'];
    ?>
</p></div>
            <div class="col-md-2 col-sm-2 col-xs-12"><p><?php 
    echo $Category->getParent($Category->Data['parent_id']);
    ?>
</p></div>
            <div class="col-md-2 col-sm-1 col-xs-12"><p><?php 
    echo $Category->insertProducts();
    ?>
</p></div>
            <div class="col-md-2 col-sm-1 col-xs-12"><p><?php 
    echo $Category->insertDependencies();
    ?>
</p></div>
            <div class="col-md-2 col-sm-1 col-xs-12">
              <a href="edit.php?id=<?php 
    echo $Category->ID;
    ?>
"><button type="button" name="button" class="btn mainbtn modBtnList"><i class="fa fa-pencil"></i></button></a>