X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fhelper%2Fweb%2Flinks%2Fclass_WebLinkHelper.php;h=540cf80c1698d7df1e70a690a6164d3ca5b7e401;hp=39b62eed061d74a9f6b89a77d1c3ae4c16454a14;hb=bbf48d46cb9063a4d2b78c106747147712f5474e;hpb=2395ee5b9b0a54681e7b04297cb2aa21fe646a23 diff --git a/inc/classes/main/helper/web/links/class_WebLinkHelper.php b/inc/classes/main/helper/web/links/class_WebLinkHelper.php index 39b62ee..540cf80 100644 --- a/inc/classes/main/helper/web/links/class_WebLinkHelper.php +++ b/inc/classes/main/helper/web/links/class_WebLinkHelper.php @@ -64,7 +64,7 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate { $helperInstance->setLinkBase($linkBase); // Add default group - $helperInstance->openGroupByIdContent('main', ""); + $helperInstance->openGroupByIdContent('main', "", ""); // Return the prepared instance return $helperInstance; @@ -158,49 +158,59 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate { * * @param $groupId Id string of the group * @param $groupText Text for this group to add + * @param $groupCode Code to open and close groups * @return void */ - public function addLinkGroup ($groupId, $groupText) { + public function addLinkGroup ($groupId, $groupText, $groupCode = "div") { // Is a group with that name open? - if ($this->ifGroupIsOpened($groupId)) { + if ($this->ifGroupOpenedPreviously()) { // Then close it here - $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, $content); - } + $this->closePreviousGroupByContent(""); + } // END - if + + // Generate the group content + $content = sprintf("<{$groupCode} id=\"group_%s_%s\">%s", + $this->getLinkName(), + $groupId, + $groupText + ); + + // Open the new group + $this->openGroupByIdContent($groupId, $content, $groupCode); } /** * Adds text (note) to the previously opened group or throws an exception * if no previous group was opened. * + * @param $groupId Group id to set * @param $groupNote Note to be added to a group + * @param $groupCode Code to open and close groups * @return void * @throws NoGroupOpenedException If no previous group was opened */ - public function addLinkNote ($groupNote) { + public function addLinkNote ($groupId, $groupNote, $groupCode = "div") { // Check if a previous group was opened - if (!$this->ifGroupOpenedPreviously()) { + if ($this->ifGroupOpenedPreviously() === false) { // 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); + // Is a previous sub group open? + if ($this->ifSubGroupOpenedPreviously()) { + // Then close it + $this->closePreviousSubGroupByContent(""); + } // END - if + + // Generate the group content + $content = sprintf("<{$groupCode} id=\"subgroup_%s_%s\">%s", + $this->getLinkName(), + $groupId, + $groupNote + ); + + // Open the sub group + $this->openSubGroupByIdContent($groupId, $content, $groupCode); } /** @@ -213,7 +223,7 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate { */ public function addActionLink ($linkAction, $linkText) { // Check if a previous group was opened - if (!$this->ifGroupOpenedPreviously()) { + if ($this->ifGroupOpenedPreviously() === false) { // No group was opened before! throw new NoGroupOpenedException(array($this, $linkAction."(".$linkText.")"), self::EXCEPTION_GROUP_NOT_OPENED); } // END - if