예제 #1
0
 /**
  * @param \Enlight_Loader               $loader
  * @param \Shopware_Components_Config   $config
  * @param array                         $options
  * @return \Enlight_Class|\Zend_Mail_Transport_Abstract
  */
 public function factory(\Enlight_Loader $loader, \Shopware_Components_Config $config, array $options)
 {
     if (!isset($options['type']) && !empty($config->MailerMailer) && $config->MailerMailer != 'mail') {
         $options['type'] = $config->MailerMailer;
     }
     if (empty($options['type'])) {
         $options['type'] = 'sendmail';
     }
     if ($options['type'] == 'smtp') {
         if (!isset($options['username']) && !empty($config->MailerUsername)) {
             if (!empty($config->MailerAuth)) {
                 $options['auth'] = $config->MailerAuth;
             } elseif (empty($options['auth'])) {
                 $options['auth'] = 'login';
             }
             $options['username'] = $config->MailerUsername;
             $options['password'] = $config->MailerPassword;
         }
         if (!isset($options['ssl']) && !empty($config->MailerSMTPSecure)) {
             $options['ssl'] = $config->MailerSMTPSecure;
         }
         if (!isset($options['port']) && !empty($config->MailerPort)) {
             $options['port'] = $config->MailerPort;
         }
         if (!isset($options['name']) && !empty($config->MailerHostname)) {
             $options['name'] = $config->MailerHostname;
         }
         if (!isset($options['host']) && !empty($config->MailerHost)) {
             $options['host'] = $config->MailerHost;
         }
     }
     if (!$loader->loadClass($options['type'])) {
         $transportName = ucfirst(strtolower($options['type']));
         $transportName = 'Zend_Mail_Transport_' . $transportName;
     } else {
         $transportName = $options['type'];
     }
     unset($options['type'], $options['charset']);
     if ($transportName == 'Zend_Mail_Transport_Smtp') {
         $transport = \Enlight_Class::Instance($transportName, array($options['host'], $options));
     } elseif (!empty($options)) {
         $transport = \Enlight_Class::Instance($transportName, array($options));
     } else {
         $transport = \Enlight_Class::Instance($transportName);
     }
     /** @var $transport \Zend_Mail_Transport_Abstract */
     \Enlight_Components_Mail::setDefaultTransport($transport);
     if (!isset($options['from']) && !empty($config->Mail)) {
         $options['from'] = array('email' => $config->Mail, 'name' => $config->Shopname);
     }
     if (!empty($options['from']['email'])) {
         \Enlight_Components_Mail::setDefaultFrom($options['from']['email'], !empty($options['from']['name']) ? $options['from']['name'] : null);
     }
     if (!empty($options['replyTo']['email'])) {
         \Enlight_Components_Mail::setDefaultReplyTo($options['replyTo']['email'], !empty($options['replyTo']['name']) ? $options['replyTo']['name'] : null);
     }
     return $transport;
 }
예제 #2
0
 /**
  * @param \Enlight_Event_EventManager           $eventManager
  * @param \Shopware_Components_Snippet_Manager  $snippetManager
  * @param array                                 $options
  * @return \Enlight_Template_Manager
  */
 public function factory(\Enlight_Event_EventManager $eventManager, \Shopware_Components_Snippet_Manager $snippetManager, array $options)
 {
     /** @var $template \Enlight_Template_Manager */
     $template = \Enlight_Class::Instance('Enlight_Template_Manager');
     $template->setCompileDir(Shopware()->AppPath('Cache_Compiles'));
     $template->setCacheDir(Shopware()->AppPath('Cache_Templates'));
     $template->setTemplateDir(Shopware()->AppPath('Views'));
     $template->setOptions($options);
     $template->setEventManager($eventManager);
     $template->setTemplateDir(array('custom' => '_local', 'local' => '_local', 'emotion' => '_default', 'default' => '_default', 'base' => 'templates', 'include_dir' => '.'));
     $resource = new \Enlight_Components_Snippet_Resource($snippetManager);
     $template->registerResource('snippet', $resource);
     $template->setDefaultResourceType('snippet');
     return $template;
 }
예제 #3
0
 /**
  * @param \Enlight_Event_EventManager $eventManager
  * @param \Enlight_Components_Snippet_Resource $snippetResource
  * @param EscaperInterface $escaper
  * @return \Enlight_Template_Manager
  * @param array $templateConfig
  */
 public function factory(\Enlight_Event_EventManager $eventManager, \Enlight_Components_Snippet_Resource $snippetResource, EscaperInterface $escaper, array $templateConfig)
 {
     /** @var $template \Enlight_Template_Manager */
     $template = \Enlight_Class::Instance('Enlight_Template_Manager');
     $template->setCompileDir(Shopware()->AppPath('Cache_Compiles'));
     $template->setCacheDir(Shopware()->AppPath('Cache_Templates'));
     $template->setTemplateDir(Shopware()->AppPath('Views'));
     $template->setOptions($templateConfig);
     $template->setEventManager($eventManager);
     $template->registerResource('snippet', $snippetResource);
     $template->setDefaultResourceType('snippet');
     $template->registerPlugin(\Smarty::PLUGIN_MODIFIER, 'escapeHtml', array($escaper, 'escapeHtml'));
     $template->registerPlugin(\Smarty::PLUGIN_MODIFIER, 'escapeHtmlAttr', array($escaper, 'escapeHtmlAttr'));
     $template->registerPlugin(\Smarty::PLUGIN_MODIFIER, 'escapeJs', array($escaper, 'escapeJs'));
     $template->registerPlugin(\Smarty::PLUGIN_MODIFIER, 'escapeCss', array($escaper, 'escapeCss'));
     $template->registerPlugin(\Smarty::PLUGIN_MODIFIER, 'escapeUrl', array($escaper, 'escapeUrl'));
     return $template;
 }
예제 #4
0
	/**
	 * Constructor method
	 *
	 * @param unknown_type $mailRecipients
	 * @param unknown_type $mailTransport
	 */
	public function __construct($mailRecipients, $mailTransport = array())
    {
    	if(!$mailTransport instanceof Zend_Mail_Transport_Abstract) {
	    	if(empty($mailTransport['type'])) {
	    		$mailTransport['type'] = 'sendmail';
	    	}
	    	if(!Shopware()->Loader()->loadClass($mailTransport['type'])) {
				$transportName = ucfirst(strtolower($mailTransport['type']));
				$transportName = 'Zend_Mail_Transport_'.$transportName;
			}
			if($transportName=='Zend_Mail_Transport_Smtp') {
				$mailTransport = Enlight_Class::Instance($transportName, array($mailTransport['host'], $mailTransport));
			} else {
				$mailTransport = Enlight_Class::Instance($transportName, array($mailTransport));
			}
    	}
    	$this->mailTransport = $mailTransport;
    	$this->mailRecipients = explode(',', $mailRecipients);
    }
예제 #5
0
 /**
  * Returns the instance of the application bootstrap
  *
  * @return Enlight_Bootstrap
  */
 public function Bootstrap()
 {
     if (!$this->_bootstrap) {
         $class = $this->App() . '_Bootstrap';
         $this->_bootstrap = Enlight_Class::Instance($class, array($this));
     }
     return $this->_bootstrap;
 }
예제 #6
0
파일: Document.php 프로젝트: nhp/shopware-4
	/**
	 * Static function to initiate document class
	 * @param int $orderID s_order.id
	 * @param int $documentID s_core_documents.id
	 * @param array $config - configuration array, for possible values see backend\document controller
	 * @access public
	 */
	public static function initDocument($orderID, $documentID, array $config = array()) {
		if (empty($orderID)){
			$config["_preview"] = true;
		}

        /** @var $d Shopware_Components_Document */
		$d = Enlight_Class::Instance('Shopware_Components_Document');//new Shopware_Components_Document();

		//$d->setOrder(new Shopware_Models_Document_Order($orderID,$config));
		$d->setOrder(Enlight_Class::Instance('Shopware_Models_Document_Order', array($orderID,$config)));


		$d->setConfig($config);

		$d->setDocumentId($documentID);
        $d->_compatibilityMode = false;
		if (!empty($orderID)){
			$d->_subshop = Shopware()->Db()->fetchRow("
			SELECT s_core_multilanguage.id,doc_template, template, isocode,locale FROM s_order,s_core_multilanguage WHERE s_order.subshopID = s_core_multilanguage.id AND s_order.id = ?
			",array($orderID));

			if (empty($d->_subshop["doc_template"])) $d->setTemplate($d->_defaultPath);

			if (empty($d->_subshop["id"])){
				throw new Enlight_Exception("Could not load template path for order $orderID");
			}


		}else {

			$d->_subshop = Shopware()->Db()->fetchRow("
			SELECT s_core_multilanguage.id,doc_template, template, isocode,locale FROM s_core_multilanguage WHERE s_core_multilanguage.default = 1
			");

            $d->setTemplate($d->_defaultPath);
            $d->_subshop["doc_template"] = $d->_defaultPath;



		}

		$d->initTemplateEngine();

		return $d;
	}
예제 #7
0
파일: Action.php 프로젝트: nvdnkpr/Enlight
 /**
  * Returns front controller
  *
  * @return Enlight_Controller_Front
  */
 public function Front()
 {
     if ($this->front === null) {
         $this->front = Enlight_Class::Instance('Enlight_Controller_Front');
     }
     return $this->front;
 }
예제 #8
0
    /**
     * Init mail transport
     *
     * @return Zend_Mail_Transport_Abstract
     */
    protected function initMailTransport()
    {
        $options = Shopware()->getOption('mail') ? Shopware()->getOption('mail') : array();
        $config = $this->getResource('Config');

        if (!isset($options['type']) && !empty($config->MailerMailer) && $config->MailerMailer!='mail') {
            $options['type'] = $config->MailerMailer;
        }
        if (empty($options['type'])) {
            $options['type'] = 'sendmail';
        }

        if ($options['type'] == 'smtp') {
            if (!isset($options['username']) && !empty($config->MailerUsername)) {
                if (!empty($config->MailerAuth)) {
                    $options['auth'] = $config->MailerAuth;
                } elseif (empty($options['auth'])) {
                    $options['auth'] = 'login';
                }
                $options['username'] = $config->MailerUsername;
                $options['password'] = $config->MailerPassword;
            }
            if (!isset($options['ssl']) && !empty($config->MailerSMTPSecure)) {
                $options['ssl'] = $config->MailerSMTPSecure;
            }
            if (!isset($options['port']) && !empty($config->MailerPort)) {
                $options['port'] = $config->MailerPort;
            }
            if (!isset($options['name']) && !empty($config->MailerHostname)) {
                $options['name'] = $config->MailerHostname;
            }
            if (!isset($options['host']) && !empty($config->MailerHost)) {
                $options['host'] = $config->MailerHost;
            }
        }

        if (!Shopware()->Loader()->loadClass($options['type'])) {
            $transportName = ucfirst(strtolower($options['type']));
            $transportName = 'Zend_Mail_Transport_'.$transportName;
        } else {
            $transportName = $options['type'];
        }
        unset($options['type'], $options['charset']);

        if ($transportName=='Zend_Mail_Transport_Smtp') {
            $transport = Enlight_Class::Instance($transportName, array($options['host'], $options));
        } elseif (!empty($options)) {
            $transport = Enlight_Class::Instance($transportName, array($options));
        } else {
            $transport = Enlight_Class::Instance($transportName);
        }
        Enlight_Components_Mail::setDefaultTransport($transport);

        if (!isset($options['from']) && !empty($config->Mail)) {
            $options['from'] = array('email'=>$config->Mail, 'name'=>$config->Shopname);
        }

        if (!empty($options['from']['email'])) {
            Enlight_Components_Mail::setDefaultFrom(
                $options['from']['email'],
                !empty($options['from']['name']) ? $options['from']['name'] : null
            );
        }
        if (!empty($options['replyTo']['email'])) {
            Enlight_Components_Mail::setDefaultReplyTo(
                $options['replyTo']['email'],
                !empty($options['replyTo']['name']) ? $options['replyTo']['name'] : null
            );
        }

        return $transport;
    }
예제 #9
0
 /**
  * Generates an instances of an import resource
  *
  * @param $name
  * @param $progress
  * @param $source
  * @param $target
  * @param $request
  * @return Shopware_Components_Migration_Import_Resource_Abstract
  */
 public static function resourceFactory($name, $progress, $source, $target, $request)
 {
     /** @var $import Shopware_Components_Migration_Import_Resource_Abstract */
     $className = self::$resourceNamespace . '_' . $name;
     $import = Enlight_Class::Instance($className, [$progress, $source, $target, $request]);
     return $import;
 }
예제 #10
0
 /**
  * Plugin event listener function which is fired
  * when the top seller resource has to be initialed.
  * @return Shopware_Components_TopSeller
  */
 public function initTopSellerResource()
 {
     $this->Application()->Loader()->registerNamespace('Shopware_Components', $this->Path() . 'Components/');
     $topSeller = Enlight_Class::Instance('Shopware_Components_TopSeller');
     $this->Application()->Bootstrap()->registerResource('TopSeller', $topSeller);
     return $topSeller;
 }
예제 #11
0
 /**
  * The init template method instantiates the Enlight_Template_Manager
  * and sets the cache, template and compile directory into the manager.
  * After the directories has been set, the template configuration is set
  * by the internal config array.
  *
  * @return Enlight_Template_Manager
  */
 protected function initTemplate()
 {
     /** @var $template Enlight_Template_Manager */
     $template = Enlight_Class::Instance('Enlight_Template_Manager');
     $template->setCompileDir($this->Application()->AppPath('Cache_Compiles'));
     $template->setCacheDir($this->Application()->AppPath('Cache_Templates'));
     $template->setTemplateDir($this->Application()->AppPath('Views'));
     $config = $this->Application()->getOption('template');
     $template->setOptions($config);
     return $template;
 }
예제 #12
0
 /**
  * @return DataTransformerFactory
  */
 public function getDataTransformerFactory()
 {
     if ($this->dataTransformerFactory === null) {
         $this->dataTransformerFactory = Enlight_Class::Instance('Shopware\\Components\\SwagImportExport\\Factories\\DataTransformerFactory');
     }
     return $this->dataTransformerFactory;
 }
예제 #13
0
 /**
  * The init template method instantiates the Enlight_Template_Manager
  * and sets the cache, template and compile directory into the manager.
  * After the directories has been set, the template configuration is set
  * by the internal config array.
  *
  * @return Enlight_Template_Manager
  */
 protected function initTemplate()
 {
     /** @var $template Enlight_Template_Manager */
     $template = Enlight_Class::Instance('Enlight_Template_Manager');
     $template->setCompileDir($this->Application()->AppPath('Cache_Compiles'));
     $template->setCacheDir($this->Application()->AppPath('Cache_Templates'));
     $template->setTemplateDir($this->Application()->AppPath('Views'));
     $config = $this->Application()->getOption('template');
     if ($config !== null) {
         foreach ($config as $key => $value) {
             $template->{'set' . $key}($value);
         }
     }
     return $template;
 }
예제 #14
0
 /**
  * @return Shopware_Components_CustomerInformationHandler
  */
 public function onInitCustomerInformationHandlerResource()
 {
     $this->Application()->Loader()->registerNamespace('Shopware_Components', $this->Path() . 'Components/');
     $customerInformationHandler = Enlight_Class::Instance('Shopware_Components_CustomerInformationHandler');
     $this->getShopwareBootstrap()->registerResource('CustomerInformationHandler', $customerInformationHandler);
     return $customerInformationHandler;
 }
예제 #15
0
 /**
  * Plugin event listener function which is fired
  * when the also bought resource has to be initialed.
  *
  * @return Shopware_Components_SeoIndex
  */
 public function initSeoIndexResource()
 {
     $this->Application()->Loader()->registerNamespace('Shopware_Components', $this->Path() . 'Components/');
     $seoIndex = Enlight_Class::Instance('Shopware_Components_SeoIndex');
     return $seoIndex;
 }
예제 #16
0
 /**
  * Static function to initiate document class
  * @param  int                           $orderID    s_order.id
  * @param  int                           $documentID s_core_documents.id
  * @param  array                         $config     - configuration array, for possible values see backend\document controller
  * @throws Enlight_Exception
  * @return \Shopware_Components_Document
  */
 public static function initDocument($orderID, $documentID, array $config = array())
 {
     if (empty($orderID)) {
         $config["_preview"] = true;
     }
     /** @var $document Shopware_Components_Document */
     $document = Enlight_Class::Instance('Shopware_Components_Document');
     //new Shopware_Components_Document();
     //$d->setOrder(new Shopware_Models_Document_Order($orderID,$config));
     $document->setOrder(Enlight_Class::Instance('Shopware_Models_Document_Order', array($orderID, $config)));
     $document->setConfig($config);
     $document->setDocumentId($documentID);
     if (!empty($orderID)) {
         $document->_subshop = Shopware()->Db()->fetchRow("\n                SELECT\n                    s.id,\n                    m.document_template_id as doc_template_id,\n                    m.template_id as template_id,\n                    (SELECT CONCAT('templates/', template) FROM s_core_templates WHERE id = m.document_template_id) as doc_template,\n                    (SELECT CONCAT('templates/', template) FROM s_core_templates WHERE id = m.template_id) as template,\n                    s.id as isocode,\n                    s.locale_id as locale\n                FROM s_order, s_core_shops s\n                LEFT JOIN s_core_shops m\n                    ON m.id=s.main_id\n                    OR (s.main_id IS NULL AND m.id=s.id)\n                WHERE s_order.language = s.id\n                AND s_order.id = ?\n                ", array($orderID));
         if (empty($document->_subshop["doc_template"])) {
             $document->setTemplate($document->_defaultPath);
         }
         if (empty($document->_subshop["id"])) {
             throw new Enlight_Exception("Could not load template path for order {$orderID}");
         }
     } else {
         $document->_subshop = Shopware()->Db()->fetchRow("\n            SELECT\n                s.id,\n                s.document_template_id as doc_template_id,\n                s.template_id,\n                (SELECT CONCAT('templates/', template) FROM s_core_templates WHERE id = s.document_template_id) as doc_template,\n                (SELECT CONCAT('templates/', template) FROM s_core_templates WHERE id = s.template_id) as template,\n                s.id as isocode,\n                s.locale_id as locale\n            FROM s_core_shops s\n            WHERE s.default = 1\n            ");
         $document->setTemplate($document->_defaultPath);
         $document->_subshop["doc_template"] = $document->_defaultPath;
     }
     $document->setTranslationComponent();
     $document->initTemplateEngine();
     return $document;
 }
예제 #17
-1
 /**
  * Loads the Zend resource and initials the Enlight_Controller_Front class.
  * After the front resource is loaded, the controller path is added to the
  * front dispatcher. After the controller path is set to the dispatcher,
  * the plugin namespace of the front resource is set.
  *
  * @param Container $container
  * @param \Shopware_Bootstrap $bootstrap
  * @param \Enlight_Event_EventManager $eventManager
  * @param array $options
  * @throws \Exception
  * @return \Enlight_Controller_Front
  */
 public function factory(Container $container, \Shopware_Bootstrap $bootstrap, \Enlight_Event_EventManager $eventManager, array $options)
 {
     /** @var $front \Enlight_Controller_Front */
     $front = \Enlight_Class::Instance('Enlight_Controller_Front', array($eventManager));
     $front->setDispatcher($container->get('Dispatcher'));
     $front->Dispatcher()->addModuleDirectory(Shopware()->AppPath('Controllers'));
     $front->setRouter($container->get('Router'));
     $front->setParams($options);
     /** @var $plugins  \Enlight_Plugin_PluginManager */
     $plugins = $container->get('Plugins');
     $plugins->registerNamespace($front->Plugins());
     $front->setParam('bootstrap', $bootstrap);
     if (!empty($options['throwExceptions'])) {
         $front->throwExceptions((bool) $options['throwExceptions']);
     }
     try {
         $container->load('Cache');
         $container->load('Db');
         $container->load('Plugins');
     } catch (\Exception $e) {
         if ($front->throwExceptions()) {
             throw $e;
         }
         $front->Response()->setException($e);
     }
     return $front;
 }