/** * Generates a URL from the given parameters. * * @param mixed $params The parameter values * @param array $context The context * @param Boolean $absolute Whether to generate an absolute URL * * @return string The generated URL */ public function generate($params, $context = array(), $absolute = false) { $slug = null; $defaults = $this->getDefaults(); if (isset($params['sf_subject']) && !isset($params['engine-slug'])) { // Don't override the current page if it is an engine, or a previously // pushed engine page $slug = aRouteTools::getContextEngineSlug($this); if ($slug) { $params['engine-slug'] = $slug; } else { if (method_exists($params['sf_subject'], 'getEngineSlug')) { $params['engine-slug'] = $params['sf_subject']->getEngineSlug(); } } } if (isset($params['engine-slug'])) { $slug = $params['engine-slug']; aRouteTools::pushTargetEngineSlug($slug, $defaults['module']); unset($params['engine-slug']); } $result = aRouteTools::addPageToUrl($this, parent::generate($params, $context, false), $absolute); if ($slug) { aRouteTools::popTargetEngine($defaults['module']); } return $result; }
public function executeRedirect() { $aEvent = $this->getRoute()->getObject(); aRouteTools::pushTargetEnginePage($aEvent->findBestEngine()); $url = $this->generateUrl('a_event_post', $aEvent); $this->redirect($url); }
/** * Generates a URL from the given parameters. * * @param mixed $params The parameter values * @param array $context The context * @param Boolean $absolute Whether to generate an absolute URL * * @return string The generated URL */ public function generate($params, $context = array(), $absolute = false) { $slug = null; if (isset($params['engine-slug'])) { $slug = $params['engine-slug']; aRouteTools::pushTargetEnginePage($slug); unset($params['engine-slug']); } // Note that you must pass false to parent::generate for the $absolute parameter $result = aRouteTools::addPageToUrl($this, parent::generate($params, $context, false), $absolute); if ($slug) { aRouteTools::popTargetEnginePage($slug); } return $result; }
<?php // updated page. ?> <?php slot("a-slot-controls-{$pageid}-{$name}-{$permid}"); ?> <li class="a-controls-item choose-images"> <?php aRouteTools::pushTargetEngineSlug('/admin/media', 'aMedia'); ?> <?php echo link_to('<span class="icon"></span>' . a_get_option($options, 'chooseLabel', a_('Choose Images')), 'aMedia/select', array('query_string' => http_build_query(array_merge($options['constraints'], array("multiple" => true, "aMediaIds" => implode(",", $itemIds), "type" => "image", "label" => a_get_option($options, 'browseLabel', a_('You are creating a slideshow of images.')), "after" => url_for("aSlideshowSlot/edit") . "?" . http_build_query(array("slot" => $name, "slug" => $slug, "permid" => $permid, "noajax" => 1))))), 'class' => 'a-btn icon a-media a-inject-actual-url')); ?> <?php aRouteTools::popTargetEnginePage('aMedia'); ?> </li> <?php include_partial('a/variant', array('pageid' => $pageid, 'name' => $name, 'permid' => $permid, 'slot' => $slot)); ?> <?php end_slot(); ?> <?php } ?>
public function executeRedirect() { $aBlogPost = $this->getRoute()->getObject(); aRouteTools::pushTargetEnginePage($aBlogPost->findBestEngine()); $this->redirect($this->generateUrl('a_blog_post', $this->getRoute()->getObject())); }
/** * Generates a URL from the given parameters. * * @param mixed $params The parameter values * @param array $context The context * @param Boolean $absolute Whether to generate an absolute URL * * @return string The generated URL */ public function generate($params, $context = array(), $absolute = false) { // Note that you must pass false to parent::generate for the $absolute parameter return aRouteTools::addPageToUrl($this, parent::generate($params, $context, false), $absolute); }
</div> </div> <hr class="a-hr" /> <div class="delete preview section a-form-row"> <?php $engine = $a_event->findBestEngine(); ?> <?php aRouteTools::pushTargetEnginePage($engine); ?> <?php echo link_to('<span class="icon"></span>' . a_('Preview'), 'a_blog_post', array('preview' => 1) + $a_event->getRoutingParams(), array('class' => 'a-btn icon a-search lite a-align-left', 'rel' => 'external')); ?> <?php aRouteTools::popTargetEnginePage($engine->engine); ?> <?php if ($a_event->userHasPrivilege('delete')) { ?> <?php echo link_to('<span class="icon"></span>' . a_('Delete'), 'a_event_admin_delete', $a_event, array('class' => 'a-btn icon a-delete alt lite a-align-right', 'method' => 'delete', 'confirm' => a_('Are you sure you want to delete this event?'))); ?> <?php } ?> </div> </form> <?php
?> <li><a href="#" class="a-btn icon a-page-small" onclick="return false;" id="a-this-page-toggle"><?php echo __('This Page', null, 'apostrophe'); ?> </a></li> <?php } ?> <?php foreach ($buttons as $button) { ?> <?php if ($button->getTargetEnginePage()) { ?> <?php aRouteTools::pushTargetEnginePage($button->getTargetEnginePage()); ?> <?php } ?> <li><?php echo link_to(__($button->getLabel(), null, 'apostrophe'), $button->getLink(), array('class' => 'a-btn icon ' . $button->getCssClass())); ?> </li> <?php } ?> </ul> </div> <div class="a-global-toolbar-user-settings a-personal-settings-container">
?> <!-- AddThis Button BEGIN --> <?php aRouteTools::pushTargetEnginePage($aEvent->findBestEngine()); ?> <div class="addthis_toolbox addthis_default_style"> <a href="http://addthis.com/bookmark.php?v=250&username=<?php echo $addthis_username; ?> " class="addthis_button_compact" addthis:url="<?php echo url_for('a_event', $aEvent, true); ?> " addthis:title="<?php echo $aEvent['title']; ?> ">Share</a> <span class="addthis_separator">|</span> <a class="addthis_button_facebook"></a> <a class="addthis_button_myspace"></a> <a class="addthis_button_google"></a> <a class="addthis_button_twitter"></a> </div> <?php aRouteTools::popTargetEnginePage('aEvent'); ?> <!-- AddThis Button END --> <?php use_javascript('http://s7.addthis.com/js/250/addthis_widget.js#username=' . $addthis_username); }
?> <!-- AddThis Button BEGIN --> <?php aRouteTools::pushTargetEnginePage($aBlogPost->findBestEngine()); ?> <div class="addthis_toolbox addthis_default_style"> <a href="http://addthis.com/bookmark.php?v=250&username=<?php echo $addthis_username; ?> " class="addthis_button_compact" addthis:url="<?php echo url_for('a_blog_post', $aBlogPost, true); ?> " addthis:title="<?php echo $aBlogPost['title']; ?> ">Share</a> <span class="addthis_separator">|</span> <a class="addthis_button_facebook"></a> <a class="addthis_button_myspace"></a> <a class="addthis_button_google"></a> <a class="addthis_button_twitter"></a> </div> <?php aRouteTools::popTargetEnginePage('aBlog'); ?> <!-- AddThis Button END --> <?php use_javascript('http://s7.addthis.com/js/250/addthis_widget.js#username=' . $addthis_username); }
/** * Prepends the current CMS page to the URL. * * @param string $url The URL so far obtained from parent::generate * @param Boolean $absolute Whether to generate an absolute URL * * @return string The generated URL */ public static function addPageToUrl(sfRoute $route, $url, $absolute) { $slug = aRouteTools::getContextEngineSlug($route); if (!$slug) { $defaults = $route->getDefaults(); $page = aPageTable::getFirstEnginePage($defaults['module']); if (!$page) { $slug = null; } else { $slug = $page->slug; } } if (!$slug) { throw new sfException('Attempt to generate aRoute URL for module ' . $defaults['module'] . ' with no matching engine page on the site'); } // A route URL of / for an engine route maps to the page itself, without a trailing / if ($url === '/') { $url = ''; } // Ditto for / followed by a query string (missed this before) if (substr($url, 0, 2) === '/?') { $url = substr($url, 1); } $pageUrl = aTools::urlForPage($slug, $absolute); $rr = preg_quote(sfContext::getInstance()->getRequest()->getRelativeUrlRoot(), '/'); // Strip controller off so it doesn't duplicate the controller in the // URL we just generated. Also strip off sf_relative_root if any. // We could use the slug directly, but that would // break if the CMS were not mounted at the root on a particular site. // Take care to function properly in the presence of an absolute URL if (preg_match("/^(?:https?:\\/\\/[^\\/]+)?{$rr}(?:\\/[^\\/]+\\.php)?(.*)\$/", $pageUrl, $matches)) { $pageUrl = $matches[1]; } // Fix double / at beginning when engine is at root of site (think "just a blog") $finalUrl = $pageUrl . $url; $finalUrl = preg_replace('|^//|', '/', $finalUrl); return $finalUrl; }