/** * 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; }
public function contentListAction() { # Prepare $App = $this->getHelper('App'); $Identity = $App->getUser(); $Request = $this->getRequest(); $type = $Request->getParam('type', 'content'); $App->activateNavigationItem('back.main', $type . '-list', true); $Content = $ContentCrumbs = $ContentList = $ContentArray = array(); # -------------------------- # Search $search = $App->fetchSearch(); $searchQuery = delve($search, 'query'); # Prepare Criteria $criteria = array('fetch' => 'listing', 'hydrationMode' => Doctrine::HYDRATE_ARRAY); # Criteria if ($searchQuery) { $criteria['search'] = $searchQuery; } else { # No Search # Fetch Current $Content = Bal_Doctrine_Core::getItem('Content', null, array('create' => false, 'verify' => array('verifyAccess' => array('action' => 'view', 'Identity' => $Identity)))); # Handle Current if (delve($Content, 'id')) { // We have a content as a root $ContentArray = $Content->toArray(); $ContentCrumbs = $Content->getAncestors(Doctrine::HYDRATE_ARRAY, true); // Children $criteria['Parent'] = $Content; } else { // Roots if ($type === 'content') { $criteria['Root'] = true; } // or all of type } } # Fetch $ContentList = $App->fetchRecords('Content', $criteria); # Postpare if (!$searchQuery) { # If nothing, use us if (!$ContentList && $Content) { $ContentList = array($Content); } } # -------------------------- # Apply $this->view->search = $search; $this->view->type = $type; $this->view->ContentCrumbs = $ContentCrumbs; $this->view->ContentList = $ContentList; $this->view->Content = $ContentArray; # Render $this->render('content/content-list'); # Done return true; }