public function importAction() { $this->checkPermission("translations"); $admin = $this->getParam("admin"); $merge = $this->getParam("merge"); $tmpFile = $_FILES["Filedata"]["tmp_name"]; $overwrite = $merge ? false : true; if ($admin) { $delta = Translation\Admin::importTranslationsFromFile($tmpFile, $overwrite, Tool\Admin::getLanguages()); } else { $delta = Translation\Website::importTranslationsFromFile($tmpFile, $overwrite); } $result = array("success" => true); if ($merge) { $enrichedDelta = array(); foreach ($delta as $item) { $lg = $item["lg"]; $item["lgname"] = \Zend_Locale::getTranslation($lg, "language"); $item["icon"] = "/admin/misc/get-language-flag?language=" . $lg; $item["current"] = $item["text"]; $enrichedDelta[] = $item; } $result["delta"] = base64_encode(json_encode($enrichedDelta)); } $this->_helper->json($result, false); // set content-type to text/html, otherwise (when application/json is sent) chrome will complain in // Ext.form.Action.Submit and mark the submission as failed $this->getResponse()->setHeader("Content-Type", "text/html"); }
public function installAdminTranslations() { $csv = PIMCORE_PLUGINS_PATH . '/Toolbox/install/translations/data.csv'; Admin::importTranslationsFromFile($csv, true, \Pimcore\Tool\Admin::getLanguages()); }
/** * install function * @return string $message statusmessage to display in frontend */ public static function install() { //Cart \Pimcore\Resource::get()->query("CREATE TABLE `plugin_onlineshop_cart` (\n `id` int(20) NOT NULL AUTO_INCREMENT,\n `userid` int(20) NOT NULL,\n `name` varchar(250) COLLATE utf8_bin DEFAULT NULL,\n `creationDateTimestamp` int(10) NOT NULL,\n `modificationDateTimestamp` int(10) NOT NULL,\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); //CartCheckoutData \Pimcore\Resource::get()->query("CREATE TABLE `plugin_onlineshop_cartcheckoutdata` (\n `cartId` int(20) NOT NULL,\n `key` varchar(150) COLLATE utf8_bin NOT NULL,\n `data` longtext,\n PRIMARY KEY (`cartId`,`key`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); //CartItem \Pimcore\Resource::get()->query("CREATE TABLE `plugin_onlineshop_cartitem` (\n `productId` int(20) NOT NULL,\n `cartId` int(20) NOT NULL,\n `count` int(20) NOT NULL,\n `itemKey` varchar(100) COLLATE utf8_bin NOT NULL,\n `parentItemKey` varchar(100) COLLATE utf8_bin NOT NULL DEFAULT '0',\n `comment` LONGTEXT ASCII,\n `addedDateTimestamp` int(10) NOT NULL,\n `sortIndex` INT(10) UNSIGNED NULL DEFAULT '0',\n PRIMARY KEY (`itemKey`,`cartId`,`parentItemKey`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); // Voucher Service // Statistics \Pimcore\Resource::get()->query("CREATE TABLE `plugins_onlineshop_vouchertoolkit_statistics` (\n `id` BIGINT(20) NOT NULL AUTO_INCREMENT,\n `voucherSeriesId` BIGINT(20) NOT NULL,\n `date` DATE NOT NULL,\n PRIMARY KEY (`id`)\n )\n COLLATE='utf8_general_ci'\n ENGINE=InnoDB ;"); // Tokens \Pimcore\Resource::get()->query("CREATE TABLE `plugins_onlineshop_vouchertoolkit_tokens` (\n `id` BIGINT(20) NOT NULL AUTO_INCREMENT,\n `voucherSeriesId` BIGINT(20) NULL DEFAULT NULL,\n `token` VARCHAR(250) NULL DEFAULT NULL COLLATE 'latin1_bin',\n `length` INT(11) NULL DEFAULT NULL,\n `type` VARCHAR(50) NULL DEFAULT NULL,\n `usages` BIGINT(20) NULL DEFAULT '0',\n `timestamp` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`),\n UNIQUE INDEX `token` (`token`)\n )\n COLLATE='utf8_general_ci'\n ENGINE=InnoDB;"); // Reservations \Pimcore\Resource::get()->query("CREATE TABLE `plugins_onlineshop_vouchertoolkit_reservations` (\n `id` BIGINT(20) NOT NULL AUTO_INCREMENT,\n `token` VARCHAR(250) NOT NULL,\n `cart_id` VARCHAR(250) NOT NULL,\n `timestamp` DATETIME NOT NULL,\n PRIMARY KEY (`id`),\n INDEX `token` (`token`)\n )\n COLLATE='utf8_general_ci'\n ENGINE=InnoDB\n ;"); // Add FieldCollections $sourceFiles = scandir(PIMCORE_PLUGINS_PATH . '/OnlineShop/install/fieldcollection_sources'); foreach ($sourceFiles as $filename) { if (!is_dir($filename)) { preg_match('/_(.*)_/', $filename, $matches); $key = $matches[1]; try { $fieldCollection = \Pimcore\Model\Object\Fieldcollection\Definition::getByKey($key); } catch (Exception $e) { $fieldCollection = new \Pimcore\Model\Object\Fieldcollection\Definition(); $fieldCollection->setKey($key); } $data = file_get_contents(PIMCORE_PLUGINS_PATH . '/OnlineShop/install/fieldcollection_sources/' . $filename); $success = \Pimcore\Model\Object\ClassDefinition\Service::importFieldCollectionFromJson($fieldCollection, $data); if (!$success) { Logger::err("Could not import {$key} FieldCollection."); } } } // Add classes self::createClass("FilterDefinition", PIMCORE_PLUGINS_PATH . '/OnlineShop/install/class_source/class_FilterDefinition_export.json'); self::createClass("OnlineShopOrderItem", PIMCORE_PLUGINS_PATH . '/OnlineShop/install/class_source/class_OnlineShopOrderItem_export.json'); self::createClass("OnlineShopVoucherSeries", PIMCORE_PLUGINS_PATH . '/OnlineShop/install/class_source/class_OnlineShopVoucherSeries_export.json'); self::createClass("OnlineShopVoucherToken", PIMCORE_PLUGINS_PATH . '/OnlineShop/install/class_source/class_OnlineShopVoucherToken_export.json'); self::createClass("OnlineShopOrder", PIMCORE_PLUGINS_PATH . '/OnlineShop/install/class_source/class_OnlineShopOrder_export.json'); self::createClass("OfferToolOfferItem", PIMCORE_PLUGINS_PATH . '/OnlineShop/install/class_source/class_OfferToolOfferItem_export.json'); self::createClass("OfferToolOffer", PIMCORE_PLUGINS_PATH . '/OnlineShop/install/class_source/class_OfferToolOffer_export.json'); self::createClass("OfferToolCustomProduct", PIMCORE_PLUGINS_PATH . '/OnlineShop/install/class_source/class_OfferToolCustomProduct_export.json'); //copy config file if (!is_file(PIMCORE_WEBSITE_PATH . "/var/plugins/OnlineShop/OnlineShopConfig.xml")) { copy(PIMCORE_PLUGINS_PATH . "/OnlineShop/config/OnlineShopConfig_sample.xml", PIMCORE_WEBSITE_PATH . "/var/plugins/OnlineShop/OnlineShopConfig.xml"); copy(PIMCORE_PLUGINS_PATH . "/OnlineShop/config/.htaccess", PIMCORE_WEBSITE_PATH . "/var/plugins/OnlineShop/.htaccess"); } self::setConfig("/website/var/plugins/OnlineShop/OnlineShopConfig.xml"); // execute installations from subsystems $reflection = new ReflectionClass(__CLASS__); $methods = $reflection->getMethods(ReflectionMethod::IS_STATIC); foreach ($methods as $method) { /* @var ReflectionMethod $method */ if (preg_match('#^install[A-Z]#', $method->name)) { $func = $method->name; $success = self::$func(); } } // import admin-translations \Pimcore\Model\Translation\Admin::importTranslationsFromFile(PIMCORE_PLUGINS_PATH . '/OnlineShop/install/admin-translations/init.csv', true); // create status message if (self::isInstalled()) { $statusMessage = "installed"; // $translate->_("plugin_objectassetfolderrelation_installed_successfully"); } else { $statusMessage = "not installed"; // $translate->_("plugin_objectassetfolderrelation_could_not_install"); } return $statusMessage; }