예제 #1
0
파일: Social.php 프로젝트: balupton/balcms
 public function renderVimeoWidget($params = array())
 {
     # Prepare
     $oembed_endpoint = 'http://www.vimeo.com/api/oembed';
     # Extract
     $video_url = $params['content'];
     # Create the URLs
     $json_url = $oembed_endpoint . '.json?url=' . rawurlencode($video_url);
     # Load in the oEmbed Object
     $Oembed = @file_get_contents($json_url);
     if (!$Oembed) {
         return '<p>The Vimeo item could not be found.</p>';
     }
     $Oembed = json_decode($Oembed);
     # Apply the Model
     $model = compact('Oembed');
     $model = array_merge($params, $model);
     # Render
     return $this->view->getHelper('widget')->renderWidgetView(delve($params, 'partial', 'social/vimeo/vimeo'), $model);
 }
예제 #2
0
 public function contentPageAction()
 {
     # Prepare
     $App = $this->getHelper('App');
     $Request = $this->getRequest();
     $Response = $this->getResponse();
     # --------------------------
     # Fetch
     $content_id = $this->_getParam('id');
     $Content = Doctrine::getTable('Content')->find($content_id);
     if ($Content->status !== 'published') {
         throw new Zend_Controller_Action_Exception('This content does not exist', 404);
     }
     # Keywords
     $keywords = array($Content->tags);
     # Ancestors
     $Content_Ancestors = $this->view->content()->getAncestors($Content);
     foreach ($Content_Ancestors as $Ancestor) {
         $keywords[] = delve($Ancestor, 'tags');
         $this->view->headTitle()->append(delve($Ancestor, 'title'));
     }
     # Children
     $Content_Children = $this->view->content()->getChildren($Content);
     # Keywords
     $keywordstr = prepare_csv_str($keywords);
     # Meta
     $meta = preg_replace('/\\s\\s+/', ' ', strip_tags($Content->description_rendered));
     # --------------------------
     # Apply
     $this->view->Content = $Content;
     $this->view->Content_Ancestors = $Content_Ancestors;
     $this->view->Content_Children = $Content_Children;
     $this->view->headTitle()->append($Content->title);
     $this->view->headMeta()->appendName('description', $meta);
     $this->view->headMeta()->appendName('keywords', $keywordstr);
     $this->activateNavigationContentItem($Content);
     # Render
     $this->view->content = $content_id;
     $this->getHelper('Ajaxy')->render(array('template' => 'content/content', 'controller' => 'page', 'routes' => array('page-content-:content' => array('template' => 'content/content', 'controller' => 'page')), 'data' => 'content'));
     # Return true
     return true;
 }
예제 #3
0
 /**
  * Generate our Feed
  */
 protected function getFeed($type = null)
 {
     # Prepare
     $App = $this->getHelper('App');
     $Identity = $App->getUser();
     # --------------------------
     # Fetch Content
     # Search
     $search = $App->fetchSearch();
     $searchQuery = delve($search, 'query');
     # Prepare Criteria
     $criteria = array('recent' => true, 'fetch' => 'list', 'status' => 'published', 'Identity' => $Identity, 'hydrationMode' => Doctrine::HYDRATE_ARRAY);
     # Criteria: SearchQuery
     if ($searchQuery) {
         $criteria['search'] = $searchQuery;
     }
     # Fetch
     $Contents = $App->fetchRecords('Content', $criteria);
     # --------------------------
     # Generate Feed
     # Pepare Feed
     $feed = array('title' => $App->getConfig('site.title'), 'link' => $App->getBaseUrl(true), 'author' => $App->getConfig('site.author'), 'dateModified' => empty($Content[0]) ? time() : strtotime($Content->updated_at), 'description' => $App->getConfig('site.description', 'News Feed for ' . $App->getConfig('site.title')), 'categories' => prepare_csv_array($App->getConfig('site.keywords')));
     # Create Feed
     $Feed = new Zend_Feed_Writer_Feed();
     $Feed->setTitle($feed['title']);
     $Feed->setLink($feed['link']);
     $Feed->setDateModified($feed['dateModified']);
     $Feed->setDescription($feed['description']);
     $Feed->addAuthor($feed['author']['title'], $feed['author']['email'], $feed['author']['url']);
     $Feed->addHub('http://pubsubhubbub.appspot.com/');
     # Apply Categories
     $categories = array();
     foreach ($feed['categories'] as $tag) {
         $categories[] = array('term' => str_replace(' ', '-', $tag), 'label' => $tag);
     }
     $Feed->addCategories($categories);
     # Content Map
     $contentMap = array('title' => 'title', 'url' => 'link', 'updated_at' => 'dateModified', 'created_at' => 'dateCreated', 'description_rendered' => 'description', 'content_rendered' => 'content');
     # Apply Content
     foreach ($Contents as $Content) {
         # Create Entry
         $Entry = $Feed->createEntry();
         # Prepare Content
         $Content['url'] = $App->getUrl()->content($Content)->full()->toString();
         $Content['updated_at'] = strtotime($Content['updated_at']);
         $Content['created_at'] = strtotime($Content['created_at']);
         # Apply Content
         foreach ($contentMap as $from => $to) {
             $method = 'set' . ucfirst($to);
             $value = delve($Content, $from);
             $Entry->{$method}($value);
         }
         # Apply Author
         if (empty($Content['Author']['website'])) {
             $Content['Author']['website'] = $App->getUrl()->user($Content['Author'])->full()->toString();
         }
         $Entry->addAuthor($Content['Author']['displayname'], $Content['Author']['email'], $Content['Author']['website']);
         # Apply Categories
         $categories = array();
         foreach ($Content['ContentTags'] as $Tag) {
             $categories[] = array('term' => str_replace(' ', '-', $Tag['name']), 'label' => $Tag['name']);
         }
         $Entry->addCategories($categories);
         # Add Entry
         $Feed->addEntry($Entry);
     }
     # --------------------------
     # Done
     # Return Feed
     return $Feed;
 }
예제 #4
0
파일: Gallery.php 프로젝트: balupton/balcms
 protected function _handleFlickr_Search($search)
 {
     # Prepare
     $xhtml = '';
     $model = array();
     # flickr.photos.search
     $params = array('api_key' => $this->_flickr_key, 'method' => 'flickr.photos.search', 'format' => 'php_serial', 'text' => $search, 'extras' => 'owner_name, path_alias, description, url_sq, url_t, url_s, url_m, url_o', 'privacy_filter' => 1, 'sort' => 'interestingness-desc');
     $response = $this->_requestFlickr($params);
     # Apply the Model
     $model = array('flickr' => $response, 'search' => $search);
     $model = array_merge($params, $model);
     # Render Widget
     $xhtml = $this->view->getHelper('widget')->renderWidgetView(delve($params, 'partial', 'gallery/gallery/flickr/search'), $model);
     # Return xhtml
     return $xhtml;
 }
예제 #5
0
파일: Content.php 프로젝트: balupton/balcms
 /**
  * Render the Content description
  * @param {array|Content} $Content
  * @param array $params
  * @return string rendered content
  */
 public static function renderDescription($Content, array $params = array())
 {
     # Prepare
     $WidgetHelper = Bal_App::getViewHelper('widget');
     $cache = delve($params, 'cache', Bal_App::getConfig('content.cache', false));
     # Fetch
     $description = delve($Content, 'description');
     $description_rendered = delve($Content, 'description_rendered');
     # Prepare Params
     $params['Content'] = $Content;
     # Render Description
     $render = $cache && $description_rendered ? $description_rendered : $WidgetHelper->renderAll(format_to_output($description, 'rich'), $params += array('Content' => $Content));
     # Return render
     return $render;
 }
예제 #6
0
파일: Content.php 프로젝트: balupton/balcms
 /**
  * Renders the Eventlist Widget
  * 
  * @param array 			$params [optional]
  * 							The following options are provided:
  * 
  * @return string 			The following params are sent back to partial:
  * 								Content:		The Content object which is rendering this widget
  * 								EventsPast:		A Doctrine_Collection of Event objects which occurred in the past
  * 								EventsFuture:	A Doctrine_Collection of Event objects which will occur in the future
  */
 public function renderEventlistWidget(array $params = array())
 {
     # Prepare
     $timestamp = date('Y-m-d H:i:s', time());
     # Fetch
     $Content = $this->getContentObjectFromParams($params);
     $EventsPast = Doctrine_Query::create()->select('*')->from('ContentEvent c, c.Parent cp')->where('c.status = ? AND cp.id = ?', array('published', $Content->id))->orderBy('c.event_start_at ASC, c.id ASC')->limit(20)->andWhere('c.event_start_at < ?', $timestamp)->execute();
     $EventsFuture = Doctrine_Query::create()->select('*')->from('ContentEvent c, c.Parent cp')->where('c.status = ? AND cp.id = ?', array('published', $Content->id))->orderBy('c.event_start_at ASC, c.id ASC')->limit(20)->andWhere('c.event_start_at >= ?', $timestamp)->execute();
     # Apply
     $model = compact('Content', 'EventsPast', 'EventsFuture');
     $model = array_merge($params, $model);
     # Render
     return $this->view->getHelper('widget')->renderWidgetView(delve($params, 'partial', 'content/eventlist/eventlist'), $model);
     # Free
     if (FREE_RESOURCES) {
         $EventsPast->free(true);
         $EventsFuture->free(true);
     }
     # Return result
     return $result;
 }
예제 #7
0
 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;
 }