3 * A helper for web links
5 * @author Roland Haeder <webmaster@ship-simu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.ship-simu.org
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 class WebLinkHelper extends BaseWebHelper implements HelpableTemplate {
28 private $linkName = "";
31 * Protected constructor
35 protected function __construct () {
36 // Call parent constructor
37 parent::__construct(__CLASS__);
41 * Creates the helper class
43 * @param $templateInstance An instance of a template engine
44 * @param $linkName Name of the link we shall generate
45 * @return $helperInstance A prepared instance of this helper
47 public final static function createWebLinkHelper (CompileableTemplate $templateInstance, $linkName) {
49 $helperInstance = new WebLinkHelper();
51 // Set template instance
52 $helperInstance->setTemplateInstance($templateInstance);
55 $helperInstance->setLinkName($linkName);
57 // Return the prepared instance
58 return $helperInstance;
62 * Setter for link name
64 * @param $linkName Name of the link we shall generate
67 protected final function setLinkName ($linkName) {
68 $this->linkName = (string) $linkName;
72 * Getter for link name
74 * @return $linkName Name of the link we shall generate
76 public final function getLinkName () {
77 return $this->linkName;
81 * Flush the content out,e g. to a template variable
84 * @todo Completely unimplemented
86 public function flushContent () {
87 // Needed to be implemented!
91 * Adds a link group (like the form group is) with some raw language to the
94 * @param $groupId Id string of the group
95 * @param $groupText Text for this group to add
98 public function addLinkGroup ($groupId, $groupText) {
99 // Is a group with that name open?
100 if ($this->ifGroupIsOpened($groupId)) {
101 // Then close it here
102 $this->closeGroupById($groupId);
104 // Open the new group
105 $this->openGroupByIdContent($groupId, $groupText);
110 * Adds text (note) to the previously opened group or throws an exception
111 * if no previous group was opened.
113 * @param $groupNote Note to be added to a group
115 * @throws NoGroupOpenedException If no previous group was opened
117 public function addLinkNote ($groupNote) {
118 // Check if a previous group was opened
119 if (!$this->ifGroupOpenedPreviously()) {
120 // No group was opened before!
121 throw new NoGroupOpenedException(array($this, $groupNote), self::EXCEPTION_GROUP_NOT_OPENED);