Source for file ConfigurationModel.php

Documentation is available at ConfigurationModel.php

  1. <?php
  2.  
  3. /**
  4.  * @package inc
  5.  * @subpackage model
  6.  */
  7.  
  8. /**
  9.  *
  10.  * ConfigurationModel class
  11.  *
  12.  * @author Felix Rupp <kontakt@felixrupp.com>
  13.  * @version $Id$
  14.  * @copyright Copyright (c) 2011, Felix Rupp, Nicole Reinhardt
  15.  * @license http://www.opensource.org/licenses/mit-license.php MIT-License
  16.  * @license http://www.gnu.org/licenses/gpl.html GNU GPL
  17.  *
  18.  * @package inc
  19.  * @subpackage model
  20.  */
  21.  
  22.     /**
  23.     * @var ConfigurationModel $_configurator Contains single instance of our ConfigurationModel
  24.     * @staticvar $_configurator 
  25.     */
  26.     private static $_configurator NULL;
  27.     
  28.     /**
  29.      * @var SimpleXMLExtended $_configFile Contains the SimpleXMLExtended of our xml-configfile
  30.      */
  31.     private $_configFile;
  32.     
  33.     /**
  34.      * @var SimpleXMLExtended $_adminConfigFile Contains the SimpleXMLExtended of our admin configfile
  35.      */
  36.     private $_adminConfigFile;
  37.     
  38.     /**
  39.      * @var SimpleXMLExtended $_adminLangFile Contains the SimpleXMLExtended of our xml-languagefile for admin
  40.      */
  41.     private $_adminLangFile;
  42.     
  43.     /**
  44.      * @var string $_backendLang Contains iso language-code of the backend language
  45.      */
  46.     private $_backendLang;
  47.     
  48.     /**
  49.      * @var array $_backendLangugeData Contains SimpleXMLExtended object with backend language data
  50.      */
  51.     private $_backendLangugeData;
  52.     
  53.     /**
  54.      * @var array $_allBackendLanguages Contains an array with alle existing backend languages
  55.      */
  56.     private $_allBackendLanguages;
  57.     
  58.     
  59.     /**
  60.      * @var array $_isoLangCodes Contains all ISO language codes and respective language names
  61.      */
  62.     private $_isoLangCodes array(
  63.     'aa' => 'Afar',
  64.     'ab' => 'Abkhaz',
  65.     'ae' => 'Avestan',
  66.     'af' => 'Afrikaans',
  67.     'ak' => 'Akan',
  68.     'am' => 'Amharic',
  69.     'an' => 'Aragonese',
  70.     'ar' => 'Arabic',
  71.     'as' => 'Assamese',
  72.     'av' => 'Avaric',
  73.     'ay' => 'Aymara',
  74.     'az' => 'Azerbaijani',
  75.     'ba' => 'Bashkir',
  76.     'be' => 'Belarusian',
  77.     'bg' => 'Bulgarian',
  78.     'bh' => 'Bihari',
  79.     'bi' => 'Bislama',
  80.     'bm' => 'Bambara',
  81.     'bn' => 'Bengali',
  82.     'bo' => 'Tibetan Standard, Tibetan, Central',
  83.     'br' => 'Breton',
  84.     'bs' => 'Bosnian',
  85.     'ca' => 'Catalan; Valencian',
  86.     'ce' => 'Chechen',
  87.     'ch' => 'Chamorro',
  88.     'co' => 'Corsican',
  89.     'cr' => 'Cree',
  90.     'cs' => 'Czech',
  91.     'cu' => 'Old Church Slavonic, Church Slavic, Church Slavonic, Old Bulgarian, Old Slavonic',
  92.     'cv' => 'Chuvash',
  93.     'cy' => 'Welsh',
  94.     'da' => 'Danish',
  95.     'de' => 'German',
  96.     'dv' => 'Divehi; Dhivehi; Maldivian;',
  97.     'dz' => 'Dzongkha',
  98.     'ee' => 'Ewe',
  99.     'el' => 'Greek, Modern',
  100.     'en' => 'English',
  101.     'eo' => 'Esperanto',
  102.     'es' => 'Spanish; Castilian',
  103.     'et' => 'Estonian',
  104.     'eu' => 'Basque',
  105.     'fa' => 'Persian',
  106.     'ff' => 'Fula; Fulah; Pulaar; Pular',
  107.     'fi' => 'Finnish',
  108.     'fj' => 'Fijian',
  109.     'fo' => 'Faroese',
  110.     'fr' => 'French',
  111.     'fy' => 'Western Frisian',
  112.     'ga' => 'Irish',
  113.     'gd' => 'Scottish Gaelic; Gaelic',
  114.     'gl' => 'Galician',
  115.     'gn' => 'Guaraní',
  116.     'gu' => 'Gujarati',
  117.     'gv' => 'Manx',
  118.     'ha' => 'Hausa',
  119.     'he' => 'Hebrew (modern)',
  120.     'hi' => 'Hindi',
  121.     'ho' => 'Hiri Motu',
  122.     'hr' => 'Croatian',
  123.     'ht' => 'Haitian; Haitian Creole',
  124.     'hu' => 'Hungarian',
  125.     'hy' => 'Armenian',
  126.     'hz' => 'Herero',
  127.     'ia' => 'Interlingua',
  128.     'id' => 'Indonesian',
  129.     'ie' => 'Interlingue',
  130.     'ig' => 'Igbo',
  131.     'ii' => 'Nuosu',
  132.     'ik' => 'Inupiaq',
  133.     'io' => 'Ido',
  134.     'is' => 'Icelandic',
  135.     'it' => 'Italian',
  136.     'iu' => 'Inuktitut',
  137.     'ja' => 'Japanese (ja)',
  138.     'jv' => 'Javanese (jv)',
  139.     'ka' => 'Georgian',
  140.     'kg' => 'Kongo',
  141.     'ki' => 'Kikuyu, Gikuyu',
  142.     'kj' => 'Kwanyama, Kuanyama',
  143.     'kk' => 'Kazakh',
  144.     'kl' => 'Kalaallisut, Greenlandic',
  145.     'km' => 'Khmer',
  146.     'kn' => 'Kannada',
  147.     'ko' => 'Korean',
  148.     'kr' => 'Kanuri',
  149.     'ks' => 'Kashmiri',
  150.     'ku' => 'Kurdish',
  151.     'kv' => 'Komi',
  152.     'kw' => 'Cornish',
  153.     'ky' => 'Kirghiz, Kyrgyz',
  154.     'la' => 'Latin',
  155.     'lb' => 'Luxembourgish, Letzeburgesch',
  156.     'lg' => 'Luganda',
  157.     'li' => 'Limburgish, Limburgan, Limburger',
  158.     'ln' => 'Lingala',
  159.     'lo' => 'Lao',
  160.     'lt' => 'Lithuanian',
  161.     'lu' => 'Luba-Katanga',
  162.     'lv' => 'Latvian',
  163.     'mg' => 'Malagasy',
  164.     'mh' => 'Marshallese',
  165.     'mi' => 'Maori',
  166.     'mk' => 'Macedonian',
  167.     'ml' => 'Malayalam',
  168.     'mn' => 'Mongolian',
  169.     'mr' => 'Marathi (Mara?hi)',
  170.     'ms' => 'Malay',
  171.     'mt' => 'Maltese',
  172.     'my' => 'Burmese',
  173.     'na' => 'Nauru',
  174.     'nb' => 'Norwegian BokmÃ¥l',
  175.     'nd' => 'North Ndebele',
  176.     'ne' => 'Nepali',
  177.     'ng' => 'Ndonga',
  178.     'nl' => 'Dutch',
  179.     'nn' => 'Norwegian Nynorsk',
  180.     'no' => 'Norwegian',
  181.     'nr' => 'South Ndebele',
  182.     'nv' => 'Navajo, Navaho',
  183.     'ny' => 'Chichewa; Chewa; Nyanja',
  184.     'oc' => 'Occitan',
  185.     'oj' => 'Ojibwe, Ojibwa',
  186.     'om' => 'Oromo',
  187.     'or' => 'Oriya',
  188.     'os' => 'Ossetian, Ossetic',
  189.     'pa' => 'Panjabi, Punjabi',
  190.     'pi' => 'Pali',
  191.     'pl' => 'Polish',
  192.     'ps' => 'Pashto, Pushto',
  193.     'pt' => 'Portuguese',
  194.     'qu' => 'Quechua',
  195.     'rm' => 'Romansh',
  196.     'rn' => 'Kirundi',
  197.     'ro' => 'Romanian, Moldavian, Moldovan',
  198.     'ru' => 'Russian',
  199.     'rw' => 'Kinyarwanda',
  200.     'sa' => 'Sanskrit (Sa?sk?ta)',
  201.     'sc' => 'Sardinian',
  202.     'sd' => 'Sindhi',
  203.     'se' => 'Northern Sami',
  204.     'sg' => 'Sango',
  205.     'si' => 'Sinhala, Sinhalese',
  206.     'sk' => 'Slovak',
  207.     'sl' => 'Slovene',
  208.     'sm' => 'Samoan',
  209.     'sn' => 'Shona',
  210.     'so' => 'Somali',
  211.     'sq' => 'Albanian',
  212.     'sr' => 'Serbian',
  213.     'ss' => 'Swati',
  214.     'st' => 'Southern Sotho',
  215.     'su' => 'Sundanese',
  216.     'sv' => 'Swedish',
  217.     'sw' => 'Swahili',
  218.     'ta' => 'Tamil',
  219.     'te' => 'Telugu',
  220.     'tg' => 'Tajik',
  221.     'th' => 'Thai',
  222.     'ti' => 'Tigrinya',
  223.     'tk' => 'Turkmen',
  224.     'tl' => 'Tagalog',
  225.     'tn' => 'Tswana',
  226.     'to' => 'Tonga (Tonga Islands)',
  227.     'tr' => 'Turkish',
  228.     'ts' => 'Tsonga',
  229.     'tt' => 'Tatar',
  230.     'tw' => 'Twi',
  231.     'ty' => 'Tahitian',
  232.     'ug' => 'Uighur, Uyghur',
  233.     'uk' => 'Ukrainian',
  234.     'ur' => 'Urdu',
  235.     'uz' => 'Uzbek',
  236.     've' => 'Venda',
  237.     'vi' => 'Vietnamese',
  238.     'vo' => 'Volapük',
  239.     'wa' => 'Walloon',
  240.     'wo' => 'Wolof',
  241.     'xh' => 'Xhosa',
  242.     'yi' => 'Yiddish',
  243.     'yo' => 'Yoruba',
  244.     'za' => 'Zhuang, Chuang',
  245.     'zh' => 'Chinese',
  246.     'zu' => 'Zulu',
  247. );
  248.     
  249.     
  250.     
  251.     /**
  252.      * Configurator class-constructor
  253.      *
  254.      * @return void 
  255.      */
  256.     private function ConfigurationModel({
  257.  
  258.         try {
  259.             $this->reloadConfigFile();
  260.             $this->reloadAdminConfigFile();
  261.             $this->reloadAdminLangFile();
  262.             
  263.             $this->_backendLang $this->getAdminConfigString("BACKEND_LANGUAGE");
  264.             $this->_backendLangugeData $this->getBackendLanguage($this->_backendLang);
  265.             $this->_allBackendLanguages $this->getAllBackendLanguages();    
  266.         }
  267.         catch(CaramelException $e{
  268.             $e->getDetails();
  269.         }
  270.         
  271.     // End of constructor declaration
  272.     
  273.     
  274.     /**
  275.      * Singleton-create-method
  276.      *
  277.      * @return ConfigurationModel Single instance of ConfigurationModel
  278.      */
  279.     public static function getConfigurationModel({
  280.     
  281.         if (self::$_configurator === NULL{
  282.             self::$_configurator new self();
  283.         }
  284.         return self::$_configurator;
  285.     
  286.     // End of method declaration
  287.     
  288.     
  289.     # Prevent cloning
  290.     /**
  291.      * Overwrite __clone() method to prevent instance-cloning
  292.     *
  293.     * @return void 
  294.     */
  295.     private function __clone({
  296.     }
  297.         
  298.     
  299.     
  300.     /**
  301.      * This method returns an ordered array with all global settings
  302.      *
  303.      * @return Array with all global settings
  304.      */
  305.     public function getGlobalsAction({
  306.         
  307.         $configArray $this->getConfig($this->_configFile);
  308.         $globals array();
  309.                 
  310.         $languageArray array();
  311.         foreach($this->_backendLangugeData as $xmlNode{
  312.             $languageArray[(string)$xmlNode["key"]] = (string)$xmlNode;
  313.         }
  314.                 
  315.         foreach($configArray as $node{
  316.             
  317.             $globals[strtolower((string)$node["key"])array("label" => $languageArray[(string)$node["key"]]"value" => stripslashes((string)$node)"type" => (string)$node["type"]"blank" => (string)$node["blank"]"validate" => (string)$node["validate"]);
  318.             
  319.         }
  320.         
  321.         # Provide languages for default frontend language        
  322.         foreach($this->_isoLangCodes as $langCode => $langValue{
  323.                 
  324.             $globals["default_language"]["acceptedValues"][$langCode$langValue;
  325.         }
  326.         
  327.         # Set Robot and navigation active marker positions
  328.         $globals["robots"]["acceptedValues"array("index,follow"=>"index,follow""index,nofollow"=>"index,nofollow""noindex,follow"=>"noindex,follow""noindex,nofollow"=>"noindex,nofollow");
  329.         $globals["navigation_active_marker_position"]["acceptedValues"array("disabled"=>"disabled""before"=>"before""after"=>"after");
  330.                 
  331.         # Remove template settings:
  332.         if(isset($globals["template"])) {unset($globals["template"]);}
  333.         
  334.         #var_dump($globals);
  335.         
  336.         return $globals;
  337.             
  338.         /*$globals = array(
  339.                  "website_title" => array("label" => "Global website-title:", "value" => stripslashes($this->getConfigString("WEBSITE_TITLE")), "blank" => false),
  340.                  "website_title_seperator" => array("label" => "Website-title seperator:", "value" => stripslashes($this->getConfigString("WEBSITE_TITLE_SEPERATOR")), "blank" => false),
  341.                  "startpage" => array("label" => "Homepage:", "value" => stripslashes($this->getConfigString("STARTPAGE")), "acceptedValues" => array(), "blank" => false),
  342.                  "base" => array("label" => "Basepath:", "value" => stripslashes($this->getConfigString("BASE")), "blank" => false),
  343.                  "robots" => array("label" => "Robot settings:", "value" => stripslashes($this->getConfigString("ROBOTS")), "acceptedValues" => array(), "blank" => false),
  344.                  "speaking_urls" => array("label" => "Speaking URLs:", "value" => stripslashes($this->getConfigString("SPEAKING_URLS")), "blank" => false),
  345.                  "navigation_active_marker_position" => array("label" => "Position of active-navigation-marker:", "value" => stripslashes($this->getConfigString("NAVIGATION_ACTIVE_MARKER_POSITION")), "blank" => false),
  346.                  "navigation_active_marker" => array("label" => "Marker for active-navigation:", "value" => stripslashes($this->getConfigString("NAVIGATION_ACTIVE_MARKER")), "blank" => true),
  347.                  "navigation_active_class" => array("label" => "Class for active-navigation links:", "value" => stripslashes($this->getConfigString("NAVIGATION_ACTIVE_CLASS")), "blank" => true),
  348.                  "navigation_class" => array("label" => "Navigation class:", "value" => stripslashes($this->getConfigString("NAVIGATION_CLASS")), "blank" => true),
  349.                  "language_selector_in_footer" => array("label" => "Language selector in footer:", "value" => stripslashes($this->getConfigString("LANGUAGE_SELECTOR_IN_FOOTER")), "blank" => false),
  350.                  "language_selector_seperator" => array("label" => "Language selector seperator:", "value" => stripslashes($this->getConfigString("LANGUAGE_SELECTOR_SEPERATOR")), "blank" => false),
  351.                 "default_language" => array("label" => "Default language for frontend:", "value" => stripslashes($this->getConfigString("DEFAULT_LANGUAGE")), "blank" => false),
  352.         
  353.         );*/
  354.             
  355.         return $globals;
  356.             
  357.     // End of method declaration
  358.     
  359.     
  360.     
  361.     /**
  362.      * Method to save global config
  363.      *
  364.      * @param array $globals Array that contains all global settings
  365.      *
  366.      * @throws CaramelException
  367.      * @return void 
  368.      */
  369.     public function setGlobalsAction($globals{
  370.             
  371.         $result false;
  372.     
  373.         foreach($globals as $key => $valueArray{
  374.     
  375.             if($key != "submit"{
  376.                     
  377.                 $key strtoupper($key);
  378.                     
  379.                 $valueArray stripslashes((string)$valueArray["value"]);
  380.                     
  381.                 $result $this->setConfigString($key$valueArray);
  382.                 
  383.             }
  384.         }
  385.             
  386.         return $result;
  387.             
  388.     // End of method declaration
  389.     
  390.     
  391.     
  392.     /**
  393.      * Method to return the base admin login information
  394.      * 
  395.      * @throws CaramelException
  396.      * @return Simple array with admin login info to check while logging in
  397.      */
  398.     public function getLoginInfoAction({
  399.         
  400.         $loginInformation array();
  401.         
  402.         $loginInformation["username"$this->getAdminConfigString("ADMIN_USERNAME");
  403.         $loginInformation["password"$this->getAdminConfigString("ADMIN_PASSWORD");
  404.         $loginInformation["email"$this->getAdminConfigString("ADMIN_EMAIL");
  405.         
  406.         return $loginInformation;
  407.         
  408.     // End of method declaration
  409.     
  410.     
  411.     
  412.     /**
  413.     * This method returns an ordered array with all admin settings
  414.     * 
  415.     * @param string $lang Language to fetch options for
  416.     *
  417.     * @throws CaramelException
  418.     * @return Array with all admin settings
  419.     */
  420.     public function getAdminAction({
  421.                 
  422.         $adminConfigArray $this->getConfig($this->_adminConfigFile);
  423.                 
  424.         $languageArray array();
  425.         foreach($this->_backendLangugeData as $xmlNode{
  426.             $languageArray[(string)$xmlNode["key"]] = (string)$xmlNode;
  427.         }
  428.                 
  429.         foreach($adminConfigArray as $node{
  430.             
  431.             $admin[strtolower((string)$node["key"])array("label" => $languageArray[(string)$node["key"]]"value" => stripslashes((string)$node)"type" => (string)$node["type"]"blank" => (string)$node["blank"]"validate" => (string)$node["validate"]);
  432.             
  433.         }
  434.         
  435.         # Don't show passwords:
  436.         $admin["admin_password"]["value""";
  437.         
  438.         # Provide all language which are in our lang_admin.xml file for html select-tag:
  439.         $admin["backend_language"]["acceptedValues"array();
  440.                 
  441.         foreach($this->_allBackendLanguages as $langCode{
  442.                 
  443.             $admin["backend_language"]["acceptedValues"][$langCode$this->_isoLangCodes[$langCode];
  444.         }
  445.         
  446.         return $admin;
  447.             
  448.     // End of method declaration
  449.     
  450.     
  451.     
  452.     /**
  453.     * Method to save admin config
  454.     *
  455.     * @param array $globals Array that contains all admin settings
  456.     *
  457.     * @throws CaramelException
  458.     * @return Result of file_put_contents
  459.     */
  460.     public function setAdminAction($admin{
  461.             
  462.         $result false;
  463.     
  464.         foreach($admin as $key => $valueArray{
  465.     
  466.             if($key != "submit"{
  467.                     
  468.                 $key strtoupper($key);
  469.                     
  470.                 $valueArray stripslashes((string)$valueArray["value"]);
  471.                     
  472.                 $result $this->setAdminConfigString($key$valueArray);
  473.                                     
  474.             }
  475.         }
  476.             
  477.         return $result;
  478.             
  479.     // End of method declaration
  480.     
  481.     
  482.     
  483.     /**
  484.      * Method to get current active template
  485.      * 
  486.      * @throws CaramelException
  487.      * @return The current template set in template settings
  488.      */
  489.     public function getTemplateAction({
  490.         
  491.         return $this->getConfigString("TEMPLATE");
  492.         
  493.     // End of method declaration
  494.     
  495.     
  496.     
  497.     /**
  498.      * Method to set new template file for frontend
  499.      * 
  500.      * @param string $newTemplate New template to set
  501.      * 
  502.      * @throws CaramelException
  503.      * @return Result of file_put_contents
  504.      */
  505.     public function setTemplateAction($newTemplate{
  506.         
  507.         $this->setConfigString("TEMPLATE"$newTemplate);
  508.         
  509.         return file_put_contents(BASEDIR.'/config/site.xml'$this->_configFile->asXML());
  510.         
  511.     // End of method declaration
  512.     
  513.     
  514.     
  515.     /**
  516.      * Wrapper for getConfigString
  517.      * 
  518.      * @see getConfigString
  519.      *
  520.      * @param string $key Key to lookup in config-file
  521.      *
  522.      * @throws CaramelException
  523.      * @return string Value for given key
  524.      */
  525.     public function getConfigStringAction($key{
  526.     
  527.         return $this->getConfigString($key);
  528.     
  529.     // End of method declaration
  530.     
  531.     
  532.     
  533.     /**
  534.      * Wrapper for getAdminConfigString
  535.      * 
  536.      * @see getAdminConfigString
  537.      *
  538.      * @param string $key Key to lookup in config-file
  539.      *
  540.      * @throws CaramelException
  541.      * @return string Value for given key
  542.      */
  543.     public function getAdminConfigStringAction($key{
  544.     
  545.         return $this->getAdminConfigString($key);
  546.     
  547.     // End of method declaration
  548.     
  549.     
  550.     
  551.     /**
  552.      * Wrapper for getBackendLanguagestring
  553.      *
  554.      * @see getBackendLanguagestring
  555.      *
  556.      * @param string $key Key to lookup in config-file
  557.      *
  558.      * @throws CaramelException
  559.      * @return Value for given key
  560.      */
  561.     public function getBackendLanguageStringAction($key{
  562.                 
  563.         return $this->getBackendLanguageString($this->_backendLang$key);
  564.     
  565.     // End of method declaration
  566.     
  567.     
  568.         
  569. ############################################################################
  570. ##
  571. ##  Helper methods
  572. ##
  573. ############################################################################
  574.     
  575.         
  576.     /**
  577.      * Get full config from passed config file
  578.      *
  579.      * @throws CaramelException
  580.      * @return SimpleXMLExtended node mathing the $key
  581.      */
  582.     private function getConfig($configFile{
  583.     
  584.         $setting $configFile->xpath('setting');
  585.     
  586.         if(count($setting)>0{
  587.             return $setting;
  588.         }
  589.         else {
  590.             throw new CaramelException(10);
  591.         }
  592.     
  593.     // End of method declaration
  594.     
  595.     
  596.     
  597.     /**
  598.      * Get String from key of config-file
  599.      *
  600.      * @param string $key Key to lookup in config-file
  601.      *
  602.      * @throws CaramelException
  603.      * @return Value for given key
  604.      */
  605.     private function getConfigString($key{
  606.     
  607.         $setting $this->_configFile->xpath('//setting[@key="'.$key.'"]');
  608.     
  609.         if(count($setting)>0{
  610.             return (string)$setting[0];
  611.         }
  612.         else {
  613.             throw new CaramelException(10);
  614.         }
  615.     
  616.     // End of method declaration
  617.     
  618.     
  619.     
  620.     /**
  621.      * Set String from key of config-file
  622.      *
  623.      * @param string $key Key of the setting to change
  624.      * @param string $newValue New value for the setting
  625.      *
  626.      * @throws CaramelException
  627.      * @return Result of file_put_contents
  628.      */
  629.     private function setConfigString($key$newValue{
  630.     
  631.         $setting $this->_configFile->xpath('//setting[@key="'.$key.'"]');
  632.     
  633.         if(count($setting)>0{
  634.     
  635.             $setting[0][0null;
  636.             $setting[0][0]->addCData($newValue);
  637.     
  638.         }
  639.         else {
  640.             throw new CaramelException(10);
  641.         }
  642.         
  643.         return file_put_contents(BASEDIR.'/config/site.xml'$this->_configFile->asXML());        
  644.     
  645.     // End of method declaration
  646.     
  647.     
  648.     
  649.     /**
  650.      * Get String from key of admin configfile
  651.      *
  652.      * @param string $key Key to lookup in config-file
  653.      * 
  654.      * @throws CaramelException
  655.      * @return Value for given key
  656.      */
  657.     private function getAdminConfigString($key{
  658.     
  659.         $setting $this->_adminConfigFile->xpath('//setting[@key="'.$key.'"]');
  660.     
  661.         if(count($setting)>0{
  662.             return (string)$setting[0];
  663.         }
  664.         else {
  665.             throw new CaramelException(10);
  666.         }
  667.     
  668.     // End of method declaration
  669.     
  670.     
  671.     
  672.     /**
  673.     * Set String from key of admin config-file
  674.     *
  675.     * @param string $key Key of the setting to change
  676.     * @param string $newValue New value for the setting
  677.     *
  678.     * @throws CaramelException
  679.     * @return Result of file_put_contents
  680.     */
  681.     private function setAdminConfigString($key$newValue{
  682.     
  683.         $setting $this->_adminConfigFile->xpath('//setting[@key="'.$key.'"]');
  684.     
  685.         if(count($setting)>0{
  686.     
  687.             $setting[0][0null;
  688.             $setting[0][0]->addCData($newValue);
  689.     
  690.         }
  691.         else {
  692.             throw new CaramelException(10);
  693.         }
  694.     
  695.         return file_put_contents(BASEDIR.'/config/admin.xml'$this->_adminConfigFile->asXML());
  696.         
  697.     // End of method declaration
  698.     
  699.     
  700.     
  701.     /**
  702.      * Get string from backend languagefile
  703.      *
  704.      * @param string $lang The language to fetch the string for
  705.      * @param string $key The key of the language setting
  706.      *
  707.      * @throws CaramelException
  708.      * @return Value mathing the $lang and the $key
  709.      * @deprecated
  710.      */
  711.     private function getBackendLanguageString($lang$key{
  712.     
  713.         $setting $this->_adminLangFile->xpath('//lang[@code="'.$lang.'"]/setting[@key="'.$key.'"]');
  714.     
  715.         if(count($setting)>0{
  716.             return (string)$setting[0];
  717.         }
  718.         else {
  719.             throw new CaramelException(10);
  720.         }
  721.     
  722.     // End of method declaration
  723.     
  724.     
  725.     
  726.     /**
  727.      * Get string from backend languagefile
  728.      *
  729.      * @param string $lang The language to fetch the string for
  730.      *
  731.      * @throws CaramelException
  732.      * @return Value mathing the $lang and the $key
  733.      */
  734.     private function getBackendLanguage($lang{
  735.     
  736.         $setting $this->_adminLangFile->xpath('//lang[@code="'.$lang.'"]/setting');
  737.     
  738.         if(count($setting)>0{
  739.             return $setting;
  740.         }
  741.         else {
  742.             throw new CaramelException(10);
  743.         }
  744.     
  745.     // End of method declaration
  746.     
  747.     
  748.     
  749.     /**
  750.      * Get all languages in lang file
  751.      *
  752.      * @throws CaramelException
  753.      * @return Value mathing the $lang and the $key
  754.      */
  755.     private function getAllBackendLanguages({
  756.     
  757.         $allLanguages array();
  758.         
  759.         $setting $this->_adminLangFile->xpath('//@code');
  760.     
  761.         if(count($setting)>0{
  762.             
  763.             $setting array_unique($setting)# Remove double entries
  764.                 
  765.             foreach($setting as $langCode{
  766.                 array_push($allLanguages(string)$langCode)# Convert SimpleXMLElements into strings
  767.             }
  768.             
  769.             return $allLanguages;
  770.             
  771.         }
  772.         else {
  773.             throw new CaramelException(10);
  774.         }
  775.     
  776.     // End of method declaration
  777.     
  778.     
  779.     
  780.     /**
  781.      * This method updates the contents of the local configFile in our singleton.
  782.      *
  783.      * @throws CaramelException
  784.      * @return void 
  785.      */
  786.     private function reloadConfigFile({
  787.             
  788.         try {
  789.             $this->_configFile simplexml_load_file(BASEDIR.'/config/site.xml'"SimpleXMLExtended");
  790.         }
  791.         catch(Exception $e{
  792.             throw new CaramelException(11);
  793.         }
  794.             
  795.     // End of method declaration
  796.     
  797.     
  798.     
  799.     /**
  800.      * This method updates the contents of the local adminConfigFile in our singleton.
  801.      *
  802.      * @throws CaramelException
  803.      * @return void 
  804.      */
  805.     private function reloadAdminConfigFile({
  806.  
  807.         try {
  808.             $this->_adminConfigFile simplexml_load_file(BASEDIR.'/config/admin.xml'"SimpleXMLExtended");
  809.         }
  810.         catch(Exception $e{
  811.             throw new CaramelException(11);
  812.         }
  813.     
  814.     // End of method declaration
  815.     
  816.     
  817.     
  818.     /**
  819.      * This method updates the contents of the local langFile in our singleton.
  820.      *
  821.      * @throws CaramelException
  822.      * @return void 
  823.      */
  824.     private function reloadAdminLangFile({
  825.             
  826.         try {
  827.             $this->_adminLangFile simplexml_load_file(BASEDIR.'/config/lang.xml'"SimpleXMLExtended");
  828.         }
  829.         catch(Exception $e{
  830.             throw new CaramelException(11);
  831.         }
  832.             
  833.     // End of method declaration
  834.  
  835.  
  836. }
  837. ?>