From: Roland Häder Date: Mon, 25 Aug 2008 17:19:31 +0000 (+0000) Subject: Missing method added to link helper, method renamed X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=commitdiff_plain;h=e2e65313ab2b10ecf1543350095192997dd523ed Missing method added to link helper, method renamed --- diff --git a/application/blog/templates/de/code/action_login_logout.ctp b/application/blog/templates/de/code/action_login_logout.ctp index 671b44f..465e807 100644 --- a/application/blog/templates/de/code/action_login_logout.ctp +++ b/application/blog/templates/de/code/action_login_logout.ctp @@ -3,7 +3,7 @@ $helper = WebLinkHelper::createWebLinkHelper($this, 'logout_now_link', 'index.php?app=blog&page=logout&logout=1'); // Set link text -$helper->setLinkTextById('logout_now_link_text'); +$helper->addLinkWithTextById('logout_now_link_text'); // Flush the content $helper->flushContent(); @@ -12,7 +12,7 @@ $helper->flushContent(); $helper = WebLinkHelper::createWebLinkHelper($this, 'return_login_link', 'index.php?app=blog&page=login_area'); // Set link text -$helper->setLinkTextById('return_login_link_text'); +$helper->addLinkWithTextById('return_login_link_text'); // Flush the content $helper->flushContent(); diff --git a/application/blog/templates/de/code/confirm_link.ctp b/application/blog/templates/de/code/confirm_link.ctp index 95039ec..6ae9490 100644 --- a/application/blog/templates/de/code/confirm_link.ctp +++ b/application/blog/templates/de/code/confirm_link.ctp @@ -3,7 +3,7 @@ $helper = WebLinkHelper::createWebLinkHelper($this, 'direct_login_link', 'index.php?app=blog&page=login'); // Set link text -$helper->setLinkTextById('direct_login_link_text'); +$helper->addLinkWithTextById('direct_login_link_text'); // Flush the content $helper->flushContent(); diff --git a/application/blog/templates/de/code/login_failed.ctp b/application/blog/templates/de/code/login_failed.ctp index 10d0727..0424faa 100644 --- a/application/blog/templates/de/code/login_failed.ctp +++ b/application/blog/templates/de/code/login_failed.ctp @@ -3,7 +3,7 @@ $helper = WebLinkHelper::createWebLinkHelper($this, 'login_retry_link', 'index.php?app=blog&page=login'); // Set link text -$helper->setLinkTextById('login_retry_link_text'); +$helper->addLinkWithTextById('login_retry_link_text'); // Flush the content $helper->flushContent(); diff --git a/application/blog/templates/de/code/login_form.ctp b/application/blog/templates/de/code/login_form.ctp index 805f28a..e1b54bf 100644 --- a/application/blog/templates/de/code/login_form.ctp +++ b/application/blog/templates/de/code/login_form.ctp @@ -73,7 +73,7 @@ if ($helper->ifGuestLoginAllowed()) { $helper = WebLinkHelper::createWebLinkHelper($this, 'register_login_form_link', 'index.php?app=blog&page=register'); // Set link text -$helper->setLinkTextById('register_login_form_link_text'); +$helper->addLinkWithTextById('register_login_form_link_text'); // Flush the content $helper->flushContent(); diff --git a/application/blog/templates/de/code/logout_done.ctp b/application/blog/templates/de/code/logout_done.ctp index 106b228..f4d7daf 100644 --- a/application/blog/templates/de/code/logout_done.ctp +++ b/application/blog/templates/de/code/logout_done.ctp @@ -3,7 +3,7 @@ $helper = WebLinkHelper::createWebLinkHelper($this, 'relogin_link', 'index.php?app=blog&page=login'); // Set link text -$helper->setLinkTextById('relogin_link_text'); +$helper->addLinkWithTextById('relogin_link_text'); // Flush the content $helper->flushContent(); diff --git a/application/ship-simu/templates/de/code/action_login_logout.ctp b/application/ship-simu/templates/de/code/action_login_logout.ctp index 459d305..b7ebf87 100644 --- a/application/ship-simu/templates/de/code/action_login_logout.ctp +++ b/application/ship-simu/templates/de/code/action_login_logout.ctp @@ -3,7 +3,7 @@ $helper = WebLinkHelper::createWebLinkHelper($this, 'logout_now_link', 'index.php?app=ship-simu&page=logout&logout=1'); // Set link text -$helper->setLinkTextById('logout_now_link_text'); +$helper->addLinkWithTextById('logout_now_link_text'); // Flush the content $helper->flushContent(); @@ -12,7 +12,7 @@ $helper->flushContent(); $helper = WebLinkHelper::createWebLinkHelper($this, 'return_login_link', 'index.php?app=ship-simu&page=login_area'); // Set link text -$helper->setLinkTextById('return_login_link_text'); +$helper->addLinkWithTextById('return_login_link_text'); // Flush the content $helper->flushContent(); diff --git a/application/ship-simu/templates/de/code/confirm_link.ctp b/application/ship-simu/templates/de/code/confirm_link.ctp index 91ae0dc..6e6cb47 100644 --- a/application/ship-simu/templates/de/code/confirm_link.ctp +++ b/application/ship-simu/templates/de/code/confirm_link.ctp @@ -3,7 +3,7 @@ $helper = WebLinkHelper::createWebLinkHelper($this, 'direct_login_link', 'index.php?app=ship-simu&page=login'); // Set link text -$helper->setLinkTextById('direct_login_link_text'); +$helper->addLinkWithTextById('direct_login_link_text'); // Flush the content $helper->flushContent(); diff --git a/application/ship-simu/templates/de/code/login_failed.ctp b/application/ship-simu/templates/de/code/login_failed.ctp index e134fb2..14bbcc4 100644 --- a/application/ship-simu/templates/de/code/login_failed.ctp +++ b/application/ship-simu/templates/de/code/login_failed.ctp @@ -3,7 +3,7 @@ $helper = WebLinkHelper::createWebLinkHelper($this, 'login_retry_link', 'index.php?app=ship-simu&page=login'); // Set link text -$helper->setLinkTextById('login_retry_text'); +$helper->addLinkWithTextById('login_retry_text'); // Flush the content $helper->flushContent(); diff --git a/application/ship-simu/templates/de/code/login_form.ctp b/application/ship-simu/templates/de/code/login_form.ctp index 0d6b64e..c2cf6fc 100644 --- a/application/ship-simu/templates/de/code/login_form.ctp +++ b/application/ship-simu/templates/de/code/login_form.ctp @@ -73,7 +73,7 @@ if ($helper->ifGuestLoginAllowed()) { $helper = WebLinkHelper::createWebLinkHelper($this, 'register_login_form_link', 'index.php?app=ship-simu&page=register'); // Set link text -$helper->setLinkTextById('register_login_form_link_text'); +$helper->addLinkWithTextById('register_login_form_link_text'); // Flush the content $helper->flushContent(); diff --git a/application/ship-simu/templates/de/code/login_main.ctp b/application/ship-simu/templates/de/code/login_main.ctp index bf47313..81c6c11 100644 --- a/application/ship-simu/templates/de/code/login_main.ctp +++ b/application/ship-simu/templates/de/code/login_main.ctp @@ -63,13 +63,14 @@ if ($blockInstance->getValueInstance()->ifUserIsFounder()) { $blockInstance->flushContent(); // Get helper instance -$helper = WebLinkHelper::createWebLinkHelper($this, 'logout_action_link', 'index.php?app=ship-simu&page=login_area'); +$linkInstance = WebLinkHelper::createWebLinkHelper($this, 'logout_action_link', 'index.php?app=ship-simu&page=login_area'); // Add action -$helper->addActionLink('logout', "Ausloggen"); +$linkInstance->addLinkGroup('logout', ""); +$linkInstance->addActionLink('logout', "Ausloggen"); // Flush the content -$helper->flushContent(); +$linkInstance->flushContent(); // End of all PHP commands ?> diff --git a/application/ship-simu/templates/de/code/logout_done.ctp b/application/ship-simu/templates/de/code/logout_done.ctp index b956f23..1f37ca8 100644 --- a/application/ship-simu/templates/de/code/logout_done.ctp +++ b/application/ship-simu/templates/de/code/logout_done.ctp @@ -3,7 +3,7 @@ $helper = WebLinkHelper::createWebLinkHelper($this, 'relogin_link', 'index.php?app=ship-simu&page=login'); // Set link text -$helper->setLinkTextById('relogin_link_text'); +$helper->addLinkWithTextById('relogin_link_text'); // Flush the content $helper->flushContent(); diff --git a/inc/classes/main/helper/web/links/class_WebLinkHelper.php b/inc/classes/main/helper/web/links/class_WebLinkHelper.php index 24fb844..40d9c66 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); } diff --git a/tests/RegistryTest.php b/tests/RegistryTest.php index 4e8bafe..73ca258 100644 --- a/tests/RegistryTest.php +++ b/tests/RegistryTest.php @@ -58,7 +58,7 @@ class RegistryTest extends PHPUnit_Framework_TestCase { $registryInstance = Registry::getRegistry(); // Create a User instance - $userInstance = User::createUserByEmail("webmaster@ship-simu.org"); + $userInstance = Member::createMemberByEmail("webmaster@ship-simu.org"); // Now store the instance in the registry $registryInstance->addInstance('user', $userInstance);