Code

Updated repository list.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 28 Nov 2007 07:38:43 +0000 (07:38 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 28 Nov 2007 07:38:43 +0000 (07:38 +0000)
 - Its time for a new list, the old one does unpredictable things.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7921 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_servRepository.inc
plugins/admin/systems/servRepository.tpl

index e1c9a2e05de0b2308a657c4c362c50048c2d26aa..de72d986e397a8165a1782e6eecca2c3a509729e 100644 (file)
@@ -12,9 +12,6 @@ class servrepository extends goService
   var $attributes             = array("FAIrepository");
   var $objectclasses          = array("FAIrepositoryServer");
   
-  /* Search filter */
-  var $regex                  = "*";
-
   /* Repositories */
   var $repositories          = array();
   var $FAIrepository         = array();
@@ -25,6 +22,8 @@ class servrepository extends goService
   var $view_logged            = FALSE;
   var $fai_activated          = FALSE;
 
+  var $divlist = NULL;
+
   function servrepository (&$config, $dn= NULL, $parent= NULL)
   {
     plugin::plugin ($config, $dn, $parent);
@@ -79,6 +78,24 @@ class servrepository extends goService
         $this->repositories[$tmp[2]]=$tmp2;      
       }
     }
+
+
+    /* Create divlist */
+    $divlist = new MultiSelectWindow($this->config,"repositories","server/servRepository");
+    $divlist->SetTitle("repositories");
+    $divlist->SetSummary(_("List of configured repositories."));
+    $divlist->SetInformation(_("This menu allows you to create, delete and edit repository settings."));
+    $divlist->EnableCloseButton(FALSE);
+    $divlist->EnableSaveButton(FALSE);
+    $divlist->AddHeader(array("string"=>_("Release"),"attach"=>"style='width:80px;'"));
+    $divlist->AddHeader(array("string"=>_("Sections")));
+    $divlist->AddHeader(array("string"=>_("Options"),"attach"=>"style='border-right:0px;width:55px;'"));
+    $divlist->AddRegex("regex",_("Regular expression for matching object names"),"*",TRUE);
+    $divlist->EnableAplhabet(TRUE);
+    if($this->acl_is_createable()){
+      $divlist->SetListHeader("<input type=\"image\" src=\"images/fai_new_packages.png\" title=\""._("Add repository")."\" name=\"AddRepository\">");
+    }
+    $this->divlist = $divlist;
   }
 
   function execute()
@@ -101,15 +118,6 @@ class servrepository extends goService
     $smarty->assign("is_createable",$this->acl_is_createable());
     $display= "";
 
-    /* Smarty vars*/
-    $smarty->assign("infoimage",    get_template_path('images/info.png'));
-    $smarty->assign("search_image", get_template_path('images/search.png'));
-    $smarty->assign("launchimage",  get_template_path('images/small_filter.png'));
-    $smarty->assign("tree_image",   get_template_path('images/tree.png'));
-    $smarty->assign("alphabet",     generate_alphabet());
-    $smarty->assign("apply",        apply_filter());
-    $smarty->assign("regex",        $this->regex);
-
     /* Show tab dialog headers */
     /*
        ADD / EDIT Repository
@@ -200,14 +208,14 @@ class servrepository extends goService
         }
       }
     }
-    if((isset($_GET['act']))&&($_GET['act']=="open")&&(isset($_GET['id']))){
+    if((isset($_GET['act']))&&($_GET['act']=="open_repository")&&(isset($_GET['id']))){
       $obj = $this->repositories[base64_decode($_GET['id'])];
       $obj['initialy_was'] = $obj['Release'];
       $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj);
       $this->dialog->parent = $this;
     }
 
-    if(isset($_POST['repository_setup_save'])){
+    if(isset($_POST['repository_setup_save']) && is_object($this->dialog)){
       $this->dialog->save_object();
       if(($this->dialog->is_new_name())&&(isset($this->repositories[$this->dialog->GetName()]))){
         print_red(_("This name is already in use."));
@@ -246,17 +254,8 @@ class servrepository extends goService
       Repository setup dialog handling /END
     */
 
-    $divlist = new divlist("repositories");
-    $divlist->SetEntriesPerPage(0);
-    $divlist->setHeight(400);
-    $divlist->SetPluginMode();
 
-    $divlist->setHeader(array(array("string"=>_("Release"),"attach"=>"style='width:80px;'"),
-                              array("string"=>_("Sections")),
-                              array("string"=>_("Options"),"attach"=>"style='border-right:0px;width:55px;'")
-                       )     );
-
-    $link   = "<a href='?plug=".$_GET['plug']."&amp;act=open&amp;id=%s'>%s</a>";
+    $link   = "<a href='?plug=".$_GET['plug']."&amp;act=open_repository&amp;id=%s'>%s</a>";
     $edit   = "<input type='image' value='%s' name='edit_%s'   src='images/edit.png'>&nbsp;";
    
     /* Hide delete icon, if delete is not allowed */ 
@@ -266,22 +265,23 @@ class servrepository extends goService
       $delete = "<img src='images/empty.png' alt='&nbsp;'>";
     }
   
+    $this->divlist->ClearElementsList(); 
     foreach($this->repositories as $name => $reps){
 
       $str = " ";
-      if(preg_match("/".str_replace("*",".*",$this->regex)."/",$reps['Release'])){
-      foreach($reps['Sections'] as $sec){
-        $str.=$sec." ";  
-      }    
-      $divlist->AddEntry(array(
-          array("string"=>sprintf($link,base64_encode($name),$name),"attach"=>"style='width:80px;'"),
-          array("string"=>sprintf($link,base64_encode($name),_("Sections")." :".$str)),
-          array("string"=>preg_replace("/%s/",base64_encode($name),$edit.$delete),"attach"=>"style='border-right:0px;width:55px;text-align:right;'")
-                              ));
+      if(preg_match("/".str_replace("*",".*",$this->divlist->regex)."/",$reps['Release'])){
+        foreach($reps['Sections'] as $sec){
+          $str.=$sec." ";  
+        }    
+        $this->divlist->AddElement(array(
+              array("string"=>sprintf($link,base64_encode($name),$name),"attach"=>"style='width:80px;'"),
+              array("string"=>sprintf($link,base64_encode($name),_("Sections")." :".$str)),
+              array("string"=>preg_replace("/%s/",base64_encode($name),$edit.$delete),"attach"=>"style='border-right:0px;width:55px;text-align:right;'")
+              ));
       }
     }
  
-    $smarty -> assign("Repositories",$divlist->DrawList());
+    $smarty->assign("Repositories",$this->divlist->Draw());
 
     $display.= $smarty->fetch(get_template_path('servRepository.tpl', TRUE));
     return($display);
@@ -292,8 +292,8 @@ class servrepository extends goService
   function save_object()
   {
     plugin::save_object();
-    if(isset($_POST['regex'])){
-      $this->regex = $_POST['regex'];
+    if(is_object($this->divlist)){
+      $this->divlist->save_object();
     }
   }
 
index 7feaf1d3c2b2838edfbac12439507428d062cfb9..ca42710c15e9ea9c304b9136cb8ede80984f64a5 100644 (file)
@@ -1,70 +1,9 @@
-<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
-<tr>
-  <td style="vertical-align:top;width:600px">
-  <div class="contentboxh" style="height:20px;">
-    <p class="contentboxh" style="font-size:12px">
-     {t}List of configured repositories.{/t}
-    </p>
-  </div>
-  <div class="contentboxb">
-       <div style='background:#F0F0F9;padding:5px;'>
-{if $is_createable}
-               <input type="image" src="images/fai_new_packages.png" title="{t}Add repository{/t}" name="AddRepository">
-{/if}
-       </div>
-</div>
-<div style='height:4px;'></div>          
-  <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
 {$Repositories}
-    <input type=hidden name="edit_helper">
-  </div>
-  </td>
-               <td style="vertical-align:top;">
-                       <div class="contentboxh" style="height:20px;border-bottom:1px solid #B0B0B0">
-                               <p class="contentboxh" style="font-size:12px">
-                                       <img src="images/info_small.png" align="right" alt="[i]">
-                                       {t}Information{/t}
-                               </p>
-                       </div>
-                       <div class="contentboxb" style="padding:0px;margin:0px;background:#f0f0f0;">
-                               <p class="contentboxb" style="border-color:#f0f0f0;">
-                                       {t}This menu allows you to create, delete and edit repository settings.{/t}
-                               </p>
-                       </div>
-                       <br>
-                       <div class="contentboxh" style="height:20px">
-                               <p class="contentboxh" style="font-size:12px">
-                                       <img src="images/small_filter.png" align="right" alt="[F]">
-                                       {t}Filters{/t}
-                               </p>
-                       </div>
-   <div class="contentboxb">
-     <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
-      {$alphabet}
-     </table>
-     <table summary=""  style="width:100%;border-top:1px solid #B0B0B0;">
-     <tr>
-     <td>
-     <img alt="{t}Display objects matching{/t}" src="{$search_image}" align='middle' title='{t}Display objects matching{/t}'/>
-     </td>
-     <td width="99%">
-     <input type='text' name='regex' maxlength='20' style='width:99%' value='{$regex}' id='filter' 
-     title='{t}Regular expression for matching object names{/t}' onChange="mainform.submit()">
-     </td>
-     </tr>
-     </table>
-                         {$apply}
-   </div>
-  </td>
-</tr>
-</table>
 <input type="hidden" name="servRepository" value="1">
 
 <p class="seperator">&nbsp;</p>
-<p>
 <div style="width:100%; text-align:right;">
        <input type='submit' name='SaveService' value='{t}Save{/t}'>
        &nbsp; 
        <input type='submit' name='CancelService' value='{t}Cancel{/t}'> 
 </div>
-</p>