Exemple #1
0
 public function addLanguage($languageToAdd)
 {
     // Check if language is not already added
     if (in_array($languageToAdd, Tool::getValidLanguages())) {
         $result = false;
     } else {
         // Read all the documents from the first language
         $availableLanguages = Tool::getValidLanguages();
         $firstLanguageDocument = \Pimcore\Model\Document::getByPath('/' . reset($availableLanguages));
         \Zend_Registry::set('SEI18N_add', 1);
         // Add the language main folder
         $document = Page::create(1, array('key' => $languageToAdd, "userOwner" => 1, "userModification" => 1, "published" => true, "controller" => 'default', "action" => 'go-to-first-child'));
         $document->setProperty('language', 'text', $languageToAdd);
         // Set the language to this folder and let it inherit to the child pages
         $document->setProperty('isLanguageRoot', 'text', 1, false, false);
         // Set as language root document
         $document->save();
         // Add Link to other languages
         $t = new Keys();
         $t->insert(array("document_id" => $document->getId(), "language" => $languageToAdd, "sourcePath" => $firstLanguageDocument->getFullPath()));
         // Lets add all the docs
         $this->addDocuments($firstLanguageDocument->getId(), $languageToAdd);
         \Zend_Registry::set('SEI18N_add', 0);
         $oldConfig = Config::getSystemConfig();
         $settings = $oldConfig->toArray();
         $languages = explode(',', $settings['general']['validLanguages']);
         $languages[] = $languageToAdd;
         $settings['general']['validLanguages'] = implode(',', $languages);
         $config = new \Zend_Config($settings, true);
         $writer = new \Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_SYSTEM));
         $writer->write();
         $result = true;
     }
     return $result;
 }
Exemple #2
0
 public function installAction()
 {
     // try to establish a mysql connection
     try {
         $db = Zend_Db::factory($this->_getParam("mysql_adapter"), array('host' => $this->_getParam("mysql_host"), 'username' => $this->_getParam("mysql_username"), 'password' => $this->_getParam("mysql_password"), 'dbname' => $this->_getParam("mysql_database"), "port" => $this->_getParam("mysql_port")));
         $db->getConnection();
         // check utf-8 encoding
         $result = $db->fetchRow('SHOW VARIABLES LIKE "character\\_set\\_database"');
         if ($result['Value'] != "utf8") {
             $errors[] = "Database charset is not utf-8";
         }
     } catch (Exception $e) {
         $errors[] = "Couldn't establish connection to mysql: " . $e->getMessage();
     }
     // check username & password
     if (strlen($this->_getParam("admin_password")) < 4 || strlen($this->_getParam("admin_username")) < 4) {
         $errors[] = "Username and password should have at least 4 characters";
     }
     if (empty($errors)) {
         // write configuration file
         $settings = array("general" => array("timezone" => "Europe/Berlin", "language" => "en", "validLanguages" => "en", "debug" => "1", "theme" => "/pimcore/static/js/lib/ext/resources/css/xtheme-gray.css", "loginscreenimageservice" => "1", "welcomescreen" => "1", "loglevel" => array("debug" => "1", "info" => "1", "notice" => "1", "warning" => "1", "error" => "1", "critical" => "1", "alert" => "1", "emergency" => "1")), "database" => array("adapter" => $this->_getParam("mysql_adapter"), "params" => array("host" => $this->_getParam("mysql_host"), "username" => $this->_getParam("mysql_username"), "password" => $this->_getParam("mysql_password"), "dbname" => $this->_getParam("mysql_database"), "port" => $this->_getParam("mysql_port"))), "documents" => array("versions" => array("steps" => "10"), "default_controller" => "default", "default_action" => "default", "error_page" => "/", "allowtrailingslash" => "no", "allowcapitals" => "no"), "objects" => array("versions" => array("steps" => "10")), "assets" => array("versions" => array("steps" => "10")), "services" => array(), "cache" => array("excludeCookie" => "pimcore_admin_sid"), "httpclient" => array("adapter" => "Zend_Http_Client_Adapter_Socket"));
         $config = new Zend_Config($settings, true);
         $writer = new Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_SYSTEM));
         $writer->write();
         // insert db dump
         $db = Pimcore_Resource::get();
         $mysqlInstallScript = file_get_contents(PIMCORE_PATH . "/modules/install/mysql/install.sql");
         // remove comments in SQL script
         $mysqlInstallScript = preg_replace("/\\s*(?!<\")\\/\\*[^\\*]+\\*\\/(?!\")\\s*/", "", $mysqlInstallScript);
         // get every command as single part
         $mysqlInstallScripts = explode(";", $mysqlInstallScript);
         // execute every script with a separate call, otherwise this will end in a PDO_Exception "unbufferd queries, ..." seems to be a PDO bug after some googling
         foreach ($mysqlInstallScripts as $m) {
             $sql = trim($m);
             if (strlen($sql) > 0) {
                 $sql .= ";";
                 $db->query($m);
             }
         }
         // get a new database connection
         $db = Pimcore_Resource::reset();
         // insert data into database
         $db->insert("assets", array("id" => 1, "parentId" => 0, "type" => "folder", "filename" => "", "path" => "/", "creationDate" => time(), "modificationDate" => time(), "userOwner" => 1, "userModification" => 1));
         $db->insert("documents", array("id" => 1, "parentId" => 0, "type" => "page", "key" => "", "path" => "/", "index" => 999999, "published" => 1, "creationDate" => time(), "modificationDate" => time(), "userOwner" => 1, "userModification" => 1));
         $db->insert("documents_page", array("id" => 1, "controller" => "", "action" => "", "template" => "", "title" => "", "description" => "", "keywords" => ""));
         $db->insert("objects", array("o_id" => 1, "o_parentId" => 0, "o_type" => "folder", "o_key" => "", "o_path" => "/", "o_index" => 999999, "o_published" => 1, "o_creationDate" => time(), "o_modificationDate" => time(), "o_userOwner" => 1, "o_userModification" => 1));
         $userPermissions = array(array("key" => "assets", "translation" => "permission_assets"), array("key" => "classes", "translation" => "permission_classes"), array("key" => "clear_cache", "translation" => "permission_clear_cache"), array("key" => "clear_temp_files", "translation" => "permission_clear_temp_files"), array("key" => "document_types", "translation" => "permission_document_types"), array("key" => "documents", "translation" => "permission_documents"), array("key" => "objects", "translation" => "permission_objects"), array("key" => "plugins", "translation" => "permission_plugins"), array("key" => "predefined_properties", "translation" => "permission_predefined_properties"), array("key" => "routes", "translation" => "permission_routes"), array("key" => "seemode", "translation" => "permission_seemode"), array("key" => "system_settings", "translation" => "permission_system_settings"), array("key" => "thumbnails", "translation" => "permission_thumbnails"), array("key" => "translations", "translation" => "permission_translations"), array("key" => "users", "translation" => "permission_users"), array("key" => "update", "translation" => "permissions_update"), array("key" => "redirects", "translation" => "permissions_redirects"), array("key" => "glossary", "translation" => "permissions_glossary"), array("key" => "reports", "translation" => "permissions_reports_marketing"));
         foreach ($userPermissions as $up) {
             $db->insert("users_permission_definitions", $up);
         }
         Pimcore::initConfiguration();
         $user = User::create(array("parentId" => 0, "username" => $this->_getParam("admin_username"), "password" => Pimcore_Tool_Authentication::getPasswordHash($this->_getParam("admin_username"), $this->_getParam("admin_password")), "hasCredentials" => true, "active" => true));
         $user->setAdmin(true);
         $user->save();
         $this->_helper->json(array("success" => true));
     } else {
         echo implode("<br />", $errors);
         die;
     }
 }
 public function editCatalogAction()
 {
     $catalogForm = Model_Static_Loader::loadForm("catalog");
     $catalogForm->preview->setDestination(APPLICATION_ROOT . "/public/files/catalogs");
     $catalogForm->file->setDestination(APPLICATION_ROOT . "/public/files/catalogs");
     $catalogs = new Zend_Config_Xml(APPLICATION_PATH . "/config/catalogs.xml");
     $id = $this->getRequest()->getParam('guid');
     if ($id && !isset($catalogs->{$id})) {
         throw new Zend_Exception("Not found", 404);
     } elseif ($id) {
         $catalogForm->setDefaults($catalogs->{$id}->toArray());
     }
     if ($this->getRequest()->isPost() && $catalogForm->isValid($_POST)) {
         $data = $catalogForm->getValues();
         $data["preview"] = "/files/catalogs/" . $data["preview"];
         $data["file"] = "/files/catalogs/" . $data["file"];
         $catalogs = $catalogs->toArray();
         if ($id) {
             $catalogs[$id] = $data;
         } else {
             $catalogs['cat' . date("ymdhis")] = $data;
         }
         $xml = new Zend_Config_Writer_Xml();
         $xml->setConfig(new Zend_Config($catalogs));
         $xml->setFilename(APPLICATION_PATH . "/config/catalogs.xml");
         $xml->write();
     }
     $this->view->form = $catalogForm;
 }
Exemple #4
0
 /**
  * @return void
  */
 public function save()
 {
     $arrayConfig = object2array($this);
     $config = new \Zend_Config($arrayConfig);
     $writer = new \Zend_Config_Writer_Xml(array("config" => $config, "filename" => $this->getConfigFile()));
     $writer->write();
     return true;
 }
Exemple #5
0
 public static function setConfig($onlineshopConfigFile)
 {
     $config = self::getConfig(false);
     $config->onlineshop_config_file = $onlineshopConfigFile;
     // Write the config file
     $writer = new Zend_Config_Writer_Xml(array('config' => $config, 'filename' => PIMCORE_PLUGINS_PATH . OnlineShop_Plugin::$configFile));
     $writer->write();
 }
Exemple #6
0
 public function saveAction()
 {
     $this->checkPermission("system_settings");
     $values = \Zend_Json::decode($this->getParam("data"));
     $config = new \Zend_Config($values, true);
     $writer = new \Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_DIRECTORY . "/reports.xml"));
     $writer->write();
     $this->_helper->json(array("success" => true));
 }
 public function save()
 {
     $defaults = $this->defaults;
     $params = $this->getData();
     $data = $this->array_join($defaults, $params);
     $config = new Zend_Config($data, true);
     $writer = new Zend_Config_Writer_Xml(array("config" => $config, "filename" => SPHINX_VAR . DIRECTORY_SEPARATOR . "config.xml"));
     $writer->write();
 }
 public function saveAction()
 {
     if ($this->getUser()->isAllowed("system_settings")) {
         $values = Zend_Json::decode($this->_getParam("data"));
         $config = new Zend_Config($values, true);
         $writer = new Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_DIRECTORY . "/reports.xml"));
         $writer->write();
         $this->_helper->json(array("success" => true));
     }
     $this->_helper->json(false);
 }
Exemple #9
0
 public function indexAction()
 {
     if ($this->getParam("save") === 'yes') {
         $settings = array("replaceobjects" => $this->getParam("replaceobjects") === PimPon_Plugin::ALLOW_REPLACE ? PimPon_Plugin::ALLOW_REPLACE : PimPon_Plugin::DENY_REPLACE, "replacedocuments" => $this->getParam("replacedocuments") === PimPon_Plugin::ALLOW_REPLACE ? PimPon_Plugin::ALLOW_REPLACE : PimPon_Plugin::DENY_REPLACE, "replaceroutes" => $this->getParam("replaceroutes") === PimPon_Plugin::ALLOW_REPLACE ? PimPon_Plugin::ALLOW_REPLACE : PimPon_Plugin::DENY_REPLACE, "replaceusers" => $this->getParam("replaceusers") === PimPon_Plugin::ALLOW_REPLACE ? PimPon_Plugin::ALLOW_REPLACE : PimPon_Plugin::DENY_REPLACE, "replaceroles" => $this->getParam("replaceroles") === PimPon_Plugin::ALLOW_REPLACE ? PimPon_Plugin::ALLOW_REPLACE : PimPon_Plugin::DENY_REPLACE);
         $config = new Zend_Config($settings, true);
         $writer = new Zend_Config_Writer_Xml(array("config" => $config, "filename" => PimPon_Plugin::getConfigFile()));
         $writer->write();
     }
     $config = PimPon_Plugin::getConfig();
     $this->view->config = $config;
 }
Exemple #10
0
 /**
  * @return void
  */
 public function save()
 {
     $arrayConfig = object2array($this);
     $items = $arrayConfig["items"];
     $arrayConfig["items"] = array("item" => $items);
     $params = $arrayConfig["params"];
     $arrayConfig["params"] = array("param" => $params);
     $config = new Zend_Config($arrayConfig);
     $writer = new Zend_Config_Writer_Xml(array("config" => $config, "filename" => $this->getConfigFile()));
     $writer->write();
     return true;
 }
Exemple #11
0
 private function activateTheme($theme)
 {
     if (in_array($theme, $this->view->themes)) {
         $conf = new Zend_Config_Xml("config/config.xml", null, array('skipExtends' => true, 'allowModifications' => true));
         $conf->general->theme = $theme;
         // Write the configuration file
         $writer = new Zend_Config_Writer_Xml(array('config' => $conf, 'filename' => 'config/config.xml'));
         $writer->write();
     } else {
         throw new Exception($this->view->translate("The theme you are trying to activate doesn't exist!"));
     }
 }
 public function processAction()
 {
     $error = array();
     $defaultNamespace = new Zend_Session_Namespace('Default');
     $options = array('authentication' => array('email' => $this->getRequest()->getParam('admin_email'), 'password' => $this->getRequest()->getParam('admin_password')), 'settings' => array('default_from' => $this->getRequest()->getParam('default_from'), 'keep_history' => $this->getRequest()->getParam('keep_history'), 'alchemy_api_key' => $this->getRequest()->getParam('alchemy_api_key')), 'resources' => array('db' => array('adapter' => 'PDO_MYSQL', 'params' => array('host' => $this->getRequest()->getParam('db_host'), 'username' => $this->getRequest()->getParam('db_user'), 'password' => $this->getRequest()->getParam('db_password'), 'dbname' => $this->getRequest()->getParam('db_name'), 'prefix' => $this->getRequest()->getParam('db_prefix')))), 'template' => $this->getRequest()->getParam('template'));
     $validator = new Zend_Validate_EmailAddress();
     if (!$validator->isValid($options['authentication']['email'])) {
         $error['admin_email'] = 'Administrator e-mail is invalid';
     }
     if (!trim($options['authentication']['password'])) {
         $error['admin_password'] = '******';
     }
     if (!$validator->isValid($options['settings']['default_from'])) {
         $error['default_from'] = 'Default "from" e-mail is invalid';
     }
     if (!trim($options['resources']['db']['params']['host'])) {
         $error['db_host'] = 'Database host can not be blank';
     }
     if (!trim($options['resources']['db']['params']['username'])) {
         $error['db_user'] = '******';
     }
     if (!trim($options['resources']['db']['params']['dbname'])) {
         $error['db_name'] = 'Database name can not be blank';
     }
     if ((int) $options['settings']['keep_history'] <= 0) {
         $error['keep_history'] = 'Timeline display length have to be positive integer';
     }
     if (!($db = new Zend_Db_Adapter_Pdo_Mysql(array('host' => $options['resources']['db']['params']['host'], 'username' => $options['resources']['db']['params']['username'], 'password' => $options['resources']['db']['params']['password'], 'dbname' => $options['resources']['db']['params']['dbname'])))) {
         $error[] = 'Incorrect database connection details';
     }
     if (count($error)) {
         /**
          * Redirect back
          */
         $defaultNamespace->error = $error;
         $defaultNamespace->options = $options;
         $this->_helper->redirector('index', 'index', 'install');
     } else {
         /**
          * Write .ini file
          */
         unset($defaultNamespace->options);
         /** @var $bootstrap Bootstrap */
         $bootstrap = $this->getInvokeArg('bootstrap');
         $options = new Zend_Config($options);
         $writer = new Zend_Config_Writer_Xml();
         $writer->write($bootstrap->getOption('local_config'), $options);
         $options = $bootstrap->getOptions();
         $options = new Zend_Config($options);
         $writer->write('application.xml', $options);
         $this->_helper->redirector('index', 'index', 'default');
     }
 }
Exemple #13
0
 /**
  * @static
  * @param  Object_Class $class
  * @return string
  */
 public static function generateFieldCollectionXml($fieldCollection)
 {
     $FieldCollectionJson = Zend_Json::encode($fieldCollection);
     $data = Zend_Json::decode($FieldCollectionJson);
     unset($data["key"]);
     $referenceFunction = function (&$value, $key) {
         $value = htmlspecialchars($value);
     };
     array_walk_recursive($data, $referenceFunction);
     $config = new Zend_Config($data, true);
     $writer = new Zend_Config_Writer_Xml(array("config" => $config));
     return $writer->render();
 }
Exemple #14
0
 /**
  * 
  * @param array $array
  * @return string
  */
 public static function serialize($array)
 {
     $config = new Zend_Config_Writer_Xml();
     ZendT_Xml::encodeXml($array);
     $config->setConfig(new Zend_Config($array));
     $xml = $config->render();
     return $xml;
     /*$serializer = new XML_Serializer(array(XML_SERIALIZER_OPTION_ROOT_NAME=>'config'));
       $result = $serializer->serialize($array);
       if ($result){
           $xml = $serializer->getSerializedData();
       }
       return $xml;*/
 }
 public function setAction()
 {
     $values = \Zend_Json::decode($this->getParam("data"));
     // convert all special characters to their entities so the xml writer can put it into the file
     $values = array_htmlspecialchars($values);
     // email settings
     $oldConfig = Config::getConfig();
     $oldValues = $oldConfig->toArray();
     $settings = array("base" => array("base-currency" => $values["base.base-currency"]), "product" => array("default-image" => $values["product.default-image"], "days-as-new" => $values["product.days-as-new"]), "category" => array("default-image" => $values["category.default-image"]));
     $config = new \Zend_Config($settings, true);
     $writer = new \Zend_Config_Writer_Xml(array("config" => $config, "filename" => CORESHOP_CONFIGURATION));
     $writer->write();
     $this->_helper->json(array("success" => true));
 }
 public function newControllerAction()
 {
     $this->setLayout("nolayout");
     $this->setInnerLayout(self::LAYOUT_DEFAULT);
     $params = $this->_request->getParams();
     $this->view->con = $params['con'];
     $this->view->mdl = $params['mdl'];
     $this->view->act = $params['act'];
     if (isset($_POST)) {
         $module = $params['moduleName'];
         $controllerClassName = $params['controllerName'];
         $controllerClassName2 = strtolower(preg_replace('/(?<=\\w)(?=[A-Z])/', "-\$1", $controllerClassName));
         $label = $params['controllerLabel'];
         $icon = $params['controllerIcon'];
         $extendController = $params['extendController'];
         $defaultModel = $params['defaultModel'];
         if ($controllerClassName != '') {
             $gen = new App_Code_GenController();
             $gen->gen($module, $controllerClassName, $label, $extendController, $defaultModel);
             //เพิ่มในรายการเมนู
             $configfile = APPLICATION_PATH . '/configs/navigation-admin.xml';
             $config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation-admin.xml', null, true);
             $sub = $config->nav->{$module}->sub->toArray();
             $sub[$controllerClassName2] = array('label' => $label, 'icon' => $icon);
             $config->nav->{$module}->sub = $sub;
             $writer = new Zend_Config_Writer_Xml();
             $writer->write($configfile, $config);
         }
     }
 }
Exemple #17
0
function getStaticSalt($conf)
{
    if (!isset($conf->db->passwordSalt)) {
        $salt = "";
        for ($i = 0; $i < 50; $i++) {
            $salt .= chr(rand(97, 122));
        }
        $tempConf = new Zend_Config_Xml("config/config.xml", null, array('skipExtends' => true, 'allowModifications' => true));
        $tempConf->db->passwordSalt = $salt;
        $writer = new Zend_Config_Writer_Xml(array('config' => $conf, 'filename' => 'config/config.xml'));
        $writer->write();
        Zend_Registry::set('staticSalt', $salt);
    } else {
        Zend_Registry::set('staticSalt', $conf->db->passwordSalt);
    }
}
 public function saveAction()
 {
     $this->_helper->layout()->setLayout("nolayout");
     $modelname = $this->_request->getParam("model", 'Eau_Model_Company');
     $suffixname = "model-config.xml";
     $modelnameAr = explode("_", $modelname);
     $packet = strtolower($modelnameAr[0]);
     $configfile = $packet . "-" . $suffixname;
     $config = new Zend_Config_Xml(CONFIG_PATH . "{$configfile}", null, true);
     $allfield = array();
     $arrayKey = array();
     $i = 0;
     foreach (App_Model_Config::get($modelname)->getProperties() as $element) {
         $allfield[] = $element->name;
         $arrayKey[$element->name] = $i++;
     }
     $config->production->classes->{$modelname}->text = "2";
     $props = $config->production->classes->{$modelname}->prop->toArray();
     foreach ($_POST as $key => $value) {
         list($field, $property) = explode("_", $key);
         if (in_array($field, $allfield)) {
             $index = $arrayKey[$field];
             foreach ($props as $key => $prop) {
                 if ($prop['name'] == $field) {
                     $props[$key][$property] = $value;
                     //$config->classes->{$modelname}->props->$field->$property = $value;
                 }
                 //echo $prop->name,"<br/>";
             }
             //$config->classes->{$modelname}->prop->$property = $value;
         }
     }
     $config->production->classes->{$modelname}->prop = $props;
     $config->staging = array();
     $config->setExtend('staging', 'production');
     $config->development = array();
     $config->setExtend('development', 'production');
     $writer = new Zend_Config_Writer_Xml();
     $writer->write(CONFIG_PATH . $configfile, $config);
     $this->render('blank', null, true);
 }
 public function editAction()
 {
     $this->view->title = "Edit module";
     $form = new Controlmodule_Form_Controlmodulexml();
     $form->submit->setLabel('Save');
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             //si cambiamos name hay que cambiar la carpeta
             Zend_Debug::dump($formData, "model_role", true);
             $path = APPLICATION_PATH . "/modules/" . $formData["name"] . "/info.xml";
             $config = new Zend_Config(array(), true);
             $config->info = array();
             $config->info->name = $formData["name"];
             $config->info->description = $formData["description"];
             $config->info->version = $formData["version"];
             $config->info->copyright = $formData["copyright"];
             $config->info->developer = $formData["developer"];
             $writer = new Zend_Config_Writer_Xml(array('config' => $config, 'skipExtends' => true, 'filename' => $path));
             $writer->write();
             $this->_helper->redirector('index');
         } else {
             $form->populate($formData);
         }
     } else {
         $request = $this->getRequest();
         $path = APPLICATION_PATH . "/modules/" . $request->module_name . "/info.xml";
         $config = new Zend_Config_Xml($path, 'info');
         $arrayinfo["name"] = $config->name;
         $arrayinfo["version"] = $config->version;
         $arrayinfo["description"] = $config->description;
         $arrayinfo["copyright"] = $config->copyright;
         $arrayinfo["developer"] = $config->developer;
         $this->view->form->populate($arrayinfo);
     }
 }
Exemple #20
0
 /**
  * @param array $config
  */
 public function config($config = array())
 {
     $settings = null;
     // check for an initial configuration template
     // used eg. by the demo installer
     $configTemplatePath = PIMCORE_CONFIGURATION_DIRECTORY . "/system.xml.template";
     if (file_exists($configTemplatePath)) {
         try {
             $configTemplate = new \Zend_Config_Xml($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 = array("general" => array("timezone" => "Europe/Berlin", "language" => "en", "validLanguages" => "en", "debug" => "1", "debugloglevel" => "debug", "custom_php_logfile" => "1", "extjs6" => "1"), "database" => array("adapter" => "Mysqli", "params" => array("username" => "root", "password" => "", "dbname" => "")), "documents" => array("versions" => array("steps" => "10"), "default_controller" => "default", "default_action" => "default", "error_pages" => array("default" => "/"), "createredirectwhenmoved" => "", "allowtrailingslash" => "no", "allowcapitals" => "no", "generatepreview" => "1"), "objects" => array("versions" => array("steps" => "10")), "assets" => array("versions" => array("steps" => "10")), "services" => array(), "cache" => array("excludeCookie" => ""), "httpclient" => array("adapter" => "Zend_Http_Client_Adapter_Socket"));
     }
     $settings = array_replace_recursive($settings, $config);
     // convert all special characters to their entities so the xml writer can put it into the file
     $settings = array_htmlspecialchars($settings);
     // create initial /website/var folder structure
     // @TODO: should use values out of startup.php (Constants)
     $varFolders = array("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);
     }
     $config = new \Zend_Config($settings, true);
     $writer = new \Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_SYSTEM));
     $writer->write();
 }
 function backupAction()
 {
     //$message = var_export($this->getRequest()->getPost(), true);
     ignore_user_abort();
     /* @var $request Zend_Controller_Request_Http */
     $request = $this->getRequest();
     $fastAction = $request->getParam('a', false);
     if ($request->isPost() || $fastAction !== false) {
         $components = $request->getPost('components', array());
         $plugins = X_VlcShares_Plugins::broker()->getPlugins();
         $items = array();
         foreach ($plugins as $pId => $plugin) {
             if (array_key_exists($pId, $components) && (bool) $components[$pId] || $fastAction == 'all' || $fastAction == $pId) {
                 if ($plugin instanceof X_VlcShares_Plugins_BackuppableInterface) {
                     //$toBackup[$pId] = $plugin;
                     $items[$pId] = $plugin->getBackupItems();
                     X_Debug::i('Backuppable plugin: ' . $pId);
                 } elseif ($fastAction != 'all') {
                     $this->_helper->flashMessenger(array('text' => X_Env::_('p_backupper_backup_invalidplugin') . ": {$pId}", 'type' => 'error'));
                 }
             } else {
                 //X_Debug::i('Discarded plugin: '.$pId);
             }
         }
         //$this->_helper->flashMessenger(var_export($items, true));
         if (count($items)) {
             $writer = new Zend_Config_Writer_Xml();
             $date = date("Y-m-d_H-i-s");
             $type = $fastAction !== false ? $fastAction : 'custom';
             $data['metadata'] = array('version' => X_VlcShares::VERSION, 'created' => date('d/m/Y H:i:s'), 'decrypt' => 'backupper_decodevalues_0_5_5');
             $data['plugins'] = $items;
             $filename = APPLICATION_PATH . "/../data/backupper/backup_{$date}_{$type}.xml";
             $data['plugins'] = array_map('backupper_encodevalues', $data['plugins']);
             $configs = new Zend_Config($data);
             $writer->setFilename($filename);
             try {
                 $writer->write(null, $configs, true);
                 $this->_helper->flashMessenger(array('text' => X_Env::_('p_backupper_backup_done'), 'type' => 'info'));
             } catch (Exception $e) {
                 $this->_helper->flashMessenger(array('text' => X_Env::_('p_backupper_err_writefile') . ": {$e->getMessage()}", 'type' => 'error'));
             }
         } else {
             $this->_helper->flashMessenger(array('text' => X_Env::_('p_backupper_backup_nobackupactionneeded'), 'type' => 'warning'));
         }
     }
     //$this->_helper->flashMessenger($message);
     $this->_helper->redirector('index', 'backupper');
 }
 public function websiteSaveAction()
 {
     $data = Zend_Json::decode($this->_getParam("data"));
     // convert all special characters to their entities to ensure that Zend_Config can write it
     foreach ($data as &$setting) {
         $setting["data"] = htmlspecialchars($setting["data"], ENT_COMPAT, "UTF-8");
     }
     $config = new Zend_Config($data, true);
     $writer = new Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_DIRECTORY . "/website.xml"));
     $writer->write();
     // clear cache
     Pimcore_Model_Cache::clearTags(array("output", "system"));
     $this->_helper->json(array("success" => true));
 }
Exemple #23
0
 public function removeClassmap($from)
 {
     $classmapXml = PIMCORE_CONFIGURATION_DIRECTORY . '/classmap.xml';
     try {
         $conf = new \Zend_Config_Xml($classmapXml);
         $classmap = $conf->toArray();
         unset($classmap[$from]);
         $writer = new \Zend_Config_Writer_Xml(array('config' => new \Zend_Config($classmap), 'filename' => $classmapXml));
         $writer->write();
     } catch (\Exception $e) {
     }
 }
 /**
  * @static
  * @param \Zend_Config $config
  * @return void
  */
 public static function setConfig(\Zend_Config $config)
 {
     self::$config = $config;
     $writer = new \Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_DIRECTORY . "/extensions.xml"));
     $writer->write();
 }
Exemple #25
0
 /**
  * @return void
  */
 public function save()
 {
     $arrayConfig = object2array($this);
     $items = $arrayConfig["columnConfiguration"];
     $arrayConfig["columnConfiguration"] = array("columnConfiguration" => $items);
     if ($arrayConfig["dataSourceConfig"]) {
         $configArray = array();
         foreach ($arrayConfig["dataSourceConfig"] as $config) {
             $configArray[] = json_encode($config);
         }
         $arrayConfig["dataSourceConfig"] = array("dataSourceConfig" => $configArray);
     } else {
         $arrayConfig["dataSourceConfig"] = array("dataSourceConfig" => array());
     }
     $items = $arrayConfig["yAxis"];
     $arrayConfig["yAxis"] = array("yAxis" => $items);
     $config = new \Zend_Config($arrayConfig);
     $writer = new \Zend_Config_Writer_Xml(array("config" => $config, "filename" => $this->getConfigFile()));
     $writer->write();
     return true;
 }
 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"], "contactemail" => $values["general.contactemail"], "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"], "environment" => $values["general.environment"], "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("webdav" => array("hostname" => $values["assets.webdav.hostname"]), "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"];
     // convert all special characters to their entities so the xml writer can put it into the file
     $settings = array_htmlspecialchars($settings);
     $config = new \Zend_Config($settings, true);
     $writer = new \Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_SYSTEM));
     $writer->write();
     $this->_helper->json(array("success" => true));
 }
<?php

$configArray = Zend_Registry::get("pimcore_config_system")->toArray();
$configArray["services"]["googlemaps"]["apikey"] = "";
$config = new Zend_Config($configArray, true);
$writer = new Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_SYSTEM));
$writer->write();
?>

<b>Release Notes (233):</b>
<br />
- GeoPoint for objects with OSM (standard) or Google Maps (if key configured) preview<br />
 public function removeCustomView()
 {
     $customViews = \Pimcore\Tool::getCustomViewConfig();
     if ($customViews) {
         foreach ($customViews as $key => $view) {
             if ($view['name'] == 'CoreShop') {
                 unset($customViews[$key]);
                 break;
             }
         }
         $writer = new \Zend_Config_Writer_Xml(array('config' => new \Zend_Config(array('views' => array('view' => $customViews))), 'filename' => PIMCORE_CONFIGURATION_DIRECTORY . '/customviews.xml'));
         $writer->write();
     }
 }
Exemple #29
0
 /**
  * @param $newConfiguration
  * @param bool $update
  * @throws Zend_Config_Exception
  */
 private function writeConfigToFile($newConfiguration, $update = true)
 {
     $configFile = __DIR__ . "/../data/config-example.xml";
     if ($update) {
         $configFile = __DIR__ . "/../data/config.xml";
     }
     $config = new Zend_Config_Xml($configFile);
     $configWriter = new Zend_Config_Writer_Xml(["config" => new Zend_Config(Process::arrayMergeRecursiveDistinct($config->toArray(), $newConfiguration)), "filename" => __DIR__ . "/../data/config.xml"]);
     $configWriter->write();
 }
 /**
  * CUSTOM VIEWS
  */
 public function saveCustomviewsAction()
 {
     $success = true;
     $settings = array("views" => array("view" => array()));
     for ($i = 0; $i < 1000; $i++) {
         if ($this->getParam("name_" . $i)) {
             // check for root-folder
             $rootfolder = "/";
             if ($this->getParam("rootfolder_" . $i)) {
                 $rootfolder = $this->getParam("rootfolder_" . $i);
             }
             $settings["views"]["view"][] = 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" => $this->getParam("classes_" . $i));
         }
     }
     $config = new \Zend_Config($settings, true);
     $writer = new \Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_DIRECTORY . "/customviews.xml"));
     $writer->write();
     $this->_helper->json(array("success" => $success));
 }