상속: extends AbstractTranslation
예제 #1
0
 private function translateLabel($key)
 {
     try {
         return \Pimcore\Model\Translation\Admin::getByKeyLocalized($key, false, true);
     } catch (\Exception $e) {
         return $key;
     }
 }
예제 #2
0
 public function addAdminTranslationKeysAction()
 {
     $this->removeViewRenderer();
     $keys = $this->getParam("keys");
     if ($keys) {
         $availableLanguages = Tool\Admin::getLanguages();
         $data = \Zend_Json_Decoder::decode($keys);
         foreach ($data as $translationData) {
             $t = null;
             // reset
             try {
                 $t = Translation\Admin::getByKey($translationData);
             } catch (\Exception $e) {
                 \Logger::log($e);
             }
             if (!$t instanceof Translation\Admin) {
                 $t = new Translation\Admin();
                 $t->setKey($translationData);
                 $t->setCreationDate(time());
                 $t->setModificationDate(time());
                 foreach ($availableLanguages as $lang) {
                     $t->addTranslation($lang, "");
                 }
                 try {
                     $t->save();
                 } catch (\Exception $e) {
                     \Logger::log($e);
                 }
             }
         }
     }
 }
예제 #3
0
 public function getTreeAction()
 {
     $defaultIcon = "/pimcore/static6/img/flat-color-icons/timeline.svg";
     if (!\Pimcore\Tool\Admin::isExtJS6()) {
         $defaultIcon = '/pimcore/static6/img/icon/database_gear.png';
     }
     $classesList = new Object\ClassDefinition\Listing();
     $classesList->setOrderKey("name");
     $classesList->setOrder("asc");
     $classes = $classesList->load();
     // filter classes
     if ($this->getParam("createAllowed")) {
         $tmpClasses = [];
         foreach ($classes as $class) {
             if ($this->getUser()->isAllowed($class->getId(), "class")) {
                 $tmpClasses[] = $class;
             }
         }
         $classes = $tmpClasses;
     }
     $getClassConfig = function ($class) use($defaultIcon) {
         return ["id" => $class->getId(), "text" => $class->getName(), "leaf" => true, "icon" => $class->getIcon() ? $class->getIcon() : $defaultIcon, "propertyVisibility" => $class->getPropertyVisibility(), "qtipCfg" => ["title" => "ID: " . $class->getId()]];
     };
     // build groups
     $groups = [];
     foreach ($classes as $class) {
         if ($class->getGroup()) {
             $type = "manual";
             $groupName = $class->getGroup();
         } else {
             $type = "auto";
             preg_match("@^([A-Za-z])([^A-Z]+)@", $class->getName(), $matches);
             $groupName = $matches[0];
         }
         $groupName = \Pimcore\Model\Translation\Admin::getByKeyLocalized($groupName, true, true);
         if (!isset($groups[$groupName])) {
             $groups[$groupName] = ["classes" => [], "type" => $type];
         }
         $groups[$groupName]["classes"][] = $class;
     }
     $treeNodes = [];
     if (!$this->getParam('grouped')) {
         // list output
         foreach ($groups as $groupName => $groupData) {
             foreach ($groupData["classes"] as $class) {
                 $node = $getClassConfig($class);
                 if (count($groupData["classes"]) > 1 || $groupData["type"] == "manual") {
                     $node["group"] = $groupName;
                 }
                 $treeNodes[] = $node;
             }
         }
     } else {
         // create json output
         foreach ($groups as $groupName => $groupData) {
             if (count($groupData["classes"]) === 1 && $groupData["type"] == "auto") {
                 // no group, only one child
                 $node = $getClassConfig($groupData["classes"][0]);
             } else {
                 // group classes
                 $node = ["id" => "folder_" . $groupName, "text" => $groupName, "leaf" => false, 'expandable' => true, 'allowChildren' => true, 'iconCls' => 'pimcore_icon_folder', "children" => []];
                 foreach ($groupData["classes"] as $class) {
                     $node['children'][] = $getClassConfig($class);
                 }
             }
             $treeNodes[] = $node;
         }
     }
     $this->_helper->json($treeNodes);
 }
예제 #4
0
 public function installAdminTranslations()
 {
     $csv = PIMCORE_PLUGINS_PATH . '/Toolbox/install/translations/data.csv';
     Admin::importTranslationsFromFile($csv, true, \Pimcore\Tool\Admin::getLanguages());
 }
예제 #5
0
파일: Plugin.php 프로젝트: ascertain/NGshop
 /**
  *  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;
 }