Ejemplo n.º 1
0
 /**
  * Returns the context item for backend operations
  *
  * @param array $templatePaths List of paths to the view templates
  * @return \Aimeos\MShop\Context\Item\Iface Context item
  */
 protected function getContextBackend(array $templatePaths = array(), $withView = true)
 {
     if (!isset($this->contextBE)) {
         $lang = 'en';
         $site = 'default';
         if (isset($GLOBALS['BE_USER']->uc['lang']) && $GLOBALS['BE_USER']->uc['lang'] != '') {
             $lang = $GLOBALS['BE_USER']->uc['lang'];
         }
         if ($this->request->hasArgument('lang')) {
             $lang = $this->request->getArgument('lang');
         }
         if ($this->request->hasArgument('site')) {
             $site = $this->request->getArgument('site');
         }
         $config = Base::getConfig((array) $this->settings);
         $context = Base::getContext($config);
         $locale = Base::getLocaleBackend($context, $site);
         $context->setLocale($locale);
         $i18n = Base::getI18n(array($lang, 'en'), $config->get('i18n', array()));
         $context->setI18n($i18n);
         if ($withView) {
             $view = Base::getView($config, $this->uriBuilder, $templatePaths, $this->request, $lang, false);
             $context->setView($view);
         }
         $this->contextBE = $context;
     }
     return $this->contextBE;
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
0
 /**
  * Creates a new configuration object.
  *
  * @return MW_Config_Interface Configuration object
  */
 protected function getConfig()
 {
     $settings = (array) $this->settings;
     if (isset($this->settings['typo3']['tsconfig'])) {
         $tsconfig = Base::parseTS($this->settings['typo3']['tsconfig']);
         $settings = \TYPO3\CMS\Extbase\Utility\ArrayUtility::arrayMergeRecursiveOverrule($settings, $tsconfig);
     }
     return Base::getConfig($settings);
 }
Ejemplo n.º 4
0
 /**
  * Returns a new context object.
  *
  * @return MShop_Context_Item_Interface Context object
  */
 protected static function getContext()
 {
     $ctx = new \Aimeos\MShop\Context\Item\Standard();
     $conf = \Aimeos\Aimeos\Base::getConfig();
     $ctx->setConfig($conf);
     $dbm = new \Aimeos\MW\DB\Manager\DBAL($conf);
     $ctx->setDatabaseManager($dbm);
     $logger = new \Aimeos\MW\Logger\Errorlog(\Aimeos\MW\Logger\Base::INFO);
     $ctx->setLogger($logger);
     $session = new \Aimeos\MW\Session\None();
     $ctx->setSession($session);
     $cache = new \Aimeos\MW\Cache\None();
     $ctx->setCache($cache);
     return $ctx;
 }
Ejemplo n.º 5
0
 /**
  * Returns the list of categories with their ID.
  *
  * @param array $config Associative array of existing configurations
  * @param \TYPO3\CMS\Backend\Form\FormEngine|\TYPO3\CMS\Backend\Form\DataPreprocessor $tceForms TCE forms object
  * @param string $sitecode Unique code of the site to retrieve the categories for
  * @return array Associative array with existing and new entries
  */
 public function getCategories(array $config, $tceForms = null, $sitecode = 'default')
 {
     if (isset($config['row']) && isset($config['row']['pid'])) {
         $pageTSConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getModTSconfig($config['row']['pid'], 'tx_aimeos');
         if (isset($pageTSConfig['properties']['mshop.']['locale.']['site'])) {
             $sitecode = $pageTSConfig['properties']['mshop.']['locale.']['site'];
         }
     }
     try {
         $context = Base::getContext(Base::getConfig());
         $context->setEditor('flexform');
         $localeManager = \MShop_Locale_Manager_Factory::createManager($context);
         $context->setLocale($localeManager->bootstrap($sitecode, '', '', false));
         $manager = \MShop_Catalog_Manager_Factory::createManager($context);
         $item = $manager->getTree(null, array(), \MW_Tree_Manager_Abstract::LEVEL_TREE);
         $config['items'] = array_merge($config['items'], $this->getCategoryList($item, 0));
     } catch (Exception $e) {
         error_log($e->getMessage() . PHP_EOL . $e->getTraceAsString());
     }
     return $config;
 }
Ejemplo n.º 6
0
 /**
  * Returns a new context object.
  *
  * @return MShop_Context_Item_Interface Context object
  */
 protected static function getContext()
 {
     $ctx = new \MShop_Context_Item_Default();
     $conf = \Aimeos\Aimeos\Base::getConfig();
     $ctx->setConfig($conf);
     $dbm = new \MW_DB_Manager_PDO($conf);
     $ctx->setDatabaseManager($dbm);
     $logger = new \MW_Logger_Errorlog(\MW_Logger_ABSTRACT::INFO);
     $ctx->setLogger($logger);
     $session = new \MW_Session_None();
     $ctx->setSession($session);
     $cache = new \MW_Cache_None();
     $ctx->setCache($cache);
     return $ctx;
 }
Ejemplo n.º 7
-1
 /**
  * Returns the list of categories with their ID.
  *
  * @param array $config Associative array of existing configurations
  * @param \TYPO3\CMS\Backend\Form\FormEngine|\TYPO3\CMS\Backend\Form\DataPreprocessor $tceForms TCE forms object
  * @param string $sitecode Unique code of the site to retrieve the categories for
  * @return array Associative array with existing and new entries
  */
 public function getCategories(array $config, $tceForms = null, $sitecode = 'default')
 {
     if (isset($config['flexParentDatabaseRow']['pid'])) {
         // TYPO3 7+
         $pid = $config['flexParentDatabaseRow']['pid'];
     } elseif (isset($config['row']['pid'])) {
         // TYPO3 6.2
         $pid = $config['row']['pid'];
     }
     $pageTSConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getModTSconfig($pid, 'tx_aimeos');
     if (isset($pageTSConfig['properties']['mshop.']['locale.']['site'])) {
         $sitecode = $pageTSConfig['properties']['mshop.']['locale.']['site'];
     }
     try {
         $context = Base::getContext(Base::getConfig());
         $context->setEditor('flexform');
         $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
         $context->setLocale($localeManager->bootstrap($sitecode, '', '', false));
         $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($context);
         $item = $manager->getTree(null, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE);
         $config['items'] = array_merge($config['items'], $this->getCategoryList($item, $item->getName()));
     } catch (\Exception $e) {
         error_log($e->getMessage() . PHP_EOL . $e->getTraceAsString());
     }
     return $config;
 }