Exemplo n.º 1
0
 public function userAction()
 {
     # Prepare
     $App = $this->getHelper('App');
     # --------------------------
     # Fetch
     $User = Bal_Doctrine_Core::fetchItem('User');
     if (!delve($User, 'id')) {
         throw new Zend_Controller_Action_Exception('This user does not exist', 404);
     }
     # Meta
     $meta = preg_replace('/\\s\\s+/', ' ', strip_tags($User->description));
     # --------------------------
     # Apply
     $this->view->User = $User;
     $this->view->headTitle()->append('User');
     $this->view->headTitle()->append($User->displayname);
     $this->view->headMeta()->appendName('description', $meta);
     # Render
     $this->view->user = $User->id;
     $this->getHelper('Ajaxy')->render(array('template' => 'user/user', 'controller' => 'page', 'routes' => array('page-user-:user' => array('template' => 'user/user', 'controller' => 'page')), 'data' => 'user'));
     # Return true
     return true;
 }
Exemplo n.º 2
0
<?php

/**
 * This file is from the paypal system api.
 * It gets the information of the transaction over the multiple stages and ensures vailidty.
 * @todo this will need to be updated to be compatiable with balCMS systems, rather than just the Gates sytem.
 */
# Load
require_once dirname(__FILE__) . '/config.php';
# Fetch the Payment Invoice
$PaymentInvoice = $Paypal->handleResponse();
# Process the Payment for the Doctrine Invoice
$Invoice = Bal_Doctrine_Core::fetchRecord('Invoice', array('Invoice' => $PaymentInvoice->id));
$Invoice->processPaymentAndSave($PaymentInvoice);
# We may want to continue into other scripts, so don't die
Exemplo n.º 3
0
 /**
  * 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;
 }
Exemplo n.º 4
0
 /**
  * Fetch all the records for public access
  * @version 1.0, April 12, 2010
  * @return mixed
  */
 public static function fetch(array $params = array())
 {
     # Prepare
     Bal_Doctrine_Core::prepareFetchParams($params, array('fetch', 'Content', 'Root', 'Parent', 'User', 'Author', 'ContentTags', 'codes', 'featured', 'recent', 'status'));
     extract($params);
     # Query
     $Query = Doctrine_Query::create();
     # Handle
     switch ($fetch) {
         case 'list':
             $Query->select('Content.id, Content.code, Content.title, Content.tagline, Content.content_rendered, Content.description_rendered, Content.position, Content.status, Content.created_at, Content.updated_at, Route.*, Parent.id, Parent.code, Parent.title, ContentTag.name, Author.id, Author.code, Author.displayname, Author.email, Author.website, Avatar.id, Avatar.url')->from('Content, Content.Route Route, Content.Parent Parent, Content.ContentTags ContentTag, Content.Author Author, Content.Avatar Avatar')->orderBy('Content.position ASC, Content.id ASC');
             break;
         case 'simplelist':
             $Query->select('Content.id, Content.code, Content.title, Content.tagline, Content.position, Content.status, Parent.id, Parent.code, Route.*')->from('Content, Content.Route Route, Content.Parent Parent, Content.ContentTags ContentTag')->orderBy('Content.position ASC, Content.id ASC');
             break;
         default:
             $Query->select('Content.*, Route.*, Parent.id, Parent.code, Parent.title, ContentTag.name, Author.id, Author.code, Author.displayname, Avatar.id, Avatar.url')->from('Content, Content.Route Route, Content.Parent Parent, Content.ContentTags ContentTag, Content.Author Author, Content.Avatar Avatar')->orderBy('Content.position ASC, Content.id ASC');
             break;
     }
     # Criteria
     if ($Content) {
         $identifier = Bal_Doctrine_Core::resolveIdentifier('Content', $Content);
         $Query->andWhere('Content.' . $identifier['column'] . ' = ?', $identifier['value']);
     }
     if ($User) {
         $identifier = Bal_Doctrine_Core::resolveIdentifier('User', $User);
         $Query->andWhere('Content.Author.' . $identifier['column'] . ' = ?', $identifier['value']);
     }
     if ($Author) {
         $identifier = Bal_Doctrine_Core::resolveIdentifier('User', $Author);
         $Query->andWhere('Content.Author.' . $identifier['column'] . ' = ?', $identifier['value']);
     }
     if ($Parent) {
         $identifier = Bal_Doctrine_Core::resolveIdentifier('Content', $Parent);
         $Query->andWhere('Content.Parent.' . $identifier['column'] . ' = ?', $identifier['value']);
     }
     if ($status) {
         $Query->andWhereIn('Content.status', $status);
     }
     if ($codes) {
         $Query->andWhereIn('Content.code', $codes);
     }
     if ($featured) {
         $tags = array('featured');
         $Query->andWhere('Content.tags LIKE "%featured%"');
         //$Query->andWhere('EXISTS (SELECT Content.ContentTags.name FROM Content.ContentTags WHERE Content.ContentTags.name IN ("'.implode($tags,'","').'"))');
     }
     if ($recent) {
         $Query->orderBy('Content.published_at DESC, Content.position ASC, Content.id ASC');
     }
     if ($ContentTags) {
         $tags = $ContentTags;
         //$Query->andWhere('EXISTS (SELECT c.id FROM Content c, c.ContentTags ct WHERE c.id = Content.id AND cc.name IN ("'.implode($tags,'","').'"))');
         //$Query->andWhereIn('ContentTag.name', $ContentTags);
     }
     if ($Root) {
         $Query->andWhere('Content.Parent_id IS ?', null);
         //NOT EXISTS (SELECT ContentOrphan.id FROM Content ContentOrphan WHERE ContentOrphan.id = Content.Parent_id)');
     }
     # Fetch
     $result = Bal_Doctrine_Core::prepareFetchResult($params, $Query, 'Content');
     # Done
     return $result;
 }
Exemplo n.º 5
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;
 }