Ejemplo n.º 1
0
 /**
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  * @return boolean Indicating success.
  */
 public function _handler_view($handler_id, array $args, array &$data)
 {
     $data['name'] = $args[0];
     if (!midcom::get('componentloader')->is_installed($data['name'])) {
         throw new midcom_error_notfound("Component {$data['name']} is not installed.");
     }
     $componentpath = midcom::get('componentloader')->path_to_snippetpath($data['name']);
     // Load and parse the global config
     $cfg = midcom_baseclasses_components_configuration::read_array_from_file("{$componentpath}/config/config.inc");
     if (!$cfg) {
         // hmmm... that should never happen
         $cfg = array();
     }
     $config = new midcom_helper_configuration($cfg);
     // Go for the sitewide default
     $cfg = midcom_baseclasses_components_configuration::read_array_from_file("/etc/midgard/midcom/{$data['name']}/config.inc");
     if ($cfg !== false) {
         $config->store($cfg, false);
     }
     // Finally, check the sitegroup config
     $cfg = midcom_baseclasses_components_configuration::read_array_from_snippet("{$GLOBALS['midcom_config']['midcom_sgconfig_basedir']}/{$data['name']}/config");
     if ($cfg !== false) {
         $config->store($cfg, false);
     }
     $data['config'] =& $config;
     $this->_update_breadcrumb($data['name']);
     $this->_prepare_toolbar($data);
     midcom::get('head')->set_pagetitle($data['view_title']);
 }
Ejemplo n.º 2
0
 private function _load_configs($component, $object = null)
 {
     $componentpath = midcom::get('componentloader')->path_to_snippetpath($component);
     // Load and parse the global config
     $cfg = midcom_baseclasses_components_configuration::read_array_from_file("{$componentpath}/config/config.inc");
     if (!$cfg) {
         // Empty defaults
         $cfg = array();
     }
     $config = new midcom_helper_configuration($cfg);
     if ($object) {
         $topic_config = new midcom_helper_configuration($object, $component);
     }
     // Go for the sitewide default
     $cfg = midcom_baseclasses_components_configuration::read_array_from_file("/etc/midgard/midcom/{$component}/config.inc");
     if ($cfg !== false) {
         $config->store($cfg, false);
     }
     // Finally, check the sitegroup config
     $cfg = midcom_baseclasses_components_configuration::read_array_from_snippet("{$GLOBALS['midcom_config']['midcom_sgconfig_basedir']}/{$component}/config");
     if ($cfg !== false) {
         $config->store($cfg, false);
     }
     if (isset($topic_config)) {
         $config->store($topic_config->_local);
     }
     return $config;
 }
Ejemplo n.º 3
0
 /**
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  * @return boolean Indicating success.
  */
 public function _handler_edit($handler_id, array $args, array &$data)
 {
     $this->_component_name = $args[0];
     if (!midcom::get('componentloader')->is_installed($this->_component_name)) {
         throw new midcom_error_notfound("Component {$this->_component_name} is not installed.");
     }
     $componentpath = midcom::get('componentloader')->path_to_snippetpath($this->_component_name);
     // Load and parse the global config
     $cfg = midcom_baseclasses_components_configuration::read_array_from_file("{$componentpath}/config/config.inc");
     if (!$cfg) {
         // hmmm... that should never happen
         $cfg = array();
     }
     $this->_libconfig = new midcom_helper_configuration($cfg);
     // Go for the sitewide default
     $cfg = midcom_baseclasses_components_configuration::read_array_from_file("/etc/midgard/midcom/{$this->_component_name}}/config.inc");
     if ($cfg !== false) {
         $this->_libconfig->store($cfg, false);
     }
     // Finally, check the sitegroup config
     $cfg = midcom_baseclasses_components_configuration::read_array_from_snippet("{$GLOBALS['midcom_config']['midcom_sgconfig_basedir']}/{$this->_component_name}/config");
     if ($cfg !== false) {
         $this->_libconfig->store($cfg, false);
     }
     $this->_controller = $this->get_controller('nullstorage');
     switch ($this->_controller->process_form()) {
         case 'save':
             if ($this->_save_configuration()) {
                 mgd_cache_invalidate();
                 midcom::get('uimessages')->add($this->_l10n->get('host configuration'), $this->_l10n->get('settings saved successfully') . $this->_codeinit->id, 'ok');
             } else {
                 midcom::get('uimessages')->add($this->_l10n->get('host configuration'), sprintf($this->_l10n->get('failed to save settings, reason %s')), 'error');
             }
             // *** FALL-THROUGH ***
         // *** FALL-THROUGH ***
         case 'cancel':
             return new midcom_response_relocate('__mfa/asgard_midcom.admin.libconfig/edit/' . $this->_component_name);
     }
     $data['controller'] =& $this->_controller;
     $this->_update_breadcrumb();
     midcom::get('head')->set_pagetitle($data['view_title']);
 }