public function main() { $pageview = Lib::view('page'); $pages = $pageview->getPages(); $this->set('pageview', $pageview); $this->set('pages', $pages); }
public function filter() { $keys = array('state', 'assignee', 'sort', 'project'); if (!Req::haspost($keys)) { return $this->fail('Insufficient data.'); } $identifier = Lib::cookie(Lib::hash(Config::$userkey)); $user = Lib::table('user'); $isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier)); if (!$isLoggedIn) { return $this->fail('You are not authorized.'); } $post = Req::post($keys); $projectTable = Lib::table('project'); if ($post['project'] !== 'all' && !$projectTable->load(array('name' => $post['project']))) { return $this->fail('No such project.'); } $cookie = Lib::cookie(); foreach ($keys as $key) { $cookie->set('filter-' . $key, $post[$key]); } $reportModel = Lib::model('report'); $reports = $reportModel->getItems(array('state' => constant('STATE_' . strtoupper($post['state'])), 'assignee_id' => $post['assignee'], 'order' => 'date', 'direction' => $post['sort'], 'project_id' => $projectTable->id)); $userModel = Lib::model('user'); $assignees = $userModel->getProjectAssignees($projectTable->id); $html = ''; $view = Lib::view('embed'); foreach ($reports as $report) { $html .= $view->loadTemplate('report-item', array('report' => $report, 'assignees' => $assignees, 'user' => $user)); } return $this->success($html); }
<span class="menu-button-line line-bottom"></span> </div> </div> <ul class="menu-items"> <li class="menu-item menu-item-index"><a class="menu-item-link <?php if ($viewname === 'index') { ?> active<?php } ?> " href="<?php echo Lib::url('index'); ?> ">Index</a></li> <?php foreach (Lib::view('page')->getPages() as $pageslug => $page) { ?> <li class="menu-item"><a class="menu-item-link <?php if ($viewname === 'page' && $pageslug === $slug) { ?> active<?php } ?> " href="<?php echo Lib::url('page', array('slug' => $pageslug)); ?> "><?php echo $page->title; ?> </a></li> <?php
public static function output($namespace, $vars = array()) { $segments = explode('/', $namespace); $view = array_shift($segments); $path = implode('/', $segments); $class = Lib::view($view); $class->set($vars); return $class->output($path); }
public function sync() { if (!Req::haspost('reports', 'ids')) { return $this->fail('Insufficient data.'); } $identifier = Lib::cookie(Lib::hash(Config::$userkey)); $user = Lib::table('user'); $isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier)); if (!$isLoggedIn) { return $this->fail('You are not authorized.'); } $reports = json_decode(Req::post('reports')); $ids = Req::post('ids'); $updated = array(); $commentModel = Lib::model('comment'); $comments = $commentModel->getComments(array('report_id' => $ids)); $commentsByReportId = array(); foreach ($comments as $comment) { $commentsByReportId[$comment->report_id][$comment->id] = $comment; } foreach ($reports as $id => $report) { $newTotalComments = empty($commentsByReportId[$id]) ? 0 : count($commentsByReportId[$id]); if ($report->totalComments == $newTotalComments) { continue; } $updated[$id] = array('totalComments' => $newTotalComments, 'comments' => array()); if (!$report->commentsLoaded) { continue; } $view = Lib::view('embed'); foreach ($commentsByReportId[$id] as $commentid => $newComment) { if (in_array($commentid, $report->comments)) { $updated[$id]['comments'][$commentid] = false; continue; } $updated[$id]['comments'][$commentid] = $view->loadTemplate('comment-item', array('comment' => $comment, 'user' => $user)); } } return $this->success($updated); }
public function route($segments = array()) { $result = $this->decode($segments); $view = Lib::view($this->key); $view->display(); }