From: Roland Häder Date: Thu, 14 Aug 2008 16:21:40 +0000 (+0000) Subject: Web link helper basicly finished X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=28c194c4d15972dc8d798c4e3ef015324518099b;p=shipsimu.git Web link helper basicly finished --- diff --git a/inc/classes/main/helper/class_BaseHelper.php b/inc/classes/main/helper/class_BaseHelper.php index 3993e98..94f4ed5 100644 --- a/inc/classes/main/helper/class_BaseHelper.php +++ b/inc/classes/main/helper/class_BaseHelper.php @@ -366,7 +366,7 @@ class BaseHelper extends BaseFrameworkSystem { $content .= $subGroupContent; } else { // Something went wrong - die("GROUP/SUB GROUP ERROR: {$idx}"); + $this->debugInstance(); } } // END - for diff --git a/inc/classes/main/helper/web/links/class_WebLinkHelper.php b/inc/classes/main/helper/web/links/class_WebLinkHelper.php index d526102..24fb844 100644 --- a/inc/classes/main/helper/web/links/class_WebLinkHelper.php +++ b/inc/classes/main/helper/web/links/class_WebLinkHelper.php @@ -112,7 +112,20 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate { * @todo Completely unimplemented */ public function flushContent () { - // Needed to be implemented! + // Is a previous opened group still open? + if ($this->ifGroupOpenedPreviously()) { + // Then close it + $this->closePreviousGroupByContent(""); + } // END - if + + // Get the content + $content = $this->renderContent(); + + // Get template engine + $templateInstance = $this->getTemplateInstance(); + + // Add content to variable + $templateInstance->assignVariable($this->getLinkName(), $content); } /** @@ -127,10 +140,23 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate { // Is a group with that name open? if ($this->ifGroupIsOpened($groupId)) { // Then close it here - $this->closeGroupById($groupId); + $this->closePreviousGroupByContent(""); } else { + // Is a previous opened group still open? + if ($this->ifGroupOpenedPreviously()) { + // Then close it + $this->closePreviousGroupByContent(""); + } // END - if + + // Generate the group content + $content = sprintf("
%s", + $this->getLinkName(), + $groupId, + $groupText + ); + // Open the new group - $this->openGroupByIdContent($groupId, $groupText); + $this->openGroupByIdContent($groupId, $content); } } @@ -141,17 +167,57 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate { * @param $groupNote Note to be added to a group * @return void * @throws NoGroupOpenedException If no previous group was opened - * @todo Implement adding the note to the previously opened group or sub group */ public function addLinkNote ($groupNote) { // 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); + } // END - if + + // Add the content to the previous group + $this->addContentToPreviousGroup($groupNote); + } + + /** + * Adds a link to the previously opened group or throws an exception if no group has been opened + * + * @param $linkAction Action (action=xxx) value for the link + * @param $linkText Link text and title (title="xxx") for the link + * @return void + * @throws NoGroupOpenedException If no previous group was opened + */ + public function addActionLink ($linkAction, $linkText) { + // 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); + } // END - if + + // Default parameter seperator is & + $seperator = "&"; + + // Get link base + $linkBase = $this->getLinkBase(); + + // Is there a question mark in? + $linkArray = explode("?", $linkBase); + if (count($linkArray) == 0) { + // No question mark + $seperator = "?"; } - // Not fully implemented! - $this->partialStub(); + // Renders the link content + $linkContent = sprintf("%s", + $linkBase, + $seperator, + $linkAction, + $linkText, + $linkText + ); + + // Add the content to the previous group + $this->addContentToPreviousGroup($linkContent); } }