Code

Updated Config Management
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 4 Apr 2011 13:50:16 +0000 (13:50 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 4 Apr 2011 13:50:16 +0000 (13:50 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20648 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto-ng/admin/newConfigManagement/class_ConfigManagementListing.inc
gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc
gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/TemplateEngine.tpl [new file with mode: 0644]
gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/puppet.tpl [new file with mode: 0644]

index 8c3ea548a2b434e21570150f4baa38bfb1f71fc9..762353f433a0097b0f989ce47875e69819557d3e 100644 (file)
@@ -63,6 +63,20 @@ class ConfigManagementListing extends management
         $this->objectTypeStr = $str;
     }
 
+    
+    // Inject user actions
+    function detectPostActions()
+    {
+        $action = management::detectPostActions();
+        if(isset($_POST['saveItemEdit'])) $action['action'] = "saveItemChanges";
+        if(isset($_POST['saveItemAdd'])) $action['action'] = "saveItemAdd";
+        if(isset($_POST['cancelItemEdit'])) $action['action'] = "cancelItemEdit";
+        if(isset($_POST['cancelItemAdd'])) $action['action'] = "cancelItemAdd";
+        return($action);
+    }
+
+
+
 
     function execute()
     {
@@ -171,6 +185,9 @@ class ConfigManagementListing extends management
         $this->registerAction("saveFilter","saveFilter");
         $this->registerAction("cancelFilter","cancelFilter");
 
+        $this->registerAction("cancelItemEdit", "closeDialogs");
+        $this->registerAction("cancelItemAdd", "closeDialogs");
+        $this->registerAction("saveItemAdd", "saveItemAdd");
     }
 
     function removeEntryRequested($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
@@ -185,7 +202,10 @@ class ConfigManagementListing extends management
 
     function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
     {
-        $this->parent->editEntry($target);
+        $this->dialogObject = $this->parent->TemplateEngine;
+        $this->skipFooter = TRUE;
+        $this->dialog = TRUE;
+
     }
 } 
 
index 5b2a60f2e0edae5b5dc73371ebe6a6143552b802..f3d16981970b725569b245d4b5bfa529ba1e1991 100644 (file)
@@ -21,6 +21,11 @@ class newConfigManagement extends plugin
         $this->config = &$config;
         $this->listing = new ConfigManagementListing($this->config, get_userinfo(), $this);
 
+        // Load the template engine and tell her what template
+        //  to use for the HTML it produces.
+        $this->TemplateEngine = new TemplateEngine($config);
+        $this->TemplateEngine->setTemplate('puppet.tpl');
+
         // Request an update of the data model
         $this->loadInstallationMethods();
         $this->updateDataModel();
@@ -28,6 +33,45 @@ class newConfigManagement extends plugin
     }
 
 
+    /*! \brief  Sets the installation method to the given method.
+     *          Updates the template engine and adds the initial root
+     *           object for the selected method.
+     *  @param  The method to use.
+     *  @return TRUE on success else FALSE.
+     */
+    function setInstallMethod($str)
+    {
+        if(!isset($this->installationMethods[$str])){
+            $this->itemConfig = array();
+            $this->invalidInstallMethod =TRUE;
+            $this->errorMessage = sprintf(_("Invalid installation method %s selected!"), bold($str));
+            msg_dialog::display(_("Setup"), $this->errorMessage, ERROR_DIALOG);
+            return(FALSE);
+        }else{
+
+            $this->itemConfig = $this->installationMethods[$str]['items'];
+            $this->invalidInstallMethod =FALSE;
+            $this->TemplateEngine->load($this->itemConfig);
+
+            // Detect root item, its name is /
+            $root = NULL;
+            foreach($this->itemConfig as $key => $item){
+                if($item['name'] == '/') {
+                    $root = $key;
+                    break;
+                }
+            }
+            if(!$root){
+                $this->errorMessage = sprintf(_("Installation method %s is invalid: no root object found!"), bold($str));
+                msg_dialog::display(_("Setup"), $this->errorMessage , ERROR_DIALOG);
+                $this->initFailed = TRUE;
+                $this->itemConfig = array();
+                return(FALSE);
+            }
+        }
+    }
+
+
     /*! \brief  Updates all distributions, releases, packages and items in the dataModel
      *          Load information from the backend.
      */
@@ -160,6 +204,9 @@ class newConfigManagement extends plugin
         // Transfer checked values back to the listing class.
         $this->listing->setContainers($this->getContainerList());
         $this->listing->setContainer($cont);
+
+        $this->setInstallMethod('puppet');
+
     }
 
 
@@ -303,36 +350,9 @@ class newConfigManagement extends plugin
      */
     function editEntry($ids)
     {
-        foreach($ids as $id){
-            echo "<br>Edit {$id}";
-        }
-    }
-
-
-    /*! \brief  Acts on remove requests.
-     *          (This action is received from the ConfigManagementListing class.)
-     *  @param  Array   The items ids. (May contain multiple ids)
-     *  @return  
-     */
-    function removeEntry($ids)
-    {
-        foreach($ids as $id){
-            echo "<br>Remove {$id}";
-        }
-    }
-
-
-    /*! \brief  Acts on open requests.
-     *          (This action is received from the ConfigManagementListing class.)
-     *  @param  Array   The items ids. (May contain multiple ids)
-     *  @return  
-     */
-    function openEntry($ids)
-    {
-        $id = $ids[0];
-        $item = $this->dataModel->getItemById($id);
-        $this->setCurrentContainer($item['path']);
-        return; 
+        // Update the template engine to use another type of item and
+        //  some other values.
+        $this->TemplateEngine->setValues('PuppetTemplate',array('data' => array()));
     }
 
 
@@ -356,6 +376,21 @@ class newConfigManagement extends plugin
     }
 
 
+    /*! \brief  Acts on open requests.
+     *          (This action is received from the ConfigManagementListing class.)
+     *  @param  Array   The items ids. (May contain multiple ids)
+     *  @return
+     */
+    function openEntry($ids)
+    {
+        $id = $ids[0];
+        $item = $this->dataModel->getItemById($id);
+        $this->setCurrentContainer($item['path']);
+        return;
+    }
+
+
+
     /*! \brief   
      *  @param  
      *  @return 
diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/TemplateEngine.tpl b/gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/TemplateEngine.tpl
new file mode 100644 (file)
index 0000000..e60c5ae
--- /dev/null
@@ -0,0 +1,11 @@
+<h3>Bla</h3>
+
+{$template}
+
+<hr>
+
+<div class='plugin-actions'>
+    <button name='saveItemEdit'>{msgPool type=okButton}</button>
+    <button name='cancelItemEdit'>{msgPool type=cancelButton}</button>
+</div>
+
diff --git a/gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/puppet.tpl b/gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/puppet.tpl
new file mode 100644 (file)
index 0000000..8b8d95b
--- /dev/null
@@ -0,0 +1,39 @@
+{if $type == 'PuppetModule'}
+    <table width="100%">
+        <tr>
+            <td style="width:50%; vertical-align: top;">
+                <table>
+                    <tr>
+                        <td>{$nameName}</td>
+                        <td>{$name}</td>
+                    </tr>
+                    <tr>
+                        <td>{$descriptionName}</td>
+                        <td>{$description}</td>
+                    </tr>
+                    <tr>
+                        <td>{$versionName}</td>
+                        <td>{$version}</td>
+                    </tr>
+                </table>
+            </td>
+            <td style="width:50%; vertical-align: top;">
+                {$dependencyName}:<br>
+                {$dependency}
+            </td>
+        </tr>
+    </table>
+{/if}
+{if $type == 'PuppetTemplate'}
+    <table>
+        <tr>
+            <td>{$nameName}</td>
+            <td>{$name}</td>
+        </tr>
+        <tr>
+            <td>{$dataName}</td>
+            <td>{$data}</td>
+        </tr>
+    </table>
+    <input type='submit'>    
+{/if}