Esempio n. 1
0
 /**
  * Do detection of content type, and retrieve parameters from raw body if
  * present
  *
  * @return void
  */
 protected function _loadParams()
 {
     $request = $this->getRequest();
     $contentType = $request->getHeader('Content-Type');
     $rawBody = $request->getRawBody();
     if (!$rawBody) {
         return;
     }
     switch (true) {
         case strstr($contentType, 'application/json'):
             $this->setBodyParams(Zend_Json::decode($rawBody));
             break;
         case strstr($contentType, 'application/xml'):
             $config = new Zend_Config_Xml($rawBody);
             $this->setBodyParams($config->toArray());
             break;
         default:
             if ($request->isPut()) {
                 parse_str($rawBody, $params);
                 $this->setBodyParams($params);
             }
             break;
     }
     self::$_paramsLoaded = true;
 }
Esempio n. 2
0
 /**
  * 
  */
 public function __construct($object = null)
 {
     $this->_object = $object;
     if (file_exists('/var/www/html/MaisVenda/cron.php')) {
         $this->_documentRoot = '/var/www/html/MaisVenda';
     } else {
         $this->_documentRoot = str_replace("\\", "/", realpath('.'));
     }
     /**
      * Busca as configurações do ambiente PHP
      */
     $filenameConfig = $this->_documentRoot . "/job/Config.xml";
     if (file_exists($filenameConfig)) {
         $xml = file_get_contents($filenameConfig);
         $config = new Zend_Config_Xml($xml);
         $this->_config = $config->toArray();
     }
     if (!isset($this->_config['Config']['Path'])) {
         $this->_config['Config']['Path'] = $this->_documentRoot . '/job/data';
     }
     if (!isset($this->_config['Config']['OperationSystem'])) {
         $this->_config['Config']['OperationSystem'] = 'Linux';
     }
     if (!isset($this->_config['Config']['PathPhpExe'])) {
         $this->_config['Config']['PathPhpExe'] = 'php';
     }
     if (!isset($this->_config['Config']['PathPhpExe'])) {
         $this->_config['Config']['PathPhpIni'] = '/etc/php.ini';
     }
     $this->_path = $this->_config['Config']['Path'];
     $this->_path = str_replace('\\', '/', $this->_path) . '/';
     //$this->_clearFiles();
 }
 function sidebarMenu()
 {
     $config = new Zend_Config_Xml(APPLICATION_PATH . '/modules/admin/configs/sidebar.xml', 'sidebar');
     $container = new Zend_Navigation();
     $container->setPages($config->toArray());
     $view = new Zend_View();
     echo $view->navigation($container)->menu()->setMaxDepth(1)->render();
 }
Esempio n. 4
0
 /**
  * @param String $rawXmlResponse The response that comes back directly from the AT SOAP service.
  * @param String $methodName Name of the SOAP method called.
  */
 public function __construct($rawXmlResponse, $methodName)
 {
     $resultKey = $methodName . 'Result';
     $xml = $rawXmlResponse->{$resultKey};
     $xmlParser = new Zend_Config_Xml($xml);
     $resultArray = $xmlParser->toArray();
     $this->exchangeArray($resultArray);
 }
Esempio n. 5
0
 public static function getConfig()
 {
     if (!self::$pluginConfig) {
         $xml = new \Zend_Config_Xml(self::getConfigFile());
         self::$pluginConfig = $xml->toArray();
     }
     return self::$pluginConfig;
 }
 function navbarMainMenu()
 {
     $config = new Zend_Config_Xml(APPLICATION_PATH . '/modules/admin/configs/navbar.xml', 'main');
     $container = new Zend_Navigation();
     $container->setPages($config->toArray());
     $view = new Zend_View();
     echo $view->navigation($container)->menu()->setUlClass('nav navbar-nav')->setMaxDepth(0)->render();
 }
 public function __construct()
 {
     try {
         $config = new Zend_Config_Xml(SPHINX_VAR . DIRECTORY_SEPARATOR . "config.xml");
         $this->config = $config->toArray();
     } catch (Zend_Config_Exception $e) {
         $this->config = $this->defaults;
     }
 }
Esempio n. 8
0
 protected function _initNavigation()
 {
     $this->bootstrap('view');
     $this->bootstrap('frontController');
     $this->bootstrap('acl');
     $config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
     $resource = new Zend_Application_Resource_Navigation(array('pages' => $config->toArray()));
     $resource->setBootstrap($this);
     return $resource->init();
 }
Esempio n. 9
0
 public function unsetClassmap()
 {
     $classmapXml = PIMCORE_CONFIGURATION_DIRECTORY . '/classmap.xml';
     try {
         $conf = new Zend_Config_Xml($classmapXml);
         $classmap = $conf->toArray();
         unset($classmap['Object_BlogEntry']);
         $writer = new Zend_Config_Writer_Xml(array('config' => new Zend_Config($classmap), 'filename' => $classmapXml));
         $writer->write();
     } catch (Exception $e) {
     }
 }
Esempio n. 10
0
 /**
  * (non-PHPdoc)
  *
  * @see Zend_Auth_Adapter_Interface::authenticate()
  */
 public function authenticate()
 {
     $users = new Zend_Config_Xml(APPLICATION_PATH . "/modules/utils/configs/auth.xml");
     foreach ($users->toArray() as $user) {
         if ($user['email'] == $this->user) {
             if ($user['password'] == sha1($this->password)) {
                 return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, (object) $user);
             } else {
                 return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $user);
             }
         }
     }
     return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $user);
 }
 function navbarRightMenu()
 {
     $config = new Zend_Config_Xml(APPLICATION_PATH . '/modules/admin/configs/navbar.xml', 'nav');
     $container = new Zend_Navigation();
     $container->setPages($config->toArray());
     /*$container->addPage(
       array(
           'label'      => Zend_Auth::getInstance()->getIdentity()->email,
           'title'      => 'Dashboard',
           'uri'     => '/admin/'
       ));*/
     $view = new Zend_View();
     echo $view->navigation($container)->menu()->setUlClass('dropdown-menu')->render();
 }
Esempio n. 12
0
 function databaseDetails()
 {
     switch ($this->whichShoppingCart()) {
         case 'prestashop':
             require_once $this->shoppingCartRoot() . '/config/settings.inc.php';
             return array('dbname' => _DB_NAME_, 'username' => _DB_USER_, 'password' => _DB_PASSWD_, 'product_table' => 'ps_product', 'product_sku_field' => 'reference', 'product_id_field' => 'id_product');
         case 'magento':
             $config = new \Zend_Config_Xml($this->shoppingCartRoot() . 'app/etc/local.xml');
             $dbConfig = $config->toArray();
             $dbinfo = $dbConfig['global']['resources']['default_setup']['connection'];
             $dbinfo = $dbinfo + array('product_table' => 'catalog_product_entity', 'product_sku_field' => 'sku', 'product_id_field' => 'entity_id');
             return $dbinfo;
         default:
             throw new \Exception('Unable to detect shopping cart');
     }
 }
Esempio n. 13
0
 /**
  * creates a class called "unittest" containing all Object_Class_Data Types currently available.
  * @return void
  * @depends testFieldCollectionCreate
  */
 public function testClassCreate()
 {
     $conf = new Zend_Config_Xml(TESTS_PATH . "/resources/objects/class-import.xml");
     $importData = $conf->toArray();
     $layout = Object_Class_Service::generateLayoutTreeFromArray($importData["layoutDefinitions"]);
     $class = Object_Class::create();
     $class->setName("unittest");
     $class->setUserOwner(1);
     $class->save();
     $id = $class->getId();
     $this->assertTrue($id > 0);
     $class = Object_Class::getById($id);
     $class->setLayoutDefinitions($layout);
     $class->setUserModification(1);
     $class->setModificationDate(time());
     $class->save();
 }
Esempio n. 14
0
 /**
  * @static
  * @return mixed|Zend_Config
  */
 public static function getWebsiteConfig()
 {
     try {
         $config = Zend_Registry::get("pimcore_config_website");
     } catch (Exception $e) {
         $cacheKey = "website_config";
         if (!($config = Pimcore_Model_Cache::load($cacheKey))) {
             $websiteSettingFile = PIMCORE_CONFIGURATION_DIRECTORY . "/website.xml";
             $settingsArray = array();
             if (is_file($websiteSettingFile)) {
                 $rawConfig = new Zend_Config_Xml($websiteSettingFile);
                 $arrayData = $rawConfig->toArray();
                 foreach ($arrayData as $key => $value) {
                     $s = null;
                     if ($value["type"] == "document") {
                         $s = Document::getByPath($value["data"]);
                     } else {
                         if ($value["type"] == "asset") {
                             $s = Asset::getByPath($value["data"]);
                         } else {
                             if ($value["type"] == "object") {
                                 $s = Object_Abstract::getByPath($value["data"]);
                             } else {
                                 if ($value["type"] == "bool") {
                                     $s = (bool) $value["data"];
                                 } else {
                                     if ($value["type"] == "text") {
                                         $s = (string) $value["data"];
                                     }
                                 }
                             }
                         }
                     }
                     if ($s) {
                         $settingsArray[$key] = $s;
                     }
                 }
             }
             $config = new Zend_Config($settingsArray, true);
             Pimcore_Model_Cache::save($config, $cacheKey, array("websiteconfig", "system", "config"), null, 998);
         }
         self::setWebsiteConfig($config);
     }
     return $config;
 }
Esempio n. 15
0
 /**
  * Load the config file
  *
  * @param string $fullpath
  * @return array
  */
 protected function _loadOptions($fullpath)
 {
     if (file_exists($fullpath)) {
         switch (substr(trim(strtolower($fullpath)), -3)) {
             case 'ini':
                 $cfg = new Zend_Config_Ini($fullpath, $this->getBootstrap()->getEnvironment());
                 break;
             case 'xml':
                 $cfg = new Zend_Config_Xml($fullpath, $this->getBootstrap()->getEnvironment());
                 break;
             default:
                 throw new Zend_Config_Exception('Invalid format for config file');
                 break;
         }
     } else {
         throw new Zend_Application_Resource_Exception('File does not exist');
     }
     return $cfg->toArray();
 }
Esempio n. 16
0
 /**
  * Do detection of content type, and retrieve parameters from raw body if present
  *
  * @return void
  */
 public function init()
 {
     // Allows for \App\Engine\Exception to be thrown AND caught by default error controller
     // For full explanation, see: http://stackoverflow.com/questions/4076578/do-action-helpers-with-hooks-to-auto-run-throw-exceptions-or-not
     if ($this->getRequest()->getActionName() == 'error' && $this->getRequest()->getControllerName() == 'error') {
         return;
     }
     $request = $this->getRequest();
     $contentType = $request->getHeader('Content-Type');
     $rawBody = $request->getRawBody();
     if (!$rawBody) {
         return;
     }
     switch (true) {
         case stristr($contentType, 'application/json'):
             $data = Zend_Json::decode($rawBody);
             $this->setBodyParams($data['request']);
             break;
         case stristr($contentType, 'application/xml'):
             try {
                 $config = new Zend_Config_Xml($rawBody);
             } catch (Exception $e) {
                 $error = substr($e, 0, stripos($e, "\n"));
                 throw new \App\Engine\Exception('Malformed XML: ' . $error, 400);
             }
             $this->setBodyParams($config->toArray());
             break;
         case stristr($contentType, 'application/x-www-form-urlencoded'):
             if ($request->isPut()) {
                 parse_str($rawBody, $params);
                 $this->setBodyParams($params);
             }
             break;
         default:
             throw new \App\Engine\Exception('Unsupported Content-Type provided.', 501);
             // http://trac.agavi.org/browser/tags/1.0.2/src/request/AgaviWebRequest.class.php
             // use above to possibly handle files sent via post/put
             break;
     }
 }
 /**
  *   Retourne un tableau formaté des caractéristiques d'un article
  *
  * @param string $detailsXml   Détails de l'article dans le format XML
  * @return array()   Détail de l'article (ensemble des caractéristiques dans
  *      un tableau formaté
  */
 public static function formatDetails($detailsXml)
 {
     // initialisation
     $details = array();
     $keepTrying = true;
     $i = 1;
     $detailsXml = '<?xml version="1.0" encoding="ISO-8859-1"?>' . html_entity_decode($detailsXml);
     // on charge les librairies de Zend Framework
     ProjectConfiguration::registerZend();
     // on format les details de l'article
     do {
         try {
             // on recupere une à une les caractéristiques de l'article
             $caract = new Zend_Config_Xml($detailsXml, 'caract_' . $i);
             $details[] = $caract->toArray();
             $i++;
         } catch (Zend_Config_Exception $e) {
             $keepTrying = false;
         }
     } while ($keepTrying);
     return $details;
 }
Esempio n. 18
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();
 }
Esempio n. 19
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) {
     }
 }
Esempio n. 20
0
 /**
  * @param string $layoutName - e.g. catalogsearch.xml
  * @param string $handleName - e.g. catalogsearch_result_index
  * @return array $container  - one-dimensional array with nodes
  */
 protected function getHandleNodesFromLayout($layoutName, $handleName)
 {
     $container = array();
     $appEmulation = Mage::getSingleton('core/app_emulation');
     $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation(Mage::app()->getDefaultStoreView()->getId(), Mage_Core_Model_App_Area::AREA_FRONTEND);
     $catalogSearchLayoutFile = Mage::getDesign()->getLayoutFilename($layoutName);
     $catalogSearchXml = new Zend_Config_Xml($catalogSearchLayoutFile, $handleName);
     $catalogSearchArray = $catalogSearchXml->toArray();
     $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($catalogSearchArray));
     $container = iterator_to_array($iterator, false);
     $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
     return $container;
 }
Esempio n. 21
0
 /**
  * @return Array $pluginConfigs
  */
 public static function getPluginConfigs()
 {
     $pluginConfigs = array();
     if (is_dir(PIMCORE_PLUGINS_PATH) && is_readable(PIMCORE_PLUGINS_PATH)) {
         $pluginDirs = scandir(PIMCORE_PLUGINS_PATH);
         if (is_array($pluginDirs)) {
             foreach ($pluginDirs as $d) {
                 if ($d != "." and $d != ".." and is_dir(PIMCORE_PLUGINS_PATH . "//" . $d)) {
                     if (file_exists(PIMCORE_PLUGINS_PATH . "/" . $d . "/plugin.xml")) {
                         try {
                             $pluginConf = new \Zend_Config_Xml(PIMCORE_PLUGINS_PATH . "/" . $d . "/plugin.xml");
                             if ($pluginConf != null) {
                                 $pluginConfigs[] = $pluginConf->toArray();
                             }
                         } catch (\Exception $e) {
                             \Logger::error("Unable to initialize plugin with ID: " . $d);
                             \Logger::error($e);
                         }
                     }
                 }
             }
         }
     }
     return $pluginConfigs;
 }
Esempio n. 22
0
 /**
  * @return void
  */
 public function load()
 {
     $configXml = new \Zend_Config_Xml($this->getConfigFile());
     $configArray = $configXml->toArray();
     if (array_key_exists("columnConfiguration", $configArray) && is_array($configArray["columnConfiguration"]["columnConfiguration"])) {
         if (array_key_exists("method", $configArray["columnConfiguration"]["columnConfiguration"])) {
             $configArray["columnConfiguration"] = array($configArray["columnConfiguration"]["columnConfiguration"]);
         } else {
             $configArray["columnConfiguration"] = $configArray["columnConfiguration"]["columnConfiguration"];
         }
     } else {
         $configArray["columnConfiguration"] = array("columnConfiguration" => array());
     }
     if (array_key_exists("dataSourceConfig", $configArray) && is_array($configArray["dataSourceConfig"])) {
         $dataSourceConfig = array();
         foreach ($configArray["dataSourceConfig"] as $c) {
             if ($c) {
                 $dataSourceConfig[] = json_decode($c);
             }
         }
         $configArray["dataSourceConfig"] = $dataSourceConfig;
     } else {
         $configArray["dataSourceConfig"] = array();
     }
     if (array_key_exists("yAxis", $configArray) && is_array($configArray["yAxis"])) {
         if (!is_array($configArray["yAxis"]["yAxis"])) {
             $configArray["yAxis"] = array($configArray["yAxis"]["yAxis"]);
         } else {
             $configArray["yAxis"] = $configArray["yAxis"]["yAxis"];
         }
     }
     // to preserve compatibility to older sql reports
     if ($configArray["sql"] && empty($configArray["dataSourceConfig"])) {
         $legacy = new \stdClass();
         $legacy->type = "sql";
         $legacy->sql = $configArray["sql"];
         $configArray["dataSourceConfig"][] = $legacy;
     }
     foreach ($configArray as $key => $value) {
         $setter = "set" . ucfirst($key);
         if (method_exists($this, $setter)) {
             $this->{$setter}($value);
         }
     }
     return true;
 }
Esempio n. 23
0
{
    try {
        $db = Pimcore_Resource::get();
        $db->query($sql);
    } catch (Exception $e) {
        echo $e->getMessage();
        echo "Please execute the following query manually: <br />";
        echo "<pre>" . $sql . "</pre><hr />";
    }
}
sendQuery("DROP TABLE IF EXISTS `website_settings`;");
sendQuery("CREATE TABLE `website_settings` (\r\n\t`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n\t`name` VARCHAR(255) NOT NULL DEFAULT '',\r\n\t`type` ENUM('text','document','asset','object','bool') NULL DEFAULT NULL,\r\n\t`data` TEXT NULL,\r\n\t`siteId` INT(11) UNSIGNED NULL DEFAULT NULL,\r\n\t`creationDate` BIGINT(20) UNSIGNED NULL DEFAULT '0',\r\n\t`modificationDate` BIGINT(20) UNSIGNED NULL DEFAULT '0',\r\n\tPRIMARY KEY (`id`),\r\n\tINDEX `name` (`name`),\r\n\tINDEX `siteId` (`siteId`)\r\n)\r\nDEFAULT CHARSET=utf8;");
$configFile = PIMCORE_CONFIGURATION_DIRECTORY . "/website.xml";
$configFileNew = PIMCORE_CONFIGURATION_DIRECTORY . "/website-legacy.xml";
$rawConfig = new Zend_Config_Xml($configFile);
$arrayData = $rawConfig->toArray();
$data = array();
foreach ($arrayData as $key => $value) {
    $setting = new WebsiteSetting();
    $setting->setName($key);
    $type = $value["type"];
    $setting->setType($type);
    $data = $value["data"];
    if ($type == "bool") {
        $data = (bool) $data;
    } else {
        if ($type == "document") {
            $data = Document::getByPath($value["data"]);
        } else {
            if ($type == "asset") {
                $data = Asset::getByPath($value["data"]);
Esempio n. 24
0
 public function testXmlWithAttrsIsEqual()
 {
     $config = new Zend_Config_Xml($this->_xmlFileConfig, 'staging');
     $configWithAttr = new Zend_Config_Xml($this->_xmlFileConfigWithAttr, 'staging');
     $allSecConfig = new Zend_Config_Xml($this->_xmlFileAllSectionsConfig);
     $allSecConfigWithAttr = new Zend_Config_Xml($this->_xmlFileAllSectionsConfigWithAttr);
     $this->assertEquals($config->toArray(), $configWithAttr->toArray());
     $this->assertEquals($allSecConfig->toArray(), $allSecConfigWithAttr->toArray());
 }
Esempio n. 25
0
 /**
  * @return void
  */
 public function load()
 {
     $configXml = new Zend_Config_Xml($this->getConfigFile());
     $configArray = $configXml->toArray();
     if (array_key_exists("items", $configArray) && is_array($configArray["items"]["item"])) {
         // if code is in it, that means that there's only one item it it
         if (array_key_exists("code", $configArray["items"]["item"])) {
             $configArray["items"] = array($configArray["items"]["item"]);
         } else {
             $configArray["items"] = $configArray["items"]["item"];
         }
     } else {
         $configArray["items"] = array("item" => array());
     }
     if (array_key_exists("params", $configArray)) {
         $configArray["params"] = $configArray["params"]["param"];
     }
     foreach ($configArray as $key => $value) {
         $setter = "set" . ucfirst($key);
         if (method_exists($this, $setter)) {
             $this->{$setter}($value);
         }
     }
     return true;
 }
Esempio n. 26
0
 /**
  * Imports group and key config from XML format.
  */
 public function importAction()
 {
     $tmpFile = file_get_contents($_FILES["Filedata"]["tmp_name"]);
     $conf = new \Zend_Config_Xml($tmpFile);
     $importData = $conf->toArray();
     Object\KeyValue\Helper::import($importData);
     $this->_helper->json(["success" => true], 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", true);
 }
Esempio n. 27
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();
 }
Esempio n. 28
0
 /**
  * @static
  * @return array|bool
  */
 public static function getCustomViewConfig()
 {
     $cvConfigFile = PIMCORE_CONFIGURATION_DIRECTORY . "/customviews.xml";
     $cvData = array();
     if (!is_file($cvConfigFile)) {
         $cvData = false;
     } else {
         $config = new \Zend_Config_Xml($cvConfigFile);
         $confArray = $config->toArray();
         if (empty($confArray["views"]["view"])) {
             return array();
         } else {
             if ($confArray["views"]["view"][0]) {
                 $cvData = $confArray["views"]["view"];
             } else {
                 $cvData[] = $confArray["views"]["view"];
             }
         }
         foreach ($cvData as &$tmp) {
             $tmp["showroot"] = (bool) $tmp["showroot"];
         }
     }
     return $cvData;
 }
Esempio n. 29
0
 public function websiteLoadAction()
 {
     $configFile = PIMCORE_CONFIGURATION_DIRECTORY . "/website.xml";
     // file doesn't exist => send empty array to frontend
     if (!is_file($configFile)) {
         $this->_helper->json(array("settings" => array()));
         return;
     }
     $rawConfig = new Zend_Config_Xml($configFile);
     $arrayData = $rawConfig->toArray();
     $data = array();
     foreach ($arrayData as $key => $value) {
         if ($value["type"] == "bool") {
             $value["data"] = (bool) $value["data"];
         }
         $data[] = array("name" => $key, "type" => $value["type"], "data" => $value["data"]);
     }
     $this->_helper->json(array("settings" => $data));
 }
Esempio n. 30
0
 /**
  * @return void
  */
 public function load()
 {
     $configXml = new Zend_Config_Xml($this->getConfigFile());
     $configArray = $configXml->toArray();
     if (array_key_exists("items", $configArray) && is_array($configArray["items"]["item"])) {
         if (array_key_exists("method", $configArray["items"]["item"])) {
             $configArray["items"] = array($configArray["items"]["item"]);
         } else {
             $configArray["items"] = $configArray["items"]["item"];
         }
     } else {
         $configArray["items"] = array("item" => array());
     }
     foreach ($configArray as $key => $value) {
         $setter = "set" . ucfirst($key);
         if (method_exists($this, $setter)) {
             $this->{$setter}($value);
         }
     }
     return true;
 }