public function createQuery($alias = '') { $query = parent::createQuery($alias); $query->orderBy($query->getRootAlias() . '.start_date asc'); $query->addOrderBy($query->getRootAlias() . '.start_time asc'); return $query; }
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)); }
<div id="disqus_thread"></div> <script type="text/javascript"> <?php // Newer versions pass the post object so we can access a custom disqus identifier ?> <?php // from a Wordpress import etc. Older versions do not and we shouldn't break older ?> <?php // overrides of those templates. The prefix app.yml option only makes sense when we ?> <?php // are not using a legacy identifier imported from another system ?> var disqus_identifier = <?php echo json_encode(aBlogItemTable::getDisqusIdentifier(isset($post) ? $post : null, $id)); ?> ; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = "http://<?php echo $disqus_shortname; ?> .disqus.com/embed.js"; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); <?php if (sfConfig::get('app_aBlog_disqus_developer', true)) { ?> var disqus_developer = true; <?php
$a_blog_post = isset($a_blog_post) ? $sf_data->getRaw('a_blog_post') : null; ?> <ul class="a-blog-item-meta"> <li class="post-date"><?php echo aDate::pretty($a_blog_post['published_at']); ?> </li> <li class="post-author"> <?php include_partial('aBlog/author', array('a_blog_post' => $a_blog_post)); ?> </li> <?php slot('disqus_needed', 1); ?> <?php if (sfConfig::get('app_aBlog_disqus_enabled')) { ?> <li><a class="disqus-comment-count" data-disqus-identifier="<?php echo htmlspecialchars(aBlogItemTable::getDisqusIdentifier($a_blog_post)); ?> " href="<?php echo url_for('a_blog_post', $a_blog_post); ?> #disqus_thread">0</a></li> <?php } ?> </ul>
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)); }
$searchLabel = isset($searchLabel) ? $sf_data->getRaw('searchLabel') : null; $newLabel = isset($newLabel) ? $sf_data->getRaw('newLabel') : null; $adminModule = isset($adminModule) ? $sf_data->getRaw('adminModule') : null; $calendar = isset($calendar) ? $sf_data->getRaw('calendar') : null; $tag = !is_null($sf_params->get('tag')) ? $sf_params->get('tag') : null; $selected = array('icon', 'a-selected'); // Class names for selected filters ?> <?php // url_for is the LAST step after other addParams calls play with what we want to include. Don't do it now $filterUrl = aUrl::addParams($url, array('tag' => $sf_params->get('tag'), 'cat' => $sf_params->get('cat'), 'year' => $sf_params->get('year'), 'month' => $sf_params->get('month'), 'day' => $sf_params->get('day'), 'q' => $sf_params->get('q'))); ?> <?php if (aBlogItemTable::userCanPost()) { ?> <div class="a-ui clearfix a-subnav-section a-sidebar-button-wrapper"> <?php echo a_js_button($newLabel, array('big', 'a-add', 'a-blog-new-post-button', 'a-sidebar-button'), 'a-blog-new-post-button'); ?> <div class="a-options a-blog-admin-new-ajax dropshadow"> <?php include_component($newModule, $newComponent); ?> </div> </div> <?php } ?>
public function createQuery($alias = '') { $query = parent::createQuery($alias); $query->orderBy($query->getRootAlias() . '.published_at desc'); return $query; }