/** * @return string */ public function menu() { $model = new Site_Model_Menu(); $items = $model->fetchAll(null, 'orderid'); $activeItem = $model->fetchRow(array('"' . addcslashes($this->view->url(), "'") . '" LIKE CONCAT("%",url,"%")'), 'LENGTH(url) desc'); $this->view->items = $items; if ($activeItem) { $this->view->activeId = $activeItem->id; } return $this->view->render('menu.phtml'); }
/** * Fungsi utama untuk sorting * * @param array $sorter komponen sorting * @param array $options settingan sorting * * @return string */ function columnSort($sorter, $options) { $html = ''; // Menampilkan nama kolom $html .= '<a href="' . $this->view->url($sorter) . '#firstsection' . '">'; $html .= $options['title']; $html .= '</a>'; // Menampilkan gambar sorting if ($sorter['sortby'] == $options['param']) { $html .= '<span class="img-sort">' . $this->view->statusSort($sorter['sortorder']) . '</span>'; } return $html; }
/** * Generates a form element (and corresponding close tag) * * @param string|array either a url or set of url parameters to use as the form's action * @param boolean (optional) whether this is an close tag * @param string (optional) method to use for this form * @param array (optional) collection of attributes to apply to this tag * @return string */ public function form($url, $close = false, $method = 'post', $attribs = null) { if ($close) { return '</form>'; } if (is_array($url)) { $url = $this->_view->url($url); } if ($attribs !== null) { $attribs = array_map(array(get_class($this), 'produce_combined'), array_keys($attribs), array_values($attribs)); $attribs = ' ' . implode($attribs, ' '); } else { $attribs = ''; } return "<form action=\"{$url}\" method=\"{$method}\"{$attribs}>"; }
/** * Render a menu item * * @param Zym_Menu_Item $item * @return string */ protected function _renderMenuItem(Zym_Menu_Item $item, $menuClass) { $link = null; $target = $item->getTarget(); if (!empty($target)) { if (is_array($target)) { $link = (string) $this->_view->url($target, null, true); } else { $link = (string) $target; } } $xhtml .= sprintf('<li id="%s" class="%sitem', $item->getId(), $menuClass); if ($item->isSelected()) { $xhtml .= ' activeMenuItem'; } $xhtml .= '">'; if (!empty($link)) { $xhtml .= sprintf('<a class="%sitemlabel" href="%s">%s</a>', $menuClass, $link, $item->getLabel()); } else { $xhtml .= $item->getLabel(); } if ($item->hasMenuItems()) { $xhtml .= $this->_renderMenu($item, $menuClass); } $xhtml .= '</li>'; return $xhtml; }
/** * Render a menu item * * @param Zym_Menu_Item $item * @return string */ protected function _renderMenuItem(Zym_Menu_Item $item) { $link = null; $target = $item->getTarget(); if (!empty($target)) { if (is_array($target)) { $link = $this->_view->url($target, null, true); } else { $link = (string) $target; } } $js .= sprintf('{text:"%s"', $item->getLabel()); if ($item->isSelected()) { $js .= ',selected:true'; } if (!empty($link)) { $js .= sprintf(',url:"%s"', $link); } if ($item->hasMenuItems()) { $js .= sprintf(',submenu:{id:"%s",itemdata:%s}', $item->getId(), $this->_renderMenu($item)); } $js .= '}'; return $js; }
/** * Output a lock icon which also serves as a link to unlock a page (if the user has permission * to do this) * * @param Array menu item array for this lock * @param DbUserModel user that is currently logged in * @return string */ public function lockIcon($menu, DbUserModel $user) { if ($menu['locked']) { $user = new DbUserModel(array('dbUserID' => $menu['locked'], 'depth' => 'dbUser')); $title = "Currently locked by '{$this->h($user->dbUserFullName)}'."; if ($user->hasAccess('edit', $menu['page']) || $user->hasAccess('approve', $menu['page'])) { $title .= ' Click to unlock.'; $html = $this->view->linkTo('#', $this->view->imageTag('icons/ffffff/lock_small.png', array('id' => $this->view->url(array('action' => 'unlock', 'id' => $menu['page']->pageID)), 'class' => 'inline lock tooltip', 'tooltip' => $title))); } else { $html = $this->view->imageTag('icons/ffffff/lock_small.png', array('class' => 'inline', 'title' => $title)); } } else { $html = ''; } return $html; }
/** * Returns a link for the header bar of a page * * @param PageModel current page * @param DbUserModel currently logged in user * @param integer The current page number * @return string */ public function topLinks($page, $user, $spNum) { if ($page->numQuestions <= 0) { return; } $current = Zend_Controller_Front::getInstance()->getRequest()->getActionName(); $actions = "<li class=\"current\">{$current}</li>"; //TODO need to relocate this list of available actions somewhere more appropriate foreach (array('view', 'edit', 'approve') as $action) { if ($action !== $current && $user->hasAccess($action, $page)) { $links[] = $this->view->linkTo($this->view->url(array('action' => $action, 'id' => $page->pageID)) . "?sp={$spNum}", $action); } } $actions = '<ul id="pageHeading">' . $actions . '<li>'; if (isset($links)) { $actions .= implode($links, ' | </li><li>') . '</li>'; } return "{$actions}<li class=\"stats\">{$this->stats($page)}</li><li class=\"bottom\"></li></ul>"; }
/** * */ public function actionLink($content, $controller, $action, $data = array()) { $data["controller"] = $controller; $data["action"] = $action; return "<a href=\"" . $this->view->url($data) . "\">{$content}</a>"; }
/** * Renders the url of the file * @param $params * @return string */ public function renderUrlWidget(array $params = array()) { # Extract $link = delve($params, 'link', false); $file = delve($params, 'file', null); $user = delve($params, 'user', null); $content = delve($params, 'content', null); $innerContent = delve($params, 'innerContent', null); if ($content === $innerContent) { $content = null; } $result = $text = $url = ''; $free = false; # Handle switch (true) { case $file: if (strstr($file, '/')) { $text = basename($file); } else { # Resolve if (!Bal_Doctrine_Core::isRecord('File', $file)) { $file = Bal_Doctrine_Core::getItem('File', $file); $free = $file; } # Check if (!$file || !$file->id) { break; } # Fetch $text = $file->title; } $url = $this->view->url()->file($file)->toString(); break; case $content: # Resolve if (!Bal_Doctrine_Core::isRecord('Content', $content)) { $content = Bal_Doctrine_Core::getItem('Content', $content); $free = $content; } # Check if (!$content || !$content->id) { break; } # Fetch $text = $content->title; $url = $this->view->url()->content($content)->toString(); break; case $user: # Resolve if (!Bal_Doctrine_Core::isRecord('User', $user)) { $user = Bal_Doctrine_Core::getItem('User', $user); $free = $user; } # Check if (!$user || !$user->id) { break; } # Fetch $text = $user->displayname; $url = $this->view->url()->user($user)->toString(); break; } # Free if ($free && FREE_RESOURCES) { // $free->free(false); } # Prepare if ($url) { if ($link) { if (!$text) { $text = $innerContent; } $result = '<a href="' . $url . '">' . $text . '</a>'; } else { $result = $url; } } else { $result = '(link is dead)'; } # Return result return $result; }
/** * Returns the url as string. * * @return string */ public function __toString() { $query = count($this->queryParams) !== 0 ? '?' . http_build_query($this->queryParams) : ''; $anchor = $this->anchor === null ? '' : '#' . $this->anchor; return $this->view->url($this->params, $this->route, $this->resetParams) . $query . $anchor; }