コード例 #1
0
ファイル: Settings.php プロジェクト: rubenjohne/ts-echo
 public function loadTool($page = 'product')
 {
     if (null === self::$_toolCoreClass) {
         require_once BP . str_replace('/', DS, '/app/code/local/MagicToolbox/MagicZoomPlus/core/magiczoomplus.module.core.class.php');
         self::$_toolCoreClass = new MagicZoomPlusModuleCoreClass();
         $designPackage = Mage::getSingleton('core/design_package');
         $interface = $designPackage->getPackageName();
         $theme = $designPackage->getTheme('template');
         $coll = Mage::getModel('magiczoomplus/settings')->getCollection();
         $coll->getSelect()->columns('value')->where('package = ?', $interface)->where('theme = ?', $theme);
         if (!$coll->getSize()) {
             $coll->getSelect()->reset(Zend_Db_Select::WHERE)->where('package = ?', 'all')->where('theme = ?', 'all');
         }
         $params = $coll->getFirstItem()->getValue();
         if (!empty($params)) {
             $params = unserialize($params);
             foreach ($params as $id => $value) {
                 self::$_toolCoreClass->params->params[$id]['value'] = $value;
             }
         }
         /* load locale */
         $mz_lt = $this->__('MagicZoomPlus_LoadingText');
         if ($mz_lt != 'MagicZoomPlus_LoadingText') {
             self::$_toolCoreClass->params->set('loading-msg', $mz_lt);
         }
         $mz_m = $this->__('MagicZoomPlus_Message');
         if ($mz_m != 'MagicZoomPlus_Message') {
             self::$_toolCoreClass->params->set('message', $mz_m);
         }
         if (self::$_toolCoreClass->params->checkValue('use-effect-on-' . $page . '-page', 'Zoom')) {
             self::$_toolCoreClass->params->set('disable-expand', 'Yes');
             self::$_toolCoreClass->params->set('disable-zoom', 'No');
             self::$_toolCoreClass->params->set('use-effect-on-' . $page . '-page', 'Zoom&Expand');
         } elseif (self::$_toolCoreClass->params->checkValue('use-effect-on-' . $page . '-page', 'Expand')) {
             self::$_toolCoreClass->params->set('disable-expand', 'No');
             self::$_toolCoreClass->params->set('disable-zoom', 'Yes');
             self::$_toolCoreClass->params->set('use-effect-on-' . $page . '-page', 'Zoom&Expand');
         }
         if (self::$_toolCoreClass->type == 'standard' && self::$_toolCoreClass->params->checkValue('magicscroll', 'yes')) {
             require_once BP . str_replace('/', DS, '/app/code/local/MagicToolbox/MagicZoomPlus/core/magicscroll.module.core.class.php');
             self::$_scrollCoreClass = new MagicScrollModuleCoreClass();
             self::$_scrollCoreClass->params->appendArray(self::$_toolCoreClass->params->getArray());
             self::$_scrollCoreClass->params->set('direction', self::$_toolCoreClass->params->checkValue('template', array('left', 'right')) ? 'bottom' : 'right');
         }
         require_once BP . str_replace('/', DS, '/app/code/local/MagicToolbox/MagicZoomPlus/core/magictoolbox.templatehelper.class.php');
         MagicToolboxTemplateHelper::setPath(dirname(Mage::getSingleton('core/design_package')->getTemplateFilename('magiczoomplus' . DS . 'media.phtml')) . DS . 'templates');
         MagicToolboxTemplateHelper::setOptions(self::$_toolCoreClass->params);
     }
     return self::$_toolCoreClass;
 }
コード例 #2
0
ファイル: Settings.php プロジェクト: CE-Webmaster/CE-Hub
 public function loadTool($profile = '')
 {
     if (null === self::$_toolCoreClass) {
         $helper = Mage::helper('magiczoomplus/params');
         require_once BP . str_replace('/', DS, '/app/code/local/MagicToolbox/MagicZoomPlus/core/magiczoomplus.module.core.class.php');
         self::$_toolCoreClass = new MagicZoomPlusModuleCoreClass();
         /*
         foreach($helper->getDefaultValues() as $block => $params) {
             foreach($params as $id => $value) {
                 self::$_toolCoreClass->params->setValue($id, $value, $block);
             }
         }
         */
         $store = Mage::app()->getStore();
         $website_id = $store->getWebsiteId();
         $group_id = $store->getGroupId();
         $store_id = $store->getId();
         $designPackage = Mage::getSingleton('core/design_package');
         $interface = $designPackage->getPackageName();
         $theme = $designPackage->getTheme('template');
         $model = Mage::getModel('magiczoomplus/settings');
         $collection = $model->getCollection();
         $zendDbSelect = $collection->getSelect();
         $zendDbSelect->where('(website_id = ?) OR (website_id IS NULL)', $website_id);
         $zendDbSelect->where('(group_id = ?) OR (group_id IS NULL)', $group_id);
         $zendDbSelect->where('(store_id = ?) OR (store_id IS NULL)', $store_id);
         $zendDbSelect->where('(package = ?) OR (package = \'\')', $interface);
         $zendDbSelect->where('(theme = ?) OR (theme = \'\')', $theme);
         $zendDbSelect->order(array('theme DESC', 'package DESC', 'store_id DESC', 'group_id DESC', 'website_id DESC'));
         $_params = $collection->getFirstItem()->getValue();
         if (!empty($_params)) {
             $_params = unserialize($_params);
             foreach ($_params as $block => $params) {
                 if (is_array($params)) {
                     foreach ($params as $id => $value) {
                         self::$_toolCoreClass->params->setValue($id, $value, $block);
                     }
                 }
             }
         }
         foreach ($helper->getBlocks() as $id => $label) {
             switch (self::$_toolCoreClass->params->getValue('enable-effect', $id)) {
                 case 'Zoom':
                     self::$_toolCoreClass->params->setValue('disable-expand', 'Yes', $id);
                     break;
                 case 'Expand':
                     self::$_toolCoreClass->params->setValue('disable-zoom', 'Yes', $id);
                     break;
                 case 'Swap images only':
                     self::$_toolCoreClass->params->setValue('disable-expand', 'Yes', $id);
                     self::$_toolCoreClass->params->setValue('disable-zoom', 'Yes', $id);
                     break;
             }
             /* load locale */
             $locale = $this->__('MagicZoomPlus_LoadingMessage');
             if (strpos($locale, 'MagicZoomPlus_LoadingMessage') === false) {
                 //if($locale != 'MagicZoomPlus_LoadingMessage') {
                 self::$_toolCoreClass->params->setValue('loading-msg', $locale, $id);
             }
             $locale = $this->__('MagicZoomPlus_Message');
             if (strpos($locale, 'MagicZoomPlus_Message') === false) {
                 //if($locale != 'MagicZoomPlus_Message') {
                 self::$_toolCoreClass->params->setValue('message', $locale, $id);
             }
         }
         if (self::$_toolCoreClass->params->checkValue('magicscroll', 'yes', 'product')) {
             require_once BP . str_replace('/', DS, '/app/code/local/MagicToolbox/MagicZoomPlus/core/magicscroll.module.core.class.php');
             self::$_scrollCoreClass = new MagicScrollModuleCoreClass();
             self::$_scrollCoreClass->params->setScope('MagicScroll');
             self::$_scrollCoreClass->params->appendParams(self::$_toolCoreClass->params->getParams('product'));
             self::$_scrollCoreClass->params->setValue('direction', self::$_scrollCoreClass->params->checkValue('template', array('left', 'right')) ? 'bottom' : 'right');
         }
         require_once BP . str_replace('/', DS, '/app/code/local/MagicToolbox/MagicZoomPlus/core/magictoolbox.templatehelper.class.php');
         //MagicToolboxTemplateHelperClass::setPath(dirname(Mage::getSingleton('core/design_package')->getTemplateFilename('magiczoomplus'.DS.'media.phtml')) . DS . 'templates');
         MagicToolboxTemplateHelperClass::setPath(dirname(Mage::getSingleton('core/design_package')->getTemplateFilename('magiczoomplus' . DS . 'templates' . DS . preg_replace('/[^a-zA-Z0-9_]/is', '-', self::$_toolCoreClass->params->getValue('template', 'product')) . '.tpl.php')));
         MagicToolboxTemplateHelperClass::setOptions(self::$_toolCoreClass->params);
     }
     if ($profile) {
         self::$_toolCoreClass->params->setProfile($profile);
     }
     return self::$_toolCoreClass;
 }