target = $target; return $this; } /** * @return mixed */ public function getTarget() { return $this->target; } public function render() { $attribs = [ 'href' => $this->getHref(), 'title' => $this->getLinkTitle() ]; if ($this->getTarget()) { $attribs['target'] = $this->getTarget(); } if ($this->getConfirmMessage()) { $attribs['onclick'] = "return confirm('" . str_replace(['"', '\''], ['\"', '\\\''], $this->getConfirmMessage()) . "');"; } return Html::renderContainer('a', $this->getTitle(), $attribs); } /** * @param array $params * @return $this */ public function setParams($params) { $this->params = $params; return $this; } /** * @return array */ public function getParams() { return $this->params; } /** * @param mixed $action * @return $this */ public function setAction($action) { $this->action = $action; return $this; } /** * @return mixed */ public function getAction() { return $this->action; } /** * @param mixed $itemName * @return $this */ public function setItemName($itemName) { $this->itemName = $itemName; return $this; } /** * @return mixed */ public function getItemName() { return $this->itemName; } /** * @param mixed $href * @return $this */ public function setHref($href) { $this->href = $href; return $this; } /** * @return mixed */ public function getHref() { if (null === $this->href) { if ($this->getFormattedLink()) { $this->href = vsprintf($this->getFormattedLink(), $this->getParams()); } else { $this->href = $this->getLink() . '&' . http_build_query($this->getParams()); } } return $this->href; } /** * @param mixed $confirmMessage * @return $this */ public function setConfirmMessage($confirmMessage) { $this->confirmMessage = $confirmMessage; return $this; } /** * @return mixed */ public function getConfirmMessage() { if (null === $this->confirmMessage && $this->action == self::ACTION_DELETE) { $this->confirmMessage = Qs_String::fill( "Do you really want to delete this %itemName%?", ['itemName' => $this->getItemName()] ); } return $this->confirmMessage; } /** * @param mixed $formattedLink * @return $this */ public function setFormattedLink($formattedLink) { $this->formattedLink = $formattedLink; return $this; } /** * @return mixed */ public function getFormattedLink() { return $this->formattedLink; } /** * @param mixed $link * @return $this */ public function setLink($link) { $this->link = $link; return $this; } /** * @return mixed */ public function getLink() { return $this->link; } /** * @param mixed $linkTitle * @return $this */ public function setLinkTitle($linkTitle) { $this->linkTitle = $linkTitle; return $this; } /** * @return mixed */ public function getLinkTitle() { return $this->linkTitle; } /** * @param mixed $separator * @return $this */ public function setSeparator($separator) { $this->separator = $separator; return $this; } /** * @return mixed */ public function getSeparator() { return $this->separator; } /** * @param mixed $title * @return $this */ public function setTitle($title) { $this->title = $title; return $this; } /** * @return mixed */ public function getTitle() { return $this->title; } }