X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fhelper%2Fweb%2Flinks%2Fclass_WebLinkHelper.php;fp=inc%2Fclasses%2Fmain%2Fhelper%2Fweb%2Flinks%2Fclass_WebLinkHelper.php;h=40d9c6666b0995bbb0210c120fab7070c75ae3bb;hp=24fb844b23ff6e0093b1fd0f853351d3513082be;hb=7be9aec7da3a85e55153376faada5388f4876541;hpb=b582e721d1e1057bfe04ab1e3a74c7e21b4ea81c diff --git a/inc/classes/main/helper/web/links/class_WebLinkHelper.php b/inc/classes/main/helper/web/links/class_WebLinkHelper.php index 24fb844b23..40d9c6666b 100644 --- a/inc/classes/main/helper/web/links/class_WebLinkHelper.php +++ b/inc/classes/main/helper/web/links/class_WebLinkHelper.php @@ -67,6 +67,27 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate { return $helperInstance; } + /** + * Renders the link content (HTML code) with given link text and optional + * extra content + * + * @param $linkText Link text to set in link + * @param $extraContent Optional extra HTML content + * @return $linkContent Rendered text link content + */ + private function renderLinkContentWithTextExtraContent ($linkText, $extraContent="") { + // Construct link content + $linkContent = sprintf("%s", + $this->getLinkBase(), + $extraContent, + $linkText, + $linkText + ); + + // Return it + return $linkContent; + } + /** * Setter for link name * @@ -191,31 +212,46 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate { // Check if a previous group was opened if (!$this->ifGroupOpenedPreviously()) { // No group was opened before! - throw new NoGroupOpenedException(array($this, $groupNote), self::EXCEPTION_GROUP_NOT_OPENED); + throw new NoGroupOpenedException(array($this, $linkAction."(".$linkText.")"), self::EXCEPTION_GROUP_NOT_OPENED); } // END - if // Default parameter seperator is & $seperator = "&"; - // Get link base - $linkBase = $this->getLinkBase(); - // Is there a question mark in? - $linkArray = explode("?", $linkBase); + $linkArray = explode("?", $this->getLinkBase()); if (count($linkArray) == 0) { // No question mark $seperator = "?"; - } + } // END - if - // Renders the link content - $linkContent = sprintf("%s", - $linkBase, + // Prepare action + $action = sprintf("%saction=%s", $seperator, - $linkAction, - $linkText, - $linkText + $linkAction ); + // Renders the link content + $linkContent = $this->renderLinkContentWithTextExtraContent($linkText, $action); + + // Add the content to the previous group + $this->addContentToPreviousGroup($linkContent); + } + + /** + * Adds a default link (no extra parameters) to the content with specified + * language id string. + * + * @param $languageId Language id string to use + * @return void + */ + public function addLinkWithTextById ($languageId) { + // Resolve the language string + $languageResolved = $this->getLanguageInstance()->getMessage($languageId); + + // Now add the link + $linkContent = $this->renderLinkContentWithTextExtraContent($languageResolved); + // Add the content to the previous group $this->addContentToPreviousGroup($linkContent); }