/**
  * 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;
     }
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * 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);
 }
예제 #5
0
    echo $stock['rtShopProduct']['id'];
    ?>
" />
      <?php 
    echo link_to($stock['rtShopProduct']['title'], '@rt_shop_product_show?id=' . $stock['rtShopProduct']['id'] . '&slug=' . $stock['rtShopProduct']['slug'], array('class' => 'title'));
    ?>
      <?php 
    echo link_to(__('delete'), '@rt_shop_order_stock_delete?id=' . $stock['id'], array('class' => 'delete'));
    ?>

      <div class="rt-shop-cart-variations"><?php 
    echo $variations;
    ?>
</div>
      <?php 
    if (rtSiteToolkit::isMultiSiteEnabled()) {
        ?>
      <?php 
        include_partial('rtAdmin/site_reference_key', array('id' => $product->getSiteId()));
        ?>
      <?php 
    }
    ?>

      <div class="rt-shop-cart-price-unit">
          <?php 
    echo format_currency($item_price, sfConfig::get('app_rt_currency', 'USD')) . ' ' . __('each');
    ?>
      </div>
      
    </td>
<?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.');