public function executeBreadcrumb($request)
 {
     $this->type = aMediaTools::getSearchParameter('type');
     $this->tag = aMediaTools::getSearchParameter('tag');
     $this->search = aMediaTools::getSearchParameter('search');
     $this->categorySlug = aMediaTools::getSearchParameter('category');
     $this->crumbs = array();
     // I tried calling I18N here but that requires enabling
     // I18N for every project which the I18N helper does not...
     // I'm not internationalizing this site, so I give up.
     // If you're reading this, tell me how to localize these labels
     // without punishing noninternationalized sites. I really don't
     // want to push this much logic into a template. tom@punkave.com
     $this->crumbs[] = array("label" => "Home", "link" => "@homepage", "first" => true);
     $this->crumbs[] = array("label" => "Media", "link" => "aMedia/index");
     if ($this->type) {
         $this->crumbs[] = array("label" => $this->type, "link" => aUrl::addParams("aMedia/index", array("type" => $this->type)));
     }
     if ($this->categorySlug) {
         $this->crumbs[] = array("label" => $this->category, "link" => aUrl::addParams("aMedia/index", array('type' => $this->type, "category" => $this->categorySlug)));
     }
     if ($this->tag) {
         $this->crumbs[] = array("label" => htmlspecialchars($this->tag), "link" => aUrl::addParams("aMedia/index", array("type" => $this->type, 'category' => $this->categorySlug, "tag" => $this->tag)));
     }
     if ($this->search) {
         $this->crumbs[] = array("label" => htmlspecialchars($this->search), "link" => aUrl::addParams("aMedia/index", array("type" => $this->type, 'category' => $this->categorySlug, "tag" => $this->tag, "search" => $this->search)));
     }
     if (isset($this->item)) {
         $this->crumbs[] = array("label" => $this->item->getTitle(), "link" => aUrl::addParams("aMedia/show", array("slug" => $this->item->getSlug())));
     }
     $this->crumbs[count($this->crumbs) - 1]['last'] = true;
 }
Example #2
0
 public function __construct($name, $label, $link, $cssClass = '', $targetEnginePage = null)
 {
     $this->name = $name;
     $this->label = $label;
     $this->link = $link;
     $this->cssClass = $cssClass;
     $this->targetEnginePage = $targetEnginePage;
     if ($this->targetEnginePage) {
         // 1.5: we've had this sane alternative to pushing and popping engines for a while so use it.
         // It's also possible that you already did this for us and didn't bother passing $targetEnginePage,
         // which is fine
         // Oops, I forgot to add $this->
         $this->link = aUrl::addParams($this->link, array('engine-slug' => $this->targetEnginePage));
     }
 }
  <?php 
// Post-form-validation error when we tried to get the thumbnail
?>
  <?php 
if (isset($serviceError)) {
    ?>
  <h3><?php 
    echo __('That is not a valid YouTube video URL.', null, 'apostrophe');
    ?>
</h3>
  <?php 
}
?>

  <form method="POST" id="a-media-edit-form" enctype="multipart/form-data" action="<?php 
echo url_for(aUrl::addParams("aMedia/editVideo", array("slug" => $slug)));
?>
">
  	<?php 
echo $form->renderHiddenFields();
?>

    <div class="a-form-row title">
      <?php 
echo $form['title']->renderLabel();
?>
      <?php 
if (!$sf_params->get('first_pass')) {
    ?>
        <?php 
    echo $form['title']->renderError();
Example #4
0
			<div class="a-form-row search"> <?php 
// div is for page validation
?>
				<label for="a-search-cms-field" style="display:none;">Search</label><?php 
// label for accessibility
?>
    		<?php 
echo $form['q']->render(array('class' => 'a-search-field'));
?>
					
				<?php 
if (isset($q)) {
    ?>
			    <?php 
    echo link_to(__('Clear Search', null, 'apostrophe'), aUrl::addParams($current, array('q' => '')), array('class' => 'a-ui a-clear-search-button', 'id' => 'a-media-search-remove', 'title' => __('Clear Search', null, 'apostrophe')));
    ?>
						
				<?php 
} else {
    ?>
					<input type="image" src="/apostrophePlugin/images/a-special-blank.gif" class="submit a-search-submit" value="Search Pages" alt="Search" title="Search"/>
				<?php 
}
?>
			</div>

<?php 
/* Removed the cancel button because everyone kept clicking cancel instead of search. If you want to get back to media click the media heading. ?> 
	    <div class="a-form-row cancel" id="a-media-video-add-by-embed-form-submit">
				<?php echo link_to('<span class="icon"></span>'.a_("Cancel"), 'aMedia/resume', array("class" => "a-btn icon a-cancel")) ?>
Example #5
0
	<?php 
include_component('aMedia', 'browser');
?>

	<div class="a-media-toolbar">
		<h3><?php 
echo __('You are editing: %title%', array('%title%' => $item->getTitle()), 'apostrophe');
?>
</h3>
	</div>

  <?php 
if ($postMaxSizeExceeded) {
    ?>
  <h3><?php 
    echo __('File too large. Limit is %POSTMAXSIZE%', array('%POSTMAXSIZE%' => ini_get('post_max_size')), 'apostrophe');
    ?>
</h3>
  <?php 
}
?>

	<div class="a-media-items">
	  <?php 
include_partial('aMedia/edit', array('item' => $item, 'form' => $form, 'popularTags' => $popularTags, 'allTags' => $allTags, 'formAction' => url_for(aUrl::addParams("aMedia/edit", array("slug" => $item->getSlug())))));
?>
		
	</div>
	
</div>
        $day_title = date('mdy', strtotime($eventDate)) == date('mdy') ? a_('Today') : '';
        ?>

				<td class="day day-<?php 
        echo $d;
        echo $day_class;
        ?>
" title="<?php 
        echo $day_title;
        ?>
">
					<?php 
        if (count($event)) {
            ?>
						<a href="<?php 
            echo url_for(aUrl::addParams($filtersWithoutDate, array('year' => date('Y', strtotime($eventDate)), 'month' => date('m', strtotime($eventDate)), 'day' => date('d', strtotime($eventDate)))));
            ?>
" title="<?php 
            echo count($event) > 1 ? count($event) . ' Events' : count($event) . ' Event';
            ?>
"><?php 
            echo date('d', strtotime($eventDate));
            ?>
</a>
					<?php 
        } else {
            ?>
						<span><?php 
            echo date('d', strtotime($eventDate));
            ?>
</span>
 public static function searchBody($action, $slugMatch, $modelClass, $categories, sfWebRequest $request)
 {
     $now = date('YmdHis');
     // create the array of pages matching the query
     $ajax = false;
     if ($request->hasParameter('term')) {
         $ajax = true;
         $q = $request->getParameter('term');
         // Wildcarding is better for autocomplete
         $q .= '*';
     } else {
         $q = $request->getParameter('q');
         if ($request->hasParameter('x')) {
             // We sometimes like to use input type="image" for presentation reasons, but it generates
             // ugly x and y parameters with click coordinates. Get rid of those and come back. Keep
             // all the other stuff
             return $action->redirect(sfContext::getInstance()->getController()->genUrl(aUrl::addParams($request->getParameter('module') . '/' . $request->getParameter('action'), array('q' => $q, 'cat' => $request->getParameter('cat'), 'tag' => $request->getParameter('tag'), 'year' => $request->getParameter('year'), 'month' => $request->getParameter('month'), 'day' => $request->getParameter('day')))));
         }
     }
     $key = strtolower(trim($q));
     $key = preg_replace('/\\s+/', ' ', $key);
     $replacements = sfConfig::get('app_a_search_refinements', array());
     if (isset($replacements[$key])) {
         $q = $replacements[$key];
     }
     try {
         $q = "({$q}) AND slug:{$slugMatch}";
         $values = aZendSearch::searchLuceneWithValues(Doctrine::getTable('aPage'), $q, aTools::getUserCulture());
     } catch (Exception $e) {
         // Lucene search error. TODO: display it nicely if they are always safe things to display. For now: just don't crash
         $values = array();
     }
     $nvalues = array();
     // The truth is that Zend cannot do all of our filtering for us, especially
     // permissions-based. So we can do some other filtering as well, although it
     // would be bad not to have Zend take care of the really big cuts (if 99% are
     // not being prefiltered by Zend, and we have a Zend max results of 1000, then
     // we are reduced to working with a maximum of 10 real results).
     if ($request->hasParameter('cat')) {
         $categories = Doctrine::getTable('aCategory')->createQuery()->where('slug = ?', array($request->getParameter('cat')))->execute(array(), Doctrine::HYDRATE_ARRAY);
     }
     if (is_null($categories)) {
         $categoryIds = array();
     } else {
         $categoryIds = aArray::getIds($categories);
     }
     foreach ($values as $value) {
         if ($ajax && count($nvalues) >= sfConfig::get('app_aBlog_autocomplete_max', 10)) {
             break;
         }
         // 1.5: the names under which we store columns in Zend Lucene have changed to
         // avoid conflict with also indexing them
         $info = unserialize($value->info_stored);
         // Do a whole bunch of filtering that can't be easily done at the Lucene level.
         // This is not ideal because the 1000 results we consider might not meet the
         // criteria and some later set of results might. For 2.0 we need to find something
         // that fully merges text search and other criteria without complaint
         // The main performance killer isn't MySQL, it's Doctrine object hydration. Just keep it light
         if (count($categoryIds) && !count(Doctrine::getTable('aPage')->createQuery('p')->where('p.id = ?', $info['id'])->innerJoin('p.Categories c')->select('p.id, c.id')->andWhereIn('c.id', $categoryIds)->execute(array(), Doctrine::HYDRATE_NONE))) {
             continue;
         }
         if ($request->hasParameter('tag') && !count(Doctrine::getTable('Tagging')->createQuery('ta')->innerJoin('ta.Tag t WITH t.name = ?', $request->getParameter('tag'))->where('ta.taggable_model = ? AND ta.taggable_id = ?', array('aPage', $info['id']))->execute(array(), Doctrine::HYDRATE_NONE))) {
             continue;
         }
         // Filter search results chronologically. How to do this depends on whether
         // we're dealing with blog or events
         $year = sprintf("%04d", $request->getParameter('year'));
         $month = sprintf("%02d", $request->getParameter('month'));
         $day = sprintf("%02d", $request->getParameter('day'));
         // This if is gross and ought to be refactored by calling a method on
         // the actions class which is differently implemented by the two classes
         if (get_class($action) === 'aEventActions') {
             if ($day > 0) {
                 if (!aBlogToolkit::between("{$year}-{$month}-{$day}", $value->start_date, $value->end_date)) {
                     continue;
                 }
             } elseif ($month > 0) {
                 if (!aBlogToolkit::between("{$year}-{$month}", substr($value->start_date, 0, 7), substr($value->end_date, 0, 7))) {
                     continue;
                 }
             } elseif ($year > 0) {
                 if (!aBlogToolkit::between("{$year}", substr($value->start_date, 0, 4), substr($value->end_date, 0, 4))) {
                     continue;
                 }
             }
         } else {
             // We store this one real picky in a keyword so it's searchable at the lucene level
             if (preg_match('/^(\\d\\d\\d\\d)(\\d\\d)(\\d\\d)/', $value->published_at, $matches)) {
                 list($dummy, $pyear, $pmonth, $pday) = $matches;
                 if ($year > 0) {
                     if ($pyear != $year) {
                         continue;
                     }
                 }
                 if ($month > 0) {
                     if ($pmonth != $month) {
                         continue;
                     }
                 }
                 if ($day > 0) {
                     if ($pday != $day) {
                         continue;
                     }
                 }
             }
         }
         // Regardless of the above if it ain't published yet we can't see it
         if ($value->published_at > $now) {
             continue;
         }
         if (!aPageTable::checkPrivilege('view', $info)) {
             continue;
         }
         $nvalue = $value;
         $nvalue->page_id = $info['id'];
         $nvalue->slug = $nvalue->slug_stored;
         $nvalue->title = $nvalue->title_stored;
         $nvalue->summary = $nvalue->summary_stored;
         // Virtual page slug is a named Symfony route, it wants search results to go there
         $nvalue->url = $action->getController()->genUrl($nvalue->slug, true);
         $nvalue->class = $modelClass;
         $nvalues[] = $nvalue;
     }
     $values = $nvalues;
     if ($ajax) {
         // We need the IDs of the blog posts, not their virtual pages
         $pageIds = array();
         foreach ($values as $value) {
             $pageIds[] = $value->page_id;
         }
         $action->results = array();
         if (count($pageIds)) {
             $infos = Doctrine::getTable($modelClass)->createQuery('p')->select('p.id, p.page_id, p.status')->whereIn('p.page_id', $pageIds)->fetchArray();
             // At this point, if we're an admin, we have some posts on our list that are not actually
             // useful to return as AJAX results because we only care about posts that are published when
             // we're building up a posts slot
             foreach ($infos as $info) {
                 if ($info['status'] !== 'published') {
                     continue;
                 }
                 $pageIdToPostId[$info['page_id']] = $info['id'];
             }
             foreach ($values as $value) {
                 if (isset($pageIdToPostId[$value->page_id])) {
                     // Titles are stored as entity-escaped HTML text, so decode to meet
                     // the expectations of autocomplete
                     $action->results[] = array('label' => html_entity_decode($value->title, ENT_COMPAT, 'UTF-8'), 'value' => $pageIdToPostId[$value->page_id]);
                 }
             }
         }
         return 'Autocomplete';
     }
     $action->pager = new aArrayPager(null, sfConfig::get('app_a_search_results_per_page', 10));
     $action->pager->setResultArray($values);
     $action->pager->setPage($request->getParameter('page', 1));
     $action->pager->init();
     $action->pagerUrl = "aBlog/search?" . http_build_query(array("q" => $q));
     // setTitle takes care of escaping things
     $action->getResponse()->setTitle(aTools::getOptionI18n('title_prefix') . 'Search for ' . $q . aTools::getOptionI18n('title_suffix'));
     $action->results = $action->pager->getResults();
 }
Example #8
0
	  <span class="a-pager-navigation-image a-pager-navigation-next a-pager-navigation-disabled"><?php 
        echo __('Next Page', null, 'apostrophe');
        ?>
</span>
		<span class="a-pager-navigation-image a-pager-navigation-last a-pager-navigation-disabled"><?php 
        echo __('Last Page', null, 'apostrophe');
        ?>
</span>	
	<?php 
    } else {
        ?>
	  <a href="<?php 
        echo url_for(aUrl::addParams($pagerUrl, array('page' => $pager->getNextPage())));
        ?>
" class="a-pager-navigation-image a-pager-navigation-next"><?php 
        echo __('Next Page', null, 'apostrophe');
        ?>
</a>
  	<a href="<?php 
        echo url_for(aUrl::addParams($pagerUrl, array('page' => $pager->getLastPage())));
        ?>
" class="a-pager-navigation-image a-pager-navigation-last"><?php 
        echo __('Last Page', null, 'apostrophe');
        ?>
</a>
	<?php 
    }
    ?>
</div>
<?php 
}
Example #9
0
        $n++;
    }
    ?>
	</ul>
	
</div>
<?php 
}
?>

<?php 
if (!isset($noFeed)) {
    ?>
<hr />
<h5><?php 
    echo link_to('RSS Feed', aUrl::addParams('aBlog/index?feed=rss', $params['tag'], $params['cat']));
    ?>
</h5>
<?php 
}
?>

<script type="text/javascript">
$(document).ready(function() {
	$('.a-tag-sidebar-title.all-tags').click(function(){
		$('.a-tag-sidebar-list.all-tags').slideToggle();
		$(this).toggleClass('open');
	});
	
	$('.a-tag-sidebar-title.all-tags').hover(function(){
		$(this).toggleClass('over');
Example #10
0
    	<h4 class="a-tag-sidebar-title all-tags"><?php 
    echo __('All Tags', null, 'apostrophe');
    ?>
</h4>
	    <ul class="a-ui a-tag-sidebar-list all-tags">
	      <?php 
    $n = 1;
    foreach ($allTags as $tag => $count) {
        ?>
	  			<li <?php 
        echo $n == count($allTags) ? 'class="last"' : '';
        ?>
>
						<?php 
        echo a_button('<span class="a-tag-count icon">' . $count . '</span>' . $tag, url_for(aUrl::addParams($current, array("tag" => $tag))), array('a-link', 'a-tag', 'icon', 'no-icon', 'icon-right'));
        ?>
					</li>
	      <?php 
        $n++;
    }
    ?>
	    </ul>
  	</div>
		<?php 
}
?>

	</div>
</div>
Example #11
0
	<?php 
    $domId = "a-media-selection-list-item-{$id}";
    ?>
	<li id="<?php 
    echo $domId;
    ?>
" class="a-media-selection-list-item">
		<ul class="a-ui a-controls a-over a-media-selection-controls">
			<li>
				<?php 
    echo a_js_button(a_('Drag'), array('icon', 'a-drag', 'lite', 'no-label', 'alt'));
    ?>
			</li>
			<li>
				<?php 
    echo a_button(a_('Edit'), aUrl::addParams(url_for("aMedia/edit"), array("slug" => $item->getSlug())), array('icon', 'a-edit', 'lite', 'no-label', 'alt'));
    ?>
			</li>
			<li>
				<?php 
    echo a_js_button(a_('Crop'), array('icon', 'a-crop', 'lite', 'no-label', 'alt'));
    ?>
			</li>
			<li>
				<?php 
    echo a_js_button(a_('Delete'), array('icon', 'a-delete', 'lite', 'no-label', 'alt'));
    ?>
			</li>
		</ul>

	  <div class="a-thumbnail-container" style="background-image: url('<?php 
}
?>

<?php 
if (!isset($noFeed)) {
    ?>
	<hr class="a-hr" />
	<ul class="a-ui a-controls stacked">
  <?php 
    $full = $url . '?feed=rss';
    ?>
  <?php 
    // Everything not date-related. A date-restricted RSS feed is a bit of a contradiction
    ?>
  <?php 
    $filtered = aUrl::addParams($filterUrl, array('feed' => 'rss', 'year' => '', 'month' => '', 'day' => ''));
    ?>
  <?php 
    if ($full === $filtered) {
        ?>
    <li><?php 
        echo a_button(a_('RSS Feed'), url_for($full), array('icon', 'a-rss-feed', 'no-bg', 'alt'));
        ?>
</li>
  <?php 
    } else {
        ?>
    <li><?php 
        echo a_button(a_('Full Feed'), url_for($full), array('icon', 'a-rss-feed', 'no-bg', 'alt'));
        ?>
</li>
Example #13
0
</span></a></li>
	      <?php 
}
?>
    	</ul>

    	<h4 class="a-tag-sidebar-title all-tags"><?php 
echo __('All Tags', null, 'apostrophe');
?>
</h4>
	    <ul class="a-tag-sidebar-list all-tags">
	      <?php 
foreach ($allTags as $tag => $count) {
    ?>
	        <li><a href="<?php 
    echo url_for(aUrl::addParams($current, array("tag" => $tag)));
    ?>
"><span class="a-tag-sidebar-tag"><?php 
    echo htmlspecialchars($tag);
    ?>
</span> <span class="a-tag-sidebar-tag-count"><?php 
    echo $count;
    ?>
</span></a></li>
	      <?php 
}
?>
	    </ul>

  	</div>
Example #14
0
function a_remove_filter_button($label, $url, $parameter)
{
    if (!is_array($parameter)) {
        $parameter = array($parameter);
    }
    $remove = array();
    foreach ($parameter as $p) {
        // aUrl::addParams removes when the value is blank
        $remove[$p] = '';
    }
    $url = aUrl::addParams($url, $remove);
    return link_to($label . '<span class="icon"></span>', url_for($url), array('class' => 'a-remove-filter-button', 'title' => 'Remove Filter: ' . $label));
}
Example #15
0
 public function executeSelectCancel(sfRequest $request)
 {
     $this->forward404Unless(aMediaTools::isSelecting());
     $after = aUrl::addParams(aMediaTools::getAfter(), array("aMediaCancel" => true));
     aMediaTools::clearSelecting();
     return $this->redirect($after);
 }
Example #16
0
	
<li class="a-media-item <?php 
    echo $n % 2 ? "odd" : "even";
    ?>
">
	<div class="a-media-item-edit-form">
<?php 
}
?>

<?php 
if ($item) {
    ?>
<form method="POST" id="a-media-edit-form" enctype="multipart/form-data" 
  action="<?php 
    echo url_for(aUrl::addParams("aMedia/editImage", array("slug" => $item->getSlug())));
    ?>
">
<?php 
}
?>

		<?php 
$previewAvailable = aValidatorFilePersistent::previewAvailable($form['file']->getValue());
?>
		<?php 
if ($previewAvailable || $item) {
    ?>

		<div class="a-form-row image">
		<?php 
Example #17
0
?>
<ul class="a-ui a-controls a-media-footer-controls">
	<li class="a-media-footer-item-count"><?php 
echo $pager->count();
?>
 items</li>
	<li class="a-media-footer-separator a">|</li>
	<li class="a-media-footer-view-label">view</li>
	<?php 
foreach ($views as $n) {
    ?>
		<li class="a-media-footer-view-option"><?php 
    echo link_to($n, aUrl::addParams($pagerUrl, array('max_per_page' => $n)), array('class' => 'a-btn lite alt' . ($max_per_page == $n ? ' a-active' : '')));
    ?>
</li>
	<?php 
}
?>
	<li class="a-media-footer-separator b">|</li>
	<?php 
foreach ($enabled_layouts as $enabled_layout) {
    ?>
		<li class="a-media-footer-layout-option"><?php 
    echo link_to('<span class="icon"></span>' . $enabled_layout['name'], aUrl::addParams($pagerUrl, array('layout' => $enabled_layout['name'])), array('alt' => $enabled_layout['name'], 'class' => 'a-btn icon lite no-label a-media-' . $enabled_layout['name'] . ' alt ' . ($enabled_layout['name'] == $layout['name'] ? 'a-active' : '')));
    ?>
</li>
	<?php 
}
?>
</ul>
Example #18
0
?>

<div class="a-ui a-blog-browser">

  <?php 
include_partial('aBlog/datePrevAndNext', array('params' => $params, 'url' => $url));
?>

	<?php 
$filters = array();
?>
	<?php 
$date = $sf_params->get('day') . ' ' . ($sf_params->get('month') ? date('F', strtotime(date('Y') . '-' . $sf_params->get('month') . '-01')) : '') . ' ' . $sf_params->get('year');
?>
	<?php 
$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'), 'author' => $sf_params->get('author')));
?>

	<?php 
if ($sf_params->get('year') > 0) {
    ?>
	  <?php 
    $filters[] = a_('for %date%', array('%date%' => a_remove_filter_button($date, $filterUrl, array('year', 'month', 'day'))));
    ?>
	<?php 
}
?>

	<?php 
if (strlen($sf_params->get('q'))) {
    ?>
Example #19
0
            ?>
  		<?php 
            $i++;
        }
        ?>
  </div>
  <?php 
    }
}
?>

<?php 
if (count($aBlogItem->getTags()) != 0) {
    ?>
<div class="a-blog-item-tags tags">
	<span class="a-blog-item-tags-label">Tags:</span>
		<?php 
    $i = 1;
    foreach ($aBlogItem->getTags() as $tag) {
        ?>
			<?php 
        echo link_to($tag, aUrl::addParams(($type == 'post' ? 'aBlog' : 'aEvent') . '/index', array('tag' => $tag)));
        echo $i < count($aBlogItem->getTags()) ? ', ' : '';
        ?>
		<?php 
        $i++;
    }
    ?>
</div>
<?php 
}