コード例 #1
0
ファイル: List_viewPage.php プロジェクト: tgdn/cs139
 protected function get()
 {
     global $user, $routes;
     $redirect = false;
     if (isset($_GET['id'])) {
         $result = ListModel::get_from_id($_GET['id']);
         $list = $result->fetchArray(SQLITE3_ASSOC);
         /* check if result exists */
         if ($list && gettype($list) == 'array') {
             /* check that list is owned by user */
             $list_user = ListModel::get_from_id_and_user_id($list['id'], $user->pk)->fetchArray(SQLITE3_ASSOC);
             if ($list_user && gettype($list_user) == 'array') {
                 $this->list = $list;
                 $this->items = ItemModel::get_for_list_id($list['id']);
             } else {
                 $redirect = true;
             }
         } else {
             $redirect = true;
         }
     } else {
         $redirect = true;
     }
     if ($redirect) {
         header('Location: ' . $routes['lists']);
     }
 }
コード例 #2
0
 /**
  * Load the lists associated with the campaign.
  *
  * @param array $lists
  *   An array of list data for which to load the list models.
  *
  * @return $this
  */
 protected function loadLists($lists)
 {
     $this->lists = [];
     foreach ($lists as $list) {
         $this->lists[] = is_subclass_of($list, BaseModel::class) ? $list : ListModel::create($list);
     }
     return $this;
 }
コード例 #3
0
ファイル: List_deletePage.php プロジェクト: tgdn/cs139
 protected function post()
 {
     global $routes;
     /* get list or nothing */
     parent::get();
     ListModel::delete($this->list['id']);
     header('Location: ' . $routes['lists']);
 }
コード例 #4
0
ファイル: Add_listPage.php プロジェクト: tgdn/cs139
 protected function post()
 {
     global $user, $routes;
     $name = $_POST['name'];
     if (isset($name) && !empty($name)) {
         ListModel::add($user->pk, $_POST['name']);
         header('Location: ' . $routes['lists']);
     }
     // otherwise show form
 }
コード例 #5
0
ファイル: TaskModel.class.php プロジェクト: karolt/phovoter
 /**
  * @param int $userId task owner's id
  * @param int $listId list
  * @param bool $asArrays whether function should return data as array of arrays of array of objects 
  *    
  * @return TaskModel[]|array[] user's tasks sorted by id desc
  * @author Karol
  */
 public function getTasks(ListModel $list, $asArrays = false)
 {
     $tasks = $list->getTasks();
     if (!count($tasks)) {
         return array();
     }
     $tasksT = array_flip($tasks);
     $this->dump($tasks);
     $sql = sprintf("SELECT * FROM task WHERE id IN (%s)", implode(',', $tasks));
     $db = FLite::getInstance()->getDB();
     $res = $db->getResults($sql);
     if (!is_array($res)) {
         return null;
     }
     foreach ($res as $row) {
         $task = new TaskModel($row);
         $tasksT[$task->getId()] = $asArrays ? $task->toArray() : $task;
     }
     return $tasksT;
 }
コード例 #6
0
ファイル: ListController.php プロジェクト: Roma48/mvc
 public function __construct()
 {
     $items = new ListModel();
     $rez = $items->list_items('idea');
     include_once 'View/list.php';
 }
コード例 #7
0
ファイル: show.php プロジェクト: 4lb0/qadwa
<?php

// Here you're in the Qadwa singleton scope so $this
// is the same as Qadwa::getInstance().
// you can use /key/value in the URL
$show = $this->getParam('show');
// or you can use the number of the param /first/second/third..
$show = $this->getParam(2);
$return = array('title' => 'Qadwa');
// The model and library are autoloaded
// by default you can found them in models/ and library/
// but you can change those paths.
$model = new ListModel();
// this is only to show the getParam example
switch ($show) {
    case 'pros':
        $return['title'] .= ' Pros';
        $return['items'] = $model->getPros();
        break;
    case 'cons':
        $return['title'] .= ' Cons';
        $return['items'] = $model->getCons();
        break;
    default:
        $return['items'] = array();
}
return $return;
コード例 #8
0
ファイル: ListsPage.php プロジェクト: tgdn/cs139
 protected function get()
 {
     global $user;
     $this->lists = ListModel::get_for_user_id($user->pk);
 }
コード例 #9
0
ファイル: List.php プロジェクト: 290329416/guahao
 /**
  * 文章详情页
  */
 public function detailsAction($name, $path = null, $id = null)
 {
     $list = new ListModel();
     if ($id == false) {
         $id = $path;
     }
     //获取当前一级栏目
     // $oname = $list->get('category',['catid','catname','catpath','description','keyword'],['catpath' => $name]);
     //获取当前二级栏目
     // $tname = $list->get('category',['catid','catname','catpath','keyword'],['AND'=>['parentid'=>$oname['catid'],'catpath' => $path]]);
     //获取文章标题
     $title = $list->get('news', ['id', 'catid', 'title', 'keywords', 'description', 'inputtime'], ['id' => $id]);
     $tname = $this->numnavall[$title['catid']];
     if (empty($tname)) {
         misc::show404();
     }
     $two_id = $tname['catid'];
     //友情链接
     $friendurl = "<li><a href=/{$tname['name']}>";
     $friendurl .= str_replace(',', "</a></li><li><a href={$tname['name']} >", $tname['keyword']);
     $friendurl .= '</a></li>';
     //如果是二级栏目下的文章获取二级栏目的相关信息
     if ($tname['parentid'] != 0) {
         $oname = $this->numnavall[$tname['parentid']];
         //二级导航位置标签
         $nav = $list->nav($oname['catid']);
         //获取当前一级栏目的所有二级栏目catid
         $two_id = $list->getid($tname['parentid']);
         //友情链接
         $friendurl = "<li><a href={$oname['name']}>";
         $friendurl .= str_replace(',', "</a></li><li><a href={$oname['name']} >", $oname['keyword']);
         $friendurl .= '</a></li>';
     }
     $title['keywords'] = str_replace(' ', ',', $title['keywords']);
     if (empty($title['keywords'])) {
         $title['keywords'] = $title['title'];
     }
     if (!empty($title)) {
         //获取文章主体内容
         $content = $list->get('news_data', ['id', 'content'], ['id' => $id]);
         //截取P标签
         $str = "<P style=" . '\\"' . 'color:#FFFFFF' . '\\">';
         $num = strpos($content['content'], $str);
         if ($num) {
             $content['content'] = substr($content['content'], 0, $num);
         }
         //当前栏目下的最新文章
         $two_title = $list->select('news', ['id', 'title'], ['catid' => $tname['catid'], "ORDER" => "inputtime DESC", "LIMIT" => 9]);
         //最新的30条文章
         $article_s = $list->new_article(30);
         //最新的栏目的文章
         $one_content = $list->one_content($two_id, 10);
         $this->getView()->assign('title', $title);
         $this->getView()->assign('content', $content);
         $this->getView()->assign('catkey', $this->numnavall);
         $this->getView()->assign('article_s', $article_s);
         $this->getView()->assign('friendurl', $friendurl);
         $this->getView()->assign('two_title', $two_title);
         $this->getView()->assign('one_content', $one_content);
         $this->getView()->assign('oname', $oname);
         $this->getView()->assign('tname', $tname);
         $this->getView()->assign('nav', $nav);
     }
 }