コード例 #1
1
 /**
  * Returns the HTML code for the controller control.
  *
  * @param array $selected List of site codes that were previously selected by the user
  * @param string|null $filter String that must be part of the controller name
  * @return string HTML code with <option> tags for the select box
  */
 protected function getControllerOptions(array $selected, $filter = null)
 {
     $html = '';
     $aimeos = Base::getAimeos();
     $context = Scheduler\Base::getContext();
     $cntlPaths = $aimeos->getCustomPaths('controller/jobs');
     $langid = 'en';
     if (isset($GLOBALS['BE_USER']->uc['lang']) && $GLOBALS['BE_USER']->uc['lang'] != '') {
         $langid = $GLOBALS['BE_USER']->uc['lang'];
     }
     $localeItem = \MShop_Factory::createManager($context, 'locale')->createItem();
     $localeItem->setLanguageId($langid);
     $context->setLocale($localeItem);
     $controllers = \Controller_Jobs_Factory::getControllers($context, $aimeos, $cntlPaths);
     foreach ($controllers as $name => $controller) {
         if ($filter !== null && strstr($name, $filter) === false) {
             continue;
         }
         $active = in_array($name, $selected) ? 'selected="selected"' : '';
         $title = htmlspecialchars($controller->getDescription(), ENT_QUOTES, 'UTF-8');
         $cntl = htmlspecialchars($controller->getName(), ENT_QUOTES, 'UTF-8');
         $name = htmlspecialchars($name, ENT_QUOTES, 'UTF-8');
         $html .= sprintf('<option value="%1$s" title="%2$s" %3$s>%4$s</option>', $name, $title, $active, $cntl);
     }
     return $html;
 }
コード例 #2
0
ファイル: Setup.php プロジェクト: aimeos/aimeos-typo3
 /**
  * Executes the setup tasks for updating the database.
  *
  * The setup tasks print their information directly to the standard output.
  * To avoid this, it's necessary to use the output buffering handler
  * (ob_start(), ob_get_contents() and ob_end_clean()).
  */
 public static function execute()
 {
     ini_set('max_execution_time', 0);
     $aimeos = \Aimeos\Aimeos\Base::getAimeos();
     $sitecode = \Aimeos\Aimeos\Base::getExtConfig('siteCode', 'default');
     $taskPaths = $aimeos->getSetupPaths('default');
     $ctx = self::getContext();
     $dbm = $ctx->getDatabaseManager();
     $config = $ctx->getConfig();
     $config->set('setup/site', $sitecode);
     $dbconfig = $config->get('resource', array());
     foreach ($dbconfig as $rname => $dbconf) {
         if (strncmp($rname, 'db', 2) !== 0) {
             unset($dbconfig[$rname]);
         } else {
             $config->set("resource/{$rname}/limit", 2);
         }
     }
     $class = 'TYPO3\\CMS\\Extbase\\Object\\ObjectManager';
     $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($class);
     $utility = $objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\ConfigurationUtility');
     $conf = $utility->convertValuedToNestedConfiguration($utility->getCurrentConfiguration('aimeos'));
     $value = isset($conf['useDemoData']) ? $conf['useDemoData'] : '';
     $local = array('setup' => array('default' => array('demo' => (string) $value)));
     $ctx->setConfig(new \Aimeos\MW\Config\Decorator\Memory($config, $local));
     $manager = new \Aimeos\MW\Setup\Manager\Multiple($dbm, $dbconfig, $taskPaths, $ctx);
     $manager->migrate();
     $conf['useDemoData'] = '';
     $utility->writeConfiguration($conf, 'aimeos');
 }
コード例 #3
0
ファイル: Setup.php プロジェクト: nos3/aimeos-typo3
 /**
  * Executes the setup tasks for updating the database.
  *
  * The setup tasks print their information directly to the standard output.
  * To avoid this, it's necessary to use the output buffering handler
  * (ob_start(), ob_get_contents() and ob_end_clean()).
  */
 public static function execute()
 {
     ini_set('max_execution_time', 0);
     $aimeos = \Aimeos\Aimeos\Base::getAimeos();
     $sitecode = \Aimeos\Aimeos\Base::getExtConfig('siteCode', 'default');
     $taskPaths = $aimeos->getSetupPaths('default');
     $includePaths = $taskPaths;
     $includePaths[] = get_include_path();
     if (set_include_path(implode(PATH_SEPARATOR, $includePaths)) === false) {
         throw new Exception('Unable to extend include path');
     }
     if (spl_autoload_register('Aimeos\\Aimeos\\Setup::autoload') === false) {
         throw new Exception('Unable to register Aimeos\\Aimeos\\Setup::autoload');
     }
     $ctx = self::getContext();
     $dbm = $ctx->getDatabaseManager();
     $config = $ctx->getConfig();
     $local = array();
     $config->set('setup/site', $sitecode);
     $dbconfig = $config->get('resource', array());
     foreach ($dbconfig as $rname => $dbconf) {
         if (strncmp($rname, 'db', 2) !== 0) {
             unset($dbconfig[$rname]);
         } else {
             $config->set("resource/{$rname}/limit", 2);
         }
     }
     if (\Aimeos\Aimeos\Base::getExtConfig('useDemoData', 1) == 1) {
         $local = array('setup' => array('default' => array('demo' => true)));
     }
     $ctx->setConfig(new \MW_Config_Decorator_Memory($config, $local));
     $manager = new \MW_Setup_Manager_Multiple($dbm, $dbconfig, $taskPaths, $ctx);
     $manager->run('mysql');
 }
コード例 #4
0
ファイル: Base.php プロジェクト: Niko-r/aimeos-typo3
 /**
  * Returns the current context.
  *
  * @param array Multi-dimensional associative list of key/value pairs
  * @return MShop_Context_Item_Interface Context object
  */
 public static function getContext(array $conf = array())
 {
     $aimeos = Aimeos\Base::getAimeos();
     $tmplPaths = $aimeos->getCustomPaths('controller/jobs/templates');
     $tmplPaths = array_merge($tmplPaths, $aimeos->getCustomPaths('client/html'));
     $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $uriBuilder = $objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder');
     $uriBuilder->setArgumentPrefix('ai');
     $config = Aimeos\Base::getConfig($conf);
     $context = Aimeos\Base::getContext($config);
     $langManager = \Aimeos\MShop\Factory::createManager($context, 'locale/language');
     $search = $langManager->createSearch(true);
     $expr = array();
     $expr[] = $search->getConditions();
     $expr[] = $search->compare('==', 'locale.language.id', 'en');
     // default language
     if (isset($GLOBALS['BE_USER']->uc['lang']) && $GLOBALS['BE_USER']->uc['lang'] != '') {
         // BE language
         $expr[] = $search->compare('==', 'locale.language.id', $GLOBALS['BE_USER']->uc['lang']);
     }
     $search->setConditions($search->combine('||', $expr));
     $langids = array_keys($langManager->searchItems($search));
     $i18n = Aimeos\Base::getI18n($langids, isset($conf['i18n']) ? (array) $conf['i18n'] : array());
     $context->setI18n($i18n);
     $view = Aimeos\Base::getView($config, $uriBuilder, $tmplPaths);
     $context->setView($view);
     $context->setEditor('scheduler');
     return $context;
 }
コード例 #5
0
 public function setUp()
 {
     \Aimeos\Aimeos\Base::getAimeos();
     // initialize autoloader
     $this->object = $this->getAccessibleMock('Aimeos\\Aimeos\\Controller\\JqadmController', array('dummy'));
     $this->request = $this->getMockBuilder('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request')->setMethods(array('hasArgument', 'getArgument'))->disableOriginalConstructor()->getMock();
     $this->response = $this->getMockBuilder('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response')->setMethods(array('setHeader'))->disableOriginalConstructor()->getMock();
     $this->view = $this->getMockBuilder('TYPO3\\CMS\\Extbase\\Mvc\\View\\EmptyView')->setMethods(array('assign'))->disableOriginalConstructor()->getMock();
     $uriBuilder = $this->getMockBuilder('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder')->setMethods(array('buildBackendUri'))->disableOriginalConstructor()->getMock();
     $uriBuilder->expects($this->any())->method('buildBackendUri');
     $this->object->_set('uriBuilder', $uriBuilder);
     $this->object->_set('response', $this->response);
     $this->object->_set('request', $this->request);
     $this->object->_set('view', $this->view);
     $this->object->_call('initializeAction');
 }
コード例 #6
0
 /**
  * Returns the context item for the frontend
  *
  * @return \Aimeos\MShop\Context\Item\Iface Context item
  */
 protected function getContext()
 {
     $config = Base::getConfig((array) $this->settings);
     if (!isset(self::$context)) {
         $context = Base::getContext($config);
         $locale = Base::getLocale($context, $this->request);
         $context->setI18n(Base::getI18n(array($locale->getLanguageId()), $config->get('i18n', array())));
         $context->setLocale($locale);
         self::$context = $context;
     }
     // Use plugin specific configuration
     self::$context->setConfig($config);
     $langid = self::$context->getLocale()->getLanguageId();
     $templatePaths = Base::getAimeos()->getCustomPaths('client/html/templates');
     self::$context->setView(Base::getView($config, $this->uriBuilder, $templatePaths, $this->request, $langid));
     return self::$context;
 }
コード例 #7
0
 public function setUp()
 {
     \Aimeos\Aimeos\Base::getAimeos();
     // initialize autoloader
     $this->object = $this->getAccessibleMock('Aimeos\\Aimeos\\Controller\\AccountController', array('dummy'));
     $objManager = new \TYPO3\CMS\Extbase\Object\ObjectManager();
     $uriBuilder = $objManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder');
     $response = $objManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response');
     $request = $objManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request');
     $uriBuilder->setRequest($request);
     if (method_exists($response, 'setRequest')) {
         $response->setRequest($request);
     }
     $this->object->_set('uriBuilder', $uriBuilder);
     $this->object->_set('response', $response);
     $this->object->_set('request', $request);
     $this->object->_call('initializeAction');
 }
コード例 #8
0
 public function setUp()
 {
     \Aimeos\Aimeos\Base::getAimeos();
     // initialize autoloader
     $this->object = $this->getAccessibleMock('Aimeos\\Aimeos\\Controller\\JsonadmController', array('dummy'));
     $this->request = $this->getMockBuilder('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request')->setMethods(array('hasArgument', 'getArgument', 'getMethod', 'getBaseUri'))->disableOriginalConstructor()->getMock();
     $this->response = $this->getMockBuilder('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response')->setMethods(array('setStatus'))->disableOriginalConstructor()->getMock();
     $objManager = new \TYPO3\CMS\Extbase\Object\ObjectManager();
     $uriBuilder = $objManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder');
     $uriBuilder->setRequest($this->request);
     if (method_exists($response, 'setRequest')) {
         $response->setRequest($this->request);
     }
     $this->object->_set('uriBuilder', $uriBuilder);
     $this->object->_set('response', $this->response);
     $this->object->_set('request', $this->request);
     $this->object->_call('initializeAction');
 }
コード例 #9
0
 /**
  * Processes update requests from payment service providers.
  */
 public function updateAction()
 {
     try {
         $context = $this->getContext();
         $templatePaths = Base::getAimeos()->getCustomPaths('client/html');
         $client = \Aimeos\Client\Html\Checkout\Update\Factory::createClient($context, $templatePaths);
         $view = $context->getView();
         $param = array_merge(\TYPO3\CMS\Core\Utility\GeneralUtility::_GET(), \TYPO3\CMS\Core\Utility\GeneralUtility::_POST());
         $helper = new \Aimeos\MW\View\Helper\Parameter\Standard($view, $param);
         $view->addHelper('param', $helper);
         $client->setView($view);
         $client->process();
         $this->response->addAdditionalHeaderData($client->getHeader());
         return $client->getBody();
     } catch (\Exception $e) {
         @header('HTTP/1.1 500 Internal server error', true, 500);
         return 'Error: ' . $e->getMessage();
     }
 }
コード例 #10
0
 /**
  * Returns the context item
  *
  * @return \MShop_Context_Item_Interface Context item
  */
 protected function getContext()
 {
     if (!isset($this->context)) {
         $templatePaths = Base::getAimeos()->getCustomPaths('client/html');
         $config = $this->getConfig($this->settings);
         $context = Base::getContext($config);
         $localI18n = isset($this->settings['i18n']) ? $this->settings['i18n'] : array();
         $locale = $this->getLocale($context);
         $langid = $locale->getLanguageId();
         $context->setLocale($locale);
         $context->setI18n(Base::getI18n(array($langid), $localI18n));
         $context->setView(Base::getView($config, $this->uriBuilder, $templatePaths, $this->request, $langid));
         if (TYPO3_MODE === 'FE' && $GLOBALS['TSFE']->loginUser == 1) {
             $context->setEditor($GLOBALS['TSFE']->fe_user->user['username']);
             $context->setUserId($GLOBALS['TSFE']->fe_user->user[$GLOBALS['TSFE']->fe_user->userid_column]);
         }
         $this->context = $context;
     }
     return $this->context;
 }
コード例 #11
0
ファイル: Setup.php プロジェクト: Niko-r/aimeos-typo3
 /**
  * Executes the setup tasks for updating the database.
  *
  * The setup tasks print their information directly to the standard output.
  * To avoid this, it's necessary to use the output buffering handler
  * (ob_start(), ob_get_contents() and ob_end_clean()).
  */
 public static function execute()
 {
     ini_set('max_execution_time', 0);
     $aimeos = \Aimeos\Aimeos\Base::getAimeos();
     $sitecode = \Aimeos\Aimeos\Base::getExtConfig('siteCode', 'default');
     $taskPaths = $aimeos->getSetupPaths($sitecode);
     $includePaths = $taskPaths;
     $includePaths[] = get_include_path();
     if (set_include_path(implode(PATH_SEPARATOR, $includePaths)) === false) {
         throw new \Exception('Unable to extend include path');
     }
     if (spl_autoload_register('Aimeos\\Aimeos\\Setup::autoload') === false) {
         throw new \Exception('Unable to register Aimeos\\Aimeos\\Setup::autoload');
     }
     $ctx = self::getContext();
     $dbm = $ctx->getDatabaseManager();
     $config = $ctx->getConfig();
     $config->set('setup/site', $sitecode);
     $dbconfig = $config->get('resource', array());
     foreach ($dbconfig as $rname => $dbconf) {
         if (strncmp($rname, 'db', 2) !== 0) {
             unset($dbconfig[$rname]);
         } else {
             $config->set("resource/{$rname}/limit", 2);
         }
     }
     $class = '\\TYPO3\\CMS\\Extbase\\Object\\ObjectManager';
     $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($class);
     $utility = $objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\ConfigurationUtility');
     $conf = $utility->getCurrentConfiguration('aimeos');
     $local = array('setup' => array('default' => array('demo' => (string) $conf['useDemoData'])));
     $ctx->setConfig(new \Aimeos\MW\Config\Decorator\Memory($config, $local));
     $manager = new \Aimeos\MW\Setup\Manager\Multiple($dbm, $dbconfig, $taskPaths, $ctx);
     $manager->run('mysql');
     $conf['useDemoData'] = '';
     $utility->writeConfiguration($conf, 'aimeos');
 }
コード例 #12
0
 /**
  * Returns the JSON encoded translations for the ExtJS client.
  *
  * @param string $lang ISO language code like "en" or "en_GB"
  * @return string JSON encoded translation object
  */
 protected function getJsonClientI18n($lang)
 {
     $i18nPaths = Base::getAimeos()->getI18nPaths();
     $i18n = new \Aimeos\MW\Translation\Gettext($i18nPaths, $lang);
     $content = array('admin' => $i18n->getAll('admin'), 'admin/ext' => $i18n->getAll('admin/ext'));
     return json_encode($content, JSON_FORCE_OBJECT);
 }
コード例 #13
0
 /**
  * Renders the account watch list.
  */
 public function watchAction()
 {
     $templatePaths = Base::getAimeos()->getCustomPaths('client/html');
     $client = \Aimeos\Client\Html\Account\Watch\Factory::createClient($this->getContext(), $templatePaths);
     return $this->getClientOutput($client);
 }
コード例 #14
0
 /**
  * Renders the user session related catalog section.
  */
 public function sessionAction()
 {
     $templatePaths = Base::getAimeos()->getCustomPaths('client/html');
     $client = \Aimeos\Client\Html\Catalog\Session\Factory::createClient($this->getContext(), $templatePaths);
     return $this->getClientOutput($client);
 }
コード例 #15
0
 /**
  * Returns the resource controller
  *
  * @return \Aimeos\Admin\JQAdm\Iface JQAdm client
  */
 protected function createClient()
 {
     $resource = 'dashboard';
     if ($this->request->hasArgument('resource')) {
         $resource = $this->request->getArgument('resource');
     }
     $templatePaths = Base::getAimeos()->getCustomPaths('admin/jqadm/templates');
     $context = $this->getContextBackend($templatePaths);
     return \Aimeos\Admin\JQAdm\Factory::createClient($context, $templatePaths, $resource);
 }
コード例 #16
0
 /**
  * Processes requests and renders the locale selector.
  */
 public function selectAction()
 {
     $templatePaths = Base::getAimeos()->getCustomPaths('client/html');
     $client = \Client_Html_Locale_Select_Factory::createClient($this->getContext(), $templatePaths);
     return $this->getClientOutput($client);
 }
コード例 #17
0
 /**
  * Returns the resource client
  *
  * @param string Resource location, e.g. "product/stock/wareshouse"
  * @return \Aimeos\Admin\JsonAdm\Iface Jsonadm client
  */
 protected function createClient($resource)
 {
     $templatePaths = Base::getAimeos()->getCustomPaths('admin/jsonadm/templates');
     $context = $this->getContextBackend($templatePaths);
     return \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, $resource);
 }
コード例 #18
0
 /**
  * Returns the resource controller
  *
  * @param string $sitecode Unique site code
  * @param string Resource location, e.g. "product/stock/wareshouse"
  * @param string $lang Language code
  * @return \Aimeos\MShop\Context\Item\Iface Context item
  */
 protected function createController($sitecode, $resource, $lang)
 {
     $lang = $lang ? $lang : 'en';
     $context = $this->getContext($sitecode, $lang);
     $templatePaths = Base::getAimeos()->getCustomPaths('controller/jsonadm/templates');
     $view = Base::getView($context->getConfig(), $this->uriBuilder, $templatePaths, $this->request, $lang);
     $context->setView($view);
     return \Aimeos\Controller\JsonAdm\Factory::createController($context, $templatePaths, $resource);
 }
コード例 #19
0
 /**
  * Returns the JSON encoded translations for the ExtJS client.
  *
  * @param string $lang ISO language code like "en" or "en_GB"
  * @return string JSON encoded translation object
  */
 protected function getJsonClientI18n($lang)
 {
     $i18nPaths = Base::getAimeos()->getI18nPaths();
     $i18n = new \Aimeos\MW\Translation\Zend2($i18nPaths, 'gettext', $lang, array('disableNotices' => true));
     $content = array('client/extjs' => $i18n->getAll('client/extjs'), 'client/extjs/ext' => $i18n->getAll('client/extjs/ext'));
     return json_encode($content, JSON_FORCE_OBJECT);
 }
コード例 #20
0
 /**
  * Renders the related basket.
  */
 public function relatedAction()
 {
     $templatePaths = Base::getAimeos()->getCustomPaths('client/html');
     $client = \Client_Html_Basket_Related_Factory::createClient($this->getContext(), $templatePaths);
     return $this->getClientOutput($client);
 }