/** * Get the rtCorePlugin template directory for a given mode. * * @param string $mode should be either frontend or backend * @return string */ public static function getrtPluginTemplateDir($mode = self::MODE_FRONTEND) { if ($mode == 'backend') { return sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR . 'rtCorePlugin' . DIRECTORY_SEPARATOR . 'templates'; } elseif (!sfConfig::has('app_rt_template_dir')) { return sfConfig::get('sf_app_template_dir'); } else { $base = sfConfig::get('sf_root_dir') . sfConfig::get('app_rt_template_dir'); $site = rtSiteToolkit::getCurrentSite(); $reference_key = ''; if ($site) { $reference_key = $site->getReferenceKey(); } $location = $base . DIRECTORY_SEPARATOR . $reference_key; if (rtSiteToolkit::isMultiSiteEnabled() && (is_dir($location) || is_link($location))) { return $location; } if ($site = rtSiteToolkit::getCurrentSite()) { $location = $base . DIRECTORY_SEPARATOR . $site->getReferenceKey(); if (rtSiteToolkit::isMultiSiteEnabled() && (is_dir($location) || is_link($location))) { return $location; } } return $base; } }
/** * @return rtSite */ protected function getRtSite() { if (is_null($this->_rt_site)) { $this->_rt_site = rtSiteToolkit::getCurrentSite(); } return $this->_rt_site; }
/** * Adds a check for pages which belong to the current domain/site. * * Note: this will only be activated if the rt_enable_multi_site config value is set to true. * * @param Doctrine_Query $query * @return Doctrine_Query */ public function addSiteQuery(Doctrine_Query $query = null) { $query = $this->getQuery($query); if (rtSiteToolkit::isMultiSiteEnabled()) { $query->leftJoin('page.rtSite site')->andWhere('site.domain = ?', rtSiteToolkit::getCurrentDomain()); } return $query; }
public function executeBooking(sfWebRequest $request) { $site = rtSiteToolkit::getCurrentSite(); if (!$site) { $this->forward404('No site configuration found for contact form request.'); } $options = array('to' => $site->getEmailBookingAddress(), 'from' => '', 'subject' => 'Booking Form Sent', 'confirmation' => $site->getEmailBookingResponse(), 'form_class' => 'rtBookingForm', 'success_route' => 'rt_booking_confirmation', 'partial_html' => 'rtContact/email_contact_admin_html', 'partial_plain' => 'rtContact/email_contact_admin_plain'); $this->processSubmission($request, $options); }
public function executeShow(sfWebRequest $request) { $this->rt_shop_product = $this->getRoute()->getObject(); $this->forward404Unless($this->rt_shop_product); if (!$this->rt_shop_product->isPublished() && !$this->isAdmin()) { $this->forward404('Product isn\'t published.'); } $this->related_products = $this->getRelatedProducts($this->rt_shop_product); rtSiteToolkit::checkSiteReference($this->rt_shop_product); $this->updateResponse($this->rt_shop_product); }
/** * Extends the default handling to include logic to handle * * @param array $defaults An array of default values * * @return sfForm The current form instance */ public function setDefaults($defaults) { parent::setDefaults($defaults); if (rtSiteToolkit::isMultiSiteEnabled()) { $rt_site = Doctrine::getTable('rtSite')->findOneByDomain(rtSiteToolkit::getCurrentDomain()); if ($rt_site && $this->isNew()) { $this->setDefault('site_id', $rt_site->getId()); } } return $this; }
public function executeShow(sfWebRequest $request) { $this->rt_site = Doctrine::getTable('rtSite')->findOneBy('reference_key', $request->getParameter('reference_key')); $this->forward404Unless($this->rt_site); $site = rtSiteToolkit::getCurrentSite(); if (rtSiteToolkit::getCurrentSite()->getReferenceKey() !== sfConfig::get('app_rt_booking_site_ref_key')) { $site = Doctrine::getTable('rtSite')->findOneBy('reference_key', sfConfig::get('app_rt_booking_site_ref_key')); if (!$site) { $this->forward404(); } $this->redirect('http://' . $site->getDomain() . $request->getPathInfo()); } }
/** * Run the common show logic which is shared between executeIndex() and executeShow(). * * @param rtShopCategory $rt_shop_category * @param sfWebRequest $request */ public function runShow(rtShopCategory $rt_shop_category, sfWebRequest $request) { $this->rt_shop_category = $rt_shop_category; $this->forward404Unless($this->rt_shop_category); $this->forward404If(!$this->rt_shop_category->isPublished() && !$this->isAdmin(), 'Category isn\'t published.'); rtSiteToolkit::checkSiteReference($this->rt_shop_category); $this->updateResponse($this->rt_shop_category); $query = Doctrine::getTable('rtShopProduct')->addPublishedQuery()->leftJoin('page.rtShopCategories c')->leftJoin('page.rtShopProductToCategory link')->orderBy('link.position ASC')->andWhere('link.category_id = ?', $this->rt_shop_category->getId()); $this->pager = new sfDoctrinePager('rtShopProduct', $this->getCountPerPage($request)); $this->pager->setQuery($query); $this->pager->setPage($request->getParameter('page', 1)); $this->pager->init(); }
public function executeShow(sfWebRequest $request) { $this->rt_wiki_page = $this->getRoute()->getObject(); $this->forward404Unless($this->rt_wiki_page); if (!$this->rt_wiki_page->isPublished() && !$this->isAdmin()) { $this->forward('rtGuardAuth', 'secure'); } rtSiteToolkit::checkSiteReference($this->rt_wiki_page); if ($this->rt_wiki_page->getIsRoot()) { $this->redirect('@rt_wiki_page_index'); } $this->updateResponse($this->rt_wiki_page); }
/** * Update the response meta values with the data contained within a rtPage object. * * @param rtPage $rt_page * @param sfUser $sf_user * @param sfWebResponse $sf_response * @return void */ public static function setCommonMetasFromPage(rtPage $rt_page, sfUser $sf_user, sfWebResponse $sf_response) { $data = array(); $data['robots'] = $rt_page->getSearchable() ? 'index, follow' : 'NONE'; $data['keywords'] = implode(', ', $rt_page->getTags()); $data['title'] = $rt_page->getTitleHead() ? $rt_page->getTitleHead() : $rt_page->getTitle(); $data['description'] = $rt_page->getDescription(); $data['og:title'] = $rt_page->getTitle(); $data['og:type'] = self::getTypeFromObject($rt_page); $data['og:url'] = str_replace('frontend_dev.php/', '', rtSiteToolkit::getCurrentDomain(null, true) . rtSiteToolkit::getRequestUri()); if ($rt_page->getPrimaryImage()) { $img_path = rtAssetToolkit::getThumbnailPath($rt_page->getPrimaryImage()->getSystemPath(), array('maxHeight' => 400, 'maxWidth' => 400)); $data['og:image'] = rtSiteToolkit::getCurrentDomain(null, true) . $img_path; } if (rtSiteToolkit::getCurrentSite()) { $data['og:site_name'] = rtSiteToolkit::getCurrentSite()->getTitle(); } if ($rt_page->getDescription() !== '') { $data['og:description'] = $rt_page->getDescription(); } self::setCommonMetas($data, $sf_response); }
public function executeShow(sfWebRequest $request) { $q = $this->getRtSitePageTable()->addSiteQuery(); $r = $q->andWhere('slug = ?', $request->getParameter('slug'))->execute(); if (count($r) == 0) { $this->forward404Unless($this->isAdmin()); $this->redirect('rtSitePage/create?slug=' . $request->getParameter('slug')); } $this->rt_site_page = $r[0]; $this->forward404Unless($this->rt_site_page); rtSiteToolkit::checkSiteReference($this->rt_site_page); $this->handleLinks($this->rt_site_page); if ($this->rt_site_page->getNode()->isRoot()) { $this->redirect('/', 301); } if (!$this->rt_site_page->isPublished() && !$this->isAdmin()) { $this->forward404('Page isn\'t published.'); } if ('link:' === substr($this->rt_site_page['content'], 0, 5)) { $this->redirect(trim(substr($this->rt_site_page['content'], 5))); } $this->updateResponse($this->rt_site_page); }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { $rt_blog_page = $form->save(); $this->clearCache($rt_blog_page); $this->getDispatcher($request)->notify(new sfEvent($this, 'doctrine.admin.save_object', array('object' => $rt_blog_page))); $action = $request->getParameter('rt_post_save_action', 'index'); if ($action == 'edit') { $this->redirect('rtBlogPageAdmin/edit?id=' . $rt_blog_page->getId()); } elseif ($action == 'show') { rtSiteToolkit::siteRedirect($rt_blog_page); } $this->redirect('rtBlogPageAdmin/index'); } $this->getUser()->setFlash('default_error', true, false); }
<?php use_helper('I18N'); $rt_site = rtSiteToolkit::getCurrentSite(); if (sfConfig::has('app_rt_email_signature_html')) { ?> <p><?php echo sfConfig::get('app_rt_email_signature_html', ''); ?> </p> <?php } elseif ($rt_site) { ?> <p>Many thanks, <?php echo $rt_site->getTitle(); ?> </p> <?php }
/** * Get the current site object. * * @return rtSite */ public function getSite() { return rtSiteToolkit::getCurrentSite(); }
/** * Return Twitter:Tweet code snippet * * @see http://twitter.com/about/resources/tweetbutton * @return Mixed */ function get_tweet_badge() { $enabled = sfConfig::get('app_rt_share_tweet', true); if ($enabled) { // Twitter url parameters $twitter_url = 'http://twitter.com/share'; // Twitter share URL $twitter_widget_js_url = 'http://platform.twitter.com/widgets.js'; // Site url and configuration parameters $data_url = rtSiteToolkit::getCurrentDomain(null, true) . rtSiteToolkit::getRequestUri(); // Page URL $data_count = 'horizontal'; // Parameters: none, vertical or horizontal $tweet_text = 'Tweet'; $link_class = 'twitter-share-button'; // Tags $script_start = sprintf('<script type="text/javascript" src="%s">', $twitter_widget_js_url); $script_end = '</script>'; $link_start = sprintf('<a href="%s" class="%s" style="display:block;" data-url="%s" data-count="%s">', $twitter_url, $link_class, urldecode($data_url), $data_count); $link_end = '</a>'; return $script_start . $script_end . $link_start . $tweet_text . $link_end; } return; }
echo __('said'); ?> :</p> <blockquote><p><?php echo $voucher_session_array['message']; ?> </p></blockquote> <?php } ?> <p><?php echo __('You can use this voucher at our online store'); ?> : <?php echo link_to(rtSiteToolkit::getCurrentDomain(null, true), url_for('@rt_shop_order_voucher_redeem?code=' . $rt_shop_voucher->getCode() . '&redirect=' . str_replace('/frontend_dev.php', '', url_for('@homepage', true)), true)); ?> .</p> <p><?php echo __('Simply enter the voucher code'); ?> (<code><?php echo $rt_shop_voucher->getCode(); ?> </code>) <?php echo __('in the payment step of ordering, to use your'); ?> <?php echo format_currency($rt_shop_voucher->getReductionValue(), sfConfig::get('app_rt_currency', 'USD')); ?>
/** * Note: Deprecated in favour of rtSiteToolkit::checkSiteReference() * * A passing mechanism to provide site aware redirects. * * @param sfDoctrineRecord $object * @param string $route */ public static function siteRedirect(sfDoctrineRecord $object, $route = null) { $context = sfContext::getInstance(); if (is_null($route)) { $route = $object->getTable()->getTableName() . '_show'; } $protocol = $context->getRequest()->isSecure() ? 'https://' : 'http://'; $domain = rtSiteToolkit::getCurrentDomain(); if (rtSiteToolkit::isMultiSiteEnabled() && $object->rtSite && !is_null($object->rtSite->getDomain())) { $domain = $object->rtSite->getDomain(); } $route = $context->getRouting()->generate($route, $object); $context->getController()->redirect($protocol . $domain . $route); }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { $rt_comment = $form->save(); $this->clearObjectCache($form->getObject()); $action = $request->getParameter('rt_post_save_action', 'index'); if ($action == 'edit') { $this->redirect('rtCommentAdmin/edit?id=' . $rt_comment->getId()); } elseif ($action == 'show') { $object = Doctrine::getTable($form->getObject()->getModel())->find($form->getObject()->getModelId()); rtSiteToolkit::siteRedirect($object); } $this->redirect('rtCommentAdmin/index'); } $this->getUser()->setFlash('default_error', true, false); }
<?php use_helper('I18N', 'Text'); ?> <script type="text/javascript"> $(document).ready(function() { $('input[name=rt_shop_voucher_redeem_link]').click(function() { $('input[name=rt_shop_voucher_redeem_link]').select(); }); }); </script> <?php //Example link: http://localhost/order/voucher/redeem?code=VA14CFC9&redirect=http://localhost/ // Current domain $domain = rtSiteToolkit::getCurrentDomain(null, true); // Redeem voucher url $redeem_route = str_replace('/frontend_dev.php', '', url_for('rt_shop_order_voucher_redeem')); // Query string: code $query_string = '?code=' . $rt_shop_voucher->getCode(); // add redirect to query string $query_string .= '&redirect=' . str_replace('/frontend_dev.php', '', url_for('@homepage', true)); // Complete link $redeem_link = $domain . $redeem_route . $query_string; ?> <input type="text" name="rt_shop_voucher_redeem_link" class="rt-shop-voucher-redeem-link" value="<?php echo $redeem_link; ?> ">
<?php // Cart item row END $i++; } ?> <!-- Gift voucher START --> <?php $vm = $rt_shop_cart_manager->getVoucherManager(); if ($vm->hasSessionVoucher()) { ?> <?php $voucher = $rt_shop_cart_manager->getVoucherManager()->getSessionVoucherArray(); ?> <?php $options = array('rt-voucher-referer' => urlencode(rtSiteToolkit::getRequestUri())); ?> <tr class="rt-shop-cart-voucher"> <td class="rt-shop-cart-primary-image-thumb"><div> </div></td> <td class="rt-shop-cart-details"><?php echo link_to($voucher['title'], 'rt_shop_voucher_edit', $options); ?> <br /> <span><?php echo __('For'); ?> : <?php echo $voucher['first_name']; ?> <?php echo $voucher['last_name'];
<?php if (count($pager) > 0) { ?> <ul> <?php $i = 1; foreach ($pager->getResults() as $rt_index) { ?> <li> <h2> <?php echo link_to_if(isset($routes[Doctrine_Inflector::tableize($rt_index->getCleanModel()) . '_show']), $rt_index->getObject()->getTitle(), Doctrine_Inflector::tableize($rt_index->getCleanModel()) . '_show', $rt_index->getObject()); ?> <?php if (rtSiteToolkit::isMultiSiteEnabled()) { ?> <?php include_partial('rtAdmin/site_reference_key', array('id' => $rt_index->getSiteId())); ?> <?php } ?> </h2> <p> <?php echo $rt_index->getObject()->getDescription(); ?> ... <?php echo link_to_if(isset($routes[Doctrine_Inflector::tableize($rt_index->getCleanModel()) . '_show']), __('read more'), Doctrine_Inflector::tableize($rt_index->getCleanModel()) . '_show', $rt_index->getObject()); ?>
<?php use_helper('I18N', 'rtText'); $class = isset($class) ? $class : 'rt-admin-edit-tools-panel-small'; $options = array('class' => 'rt-admin-edit-tools-trigger', 'query_string' => 'rt-snippet-referer=' . urlencode(rtSiteToolkit::getRequestUri())); ?> <?php if ($snippets && $snippets->count()) { ?> <div class="rt-snippet <?php echo $class; ?> "> <?php foreach ($snippets as $snippet) { ?> <!--RTAS <div class="rt-admin-tools"><?php echo link_to(__('Edit Snippet'), 'rtSnippetAdmin/edit?id=' . $snippet->getId(), $options); ?> </div> RTAS--> <?php echo markdown_to_html($snippet->getContent(), $snippet); ?> <?php } ?> </div> <?php
<?php require_once dirname(__FILE__) . '/../bootstrap/unit.php'; $t = new lime_test(6); $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'test', true); new sfDatabaseManager($configuration); $t->is(rtSiteToolkit::cleanDomainString('www.domain.com'), 'domain.com', '::cleanDomainString() Got the correct value.'); $t->is(rtSiteToolkit::cleanDomainString('www.www-domain.com'), 'www-domain.com', '::cleanDomainString() Got the correct value.'); $t->is(rtSiteToolkit::cleanDomainString('sub1.domain.com'), 'sub1.domain.com', '::cleanDomainString() Got the correct value.'); $t->is(rtSiteToolkit::cleanDomainString('sub2.www.domain.com'), 'sub2.www.domain.com', '::cleanDomainString() Got the correct value.'); $t->is(rtSiteToolkit::isMultiSiteEnabled(), sfConfig::get('app_rt_enable_multi_site'), '::isMultiSiteEnabled() Got the correct value at default.'); sfConfig::set('app_rt_enable_multi_site', true); $t->is(rtSiteToolkit::isMultiSiteEnabled(), true, '::isMultiSiteEnabled() Got the correct value after alteration.');
public function executeShow(sfWebRequest $request) { rtSiteToolkit::siteRedirect($this->getrtShopProduct($request)); }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { $rt_wiki_page = $form->save(); $this->clearCache($rt_wiki_page); $this->getDispatcher($request)->notify(new sfEvent($this, 'doctrine.admin.save_object', array('object' => $rt_wiki_page))); if ($rt_wiki_page->getIsRoot()) { // Run a clean on other wiki pages marked as root. Only one root page allowed. $rt_wiki_pages = Doctrine::getTable('rtWikiPage')->findByIsRoot(1); if ($rt_wiki_pages) { foreach ($rt_wiki_pages as $page) { if ($page->getId() != $rt_wiki_page->getId()) { $page->setIsRoot(0); $page->save(); } } } } $action = $request->getParameter('rt_post_save_action', 'index'); if ($action == 'edit') { $this->redirect('rtWikiPageAdmin/edit?id=' . $rt_wiki_page->getId()); } elseif ($action == 'show') { rtSiteToolkit::siteRedirect($rt_wiki_page); } $this->redirect('rtWikiPageAdmin/index'); } $this->getUser()->setFlash('default_error', true, false); }