Missing method added to link helper, method renamed
authorRoland Häder <roland@mxchange.org>
Mon, 25 Aug 2008 17:19:31 +0000 (17:19 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 25 Aug 2008 17:19:31 +0000 (17:19 +0000)
13 files changed:
application/blog/templates/de/code/action_login_logout.ctp
application/blog/templates/de/code/confirm_link.ctp
application/blog/templates/de/code/login_failed.ctp
application/blog/templates/de/code/login_form.ctp
application/blog/templates/de/code/logout_done.ctp
application/ship-simu/templates/de/code/action_login_logout.ctp
application/ship-simu/templates/de/code/confirm_link.ctp
application/ship-simu/templates/de/code/login_failed.ctp
application/ship-simu/templates/de/code/login_form.ctp
application/ship-simu/templates/de/code/login_main.ctp
application/ship-simu/templates/de/code/logout_done.ctp
inc/classes/main/helper/web/links/class_WebLinkHelper.php
tests/RegistryTest.php

index 671b44ff51b9cb15899501269e9a39fcd5c773a4..465e8076b7984633b63805623652d9d15ac1c2a0 100644 (file)
@@ -3,7 +3,7 @@
 $helper = WebLinkHelper::createWebLinkHelper($this, 'logout_now_link', 'index.php?app=blog&amp;page=logout&amp;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&amp;page=login_area');
 
 // Set link text
-$helper->setLinkTextById('return_login_link_text');
+$helper->addLinkWithTextById('return_login_link_text');
 
 // Flush the content
 $helper->flushContent();
index 95039ecc0cf936b7e3896a426aaee6d833bbfcf2..6ae9490b2b2a1fe5ca2da5e3251442dfddc9308d 100644 (file)
@@ -3,7 +3,7 @@
 $helper = WebLinkHelper::createWebLinkHelper($this, 'direct_login_link', 'index.php?app=blog&amp;page=login');
 
 // Set link text
-$helper->setLinkTextById('direct_login_link_text');
+$helper->addLinkWithTextById('direct_login_link_text');
 
 // Flush the content
 $helper->flushContent();
index 10d07279cc8c805c2c9b1e94c64a463c6181d8d9..0424faa674bf1c13f892dd765044310d6609c939 100644 (file)
@@ -3,7 +3,7 @@
 $helper = WebLinkHelper::createWebLinkHelper($this, 'login_retry_link', 'index.php?app=blog&amp;page=login');
 
 // Set link text
-$helper->setLinkTextById('login_retry_link_text');
+$helper->addLinkWithTextById('login_retry_link_text');
 
 // Flush the content
 $helper->flushContent();
index 805f28a7b86c4ef4cc46bfa8fb7f10a96684edcc..e1b54bf941ec59cc3fcd6806f192aae1d328d37c 100644 (file)
@@ -73,7 +73,7 @@ if ($helper->ifGuestLoginAllowed()) {
 $helper = WebLinkHelper::createWebLinkHelper($this, 'register_login_form_link', 'index.php?app=blog&amp;page=register');
 
 // Set link text
-$helper->setLinkTextById('register_login_form_link_text');
+$helper->addLinkWithTextById('register_login_form_link_text');
 
 // Flush the content
 $helper->flushContent();
index 106b2287a2d4509c389f5c1f8a60520343712b35..f4d7daf97b9119cf7a4f81162462c1918d6e475d 100644 (file)
@@ -3,7 +3,7 @@
 $helper = WebLinkHelper::createWebLinkHelper($this, 'relogin_link', 'index.php?app=blog&amp;page=login');
 
 // Set link text
-$helper->setLinkTextById('relogin_link_text');
+$helper->addLinkWithTextById('relogin_link_text');
 
 // Flush the content
 $helper->flushContent();
index 459d305919b09d248d28db371d065b5625b648ac..b7ebf877b58b5cc2b32f27452fae01e3e1711661 100644 (file)
@@ -3,7 +3,7 @@
 $helper = WebLinkHelper::createWebLinkHelper($this, 'logout_now_link', 'index.php?app=ship-simu&amp;page=logout&amp;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&amp;page=login_area');
 
 // Set link text
-$helper->setLinkTextById('return_login_link_text');
+$helper->addLinkWithTextById('return_login_link_text');
 
 // Flush the content
 $helper->flushContent();
index 91ae0dc979f8186dce19c1eed6d40ce71f657419..6e6cb4716d3b04d91a533d5f77ca8c43ad03b6da 100644 (file)
@@ -3,7 +3,7 @@
 $helper = WebLinkHelper::createWebLinkHelper($this, 'direct_login_link', 'index.php?app=ship-simu&amp;page=login');
 
 // Set link text
-$helper->setLinkTextById('direct_login_link_text');
+$helper->addLinkWithTextById('direct_login_link_text');
 
 // Flush the content
 $helper->flushContent();
index e134fb2bab612936d49aae86b6428c03e957caa2..14bbcc48dcb707c2ee270b65c5c0a97bab6ddd6d 100644 (file)
@@ -3,7 +3,7 @@
 $helper = WebLinkHelper::createWebLinkHelper($this, 'login_retry_link', 'index.php?app=ship-simu&amp;page=login');
 
 // Set link text
-$helper->setLinkTextById('login_retry_text');
+$helper->addLinkWithTextById('login_retry_text');
 
 // Flush the content
 $helper->flushContent();
index 0d6b64e928e8b6d0ce2c281c70b76d346fd50658..c2cf6fc7489f2f388ed31a591f055c9c6cd279d6 100644 (file)
@@ -73,7 +73,7 @@ if ($helper->ifGuestLoginAllowed()) {
 $helper = WebLinkHelper::createWebLinkHelper($this, 'register_login_form_link', 'index.php?app=ship-simu&amp;page=register');
 
 // Set link text
-$helper->setLinkTextById('register_login_form_link_text');
+$helper->addLinkWithTextById('register_login_form_link_text');
 
 // Flush the content
 $helper->flushContent();
index bf47313dad9cfb1685389b14e503f46b12ac84fd..81c6c111cdfc181470e35140e9a764966bd013db 100644 (file)
@@ -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&amp;page=login_area');
+$linkInstance = WebLinkHelper::createWebLinkHelper($this, 'logout_action_link', 'index.php?app=ship-simu&amp;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
 ?>
index b956f23f8272b7349e0ad2dc2dc71ca2f2baebcb..1f37ca835b85a9538e66d8f2bd01d483f5e86f7b 100644 (file)
@@ -3,7 +3,7 @@
 $helper = WebLinkHelper::createWebLinkHelper($this, 'relogin_link', 'index.php?app=ship-simu&amp;page=login');
 
 // Set link text
-$helper->setLinkTextById('relogin_link_text');
+$helper->addLinkWithTextById('relogin_link_text');
 
 // Flush the content
 $helper->flushContent();
index 24fb844b23ff6e0093b1fd0f853351d3513082be..40d9c6666b0995bbb0210c120fab7070c75ae3bb 100644 (file)
@@ -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("<a href=\"%s%s\" title=\"%s\">%s</a>",
+                       $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 &amp;
                $seperator = "&amp;";
 
-               // 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("<a href=\"%s%saction=%s\" title=\"%s\">%s</a>",
-                       $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);
        }
index 4e8bafe0262619d34e296eb5bfe98fb722778ac2..73ca2583b6b2c18d14b53c3d209c10891447f78d 100644 (file)
@@ -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);