FAIdebianRelease = $release; $this->selected = $used_packages; $this->initializeSections(); /* Get old search filter, if there is one*/ $this->searchStrPKG = _("Please enter your search string here"); if(session::is_set("searchStrPKG")){ $this->searchStrPKG = session::get("searchStrPKG"); } } /*! \brief Load all release seactions from GOsa support daemon */ function initializeSections() { $this->package_sections = array(); $q = new gosaSupportDaemon(); $ret = $q->FAI_get_package_sections($this->FAIdebianRelease); if($q->is_error()){ msg_dialog::display(_("Service infrastructure"),msgPool::siError($q->get_error()),ERROR_DIALOG); }else{ foreach($ret as $entry){ $this->package_sections[array_pop($entry)] = TRUE; } } } /*! \brief Create HTML for this plugin. @return String The html code for this plugin. */ function execute() { /* Call parent execute */ plugin::execute(); /* Fill templating stuff */ $smarty = get_smarty(); $display = ""; /* Create section checkboxes */ $Section_boxes = "
"; $i = 0; foreach($this->package_sections as $cat => $selected){ $Section_boxes .= ""; if($i == 2){ $Section_boxes .=""; $i = 0; } if($selected){ $Section_boxes .=""; }else{ $Section_boxes .=""; } $i ++ ; } $Section_boxes .= "
 ".$cat."  ".$cat." 
"; /* Create List && fill it with packages */ $cnt = 0; $this->reload(); $divlist = new divlist("PackageEntry"); $divlist->SetPluginMode(); $divlist->SetSummary(_("This list displays all assigned package names for this repository settings.")); $divlist->SetEntriesPerPage(0); $divlist->SetHeader(array(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), array("string" => "Name", "attach" => "style='width:180px;'"), array("string" => "Version", "attach"=>"style='width:240px;'" ), array("string" => "Description", "attach" => "style='border-right:0px;text-align:left;'"))); foreach($this->pkgs as $pkg){ if(in_array($pkg['PACKAGE'],$this->selected)){ $check = " checked "; }else{ $check = ""; } $desc = " "; if(isset($pkg['DESCRIPTION'])){ $desc = base64_decode($pkg['DESCRIPTION']); } $chkbox = " "; $divlist->AddEntry(array(array("string"=>$chkbox, "attach" => "style='text-align:center;width:20px;'"), array("string"=>"
".$pkg['PACKAGE']."
", "attach" => "style='width:180px;' title='".$pkg['PACKAGE']." (".$pkg['VERSION'].")'"), array("string"=>"
".htmlentities($pkg['VERSION'])."
", "attach" => "style='width:240px' title='".$pkg['PACKAGE']." (".$pkg['VERSION'].")'"), array("string"=>htmlentities($desc), "attach" => "style='border-right:0px;text-align:left;'"))); } $smarty->assign("Section_boxes" , $Section_boxes); $smarty->assign("searchStrPKG" , $this->searchStrPKG); $smarty->assign("faihead" , ""); $smarty->assign("failist" , $divlist->DrawList()); $smarty->assign("infoimage" , get_template_path('images/info.png')); $smarty->assign("launchimage" , get_template_path('images/launch.png')); $smarty->assign("alphabet" , generate_alphabet()); $smarty->assign("apply" , apply_filter(TRUE)); $smarty->assign("search_image" , get_template_path('images/lists/search.png')); $display.= $smarty->fetch(get_template_path('faiPackageEntry.tpl', TRUE)); return($display); } /*! \brief Save HTML POST data to object */ function save_object() { /* Keep sections selected */ foreach($_POST as $name => $value){ if(preg_match("/^wasonpage_/i",$name)){ $name = preg_replace("/^wasonpage_/","",$name); $n =base64_decode($name); if(isset($_POST['use_'.$name])){ $this->selected[$n] = $n; }else{ if(isset($this->selected[$n])){ unset($this->selected[$n]); } } } if(preg_match("/^CAT/i", $name)) { $key = "use$name"; $section = preg_replace("/^CAT/i", "", $name); if (isset($_POST[$key])) { $this->package_sections[$section] = TRUE; }else { $this->package_sections[$section] = FALSE; } } } /* Get Posted search filter */ if(isset($_POST['searchStrPKG'])){ $this->searchStrPKG = get_post("searchStrPKG"); } if(isset($_GET['search'])){ $this->searchStrPKG= $_GET['search']."*"; } if(empty($this->searchStrPKG)){ $this->searchStrPKG = "*"; } session::set('searchStrPKG',$this->searchStrPKG); } /*! \brief Reload list of displayed packages */ function reload() { $this->pkgs = array(); $q = new gosaSupportDaemon(); $filter = preg_replace("/\*/","%",array($this->searchStrPKG)); /* Determine filter sections */ $cb = create_function('$a', 'return $a != TRUE;'); $exclude_sections = array_filter($this->package_sections, $cb); $attrs = array("distribution", "package","version", "section", "description", "timestamp"); $ret = $q->FAI_get_packages($this->FAIdebianRelease,$attrs,$filter,0,200, $exclude_sections); if($q->is_error()){ msg_dialog::display(_("Service infrastructure"),msgPool::siError($q->get_error()),ERROR_DIALOG); }else{ foreach($ret as $attr){ $this->pkgs[$attr['PACKAGE']] = $attr; } } } /*! \brief Return all selected packages @return Array All selected package names */ function save() { return($this->selected); } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>