예제 #1
0
 function AjaxBlogCatalogTreeAction()
 {
     $request = Project::getRequest();
     $request_user_id = (int) Project::getUser()->getShowedUser()->id;
     $user_id = (int) Project::getUser()->getDbUser()->id;
     $info = array();
     $catalog_id = (int) $request->getKeyByNumber(0);
     $level = (int) $request->getKeyByNumber(1);
     $filter = (int) $request->getKeyByNumber(2);
     $direction = (int) $request->getKeyByNumber(3);
     if ($direction === 1) {
         $tree_model = new BlogTreeModel();
         $info['blog_catalog'] = $tree_model->loadByCatalog($catalog_id);
         $subscribe_model = new BlogSubscribeModel();
         foreach ($info['blog_catalog'] as $key => &$item) {
             $subscribed = $subscribe_model->isSubscribed($user_id, $item['id']);
             $count_subitems = $tree_model->countSubItems($item['key']);
             if (!$filter || $subscribed || $count_subitems) {
                 $item['count_subitems'] = $count_subitems;
                 $item['need_subscribe'] = true;
                 $item['subscribed'] = $subscribed;
             } else {
                 unset($info['blog_catalog'][$key]);
             }
         }
         $info['level'] = $level + 1;
     } else {
         $info['level'] = $level;
     }
     //var_dump($info['level']);die;
     $info['direction'] = $direction;
     $info['id'] = $catalog_id;
     $info['filter'] = $filter;
     $this->_view->AjaxBlogCatalogTree($info);
     $this->_view->ajax();
 }