Example #1
0
 /**
  * 通过文章id获取分类名
  * @param unknown $id
  * @return unknown
  */
 public static function getTypeNameByAid($aid)
 {
     $t = M("addonarticle")->where(array('id' => $aid))->find();
     $typeid = $t['typeid'];
     $typename = Alist::getTypeName($typeid);
     return array('id' => $typeid, 'name' => $typename);
 }
Example #2
0
    public static function getLoadSql()
    {
        $tableName = Alist::getTableName();
        return '
			SELECT
				`' . $tableName . '`.*
			FROM
				`' . Alist::getDbName() . '`.`' . $tableName . '`
		';
    }
 function index()
 {
     $aid = (int) $_GET['aid'];
     $result = Arti::body($aid);
     $typename = Alist::getTypeNameByAid($aid);
     $typename = $typename['name'];
     $this->assign('title', $result['title']);
     $this->assign('time', $result['time']);
     $this->assign('body', $result['body']);
     $this->assign('typename', $typename);
     $this->display();
 }
 public function index()
 {
     $partId = (int) @$_GET['part'];
     $page = (int) @$_GET['page'];
     if (!$page) {
         $page = 1;
     }
     $total = Alist::itemNum($partId);
     //get total number of newd-cata
     $this->assign('page', $page);
     //curr page
     $this->assign('total', ceil($total / 10));
     //prev page
     $this->assign('tid', $partId);
     $title = Alist::getTypeName($partId);
     $this->assign('title', $title);
     $list = Alist::getList($partId, $page);
     $this->assign('list', $list);
     $this->display();
 }
 public function topic4()
 {
     $page = (int) @$_GET['page'];
     if (!$page) {
         $page = 1;
     }
     $topic = C("TOPIC");
     $partId = (int) $topic[3]['id'];
     $total = Alist::itemNum($partId);
     //get total number of newd-cata
     $this->assign('page', $page);
     //curr page
     $this->assign('total', ceil($total / 10));
     //prev page
     $this->assign('tid', $partId);
     $this->assign('topic', $topic);
     $list = Alist::getList($partId, 1);
     $this->assign('list', $list);
     $this->display();
 }
Example #6
0
 public function password($type, $id)
 {
     if ($type != "edit" and $type != "view") {
         $_SESSION['flash'] = 'Unknown password type "' . htmlspecialchars($type) . '".';
         uri::redirect('list/view/' . $id);
     }
     $list = Alist::constructByKey($id);
     if (!is_object($list)) {
         $this->view->content = new View('list/missing');
         //! \todo Ban counter
         return;
     }
     if ('edit' == $type) {
         if ('' == $list->getEditPassword() or array_key_exists($id, $_SESSION['can_edit'])) {
             uri::redirect('list/edit/' . $id);
         }
         if ($_POST) {
             if ($_POST['password'] == $list->getEditPassword()) {
                 $_SESSION['can_edit'][$list->getId()] = true;
                 uri::redirect('list/edit/' . $id);
             } else {
                 $this->view->flash = 'Sorry, that\'s not the password.';
                 //! \todo Ban counter
             }
         }
     } else {
         if ('' == $list->getViewPassword() or array_key_exists($id, $_SESSION['can_view'])) {
             uri::redirect('list/view/' . $id);
         }
         if ($_POST) {
             if ($_POST['password'] == $list->getViewPassword()) {
                 $_SESSION['can_view'][$list->getId()] = true;
                 uri::redirect('list/view/' . $id);
             } else {
                 $this->view->flash = 'Sorry, that\'s not the password.';
                 //! \todo Ban counter
             }
         }
     }
     $this->view->content = new View('list/password');
     $this->view->content->type = ucwords($type);
 }