Ejemplo n.º 1
0
 /**
  * Creates a forward / backward pager out of the passed array
  *
  * @param class_array_section_iterator $objArraySectionIterator
  * @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 string $strAdd additional params
  * @param string $strPvParam the param used to create the pagenumber-entries
  * @param string $strTemplate if passed, the pager will render all links using the passed template (if the sections are present). Expected sections: pager_fwd, pager_back, pager_entry, pager_entry_active
  *
  * @return mixed array containing the created data:
  *                         return => [strForward] = link to the next page
  *                                   [strBack]    = link to the previous page
  *                                   [strPages] = Pager ( [0][1] ...)
  */
 public function simplePager($objArraySectionIterator, $strForward = "next", $strBack = "back", $strAction = "list", $strPage = "", $strAdd = "", $strPvParam = "pv", $strTemplate = "")
 {
     $arrReturn = array("arrData" => array(), "strForward" => "", "strBack" => "", "strPages" => "");
     //read the template-sections, of given
     $bitTemplate = false;
     $strFwdId = "";
     $strBackId = "";
     $strEntryId = "";
     $strEntryActiveId = "";
     if ($strTemplate != "") {
         $strTemplateIdentifier = $this->objTemplate->readTemplate($strTemplate);
         $bitTemplate = $this->objTemplate->containsSection($strTemplateIdentifier, "pager_fwd") && $this->objTemplate->containsSection($strTemplateIdentifier, "pager_back") && $this->objTemplate->containsSection($strTemplateIdentifier, "pager_entry") && $this->objTemplate->containsSection($strTemplateIdentifier, "pager_entry_active");
         $strFwdId = $this->objTemplate->readTemplate($strTemplate, "pager_fwd");
         $strBackId = $this->objTemplate->readTemplate($strTemplate, "pager_back");
         $strEntryId = $this->objTemplate->readTemplate($strTemplate, "pager_entry");
         $strEntryActiveId = $this->objTemplate->readTemplate($strTemplate, "pager_entry_active");
     }
     $strLinkPages = "";
     $strLinkForward = "";
     $strLinkBack = "";
     $arrReturn["arrData"] = array();
     $intPage = $objArraySectionIterator->getPageNumber();
     //FowardLink
     if ($intPage < $objArraySectionIterator->getNrOfPages()) {
         if ($bitTemplate) {
             $strLinkForward = $this->objTemplate->fillTemplate(array("pageHref" => class_link::getLinkPortalHref($strPage, "", $strAction, "&" . $strPvParam . "=" . ($intPage + 1) . $strAdd)), $strFwdId);
         } else {
             $strLinkForward = class_link::getLinkPortal($strPage, "", null, $strForward, $strAction, "&" . $strPvParam . "=" . ($intPage + 1) . $strAdd);
         }
     }
     //BackLink
     if ($intPage > 1) {
         if ($bitTemplate) {
             $strLinkBack = $this->objTemplate->fillTemplate(array("pageHref" => class_link::getLinkPortalHref($strPage, "", $strAction, "&" . $strPvParam . "=" . ($intPage - 1) . $strAdd)), $strBackId);
         } else {
             $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 <= $objArraySectionIterator->getNrOfPages(); $intI++) {
         $bitDisplay = false;
         if ($intCounter2 <= 3) {
             $bitDisplay = true;
         } elseif ($intCounter2 >= $objArraySectionIterator->getNrOfPages() - 3) {
             $bitDisplay = true;
         } elseif ($intCounter2 >= $intPage - 6 && $intCounter2 <= $intPage + 6) {
             $bitDisplay = true;
         }
         if ($bitDisplay) {
             if ($bitTemplate) {
                 if ($intI == $intPage) {
                     $strLinkPages .= $this->objTemplate->fillTemplate(array("pageHref" => class_link::getLinkPortalHref($strPage, "", $strAction, "&" . $strPvParam . "=" . $intI . $strAdd), "pageNumber" => $intI), $strEntryActiveId);
                 } else {
                     $strLinkPages .= $this->objTemplate->fillTemplate(array("pageHref" => class_link::getLinkPortalHref($strPage, "", $strAction, "&" . $strPvParam . "=" . $intI . $strAdd), "pageNumber" => $intI), $strEntryId);
                 }
             } else {
                 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++;
     }
     if ($objArraySectionIterator->getNrOfPages() > 1) {
         $arrReturn["strForward"] = $strLinkForward;
         $arrReturn["strBack"] = $strLinkBack;
         $arrReturn["strPages"] = $strLinkPages;
     }
     return $arrReturn;
 }
Ejemplo n.º 2
0
 /**
  * Renders a list of items, target is the common admin-list.
  * Please be aware, that the combination of paging and sortable-lists may result in unpredictable ordering.
  * As soon as the list is sortable, the page-size should be at least the same as the number of elements. Optional
  * it is possible to provide a filter callback which is called for each entry. If the callback returns false the
  * entry gets skipped.
  *
  * @param class_array_section_iterator $objArraySectionIterator
  * @param bool $bitSortable
  * @param string $strListIdentifier an internal identifier to check the current parent-list
  * @param bool $bitAllowTreeDrop
  * @param string $strPagerAddon
  * @param Closure $objFilter
  *
  * @throws class_exception
  * @return string
  */
 protected final function renderList(class_array_section_iterator $objArraySectionIterator, $bitSortable = false, $strListIdentifier = "", $bitAllowTreeDrop = false, $strPagerAddon = "", Closure $objFilter = null)
 {
     $strReturn = "";
     $intI = 0;
     $strListId = generateSystemid();
     if (!$objArraySectionIterator->valid()) {
         $strReturn .= $this->objToolkit->getTextRow($this->getLang("commons_list_empty"));
     }
     if ($bitSortable) {
         $strReturn .= $this->objToolkit->dragableListHeader($strListId, false, $bitAllowTreeDrop, $objArraySectionIterator->getIntElementsPerPage(), $objArraySectionIterator->getPageNumber());
     } else {
         $strReturn .= $this->objToolkit->listHeader();
     }
     if ($this->renderLevelUpAction($strListIdentifier) != "") {
         $strReturn .= $this->objToolkit->genericAdminList("", "", "", $this->objToolkit->listButton($this->renderLevelUpAction($strListIdentifier)), $intI++);
     }
     $arrMassActions = $this->getBatchActionHandlers($strListIdentifier);
     $intTotalNrOfElements = $objArraySectionIterator->getNumberOfElements();
     /** @var $objOneIterable class_model|interface_model|interface_admin_listable */
     foreach ($objArraySectionIterator as $objOneIterable) {
         // if we have a filter Closure call it else use the standard rightView method
         if ($objFilter !== null) {
             if ($objFilter($objOneIterable) === false) {
                 if ($bitSortable) {
                     //inject hidden dummy row for a proper sorting
                     $strReturn .= $this->objToolkit->genericAdminList($objOneIterable->getSystemid(), "", "", "", 0, "", "", false, "hidden");
                 }
                 $intTotalNrOfElements--;
                 continue;
             }
         } else {
             if (!$objOneIterable->rightView()) {
                 if ($bitSortable) {
                     //inject hidden dummy row for a proper sorting
                     $strReturn .= $this->objToolkit->genericAdminList($objOneIterable->getSystemid(), "", "", "", 0, "", "", false, "hidden");
                 }
                 $intTotalNrOfElements--;
                 continue;
             }
         }
         $strActions = $this->getActionIcons($objOneIterable, $strListIdentifier);
         $strReturn .= $this->objToolkit->simpleAdminList($objOneIterable, $strActions, $intI++, count($arrMassActions) > 0);
     }
     $strNewActions = $this->mergeNewEntryActions($this->getNewEntryAction($strListIdentifier));
     $strBatchActions = "";
     if (count($arrMassActions) > 0) {
         $strBatchActions .= $this->objToolkit->renderBatchActionHandlers($arrMassActions);
     }
     if ($strNewActions != "" || $strBatchActions != "") {
         $strReturn .= $this->objToolkit->genericAdminList("batchActionSwitch", $strBatchActions, "", $strNewActions, $intI, "", "", $strBatchActions != "");
     }
     if ($bitSortable) {
         $strReturn .= $this->objToolkit->dragableListFooter($strListId);
     } else {
         $strReturn .= $this->objToolkit->listFooter();
     }
     $objArraySectionIterator->setIntTotalElements($intTotalNrOfElements);
     $strReturn .= $this->objToolkit->getPageview($objArraySectionIterator, $this->getArrModule("modul"), $this->getAction(), "&systemid=" . $this->getSystemid() . $this->strPeAddon . $strPagerAddon);
     return $strReturn;
 }
Ejemplo n.º 3
0
 /**
  * Creates a pageview
  *
  * @param class_array_section_iterator $objArraySectionIterator
  * @param string $strModule
  * @param string $strAction
  * @param string $strLinkAdd
  *
  * @return mixed a two-dimensional array: ["elements"] and ["pageview"]
  * @since 3.3.0
  *
  * @deprecated use getPageview instead
  */
 public function getSimplePageview($objArraySectionIterator, $strModule, $strAction, $strLinkAdd = "")
 {
     $arrReturn = array();
     $intCurrentpage = $objArraySectionIterator->getPageNumber();
     $intNrOfPages = $objArraySectionIterator->getNrOfPages();
     $intNrOfElements = $objArraySectionIterator->getNumberOfElements();
     $arrReturn["elements"] = array();
     //read templates
     $strTemplateBodyID = $this->objTemplate->readTemplate("/elements.tpl", "pageview_body");
     $strTemplateForwardID = $this->objTemplate->readTemplate("/elements.tpl", "pageview_link_forward");
     $strTemplateBackwardID = $this->objTemplate->readTemplate("/elements.tpl", "pageview_link_backward");
     $strTemplateListID = $this->objTemplate->readTemplate("/elements.tpl", "pageview_page_list");
     $strTemplateListItemActiveID = $this->objTemplate->readTemplate("/elements.tpl", "pageview_list_item_active");
     $strTemplateListItemID = $this->objTemplate->readTemplate("/elements.tpl", "pageview_list_item");
     //build layout
     $arrTemplate = array();
     $strListItems = "";
     //just load the current +-4 pages and the first/last +-2
     $intCounter2 = 1;
     for ($intI = 1; $intI <= $intNrOfPages; $intI++) {
         $bitDisplay = false;
         if ($intCounter2 <= 2) {
             $bitDisplay = true;
         } elseif ($intCounter2 >= $intNrOfPages - 1) {
             $bitDisplay = true;
         } elseif ($intCounter2 >= $intCurrentpage - 2 && $intCounter2 <= $intCurrentpage + 2) {
             $bitDisplay = true;
         }
         if ($bitDisplay) {
             $arrLinkTemplate = array();
             $arrLinkTemplate["href"] = class_link::getLinkAdminHref($strModule, $strAction, $strLinkAdd . "&pv=" . $intI);
             $arrLinkTemplate["pageNr"] = $intI;
             if ($intI == $intCurrentpage) {
                 $strListItems .= $this->objTemplate->fillTemplate($arrLinkTemplate, $strTemplateListItemActiveID);
             } else {
                 $strListItems .= $this->objTemplate->fillTemplate($arrLinkTemplate, $strTemplateListItemID);
             }
         }
         $intCounter2++;
     }
     $arrTemplate["pageList"] = $this->objTemplate->fillTemplate(array("pageListItems" => $strListItems), $strTemplateListID);
     $arrTemplate["nrOfElementsText"] = class_carrier::getInstance()->getObjLang()->getLang("pageview_total", "system");
     $arrTemplate["nrOfElements"] = $intNrOfElements;
     if ($intCurrentpage < $intNrOfPages) {
         $arrTemplate["linkForward"] = $this->objTemplate->fillTemplate(array("linkText" => class_carrier::getInstance()->getObjLang()->getLang("pageview_forward", "system"), "href" => class_link::getLinkAdminHref($strModule, $strAction, $strLinkAdd . "&pv=" . ($intCurrentpage + 1))), $strTemplateForwardID);
     }
     if ($intCurrentpage > 1) {
         $arrTemplate["linkBackward"] = $this->objTemplate->fillTemplate(array("linkText" => class_carrier::getInstance()->getObjLang()->getLang("commons_back", "commons"), "href" => class_link::getLinkAdminHref($strModule, $strAction, $strLinkAdd . "&pv=" . ($intCurrentpage - 1))), $strTemplateBackwardID);
     }
     $arrReturn["pageview"] = $this->objTemplate->fillTemplate($arrTemplate, $strTemplateBodyID);
     $arrReturn["elements"] = $objArraySectionIterator->getArrayExtended(true);
     return $arrReturn;
 }