示例#1
0
 public function testCreateManagerNotExisting()
 {
     $this->setExpectedException('MShop_Exception');
     $target = 'MShop_Common_Manager_Interface';
     $manager = MShop_Locale_Manager_Factory::createManager(TestHelper::getContext(), 'test');
     $this->assertInstanceOf($target, $manager);
 }
 /**
  * Creates new locale data if necessary
  */
 protected function _process()
 {
     $iface = 'MShop_Context_Item_Interface';
     if (!$this->_additional instanceof $iface) {
         throw new MW_Setup_Exception(sprintf('Additionally provided object is not of type "%1$s"', $iface));
     }
     $this->_msg('Adding locale data if not yet present', 0);
     // Set editor for further tasks
     $this->_additional->setEditor('core:setup');
     $code = $this->_additional->getConfig()->get('setup/site', 'default');
     $localeManager = MShop_Locale_Manager_Factory::createManager($this->_additional, 'Default');
     $siteManager = $localeManager->getSubManager('site');
     try {
         $siteItem = $siteManager->createItem();
         $siteItem->setLabel($code);
         $siteItem->setCode($code);
         $siteManager->insertItem($siteItem);
     } catch (MW_DB_Exception $e) {
         $this->_status('OK');
         return;
     }
     $localeItem = $localeManager->createItem();
     $localeItem->setSiteId($siteItem->getId());
     $localeItem->setLanguageId('en');
     $localeItem->setCurrencyId('EUR');
     $localeManager->saveItem($localeItem, false);
     $this->_status('done');
 }
 /**
  * Adds locale data.
  */
 protected function _process()
 {
     $iface = 'MShop_Context_Item_Interface';
     if (!$this->_additional instanceof $iface) {
         throw new MW_Setup_Exception(sprintf('Additionally provided object is not of type "%1$s"', $iface));
     }
     $this->_msg('Adding locale language and currency data', 0);
     $this->_status('');
     $ds = DIRECTORY_SEPARATOR;
     $localeManager = MShop_Locale_Manager_Factory::createManager($this->_additional, 'Default');
     $filename = dirname(__FILE__) . $ds . 'default' . $ds . 'data' . $ds . 'language.php';
     if (($data = (include $filename)) == false) {
         throw new MW_Setup_Exception(sprintf('No data file "%1$s" found', $filename));
     }
     if (isset($data['locale/language'])) {
         $this->_addLocaleLanguageData($localeManager, $data['locale/language']);
     }
     $filename = dirname(__FILE__) . $ds . 'default' . $ds . 'data' . $ds . 'currency.php';
     if (($data = (include $filename)) == false) {
         throw new MW_Setup_Exception(sprintf('No data file "%1$s" found', $filename));
     }
     if (isset($data['locale/currency'])) {
         $this->_addLocaleCurrencyData($localeManager, $data['locale/currency']);
     }
 }
 /**
  * Adds locale data.
  */
 protected function _process()
 {
     $iface = 'MShop_Context_Item_Interface';
     if (!$this->_additional instanceof $iface) {
         throw new MW_Setup_Exception(sprintf('Additionally provided object is not of type "%1$s"', $iface));
     }
     $this->_msg('Adding data for MShop locale domain', 0);
     $this->_status('');
     // Set editor for further tasks
     $this->_additional->setEditor('core:setup');
     if ($this->_additional->getConfig()->get('setup/site', 'default') === 'default') {
         $ds = DIRECTORY_SEPARATOR;
         $filename = dirname(__FILE__) . $ds . 'data' . $ds . 'locale.php';
         if (($data = (include $filename)) == false) {
             throw new MW_Setup_Exception(sprintf('No data file "%1$s" found', $filename));
         }
         $localeManager = MShop_Locale_Manager_Factory::createManager($this->_additional, 'Default');
         $siteIds = array();
         if (isset($data['locale/site'])) {
             $siteIds = $this->_addLocaleSiteData($localeManager, $data['locale/site']);
         }
         if (isset($data['locale'])) {
             $this->_addLocaleData($localeManager, $data['locale'], $siteIds);
         }
     }
 }
示例#5
0
 protected function setUp()
 {
     $manager = MShop_Locale_Manager_Factory::createManager(TestHelper::getContext());
     $this->_siteItem = $manager->getSubManager('site')->createItem();
     $this->_values = array('id' => 1, 'siteid' => 1, 'langid' => 'de', 'currencyid' => 'EUR', 'pos' => 1, 'status' => 1, 'mtime' => '2011-01-01 00:00:02', 'ctime' => '2011-01-01 00:00:01', 'editor' => 'unitTestUser');
     $this->_object = new MShop_Locale_Item_Default($this->_values, $this->_siteItem, array(1, 2), array(1, 3, 4));
 }
示例#6
0
 /**
  * @param string $site
  */
 private static function _createContext($site)
 {
     $ctx = new MShop_Context_Item_Default();
     $arcavias = self::getArcavias();
     $paths = $arcavias->getConfigPaths('mysql');
     $paths[] = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config';
     $file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser';
     $conf = new MW_Config_Array(array(), $paths);
     $conf = new MW_Config_Decorator_Memory($conf);
     $conf = new MW_Config_Decorator_Documentor($conf, $file);
     $ctx->setConfig($conf);
     $dbm = new MW_DB_Manager_PDO($conf);
     $ctx->setDatabaseManager($dbm);
     $logger = new MW_Logger_File($site . '.log', MW_Logger_Abstract::DEBUG);
     $ctx->setLogger($logger);
     $session = new MW_Session_None();
     $ctx->setSession($session);
     $i18n = new MW_Translation_None('de');
     $ctx->setI18n(array('de' => $i18n));
     $localeManager = MShop_Locale_Manager_Factory::createManager($ctx);
     $locale = $localeManager->bootstrap($site, 'de', '', false);
     $ctx->setLocale($locale);
     $view = self::_createView($conf);
     $ctx->setView($view);
     $ctx->setEditor('core:controller/jobs');
     return $ctx;
 }
 /**
  * Adds order test data.
  */
 protected function _process()
 {
     $iface = 'MShop_Context_Item_Interface';
     if (!$this->_additional instanceof $iface) {
         throw new MW_Setup_Exception(sprintf('Additionally provided object is not of type "%1$s"', $iface));
     }
     $this->_msg('Adding order test data', 0);
     $this->_additional->setEditor('core:unittest');
     $localeManager = MShop_Locale_Manager_Factory::createManager($this->_additional, 'Default');
     $orderManager = MShop_Order_Manager_Factory::createManager($this->_additional, 'Default');
     $orderBaseManager = $orderManager->getSubManager('base');
     $search = $orderBaseManager->createSearch();
     $search->setConditions($search->compare('==', 'order.base.sitecode', array('unittest', 'unit')));
     foreach ($orderBaseManager->searchItems($search) as $order) {
         $orderBaseManager->deleteItem($order->getId());
     }
     $ds = DIRECTORY_SEPARATOR;
     $path = dirname(__FILE__) . $ds . 'data' . $ds . 'order.php';
     if (($testdata = (include $path)) == false) {
         throw new MShop_Exception(sprintf('No file "%1$s" found for order domain', $path));
     }
     $bases = $this->_addOrderBaseData($localeManager, $orderBaseManager, $testdata);
     $bases['items'] = $this->_addOrderBaseProductData($orderBaseManager, $bases, $testdata);
     $bases['items'] = $this->_addOrderBaseServiceData($orderBaseManager, $bases, $testdata);
     //update order bases (getPrice)
     foreach ($bases['items'] as $baseItem) {
         $orderBaseManager->saveItem($baseItem, false);
     }
     $this->_addOrderData($orderManager, $bases['ids'], $testdata);
     $this->_status('done');
 }
 /**
  * Insert records from file containing the SQL records.
  *
  */
 protected function _process()
 {
     $iface = 'MShop_Context_Item_Interface';
     if (!$this->_additional instanceof $iface) {
         throw new MW_Setup_Exception(sprintf('Additionally provided object is not of type "%1$s"', $iface));
     }
     $this->_msg('Adding performance data for MShop locale domain', 0);
     $this->_status('');
     // Set editor for further tasks
     $this->_additional->setEditor('unitperf:core');
     $ds = DIRECTORY_SEPARATOR;
     $filename = dirname(__FILE__) . $ds . 'data' . $ds . 'locale.php';
     if (($testdata = (include $filename)) == false) {
         throw new MW_Setup_Exception(sprintf('No data file "%1$s" found', $filename));
     }
     $localeManager = MShop_Locale_Manager_Factory::createManager($this->_additional);
     $localeSiteManager = $localeManager->getSubManager('site');
     $siteIds = array();
     $search = $localeSiteManager->createSearch();
     $search->setConditions($search->compare('==', 'locale.site.code', 'unitperf'));
     foreach ($localeSiteManager->searchItems($search) as $site) {
         $this->_additional->setLocale($localeManager->bootstrap($site->getCode(), '', '', false));
         $localeSiteManager->deleteItem($site->getId());
     }
     if (isset($testdata['locale/site'])) {
         $siteIds = $this->_addLocaleSiteData($localeManager, $testdata['locale/site']);
     }
     if (isset($testdata['locale'])) {
         $this->_addLocaleData($localeManager, $testdata['locale'], $siteIds);
     }
 }
示例#9
0
 public function testSaveDeleteItem()
 {
     $ctx = TestHelper::getContext();
     $localeManager = MShop_Locale_Manager_Factory::createManager($ctx);
     $siteManager = $localeManager->getSubManager('site');
     $search = $siteManager->createSearch();
     $search->setConditions($search->compare('==', 'locale.site.code', 'unittest'));
     $sites = $siteManager->searchItems($search);
     if (($siteItem = reset($sites)) === false) {
         throw new Controller_ExtJS_Exception(sprintf('Site item for code "%1$s" not found', $site));
     }
     $localeItem = $localeManager->createItem();
     $localeItem->setCurrencyId('EUR');
     $localeItem->setLanguageId('en');
     $localeItem->setSiteId($siteItem->getId());
     $manager = MShop_Order_Manager_Factory::createManager($ctx);
     $baseManager = $manager->getSubManager('base');
     $baseItem = $baseManager->createItem();
     $baseItem->setCustomerId('unituser');
     $baseItem->setComment('FoooBar');
     $baseItem->setLocale($localeItem);
     $baseManager->saveItem($baseItem);
     $saveParams = (object) array('site' => 'unittest', 'items' => (object) array('order.base.address.id' => null, 'order.base.address.baseid' => $baseItem->getId(), 'order.base.address.addressid' => '-1', 'order.base.address.type' => 'payment', 'order.base.address.company' => 'MusterMax', 'order.base.address.vatid' => 'DE999999999', 'order.base.address.salutation' => MShop_Common_Item_Address_Abstract::SALUTATION_MR, 'order.base.address.title' => 'Herr', 'order.base.address.firstname' => 'Max', 'order.base.address.lastname' => 'Mustermann', 'order.base.address.address1' => 'Addresse 1', 'order.base.address.address2' => 'Addresse 2', 'order.base.address.address3' => 'Addresse 3', 'order.base.address.postal' => '22222', 'order.base.address.city' => 'Hamburg', 'order.base.address.state' => 'Hamburg', 'order.base.address.countryid' => 'en', 'order.base.address.languageid' => 'en', 'order.base.address.telephone' => '0815-4711', 'order.base.address.email' => '*****@*****.**', 'order.base.address.telefax' => '0815-4712', 'order.base.address.website' => 'www.metaways.de'));
     $searchParams = (object) array('site' => 'unittest', 'condition' => (object) array('&&' => array(0 => array('==' => (object) array('order.base.address.type' => 'payment')), 1 => array('==' => (object) array('order.base.address.baseid' => $baseItem->getId())))));
     $savedAddress = $this->_object->saveItems($saveParams);
     $searched = $this->_object->searchItems($searchParams);
     $deleteParamsAddr = (object) array('site' => 'unittest', 'items' => $savedAddress['items']->{'order.base.address.id'});
     $this->_object->deleteItems($deleteParamsAddr);
     $baseManager->deleteItem($baseItem->getId());
     $this->assertInternalType('object', $savedAddress['items']);
     $this->assertNotNull($savedAddress['items']->{'order.base.address.id'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.id'}, $searched['items'][0]->{'order.base.address.id'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.baseid'}, $searched['items'][0]->{'order.base.address.baseid'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.addressid'}, $searched['items'][0]->{'order.base.address.addressid'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.type'}, $searched['items'][0]->{'order.base.address.type'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.company'}, $searched['items'][0]->{'order.base.address.company'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.vatid'}, $searched['items'][0]->{'order.base.address.vatid'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.salutation'}, $searched['items'][0]->{'order.base.address.salutation'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.title'}, $searched['items'][0]->{'order.base.address.title'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.firstname'}, $searched['items'][0]->{'order.base.address.firstname'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.lastname'}, $searched['items'][0]->{'order.base.address.lastname'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.address1'}, $searched['items'][0]->{'order.base.address.address1'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.address2'}, $searched['items'][0]->{'order.base.address.address2'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.address3'}, $searched['items'][0]->{'order.base.address.address3'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.postal'}, $searched['items'][0]->{'order.base.address.postal'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.city'}, $searched['items'][0]->{'order.base.address.city'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.state'}, $searched['items'][0]->{'order.base.address.state'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.countryid'}, $searched['items'][0]->{'order.base.address.countryid'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.languageid'}, $searched['items'][0]->{'order.base.address.languageid'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.telephone'}, $searched['items'][0]->{'order.base.address.telephone'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.email'}, $searched['items'][0]->{'order.base.address.email'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.telefax'}, $searched['items'][0]->{'order.base.address.telefax'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.website'}, $searched['items'][0]->{'order.base.address.website'});
     $this->assertEquals(1, count($searched['items']));
     $searched = $this->_object->searchItems($searchParams);
     $this->assertEquals(0, $searched['total']);
     $this->assertTrue($searched['success']);
 }
示例#10
0
 /**
  * Returns the enabled site items which may be limited by the input arguments.
  *
  * @param \MShop_Context_Item_Interface $context Context item object
  * @param InputInterface $input Input object
  * @return \MShop_Locale_Item_Site_Interface[] List of site items
  */
 protected function getSiteItems(\MShop_Context_Item_Interface $context, InputInterface $input)
 {
     $manager = \MShop_Locale_Manager_Factory::createManager($context)->getSubManager('site');
     $search = $manager->createSearch();
     if (($codes = (string) $input->getArgument('site')) !== '') {
         $search->setConditions($search->compare('==', 'locale.site.code', explode(' ', $codes)));
     }
     return $manager->searchItems($search);
 }
示例#11
0
 /**
  * Adds locale data.
  */
 protected function _process()
 {
     $iface = 'MShop_Context_Item_Interface';
     if (!$this->_additional instanceof $iface) {
         throw new MW_Setup_Exception(sprintf('Additionally provided object is not of type "%1$s"', $iface));
     }
     $site = $this->_additional->getConfig()->get('setup/site', 'default');
     $this->_msg(sprintf('Setting locale to "%1$s"', $site), 0);
     // Set locale for further tasks
     $localeManager = MShop_Locale_Manager_Factory::createManager($this->_additional, 'Default');
     $this->_additional->setLocale($localeManager->bootstrap($site, '', '', false));
     $this->_status('OK');
 }
示例#12
0
 /**
  * Returns a context object
  *
  * @return \MShop_Context_Item_Default Context object
  */
 protected function getContext()
 {
     $lv = $this->getLaravel();
     $context = $lv->make('\\Aimeos\\Shop\\Base\\Context')->get(false);
     $tmplPaths = $lv->make('\\Aimeos\\Shop\\Base\\Aimeos')->get()->getCustomPaths('controller/jobs/layouts');
     $view = $lv->make('\\Aimeos\\Shop\\Base\\View')->create($context->getConfig(), $tmplPaths);
     $langManager = \MShop_Locale_Manager_Factory::createManager($context)->getSubManager('language');
     $langids = array_keys($langManager->searchItems($langManager->createSearch(true)));
     $i18n = $lv->make('\\Aimeos\\Shop\\Base\\I18n')->get($langids);
     $context->setEditor('aimeos:jobs');
     $context->setView($view);
     $context->setI18n($i18n);
     return $context;
 }
示例#13
0
 public function testIsAvailable()
 {
     $orderBaseManager = MShop_Order_Manager_Factory::createManager(TestHelper::getContext())->getSubManager('base');
     $localeManager = MShop_Locale_Manager_Factory::createManager(TestHelper::getContext());
     $localeItem = $localeManager->createItem();
     $orderBaseDeItem = $orderBaseManager->createItem();
     $localeItem->setLanguageId('de');
     $orderBaseDeItem->setLocale($localeItem);
     $orderBaseEnItem = $orderBaseManager->createItem();
     $localeItem->setLanguageId('en');
     $orderBaseEnItem->setLocale($localeItem);
     $this->assertFalse($this->_object->isAvailable($orderBaseDeItem));
     $this->assertTrue($this->_object->isAvailable($orderBaseEnItem));
 }
示例#14
0
 /**
  * Executes the job controllers.
  *
  * @param InputInterface $input Input object
  * @param OutputInterface $output Output object
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $context = $this->getContainer()->get('aimeos_context')->get(false);
     $context->setEditor('aimeos:cache');
     $localeManager = \MShop_Locale_Manager_Factory::createManager($context);
     foreach ($this->getSiteItems($context, $input) as $siteItem) {
         $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false);
         $lcontext = clone $context;
         $lcontext->setLocale($localeItem);
         $cache = new \MAdmin_Cache_Proxy_Default($lcontext);
         $lcontext->setCache($cache);
         $output->writeln(sprintf('Clearing the Aimeos cache for site <info>%1$s</info>', $siteItem->getCode()));
         \MAdmin_Cache_Manager_Factory::createManager($lcontext)->getCache()->flush();
     }
 }
示例#15
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $context = $this->getLaravel()->make('Aimeos\\Shop\\Base\\Context')->get(false);
     $context->setEditor('aimeos:cache');
     $localeManager = \MShop_Locale_Manager_Factory::createManager($context);
     foreach ($this->getSiteItems($context, $this->argument('site')) as $siteItem) {
         $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false);
         $lcontext = clone $context;
         $lcontext->setLocale($localeItem);
         $cache = new \MAdmin_Cache_Proxy_Default($lcontext);
         $lcontext->setCache($cache);
         $this->info(sprintf('Clearing the Aimeos cache for site "%1$s"', $siteItem->getCode()));
         \MAdmin_Cache_Manager_Factory::createManager($lcontext)->getCache()->flush();
     }
 }
示例#16
0
 public function testGetBody()
 {
     $manager = MShop_Locale_Manager_Factory::createManager(TestHelper::getContext());
     $item = $manager->createItem();
     $view = $this->_object->getView();
     $view->selectCurrencyId = 'EUR';
     $view->selectLanguageId = 'de';
     $view->selectItems = array('de' => array('EUR' => $item, 'CHF' => $item), 'en' => array('USD' => $item));
     $tags = array();
     $expire = null;
     $output = $this->_object->getBody(1, $tags, $expire);
     $this->assertStringStartsWith('<div class="locale-select-language">', $output);
     $this->assertContains('<li class="select-dropdown select-current"><a href="#">de', $output);
     $this->assertContains('<li class="select-item active">', $output);
     $this->assertEquals(0, count($tags));
     $this->assertEquals(null, $expire);
 }
示例#17
0
 /**
  * Creates a new context item.
  *
  * @param string $site Unique site code
  * @return \MShop_Context_Item_Interface Context object
  */
 private static function _createContext($site)
 {
     $ctx = new MShop_Context_Item_Default();
     $mshop = self::_getAimeos();
     $paths = $mshop->getConfigPaths('mysql');
     $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config';
     $conf = new MW_Config_Array(array(), $paths);
     $ctx->setConfig($conf);
     $dbm = new MW_DB_Manager_PDO($conf);
     $ctx->setDatabaseManager($dbm);
     $logger = new MW_Logger_File($site . '.log', MW_Logger_Abstract::DEBUG);
     $ctx->setLogger($logger);
     $session = new MW_Session_None();
     $ctx->setSession($session);
     $localeManager = MShop_Locale_Manager_Factory::createManager($ctx);
     $localeItem = $localeManager->bootstrap($site, '', '', false);
     $ctx->setLocale($localeItem);
     $ctx->setEditor('ai-symfony:unittest');
     return $ctx;
 }
示例#18
0
 private static function _createContext($site)
 {
     $ctx = new MShop_Context_Item_Default();
     $arcavias = self::_getArcavias();
     $paths = $arcavias->getConfigPaths('mysql');
     $paths[] = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config';
     $conf = new MW_Config_Array(array(), $paths);
     $conf = new MW_Config_Decorator_Memory($conf);
     $ctx->setConfig($conf);
     $dbm = new MW_DB_Manager_PDO($conf);
     $ctx->setDatabaseManager($dbm);
     $logger = new MW_Logger_File($site . '.log', MW_Logger_Abstract::DEBUG);
     $ctx->setLogger($logger);
     $session = new MW_Session_None();
     $ctx->setSession($session);
     $localeManager = MShop_Locale_Manager_Factory::createManager($ctx);
     $locale = $localeManager->bootstrap($site, '', '', false);
     $ctx->setLocale($locale);
     $ctx->setEditor('<extname>:controller/frontend');
     return $ctx;
 }
示例#19
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;
 }
示例#20
0
 /**
  * Retrieves all items matching the given criteria.
  *
  * @param stdClass $params Associative array containing the parameters
  * @return array List of associative arrays with item properties, total number of items and success property
  */
 public function searchItems(stdClass $params)
 {
     $manager = $this->_getManager();
     $total = 0;
     $search = $manager->createSearch();
     if (isset($params->options->showall) && $params->options->showall == false) {
         $localeManager = MShop_Locale_Manager_Factory::createManager($this->_getContext());
         $langids = array();
         foreach ($localeManager->searchItems($localeManager->createSearch()) as $item) {
             $langids[] = $item->getLanguageId();
         }
         if (!empty($langids)) {
             $search->setConditions($search->compare('==', 'locale.language.id', $langids));
         }
     }
     $search = $this->_initCriteria($search, $params);
     $sort = $search->getSortations();
     $sort[] = $search->sort('+', 'locale.language.label');
     $search->setSortations($sort);
     $items = $this->_getManager()->searchItems($search, array(), $total);
     return array('items' => $this->_toArray($items), 'total' => $total, 'success' => true);
 }
示例#21
0
 /**
  * @param string $site
  */
 private static function _createContext($site)
 {
     $ctx = new MShop_Context_Item_Default();
     $aimeos = self::_getAimeos();
     $paths = $aimeos->getConfigPaths('mysql');
     $paths[] = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config';
     $conf = new MW_Config_Array(array(), $paths);
     $ctx->setConfig($conf);
     $dbm = new MW_DB_Manager_PDO($conf);
     $ctx->setDatabaseManager($dbm);
     $logger = new MW_Logger_File($site . '.log', MW_Logger_Abstract::DEBUG);
     $ctx->setLogger($logger);
     $i18n = new MW_Translation_None('de');
     $ctx->setI18n(array('de' => $i18n));
     $session = new MW_Session_None();
     $ctx->setSession($session);
     $localeManager = MShop_Locale_Manager_Factory::createManager($ctx);
     $localeItem = $localeManager->bootstrap($site, '', '', false);
     $ctx->setLocale($localeItem);
     $ctx->setEditor('ai-swiftmailer:lib/custom');
     return $ctx;
 }
示例#22
0
 public function testSetLocale()
 {
     $locale = MShop_Locale_Manager_Factory::createManager(TestHelper::getContext())->createItem();
     $this->_object->setLocale($locale);
     $this->assertEquals($locale, $this->_object->getLocale());
     $this->assertTrue($this->_object->isModified());
 }
示例#23
0
 /**
  * Gets all data and exports it to the content files.
  *
  * @param array $ids List of item IDs that should be part of the document
  * @param array $lang List of languages to export (empty array for all)
  * @param string $filename Temporary folder name where to write export files
  * @return string Path to the exported file
  */
 protected function _exportData(array $ids, array $lang, $filename)
 {
     $context = $this->_getContext();
     $manager = MShop_Locale_Manager_Factory::createManager($context);
     $globalLanguageManager = $manager->getSubManager('language');
     $search = $globalLanguageManager->createSearch();
     $search->setSortations(array($search->sort('+', 'locale.language.id')));
     if (!empty($lang)) {
         $search->setConditions($search->compare('==', 'locale.language.id', $lang));
     }
     /** controller/extjs/catalog/export/text/default/container/type
      * Container file type storing all language files for the exported texts
      *
      * When exporting texts, one file or content object is created per
      * language. All those files or content objects are put into one container
      * file so editors don't have to download one file for each language.
      *
      * The container file types that are supported by default are:
      * * Zip
      *
      * Extensions implement other container types like spread sheets, XMLs or
      * more advanced ways of handling the exported data.
      *
      * @param string Container file type
      * @since 2014.03
      * @category Developer
      * @category User
      */
     /** controller/extjs/catalog/export/text/default/container/format
      * Format of the language files for the exported texts
      *
      * The exported texts are stored in one file or content object per
      * language. The format of that file or content object can be configured
      * with this option but most formats are bound to a specific container
      * type.
      *
      * The formats that are supported by default are:
      * * CSV (requires container type "Zip")
      *
      * Extensions implement other container types like spread sheets, XMLs or
      * more advanced ways of handling the exported data.
      *
      * @param string Content file type
      * @since 2014.03
      * @category Developer
      * @category User
      */
     /** controller/extjs/catalog/export/text/default/container/options
      * Options changing the output format of the exported texts
      *
      * Each content format may support some configuration options to change
      * the output for that content type.
      *
      * The options for the CSV content format are:
      * * csv-separator, default ','
      * * csv-enclosure, default '"'
      * * csv-escape, default '"'
      * * csv-lineend, default '\n'
      *
      * For format options provided by other container types implemented by
      * extensions, please have a look into the extension documentation.
      *
      * @param array Associative list of options with the name as key and its value
      * @since 2014.03
      * @category Developer
      * @category User
      */
     $containerItem = $this->_createContainer($filename, 'controller/extjs/catalog/export/text/default/container');
     $actualLangid = $context->getLocale()->getLanguageId();
     $start = 0;
     do {
         $result = $globalLanguageManager->searchItems($search);
         foreach ($result as $item) {
             $langid = $item->getId();
             $contentItem = $containerItem->create($langid);
             $contentItem->add(array('Language ID', 'Catalog label', 'Catalog ID', 'List type', 'Text type', 'Text ID', 'Text'));
             $context->getLocale()->setLanguageId($langid);
             $this->_addLanguage($contentItem, $langid, $ids);
             $containerItem->add($contentItem);
         }
         $count = count($result);
         $start += $count;
         $search->setSlice($start);
     } while ($count == $search->getSliceSize());
     $context->getLocale()->setLanguageId($actualLangid);
     $containerItem->close();
     return $containerItem->getName();
 }
示例#24
0
 /**
  * Returns the locale item for the current request
  *
  * @param \MShop_Context_Item_Interface $context Context object
  * @return \MShop_Locale_Item_Interface Locale item object
  */
 protected function getLocale(\MShop_Context_Item_Interface $context)
 {
     if ($this->locale === null) {
         $site = \Route::input('site', 'default');
         $lang = \Route::input('locale', '');
         $currency = \Route::input('currency', '');
         $disableSites = $this->config->has('shop.disableSites');
         $localeManager = \MShop_Locale_Manager_Factory::createManager($context);
         $this->locale = $localeManager->bootstrap($site, $lang, $currency, $disableSites);
     }
     return $this->locale;
 }
示例#25
0
 protected function setUp()
 {
     $this->_editor = TestHelper::getContext()->getEditor();
     $this->_object = MShop_Locale_Manager_Factory::createManager(TestHelper::getContext());
 }
示例#26
0
 /**
  * Initializes the locale controller.
  *
  * @param MShop_Context_Item_Interface $context MShop context object
  */
 public function __construct(MShop_Context_Item_Interface $context)
 {
     parent::__construct($context, 'Locale');
     $this->_manager = MShop_Locale_Manager_Factory::createManager($context);
 }
示例#27
0
 /**
  * Returns the locale item for the current request
  *
  * @param \MShop_Context_Item_Interface $context Context object
  * @param \TYPO3\Flow\Mvc\RequestInterface $request Request object
  * @return \MShop_Locale_Item_Interface Locale item object
  */
 protected function getLocale(\MShop_Context_Item_Interface $context, \TYPO3\Flow\Mvc\RequestInterface $request)
 {
     if ($this->locale === null) {
         $params = $request->getArguments();
         $site = isset($params['site']) ? $params['site'] : 'default';
         $lang = isset($params['locale']) ? $params['locale'] : '';
         $currency = isset($params['currency']) ? $params['currency'] : '';
         $disableSites = (bool) (isset($this->settings['flow']['disableSites']) ? $this->settings['flow']['disableSites'] : false);
         $localeManager = \MShop_Locale_Manager_Factory::createManager($context);
         $this->locale = $localeManager->bootstrap($site, $lang, $currency, $disableSites);
     }
     return $this->locale;
 }
示例#28
0
 /**
  * Retrieves all items matching the given criteria.
  *
  * @param stdClass $params Associative array containing the parameters
  * @return array List of associative arrays with item properties, total number of items and success property
  */
 public function searchItems(stdClass $params)
 {
     $manager = $this->_getManager();
     $total = 0;
     $search = $manager->createSearch();
     /** controller/extjs/locale/language/default/showall
      * Displays all available languages in lists instead of only the used ones
      *
      * By default, all available languages are shown in the lists displaying
      * languages in the administration interface, e.g. in text or media panels.
      * The content of these lists can be limited to the languages used by the
      * locales created for a site. This can help editors to manage content
      * faster.
      *
      * @param boolean True for all languages, false for only the ones used by existing locales
      * @since 2014.03
      * @category Developer
      * @category User
      */
     if (!$this->_getContext()->getConfig()->get('controller/extjs/locale/language/default/showall', true)) {
         $localeManager = MShop_Locale_Manager_Factory::createManager($this->_getContext());
         $langids = array();
         foreach ($localeManager->searchItems($localeManager->createSearch()) as $item) {
             $langids[] = $item->getLanguageId();
         }
         if (!empty($langids)) {
             $search->setConditions($search->compare('==', 'locale.language.id', $langids));
         }
     }
     $search = $this->_initCriteria($search, $params);
     $sort = $search->getSortations();
     $sort[] = $search->sort('+', 'locale.language.label');
     $search->setSortations($sort);
     $items = $this->_getManager()->searchItems($search, array(), $total);
     return array('items' => $this->_toArray($items), 'total' => $total, 'success' => true);
 }
 /**
  * Returns a context object for the jobs command
  *
  * @return \MShop_Context_Item_Default Context object
  */
 protected function getContext()
 {
     $aimeos = $this->objectManager->get('\\Aimeos\\Shop\\Base\\Aimeos')->get();
     $tmplPaths = $aimeos->getCustomPaths('controller/jobs/layouts');
     $uriBuilder = $this->objectManager->get('\\TYPO3\\Flow\\Mvc\\Routing\\UriBuilder');
     $context = $this->objectManager->get('\\Aimeos\\Shop\\Base\\Context')->get();
     $langManager = \MShop_Locale_Manager_Factory::createManager($context)->getSubManager('language');
     $langids = array_keys($langManager->searchItems($langManager->createSearch(true)));
     $i18n = $this->objectManager->get('\\Aimeos\\Shop\\Base\\I18n')->get($langids);
     $view = $this->objectManager->get('\\Aimeos\\Shop\\Base\\View')->create($context->getConfig(), $uriBuilder, $tmplPaths);
     $context->setEditor('aimeos:jobs');
     $context->setView($view);
     $context->setI18n($i18n);
     return $context;
 }
示例#30
0
 /**
  * Returns the locale object for the context
  *
  * @param \MShop_Context_Item_Interface $context Context object
  * @return \MShop_Locale_Item_Interface Locale item object
  */
 protected function getLocale(\MShop_Context_Item_Interface $context)
 {
     if (!isset(self::$locale)) {
         $session = $context->getSession();
         $config = $context->getConfig();
         $sitecode = $config->get('mshop/locale/site', 'default');
         $name = $config->get('typo3/param/name/site', 'loc-site');
         if ($this->request->hasArgument($name) === true) {
             $sitecode = $this->request->getArgument($name);
         }
         $langid = $config->get('mshop/locale/language', '');
         $name = $config->get('typo3/param/name/language', 'loc-language');
         if (isset($GLOBALS['TSFE']->config['config']['language'])) {
             $langid = $GLOBALS['TSFE']->config['config']['language'];
         }
         if ($this->request->hasArgument($name) === true) {
             $langid = $this->request->getArgument($name);
         }
         $currency = $config->get('mshop/locale/currency', '');
         $name = $config->get('typo3/param/name/currency', 'loc-currency');
         if ($this->request->hasArgument($name) === true) {
             $currency = $this->request->getArgument($name);
         }
         $localeManager = \MShop_Locale_Manager_Factory::createManager($context);
         self::$locale = $localeManager->bootstrap($sitecode, $langid, $currency);
     }
     return self::$locale;
 }