summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3c3e9f3)
raw | patch | inline | side by side (parent: 3c3e9f3)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 27 Mar 2008 08:29:43 +0000 (08:29 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 27 Mar 2008 08:29:43 +0000 (08:29 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10009 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/fai/admin/fai/class_debconfTemplate.inc | patch | blob | history | |
gosa-plugins/fai/admin/fai/class_faiPackageConfiguration.inc | patch | blob | history |
diff --git a/gosa-plugins/fai/admin/fai/class_debconfTemplate.inc b/gosa-plugins/fai/admin/fai/class_debconfTemplate.inc
index d781321ec8daba9f701e18fa561ff5738a966e41..7f753a0d476afa6469b896771288aea92a07a579 100644 (file)
var $package= "";
var $language= "";
var $loaded_template= FALSE;
- var $template_directory= "";
var $template= array();
- function debconf($package= "", $language= "")
+ function debconf($language= "")
{
$this->set_language($language);
- $this->set_package($package);
}
-
- function set_package($package)
- {
- $this->package= $package;
- }
-
-
- function set_template_directory($directory)
- {
- if (is_dir($directory) && is_readable($directory)){
- $this->template_directory = $directory;
- return TRUE;
- }
-
- $this->template_directory= "";
- return FALSE;
- }
-
-
function set_language($language)
{
$this->language= $language;
}
-
- function load()
+ function load_from_string($str)
{
- if( TRUE === $this->has_template() ) {
-
- /* Try to load package based template file */
- $this->template= array();
-
- /* Read template array */
- $post_name = 0;
- $langcode = $this->language.".UTF-8";
- $in_description = FALSE;
- $got_local_description = FALSE;
-
- /* get filename */
- $filename= preg_replace("/\/+/", "/", $this->template_directory."/".$this->package.".templates");
-
- /* Check if file is readable */
- if (!is_file($filename) || !is_readable($filename)){
- return(FALSE);
+ $lines = split("\n",$str);
+ $this->template = array();
+ $post_name = 0;
+ $langcode = $this->language.".UTF-8";
+ $in_description = FALSE;
+ $got_local_description = FALSE;
+
+ foreach($lines as $line){
+
+ /* Reset description flag */
+ if ($in_description && !preg_match("/^ /", $line)){
+ $in_description= FALSE;
}
- /* Open file and read content line by line */
- $fh= fopen($filename, 'r');
-
- /* While the file handle is valid && there is still data to read -> parse configuration file */
- while ($fh && !feof($fh)){
- $line= fgets($fh, 1024);
-
- /* Reset description flag */
- if ($in_description && !preg_match("/^ /", $line)){
- $in_description= FALSE;
- }
-
- /* Template header */
- if (preg_match("/^Template: /", $line)){
- $post_name ++;
- $name= trim(preg_replace("/^Template: (.*)$/", "\\1", $line));
- $this->template[$post_name]['Name'] = $name;
- $this->template[$post_name]['Default'] ="";
-
- $got_local_description= FALSE;
- continue;
- }
-
- /* Get type */
- if (preg_match("/^Type: /", $line)){
- $type= trim(preg_replace("/^Type: (.*)$/", "\\1", $line));
- $this->template[$post_name]['Type']= $type;
- continue;
- }
+ /* Template header */
+ if (preg_match("/^Template: /", $line)){
+ $post_name ++;
+ $name= trim(preg_replace("/^Template: (.*)$/", "\\1", $line));
+ $this->template[$post_name]['Name'] = $name;
+ $this->template[$post_name]['Default'] ="";
- /* Get default */
- if (preg_match("/^Default: /", $line)){
- $this->template[$post_name]['Default']= "";
- $default= trim(preg_replace("/^Default: (.*)$/", "\\1", $line));
- $this->template[$post_name]['Default']= $default;
- continue;
- }
+ $got_local_description= FALSE;
+ continue;
+ }
- /* Get description */
- if (!$got_local_description && preg_match("/^Description: /", $line)){
- $this->template[$post_name]['Description']= "";
- $description= trim(preg_replace("/^Description: (.*)$/", "\\1", $line));
- $this->template[$post_name]['Topic']= $description;
- $this->template[$post_name]['Description']= "";
- $in_description= TRUE;
- continue;
- }
+ /* Get type */
+ if (preg_match("/^Type: /", $line)){
+ $type= trim(preg_replace("/^Type: (.*)$/", "\\1", $line));
+ $this->template[$post_name]['Type']= $type;
+ continue;
+ }
- /* Fill description */
- if (!$got_local_description && $in_description){
- $description= preg_replace("/^ (.*)$/", "\\1", $line);
- $this->template[$post_name]['Description'].= $description;
- continue;
- }
+ /* Get default */
+ if (preg_match("/^Default: /", $line)){
+ $this->template[$post_name]['Default']= "";
+ $default= trim(preg_replace("/^Default: (.*)$/", "\\1", $line));
+ $this->template[$post_name]['Default']= $default;
+ continue;
+ }
- /* Get local description */
- if (preg_match("/^Description-$langcode: /", $line)){
- $description= trim(preg_replace("/^Description-$langcode: (.*)$/", "\\1", $line));
- $this->template[$post_name]['Topic']= $description;
- $in_description= TRUE;
- $got_local_description= TRUE;
- $this->template[$post_name]['Description']= "";
- continue;
- }
+ /* Get description */
+ if (!$got_local_description && preg_match("/^Description: /", $line)){
+ $this->template[$post_name]['Description']= "";
+ $description= trim(preg_replace("/^Description: (.*)$/", "\\1", $line));
+ $this->template[$post_name]['Topic']= $description;
+ $this->template[$post_name]['Description']= "";
+ $in_description= TRUE;
+ continue;
+ }
- /* Fill local description */
- if ($got_local_description && $in_description){
- $description= preg_replace("/^ (.*)$/", "\\1", $line);
- $this->template[$post_name]['Description'].= $description;
- continue;
- }
+ /* Fill description */
+ if (!$got_local_description && $in_description){
+ $description= preg_replace("/^ (.*)$/", "\\1", $line);
+ $this->template[$post_name]['Description'].= $description;
+ continue;
+ }
- /* Get native choices */
- if (preg_match("/^Choices: /", $line)){
- $type= trim(preg_replace("/^Choices: (.*)$/", "\\1", $line));
- $this->template[$post_name]['Choices']= $type;
- }
+ /* Get local description */
+ if (preg_match("/^Description-$langcode: /", $line)){
+ $description= trim(preg_replace("/^Description-$langcode: (.*)$/", "\\1", $line));
+ $this->template[$post_name]['Topic']= $description;
+ $in_description= TRUE;
+ $got_local_description= TRUE;
+ $this->template[$post_name]['Description']= "";
+ continue;
+ }
- /* Get local choices */
- if (preg_match("/^Choices-$langcode: /", $line)){
- $type= trim(preg_replace("/^Choices-$langcode: (.*)$/", "\\1", $line));
- $this->template[$post_name]['Choices-local']= $type;
- }
+ /* Fill local description */
+ if ($got_local_description && $in_description){
+ $description= preg_replace("/^ (.*)$/", "\\1", $line);
+ $this->template[$post_name]['Description'].= $description;
+ continue;
+ }
+ /* Get native choices */
+ if (preg_match("/^Choices: /", $line)){
+ $type= trim(preg_replace("/^Choices: (.*)$/", "\\1", $line));
+ $this->template[$post_name]['Choices']= $type;
}
- fclose($fh);
- $this->loaded_template= TRUE;
-
- $tmp= array();
- foreach($this->template as $post_name => $template){
- $template['post_name'] = "post_".$post_name;
- $tmp[] = $template;
+ /* Get local choices */
+ if (preg_match("/^Choices-$langcode: /", $line)){
+ $type= trim(preg_replace("/^Choices-$langcode: (.*)$/", "\\1", $line));
+ $this->template[$post_name]['Choices-local']= $type;
}
- $this->template = $tmp;
- return (TRUE);
}
- $this->loaded_template= FALSE;
- return (FALSE);
- }
+ $this->loaded_template= TRUE;
+ $tmp= array();
+ foreach($this->template as $post_name => $template){
+ $template['post_name'] = "post_".$post_name;
+ $tmp[] = $template;
+ }
+ $this->template = $tmp;
+
+ return (TRUE);
+ }
function has_template()
{
- /* Reject requests, if parameters are not set */
- if ($this->package == "" || $this->template_directory == ""){
- return (FALSE);
- }
- $filename= preg_replace("/\/+/", "/", $this->template_directory."/".$this->package.".templates");
- return (is_file($filename) && is_readable($filename));
+ return(count($this->template) != FALSE);
}
$this->template[$post_name]['Default'] = preg_replace("/, $/","",$this->template[$post_name]['Default']);
}
}
-
-
}
diff --git a/gosa-plugins/fai/admin/fai/class_faiPackageConfiguration.inc b/gosa-plugins/fai/admin/fai/class_faiPackageConfiguration.inc
index 7212e1c3be2125beb1619f2e43253c108cbde024..2317b31d59d9dfa5e4f853aeab5a93531f033c82 100644 (file)
plugin::plugin ($config, $dn);
$this->obj = $obj;
$this->release = $release;
+ $this->pkg_config = $pkg_config;
-
-# $this->Debconf_handle = new debconf();
-# $this->Debconf_handle->set_template_directory($path);
-# $this->Debconf_handle->set_package($this->obj);
-# $this->Debconf_handle->set_language(preg_replace('/_.*$/', '', get_browser_language()));
-#
-# if( $this->Debconf_handle->load() ) {
-# $this->pkg_config = $pkg_config;
-#
-# foreach($this->pkg_config as $var){
-# $this->Debconf_handle->SetDefault($var['Name'],$var['Value']);
-# }
-# }
+ /* Read pkg debconf info */
+ $q = new gosaSupportDaemon();
+ $ret = $q->FAI_get_packages($this->release,array("*"),$this->obj);
+ $tpl = "";
+ if(isset($ret['ANSWER1']) && isset($ret['ANSWER1']['TEMPLATE'])){
+ $tpl = base64_decode($ret['ANSWER1']['TEMPLATE']);
+ }
+ $this->Debconf_handle = new debconf(preg_replace('/_.*$/', '', get_browser_language()));
+ $this->Debconf_handle->load_from_string($tpl);
+ if($this->Debconf_handle->has_template()){
+ foreach($this->pkg_config as $var){
+ $this->Debconf_handle->SetDefault($var['Name'],$var['Value']);
+ }
+ }
}
function execute()
/* Call parent execute */
plugin::execute();
- $q = new gosaSupportDaemon();
- $ret = $q->FAI_get_packages($this->release,$this->obj);
- print_a($ret);
-
-
- return("Not implemented yet<input type='submit' name='CancelObjectConfig' value='back'>");
/* Fill templating stuff */
$smarty = get_smarty();