public function executeShow(sfWebRequest $request) { $this->buildParams(); $this->dateRange = ''; $this->aEvent = $this->getRoute()->getObject(); $this->blogCategories = $this->page->BlogCategories; $this->forward404Unless($this->aEvent); $this->forward404Unless($this->aEvent['status'] == 'published'); aBlogItemTable::populatePages(array($this->aEvent)); }
public function executeNormalView() { $this->setup(); $this->values = $this->slot->getArrayValue(); $q = $this->getQuery(); $this->options['slideshowOptions']['width'] = isset($this->options['slideshowOptions']['width']) ? $this->options['slideshowOptions']['width'] : 100; $this->options['slideshowOptions']['height'] = isset($this->options['slideshowOptions']['height']) ? $this->options['slideshowOptions']['height'] : 100; $this->options['slideshowOptions']['resizeType'] = isset($this->options['slideshowOptions']['resizeType']) ? $this->options['slideshowOptions']['resizeType'] : 'c'; $this->options['excerptLength'] = $this->getOption('excerptLength', 100); $this->options['maxImages'] = $this->getOption('maxImages', 1); $this->aBlogPosts = $q->execute(); aBlogItemTable::populatePages($this->aBlogPosts); }
public function configure() { // ADD YOUR FIELDS HERE $this->widgetSchema['count'] = new sfWidgetFormInput(array(), array('size' => 2)); $this->validatorSchema['count'] = new sfValidatorNumber(array('min' => 1, 'max' => 10)); $this->widgetSchema->setHelp('count', '<span class="a-help-arrow"></span> Set the number of events to display – 10 max.'); if (!$this->hasDefault('count')) { $this->setDefault('count', 3); } $choices = array('title' => 'By Title', 'tags' => 'By Category And Tag'); $this->setWidget('title_or_tag', new sfWidgetFormChoice(array('choices' => $choices))); if (!$this->hasDefault('title_or_tag')) { $this->setDefault('title_or_tag', 'tags'); } $this->setValidator('title_or_tag', new sfValidatorChoice(array('choices' => array_keys($choices)))); // We'll progressively enhance this with autocomplete so no data is needed here... // except that we do need choices matching the previously saved values, otherwise // the Symfony widget has no idea how to render them // On the rendering pass we fetch the event titles already selected. // On the validation pass there will be no defaults, so we won't have to, // and shouldn't do a bad whereIn query that matches everything etc. $ids = $this->getDefault('blog_posts'); $choices = array(); if (count($ids)) { $q = Doctrine::getTable('aBlogItem')->createQuery('p')->select('p.*')->whereIn('p.id', $ids); aDoctrine::orderByList($q, $ids); $items = $q->execute(); // Crucial to get the latest versions of titles and avoid expensive single queries aBlogItemTable::populatePages($items); foreach ($items as $item) { $choices[$item->id] = $item->getTitle(); } } $this->setWidget('blog_posts', new sfWidgetFormChoice(array('multiple' => true, 'expanded' => false, 'choices' => $choices))); // TODO: really should be specific to events, requires adding a custom query $this->validatorSchema['blog_posts'] = new sfValidatorDoctrineChoice(array('model' => 'aBlogItem', 'multiple' => true, 'required' => false)); $this->widgetSchema['categories_list'] = new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'aCategory')); $this->validatorSchema['categories_list'] = new sfValidatorDoctrineChoice(array('model' => 'aCategory', 'multiple' => true, 'required' => false)); $this->widgetSchema->setHelp('categories_list', '<span class="a-help-arrow"></span> Filter Events by Category'); $this->getWidget('categories_list')->setOption('query', Doctrine::getTable('aCategory')->createQuery()->orderBy('aCategory.name asc')); $this->widgetSchema['tags_list'] = new sfWidgetFormInput(array(), array('class' => 'tag-input', 'autocomplete' => 'off')); $this->validatorSchema['tags_list'] = new sfValidatorString(array('required' => false)); $this->widgetSchema->setHelp('tags_list', '<span class="a-help-arrow"></span> Filter Events by Tag'); // Ensures unique IDs throughout the page $this->widgetSchema->setNameFormat('slot-form-' . $this->id . '[%s]'); // You don't have to use our form formatter, but it makes things nice $this->widgetSchema->setFormFormatterName('aAdmin'); }
public function executeNormalView() { $this->setup(); $this->values = $this->slot->getArrayValue(); $this->aBlogItem = new $this->modelClass(); if (isset($this->values['blog_item'])) { $this->aBlogItem = Doctrine::getTable($this->modelClass)->findOneBy('id', $this->values['blog_item']); aBlogItemTable::populatePages(array($this->aBlogItem)); } $this->options['word_count'] = $this->getOption('word_count', 100); $this->options['slideshowOptions']['width'] = isset($this->options['slideshowOptions']['width']) ? $this->options['slideshowOptions']['width'] : 100; $this->options['slideshowOptions']['height'] = isset($this->options['slideshowOptions']['height']) ? $this->options['slideshowOptions']['height'] : 100; $this->options['slideshowOptions']['resizeType'] = isset($this->options['slideshowOptions']['resizeType']) ? $this->options['slideshowOptions']['resizeType'] : 'c'; $this->options['excerptLength'] = $this->getOption('excerptLength', 200); $this->options['maxImages'] = $this->getOption('maxImages', 1); }
public function executeNormalView() { $this->setup(); $this->values = $this->slot->getArrayValue(); $q = Doctrine::getTable($this->modelClass)->createQuery()->leftJoin($this->modelClass . '.Author a')->leftJoin($this->modelClass . '.Categories c'); Doctrine::getTable($this->modelClass)->addPublished($q); if (isset($this->values['categories_list']) && count($this->values['categories_list']) > 0) { $q->andWhereIn('c.id', $this->values['categories_list']); } if (isset($this->values['tags_list']) && strlen($this->values['tags_list']) > 0) { PluginTagTable::getObjectTaggedWithQuery($q->getRootAlias(), $this->values['tags_list'], $q, array('nb_common_tags' => 1)); } $limit = isset($this->values['count']) ? $this->values['count'] : 5; $this->options['slideshowOptions']['width'] = isset($this->options['slideshowOptions']['width']) ? $this->options['slideshowOptions']['width'] : 100; $this->options['slideshowOptions']['height'] = isset($this->options['slideshowOptions']['height']) ? $this->options['slideshowOptions']['height'] : 100; $this->options['slideshowOptions']['resizeType'] = isset($this->options['slideshowOptions']['resizeType']) ? $this->options['slideshowOptions']['resizeType'] : 'c'; $this->options['excerptLength'] = $this->getOption('excerptLength', 100); $this->options['maxImages'] = $this->getOption('maxImages', 1); aEventTable::getInstance()->addUpcoming($q, $limit); $this->aEvents = $q->execute(); aBlogItemTable::populatePages($this->aEvents); }
public function executeEdit(sfWebRequest $request) { $this->getResponse()->addJavascript('/sfDoctrineActAsTaggablePlugin/js/pkTagahead.js', 'last'); if ($this->getUser()->hasCredential('admin')) { $this->a_blog_post = $this->getRoute()->getObject(); } else { $this->a_blog_post = Doctrine::getTable('aBlogPost')->findOneEditable($request->getParameter('id'), $this->getUser()->getGuardUser()->getId()); } $this->forward404Unless($this->a_blog_post); // Separate forms for separately saved fields $this->form = new aBlogPostForm($this->a_blog_post); // Retrieve the tags currently assigned to the blog post for the inlineTaggableWidget $this->existingTags = $this->form->getObject()->getTags(); // Retrieve the 10 most popular tags for the inlineTaggableWidget $this->popularTags = TagTable::getPopulars(null, array('model' => 'aBlogPost', 'sort_by_popularity' => true), false, 10); aBlogItemTable::populatePages(array($this->a_blog_post)); }
public function executeEdit(sfWebRequest $request) { $this->setAEventForUser(); $this->forward404Unless($this->a_event); $this->form = new aEventForm($this->a_event); // Retrieve the tags currently assigned to the event for the inlineTaggableWidget $this->existingTags = $this->form->getObject()->getTags(); // Retrieve the 10 most popular tags for the inlineTaggableWidget $this->popularTags = TagTable::getAllTagNameWithCount(null, array('model' => 'aEvent', 'sort_by_popularity' => true), false, 10); aBlogItemTable::populatePages(array($this->a_event)); }
public function executeIcalFeed(sfWebRequest $request) { $this->buildParams(); $this->dateRange = ''; $this->aEvent = $this->getRoute()->getObject(); $this->categories = aCategoryTable::getCategoriesForPage($this->page); $this->forward404Unless($this->aEvent); $this->forward404Unless($this->aEvent['status'] == 'published' || $this->getUser()->isAuthenticated()); aBlogItemTable::populatePages(array($this->aEvent)); header("Content-type: text/calendar"); header('Content-disposition: attachment; filename=' . str_replace('.', '-', $this->getRequest()->getHost() . '-' . $this->aEvent->id) . '.ics'); $start = $this->aEvent->getVcalStartDateTime(); $end = $this->aEvent->getVcalEndDateTime(); $title = aString::toVcal(aHtml::toPlaintext($this->aEvent->getTitle())); $body = aString::toVcal(aHtml::toPlaintext($this->aEvent->Page->getAreaText('blog-body'))); echo <<<EOM BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT CATEGORIES:MEETING DTSTART:{$start} DTEND:{$end} SUMMARY:{$title} DESCRIPTION:{$body} CLASS:PRIVATE END:VEVENT END:VCALENDAR EOM; exit(0); }
public function getFeed() { $this->articles = $this->pager->getResults(); aBlogItemTable::populatePages($this->articles); $title = sfConfig::get('app_aBlog_feed_title', $this->page->getTitle()); $this->feed = sfFeedPeer::createFromObjects($this->articles, array('format' => 'rss', 'title' => $title, 'link' => '@a_blog', 'authorEmail' => sfConfig::get('app_aBlog_feed_author_email'), 'authorName' => sfConfig::get('app_aBlog_feed_author_name'), 'routeName' => '@a_blog_post', 'methods' => array('description' => 'getFeedText'))); $this->getResponse()->setContent($this->feed->asXml()); }
public function executeEdit(sfWebRequest $request) { if ($this->getUser()->hasCredential('admin')) { $this->a_event = $this->getRoute()->getObject(); } else { $this->a_event = Doctrine::getTable('aEvent')->findOneEditable($request->getParameter('id'), $this->getUser()->getGuardUser()->getId()); } $this->forward404Unless($this->a_event); $this->form = $this->configuration->getForm($this->a_event); aBlogItemTable::populatePages(array($this->a_event)); }