/** * @param array $config */ public function config($config = []) { $settings = null; // check for an initial configuration template // used eg. by the demo installer $configTemplatePath = PIMCORE_CONFIGURATION_DIRECTORY . "/system.template.php"; if (file_exists($configTemplatePath)) { try { $configTemplate = new \Zend_Config(include $configTemplatePath); if ($configTemplate->general) { // check if the template contains a valid configuration $settings = $configTemplate->toArray(); // unset database configuration unset($settings["database"]["params"]["host"]); unset($settings["database"]["params"]["port"]); } } catch (\Exception $e) { } } // set default configuration if no template is present if (!$settings) { // write configuration file $settings = ["general" => ["timezone" => "Europe/Berlin", "language" => "en", "validLanguages" => "en", "debug" => "1", "debugloglevel" => "debug", "custom_php_logfile" => "1", "extjs6" => "1"], "database" => ["adapter" => "Mysqli", "params" => ["username" => "root", "password" => "", "dbname" => ""]], "documents" => ["versions" => ["steps" => "10"], "default_controller" => "default", "default_action" => "default", "error_pages" => ["default" => "/"], "createredirectwhenmoved" => "", "allowtrailingslash" => "no", "generatepreview" => "1"], "objects" => ["versions" => ["steps" => "10"]], "assets" => ["versions" => ["steps" => "10"]], "services" => [], "cache" => ["excludeCookie" => ""], "httpclient" => ["adapter" => "Zend_Http_Client_Adapter_Socket"]]; } $settings = array_replace_recursive($settings, $config); // create initial /website/var folder structure // @TODO: should use values out of startup.php (Constants) $varFolders = ["areas", "assets", "backup", "cache", "classes", "config", "email", "log", "plugins", "recyclebin", "search", "system", "tmp", "versions", "webdav"]; foreach ($varFolders as $folder) { \Pimcore\File::mkdir(PIMCORE_WEBSITE_VAR . "/" . $folder); } $configFile = \Pimcore\Config::locateConfigFile("system.php"); File::putPhpFile($configFile, to_php_data_file_format($settings)); }
public function installConfigFile() { if (!is_file($this->configFile)) { $settings = array("accordion" => ["configElements" => [["type" => "select", "name" => "type", "title" => "Type", "values" => ["panel-default" => "Default", "panel-danger" => "Dangers"], "default" => "panel-default"], ["type" => "additionalClasses", "values" => []]]], "columns" => ["configElements" => [["type" => "select", "name" => "type", "title" => "Columns", "values" => ["column_12" => "1 Column", "column_4_8" => "2 Columns (33:66)", "column_8_4" => "2 Columns (66:33)", "column_3_9" => "2 Columns (25:75)", "column_9_3" => "2 Columns (75:25)", "column_6_6" => "2 Columns (50:50)", "column_4_4_4" => "3 Columns (33:33:33)"], "default" => "column_12"], ["type" => "checkbox", "name" => "equalHeight", "title" => "Equal heights?", "reload" => FALSE]]], "slideColumns" => ["configElements" => [["type" => "select", "name" => "slidesPerView", "title" => "Slides per View", "values" => ["2" => "2 Columns", "3" => "3 Columns", "4" => "4 Columns", "6" => "6 Columns"], "default" => "4"], ["type" => "checkbox", "name" => "equalHeight", "title" => "Equal heights?", "reload" => FALSE]], "columnClasses" => ["2" => "col-xs-12 col-sm-6"], "breakpoints" => []], "content" => ["configElements" => [["type" => "additionalClasses", "values" => []]]], "download" => ["configElements" => [["type" => "additionalClasses", "values" => []]]], "gallery" => ["configElements" => [["type" => "additionalClasses", "values" => []]]], "headline" => ["configElements" => [["type" => "select", "name" => "headlineType", "title" => "Headline Size", "values" => ["h1" => "Headline 1", "h2" => "Headline 2", "h3" => "Headline 3", "h4" => "Headline 4", "h5" => "Headline 5", "h6" => "Headline 6"], "default" => "h3"], ["type" => "additionalClasses", "values" => []]]], "image" => ["configElements" => [["type" => "additionalClasses", "values" => []]]], "linklist" => ["configElements" => [["type" => "additionalClasses", "values" => []]]], "parallaxContainer" => ["configElements" => [["type" => "select", "name" => "type", "title" => "Type", "values" => ["image" => "Image", "snippet" => "Snippet"], "default" => "image"], ["type" => "additionalClasses", "values" => ["window-full-height" => "min. window height"]]]], "separator" => ["configElements" => [["type" => "select", "name" => "space", "title" => "Space before & after separator", "values" => ["default" => "Default", "medium" => "Medium", "large" => "Large"], "default" => "default"], ["type" => "additionalClasses", "values" => []]]], "teaser" => ["configElements" => [["type" => "select", "name" => "type", "title" => "Type", "values" => ["direct" => "Direct", "snippet" => "Snippet"], "default" => "direct"], ["type" => "select", "name" => "layout", "title" => "Layout", "values" => ["default" => "Default"], "default" => "default", "conditions" => [["type" => "direct"]]], ["type" => "checkbox", "name" => "useLightBox", "title" => "use Lightbox?"], ["type" => "additionalClasses", "values" => []]]], "video" => ["configElements" => [["type" => "additionalClasses", "values" => []], ["type" => "checkbox", "name" => "autoplay", "title" => "Autoplay?"]]], "googleMap" => ["configElements" => [], "mapOptions" => ["streetViewControl" => TRUE, "mapTypeControl" => FALSE, "panControl" => FALSE, "scrollwheel" => FALSE], "mapStyleUrl" => FALSE, "markerIcon" => FALSE], "ckeditor" => ["styles" => [['name' => 'test', 'element' => 'p', 'attributes' => ['class' => 'h5']]]], "disallowedSubAreas" => ["accordion" => ["accordion", "container", "slideColumns"], "columns" => ["container"], "slideColumns" => ["slideColumns", "accordion", "container", "columns", "anchor"], "container" => ["container"], "image" => ["parallaxContainer"], "snippet" => ["parallaxContainer"]], "disallowedContentSnippetAreas" => ["parallaxContainer", "teaser", "container", "snippet"], "areaBlockConfiguration" => ["toolbar" => ["title" => "Inhaltsbausteine", "width" => 200, "x" => 10, "y" => 125, "buttonWidth" => 200], "groups" => FALSE]); \Pimcore\File::putPhpFile($this->configFile, to_php_data_file_format($settings)); } }
public function saveAction() { $this->checkPermission("system_settings"); $values = \Zend_Json::decode($this->getParam("data")); $configFile = \Pimcore\Config::locateConfigFile("reports.php"); File::put($configFile, to_php_data_file_format($values)); $this->_helper->json(array("success" => true)); }
protected function execute(InputInterface $input, OutputInterface $output) { $source = "http://unicode.org/repos/cldr/trunk/common/supplemental/supplementalData.xml"; $data = file_get_contents($source); $xml = simplexml_load_string($data, null, LIBXML_NOCDATA); $languageRawData = []; foreach ($xml->territoryInfo->territory as $territory) { foreach ($territory->languagePopulation as $language) { $languageCode = (string) $language["type"]; if (\Zend_Locale::isLocale($languageCode)) { $populationAbsolute = $territory["population"] * $language["populationPercent"] / 100; if (!isset($languageRawData[$languageCode])) { $languageRawData[$languageCode] = []; } if (\Zend_Locale::isLocale($languageCode . "_" . $territory["type"], true)) { $languageRawData[$languageCode][] = ["country" => (string) $territory["type"], "population" => $populationAbsolute]; } } } } $finalData = []; foreach ($languageRawData as $languageCode => $rawLanguage) { usort($rawLanguage, function ($a, $b) { if ($a["population"] == $b["population"]) { return 0; } return $a["population"] > $b["population"] ? -1 : 1; }); $finalData[$languageCode] = []; foreach ($rawLanguage as $territory) { $finalData[$languageCode][] = $territory["country"]; } } $contents = to_php_data_file_format($finalData); $dataFile = PIMCORE_PATH . "/config/data/cldr-language-territory-mapping.php"; File::putPhpFile($dataFile, $contents); $this->output->writeln("Updated mappings in " . $dataFile); }
/** * @static * @param \Zend_Config $config * @return void */ public static function setConfig(\Zend_Config $config) { self::$config = $config; $file = \Pimcore\Config::locateConfigFile("extensions.php"); File::put($file, to_php_data_file_format(self::$config->toArray())); }
/** * @param $name * @param $value */ public static function setFlag($name, $value) { $settings = self::getSystemConfig()->toArray(); if (!isset($settings["flags"])) { $settings["flags"] = []; } $settings["flags"][$name] = $value; $configFile = \Pimcore\Config::locateConfigFile("system.php"); File::putPhpFile($configFile, to_php_data_file_format($settings)); }
public function setWeb2printAction() { $this->checkPermission("web2print_settings"); $values = \Zend_Json::decode($this->getParam("data")); if ($values['wkhtml2pdfOptions']) { $optionArray = []; $lines = explode("\n", $values['wkhtml2pdfOptions']); foreach ($lines as $line) { $parts = explode(" ", substr($line, 2)); $key = trim($parts[0]); if ($key) { $value = trim($parts[1]); $optionArray[$key] = $value; } } $values['wkhtml2pdfOptions'] = $optionArray; } $configFile = \Pimcore\Config::locateConfigFile("web2print.php"); File::putPhpFile($configFile, to_php_data_file_format($values)); $this->_helper->json(["success" => true]); }
/** * @param null $sessionId * @throws \Exception * @throws \Zend_Config_Exception */ public static function activateMaintenanceMode($sessionId = null) { if (empty($sessionId)) { $sessionId = session_id(); } if (empty($sessionId)) { throw new \Exception("It's not possible to activate the maintenance mode without a session-id"); } File::put(self::getMaintenanceModeFile(), to_php_data_file_format(["sessionId" => $sessionId])); @chmod(self::getMaintenanceModeFile(), 0777); // so it can be removed also via FTP, ... }
/** * CUSTOM VIEWS */ public function saveCustomviewsAction() { $success = true; $settings = ["views" => []]; for ($i = 0; $i < 1000; $i++) { if ($this->getParam("name_" . $i)) { $classes = $this->getParam("classes_" . $i); if (is_array($classes) || \Pimcore\Tool\Admin::isExtJS6()) { $classes = implode(',', $classes); } // check for root-folder $rootfolder = "/"; if ($this->getParam("rootfolder_" . $i)) { $rootfolder = $this->getParam("rootfolder_" . $i); } $settings["views"][] = array("name" => $this->getParam("name_" . $i), "condition" => $this->getParam("condition_" . $i), "icon" => $this->getParam("icon_" . $i), "id" => $i + 1, "rootfolder" => $rootfolder, "showroot" => $this->getParam("showroot_" . $i) == "true" ? true : false, "classes" => $classes); } } $configFile = \Pimcore\Config::locateConfigFile("customviews.php"); File::put($configFile, to_php_data_file_format($settings)); $this->_helper->json(array("success" => $success)); }
/** * */ protected function save() { $contents = to_php_data_file_format($this->data); File::putPhpFile($this->filePath, $contents); }
/** * */ protected function save() { $contents = to_php_data_file_format($this->data); File::put($this->filePath, $contents); if (function_exists("opcache_reset")) { opcache_reset(); } }
public function setSystemAction() { $this->checkPermission("system_settings"); $values = \Zend_Json::decode($this->getParam("data")); // email settings $oldConfig = Config::getSystemConfig(); $oldValues = $oldConfig->toArray(); // fallback languages $fallbackLanguages = array(); $languages = explode(",", $values["general.validLanguages"]); $filteredLanguages = array(); foreach ($languages as $language) { if (isset($values["general.fallbackLanguages." . $language])) { $fallbackLanguages[$language] = str_replace(" ", "", $values["general.fallbackLanguages." . $language]); } if (\Zend_Locale::isLocale($language)) { $filteredLanguages[] = $language; } } // delete views if fallback languages has changed or the language is no more available $fallbackLanguagesChanged = array_diff_assoc($oldValues['general']['fallbackLanguages'], $fallbackLanguages); $dbName = $oldConfig->get("database")->toArray()["params"]["dbname"]; foreach ($fallbackLanguagesChanged as $language => $dummy) { $this->deleteViews($language, $dbName); } $cacheExcludePatterns = $values["cache.excludePatterns"]; if (is_array($cacheExcludePatterns)) { $cacheExcludePatterns = implode(',', $cacheExcludePatterns); } $settings = array("general" => array("timezone" => $values["general.timezone"], "php_cli" => $values["general.php_cli"], "domain" => $values["general.domain"], "redirect_to_maindomain" => $values["general.redirect_to_maindomain"], "language" => $values["general.language"], "validLanguages" => implode(",", $filteredLanguages), "fallbackLanguages" => $fallbackLanguages, "defaultLanguage" => $values["general.defaultLanguage"], "theme" => $values["general.theme"], "extjs6" => $values["general.extjs6"], "loginscreencustomimage" => $values["general.loginscreencustomimage"], "disableusagestatistics" => $values["general.disableusagestatistics"], "debug" => $values["general.debug"], "debug_ip" => $values["general.debug_ip"], "http_auth" => array("username" => $values["general.http_auth.username"], "password" => $values["general.http_auth.password"]), "custom_php_logfile" => $values["general.custom_php_logfile"], "debugloglevel" => $values["general.debugloglevel"], "disable_whoops" => $values["general.disable_whoops"], "debug_admin_translations" => $values["general.debug_admin_translations"], "devmode" => $values["general.devmode"], "logrecipient" => $values["general.logrecipient"], "viewSuffix" => $values["general.viewSuffix"], "instanceIdentifier" => $values["general.instanceIdentifier"], "show_cookie_notice" => $values["general.show_cookie_notice"]), "database" => $oldValues["database"], "documents" => array("versions" => array("days" => $values["documents.versions.days"], "steps" => $values["documents.versions.steps"]), "default_controller" => $values["documents.default_controller"], "default_action" => $values["documents.default_action"], "error_pages" => array("default" => $values["documents.error_pages.default"]), "createredirectwhenmoved" => $values["documents.createredirectwhenmoved"], "allowtrailingslash" => $values["documents.allowtrailingslash"], "allowcapitals" => $values["documents.allowcapitals"], "generatepreview" => $values["documents.generatepreview"], "wkhtmltoimage" => $values["documents.wkhtmltoimage"], "wkhtmltopdf" => $values["documents.wkhtmltopdf"]), "objects" => array("versions" => array("days" => $values["objects.versions.days"], "steps" => $values["objects.versions.steps"])), "assets" => array("versions" => array("days" => $values["assets.versions.days"], "steps" => $values["assets.versions.steps"]), "ffmpeg" => $values["assets.ffmpeg"], "ghostscript" => $values["assets.ghostscript"], "libreoffice" => $values["assets.libreoffice"], "pngcrush" => $values["assets.pngcrush"], "imgmin" => $values["assets.imgmin"], "jpegoptim" => $values["assets.jpegoptim"], "pdftotext" => $values["assets.pdftotext"], "icc_rgb_profile" => $values["assets.icc_rgb_profile"], "icc_cmyk_profile" => $values["assets.icc_cmyk_profile"], "hide_edit_image" => $values["assets.hide_edit_image"]), "services" => array("translate" => array("apikey" => $values["services.translate.apikey"]), "google" => array("client_id" => $values["services.google.client_id"], "email" => $values["services.google.email"], "simpleapikey" => $values["services.google.simpleapikey"], "browserapikey" => $values["services.google.browserapikey"])), "cache" => array("enabled" => $values["cache.enabled"], "lifetime" => $values["cache.lifetime"], "excludePatterns" => $cacheExcludePatterns, "excludeCookie" => $values["cache.excludeCookie"]), "outputfilters" => array("less" => $values["outputfilters.less"], "lesscpath" => $values["outputfilters.lesscpath"]), "webservice" => array("enabled" => $values["webservice.enabled"]), "httpclient" => array("adapter" => $values["httpclient.adapter"], "proxy_host" => $values["httpclient.proxy_host"], "proxy_port" => $values["httpclient.proxy_port"], "proxy_user" => $values["httpclient.proxy_user"], "proxy_pass" => $values["httpclient.proxy_pass"]), "applicationlog" => array("mail_notification" => array("send_log_summary" => $values['applicationlog.mail_notification.send_log_summary'], "filter_priority" => $values['applicationlog.mail_notification.filter_priority'], "mail_receiver" => $values['applicationlog.mail_notification.mail_receiver']), "archive_treshold" => $values['applicationlog.archive_treshold'], "archive_alternative_database" => $values['applicationlog.archive_alternative_database'])); // email & newsletter foreach (array("email", "newsletter") as $type) { $smtpPassword = $values[$type . ".smtp.auth.password"]; if (empty($smtpPassword)) { $smtpPassword = $oldValues[$type]['smtp']['auth']['password']; } $settings[$type] = array("sender" => array("name" => $values[$type . ".sender.name"], "email" => $values[$type . ".sender.email"]), "return" => array("name" => $values[$type . ".return.name"], "email" => $values[$type . ".return.email"]), "method" => $values[$type . ".method"], "smtp" => array("host" => $values[$type . ".smtp.host"], "port" => $values[$type . ".smtp.port"], "ssl" => $values[$type . ".smtp.ssl"], "name" => $values[$type . ".smtp.name"], "auth" => array("method" => $values[$type . ".smtp.auth.method"], "username" => $values[$type . ".smtp.auth.username"], "password" => $smtpPassword))); if (array_key_exists($type . ".debug.emailAddresses", $values)) { $settings[$type]["debug"] = array("emailaddresses" => $values[$type . ".debug.emailAddresses"]); } if (array_key_exists($type . ".bounce.type", $values)) { $settings[$type]["bounce"] = array("type" => $values[$type . ".bounce.type"], "maildir" => $values[$type . ".bounce.maildir"], "mbox" => $values[$type . ".bounce.mbox"], "imap" => array("host" => $values[$type . ".bounce.imap.host"], "port" => $values[$type . ".bounce.imap.port"], "username" => $values[$type . ".bounce.imap.username"], "password" => $values[$type . ".bounce.imap.password"], "ssl" => $values[$type . ".bounce.imap.ssl"])); } } $settings["newsletter"]["usespecific"] = $values["newsletter.usespecific"]; $configFile = \Pimcore\Config::locateConfigFile("system.php"); File::put($configFile, to_php_data_file_format($settings)); $this->_helper->json(array("success" => true)); }