/**
  * Generic list of all packages available on the local filesystem
  * @return string
  * @permissions view
  * @autoTestable
  */
 protected function actionList()
 {
     if ($this->getParam("doFilter") != "") {
         $this->objSession->setSession($this->STR_FILTER_SESSION_KEY, $this->getParam("packagelist_filter"));
         $this->setParam("pv", 1);
         $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul"), "list"));
         return "";
     }
     class_module_packagemanager_template::syncTemplatepacks();
     $strReturn = "";
     $strReturn .= $this->objToolkit->formHeader(class_link::getLinkAdminHref($this->getArrModule("modul")), "list");
     $strReturn .= $this->objToolkit->formInputText("packagelist_filter", $this->getLang("packagelist_filter"), $this->objSession->getSession($this->STR_FILTER_SESSION_KEY));
     $strReturn .= $this->objToolkit->formInputSubmit();
     $strReturn .= $this->objToolkit->formInputHidden("doFilter", "1");
     $strReturn .= $this->objToolkit->formClose();
     $objManager = new class_module_packagemanager_manager();
     $arrPackages = $objManager->getAvailablePackages($this->objSession->getSession($this->STR_FILTER_SESSION_KEY));
     $arrPackages = $objManager->sortPackages($arrPackages);
     $objArrayIterator = new class_array_iterator($arrPackages);
     $objArrayIterator->getElementsOnPage((int) ($this->getParam("pv") != "" ? $this->getParam("pv") : 1));
     $objArraySectionIterator = new class_array_section_iterator(count($arrPackages));
     $objArraySectionIterator->setPageNumber((int) ($this->getParam("pv") != "" ? $this->getParam("pv") : 1));
     $objArraySectionIterator->setArraySection($objArrayIterator->getElementsOnPage((int) ($this->getParam("pv") != "" ? $this->getParam("pv") : 1)));
     $strReturn .= $this->objToolkit->listHeader();
     $intI = 0;
     /** @var class_module_packagemanager_metadata $objOneMetadata */
     foreach ($objArraySectionIterator as $objOneMetadata) {
         $strActions = "";
         $objHandler = $objManager->getPackageManagerForPath($objOneMetadata->getStrPath());
         if ($objHandler->isInstallable()) {
             $strActions .= $this->objToolkit->listButton(class_link::getLinkAdminDialog($this->getArrModule("modul"), "processPackage", "&package=" . $objOneMetadata->getStrPath(), $this->getLang("package_install"), $this->getLang("package_installocally"), "icon_downloads", $this->getLang("package_install")));
         }
         $strActions .= $this->objToolkit->listButton(class_link::getLinkAdminDialog($this->getArrModule("modul"), "showInfo", "&package=" . $objOneMetadata->getStrTitle(), $this->getLang("package_info"), $this->getLang("package_info"), "icon_lens", $objOneMetadata->getStrTitle()));
         if ($this->getObjModule()->rightDelete()) {
             if ($objHandler->isRemovable($objOneMetadata)) {
                 $strActions .= $this->objToolkit->listDeleteButton($objOneMetadata->getStrTitle(), $this->getLang("package_delete_question"), class_link::getLinkAdminHref($this->getArrModule("modul"), "deletePackage", "&package=" . $objOneMetadata->getStrTitle()));
             } else {
                 $strActions .= $this->objToolkit->listButton(class_adminskin_helper::getAdminImage("icon_deleteLocked", $this->getLang("package_delete_locked")));
             }
         }
         $strActions .= $this->objToolkit->listButton("<span id=\"updateWrapper" . createFilename($objOneMetadata->getStrTitle(), true) . "\">" . class_adminskin_helper::getAdminImage("loadingSmall", $this->getLang("package_searchupdate")) . "</span>");
         $strActions .= "<script type='text/javascript'>\n            \$(function() {\n                KAJONA.admin.loader.loadFile('" . class_resourceloader::getInstance()->getCorePathForModule("module_packagemanager") . "/module_packagemanager/admin/scripts/packagemanager.js', function() {\n                    KAJONA.admin.packagemanager.addPackageToTest('" . $objOneMetadata->getStrTitle() . "', '" . createFilename($objOneMetadata->getStrTitle(), true) . "');\n                }); });\n            </script>";
         $strReturn .= $this->objToolkit->simpleAdminList($objOneMetadata, $strActions, $intI++);
     }
     $strAddActions = "";
     if ($this->getObjModule()->rightEdit()) {
         $strAddActions = $this->objToolkit->listButton(class_link::getLinkAdminDialog($this->getArrModule("modul"), "addPackage", "", $this->getLang("action_upload_package"), $this->getLang("action_upload_package"), "icon_new", $this->getLang("action_upload_package")));
     }
     $strReturn .= $this->objToolkit->genericAdminList(generateSystemid(), "", "", $strAddActions, $intI);
     $strReturn .= $this->objToolkit->listFooter();
     $strCore = class_resourceloader::getInstance()->getCorePathForModule("module_packagemanager");
     $strReturn .= "<script type='text/javascript'>\n            \$(function() {\n                KAJONA.admin.loader.loadFile('{$strCore}/module_packagemanager/admin/scripts/packagemanager.js', function() {\n\n                    \$(window.setTimeout(function() {\n                        KAJONA.admin.packagemanager.triggerUpdateCheck();\n                    }, 1000));\n                });\n            });\n            </script>";
     $strReturn .= $this->objToolkit->getPageview($objArraySectionIterator, $this->getArrModule("modul"), $this->getAction());
     return $strReturn;
 }
Exemplo n.º 2
0
 /**
  * Creates a forward / backward pager out of the passed array
  *
  * @param int $intNumber Records per page
  * @param int $intPage current page
  * @param string $strForward text for the forwardlink
  * @param string $strBack text for the backwardslink
  * @param string $strAction action on the targetpage
  * @param string $strPage title of the targetpage
  * @param mixed $arrData the array of records
  * @param string $strAdd additional params
  * @param string $strPvParam the param used to create the pagenumber-entries
  *
  * @return mixed array containing the created data:
  *                         return => [arrData] = array containing the shortened data
  *                                   [strForward] = link to the next page
  *                                   [strBack]    = link to the previous page
  *                                   [strPages] = Pager ( [0][1] ...)
  */
 public function pager($intNumber, $intPage = 1, $strForward = "next", $strBack = "back", $strAction = "list", $strPage = "", $arrData = array(), $strAdd = "", $strPvParam = "pv")
 {
     if ($intPage <= 0) {
         $intPage = 1;
     }
     if ((int) $intNumber <= 0) {
         $intNumber = 100;
     }
     $arrReturn = array("arrData" => array(), "strForward" => "", "strBack" => "", "strPages" => "");
     //create array-iterator
     $objIterator = new class_array_iterator($arrData);
     $objIterator->setIntElementsPerPage($intNumber);
     //Anything to create?
     if ($objIterator->getNrOfPages() == 1) {
         $arrReturn["arrData"] = $arrData;
     } else {
         $strLinkPages = "";
         $strLinkForward = "";
         $strLinkBack = "";
         $arrReturn["arrData"] = $objIterator->getElementsOnPage($intPage);
         //FowardLink
         if ($intPage < $objIterator->getNrOfPages()) {
             $strLinkForward = class_link::getLinkPortal($strPage, "", null, $strForward, $strAction, "&" . $strPvParam . "=" . ($intPage + 1) . $strAdd);
         }
         //BackLink
         if ($intPage > 1) {
             $strLinkBack = class_link::getLinkPortal($strPage, "", null, $strBack, $strAction, "&" . $strPvParam . "=" . ($intPage - 1) . $strAdd);
         }
         //just load the current +-6 pages and the first/last +-3
         $intCounter2 = 1;
         for ($intI = 1; $intI <= $objIterator->getNrOfPages(); $intI++) {
             $bitDisplay = false;
             if ($intCounter2 <= 3) {
                 $bitDisplay = true;
             } elseif ($intCounter2 >= $objIterator->getNrOfPages() - 3) {
                 $bitDisplay = true;
             } elseif ($intCounter2 >= $intPage - 6 && $intCounter2 <= $intPage + 6) {
                 $bitDisplay = true;
             }
             if ($bitDisplay) {
                 if ($intI == $intPage) {
                     $strLinkPages .= "  <strong>" . class_link::getLinkPortal($strPage, "", null, "[" . $intI . "]", $strAction, "&" . $strPvParam . "=" . $intI . $strAdd) . "</strong>";
                 } else {
                     $strLinkPages .= "  " . class_link::getLinkPortal($strPage, "", null, "[" . $intI . "]", $strAction, "&" . $strPvParam . "=" . $intI . $strAdd);
                 }
             }
             $intCounter2++;
         }
         $arrReturn["strForward"] = $strLinkForward;
         $arrReturn["strBack"] = $strLinkBack;
         $arrReturn["strPages"] = $strLinkPages;
     }
     return $arrReturn;
 }