コード例 #1
0
ファイル: Gallery.php プロジェクト: ralfhartmann/isotope_core
 /**
  * Create a gallery for product, falls back to standard gallery if none is defined
  *
  * @param IsotopeProduct $objProduct
  * @param string         $strAttribute
  * @param array          $arrConfig
  *
  * @return static
  */
 public static function createForProductAttribute(IsotopeProduct $objProduct, $strAttribute, $arrConfig)
 {
     $objGallery = static::findByPk((int) $arrConfig['gallery']);
     if (null === $objGallery) {
         $objGallery = new \Isotope\Model\Gallery\Standard();
     }
     $objGallery->setName($objProduct->getFormId() . '_' . $strAttribute);
     $objGallery->setFiles(static::mergeMediaData(deserialize($objProduct->{$strAttribute}, true), deserialize($objProduct->{$strAttribute . '_fallback'}, true)));
     $objGallery->product_id = $objProduct->pid ? $objProduct->pid : $objProduct->id;
     $objGallery->href = $objProduct->generateUrl($arrConfig['jumpTo']);
     return $objGallery;
 }
コード例 #2
0
ファイル: ProductReader.php プロジェクト: Aziz-JH/core
 /**
  * Adds canonical product URLs to the document
  * @param   IsotopeProduct
  */
 protected function addCanonicalProductUrls(IsotopeProduct $objProduct)
 {
     global $objPage;
     $arrPageIds = \Database::getInstance()->getChildRecords($objPage->rootId, \PageModel::getTable());
     $arrPageIds[] = $objPage->rootId;
     // Find the categories in the current root
     $arrCategories = array_intersect($objProduct->getCategories(), $arrPageIds);
     foreach ($arrCategories as $intPage) {
         // Do not use the index page as canonical link
         if ($objPage->alias == 'index' && count($arrCategories) > 1) {
             continue;
         }
         // Current page is the primary one, do not generate canonical link
         if ($intPage == $objPage->id) {
             break;
         }
         if (($objJumpTo = \PageModel::findWithDetails($intPage)) !== null) {
             $strDomain = \Environment::get('base');
             // Overwrite the domain
             if ($objJumpTo->dns != '') {
                 $strDomain = ($objJumpTo->useSSL ? 'https://' : 'http://') . $objJumpTo->dns . TL_PATH . '/';
             }
             $GLOBALS['TL_HEAD'][] = sprintf('<link rel="canonical" href="%s">', $strDomain . $objProduct->generateUrl($objJumpTo));
             break;
         }
     }
 }