/** * Uses the temaplate and/or HTML callback to get the inner html of each link. Relies on the ItemParamsCallback * to return information on how to draw each item. * * @param $objItem * @return string * @throws QCallerException */ protected function GetItemHtml($objItem) { if (!$this->itemParamsCallback) { throw new \Exception("Must provide an itemParamsCallback"); } $params = call_user_func($this->itemParamsCallback, $objItem, $this->intCurrentItemIndex); $strLabel = ""; if (isset($params["html"])) { $strLabel = $params["html"]; } $strId = ""; if (isset($params["id"])) { $strId = $params["id"]; } $strActionParam = $strId; if (isset($params["action"])) { $strActionParam = $params["action"]; } $attributes = []; if (isset($params["attributes"])) { $attributes = $params["attributes"]; } if (isset($attributes["class"])) { $attributes["class"] .= " list-group-item"; } else { $attributes["class"] = "list-group-item"; } if ($this->blnSaveState && $this->strSelectedItemId !== null && $this->strSelectedItemId == $strId) { $attributes["class"] .= " active"; } $strLink = $this->prxButton->RenderAsLink($strLabel, $strActionParam, $attributes, "a", false); return $strLink; }
/** * Returns the HTML for the group of buttons that come after the group of page buttons. * @return string */ protected function GetNextButtonsHtml() { list($intPageStart, $intPageEnd) = $this->CalcBunch(); // build it backwards $intPageCount = $this->PageCount; if ($this->intPageNumber >= $intPageCount) { $strNext = $this->strLabelForNext; } else { $mixActionParameter = $this->intPageNumber + 1; $strNext = $this->prxPagination->RenderAsLink($this->strLabelForNext, $mixActionParameter, ['id' => $this->ControlId . "_arrow_" . $mixActionParameter]); } $strToReturn = sprintf('<span class="arrow next">%s</span>', $strNext); $strToReturn = '<span class="break">|</span>' . $strToReturn; if ($intPageEnd != $intPageCount) { $strToReturn = $this->GetPageButtonHtml($intPageCount) . $strToReturn; $strToReturn = '<span class="ellipsis">…</span>' . $strToReturn; } return $strToReturn; }
/** * Returns the final string representing the content of the cell. * * @param mixed $item * @return string */ public function FetchCellValue($item) { $strText = parent::FetchCellValue($item); // allow post processing of cell label $getVars = null; if ($this->getVars) { if (is_array($this->getVars)) { if (array_keys($this->getVars)[0] === 0) { // assume this is not associative array. Likely we are here to extract a property list. $getVars = static::GetObjectValue($this->getVars, $item); } else { // associative array, so likely these are Get variables to be assigned individually foreach ($this->getVars as $key => $val) { $getVars[$key] = static::GetObjectValue($val, $item); } } } elseif ($this->getVars instanceof QQNode) { $getVars = static::GetObjectValue($this->getVars, $item); } else { $getVars = $this->getVars; // could be a simple action parameter. } } $tagAttributes = []; if ($this->tagAttributes && is_array($this->tagAttributes)) { foreach ($this->tagAttributes as $key => $val) { $tagAttributes[$key] = static::GetObjectValue($val, $item); } } if ($this->mixDestination === null) { return QApplication::HtmlEntities($strText); } elseif ($this->mixDestination instanceof QControlProxy) { if ($this->blnAsButton) { return $this->mixDestination->RenderAsButton($strText, $getVars, $tagAttributes); } else { return $this->mixDestination->RenderAsLink($strText, $getVars, $tagAttributes); } } else { $strDestination = static::GetObjectValue($this->mixDestination, $item); return QHtml::RenderLink(QHtml::MakeUrl($strDestination, $getVars), $strText, $tagAttributes); } }