X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=framework%2Fmain%2Fclasses%2Fhelper%2Fhtml%2Flinks%2Fclass_HtmlLinkHelper.php;h=170a309231c21ae1ef78a3bc3dff51877b952e15;hb=HEAD;hp=60846d465793c7afc23e47b35ead0f864e07497c;hpb=aa425d10f8eef36160fcfd87bcd9a7d44af9ff16;p=core.git diff --git a/framework/main/classes/helper/html/links/class_HtmlLinkHelper.php b/framework/main/classes/helper/html/links/class_HtmlLinkHelper.php index 60846d46..170a3092 100644 --- a/framework/main/classes/helper/html/links/class_HtmlLinkHelper.php +++ b/framework/main/classes/helper/html/links/class_HtmlLinkHelper.php @@ -1,21 +1,23 @@ * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.shipsimu.org * @@ -58,7 +60,7 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * * @return void */ - protected function __construct () { + private function __construct () { // Call parent constructor parent::__construct(__CLASS__); } @@ -72,7 +74,7 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * @return $helperInstance A prepared instance of this helper * @throws NoConfigEntryException A deprecated exception at this point */ - public static final function createHtmlLinkHelper (CompileableTemplate $templateInstance, $linkName, $linkBase = NULL) { + public static final function createHtmlLinkHelper (CompileableTemplate $templateInstance, string $linkName, $linkBase = NULL) { // Get new instance $helperInstance = new HtmlLinkHelper(); @@ -83,7 +85,7 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { $helperInstance->setLinkName($linkName); // Get the application instance - $applicationInstance = Registry::getRegistry()->getInstance('application'); + $applicationInstance = ApplicationHelper::getSelfInstance(); // Get the request instance $requestInstance = FrameworkBootstrap::getRequestInstance(); @@ -91,11 +93,11 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { // Sanity-check on it if (is_null($requestInstance)) { // Throw an exception here - throw new NullPointerException($helperInstance, self::EXCEPTION_IS_NULL_POINTER); - } // END - if + throw new NullPointerException($helperInstance, FrameworkInterface::EXCEPTION_IS_NULL_POINTER); + } // Get page (this will throw an exception if not set) - $command = $helperInstance->convertDashesToUnderscores($requestInstance->getRequestElement('command')); + $command = StringUtils::convertDashesToUnderscores($requestInstance->getRequestElement('command')); // Construct config entry $configEntry = $command . '_' . $linkName . '_action_url'; @@ -104,18 +106,18 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { if (!is_null($linkBase)) { // Then output a deprecation message $helperInstance->deprecationWarning('[' . __METHOD__ . ':' . __LINE__ . ']: linkBase is deprecated. Please remove it from your templates and add a config entry ' . $configEntry . ' in your config.php file.'); - } // END - if + } // Determine link base from config now and 'command' request try { - $newLinkBase = $helperInstance->getConfigInstance()->getConfigEntry($configEntry); + $newLinkBase = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configEntry); $linkBase = $newLinkBase; } catch (NoConfigEntryException $e) { // Is the deprecated linkBase not set? if (is_null($linkBase)) { // Then throw again the exception throw new NoConfigEntryException(array(__CLASS__, ($configEntry)), FrameworkConfiguration::EXCEPTION_CONFIG_ENTRY_WAS_NOT_FOUND); - } // END - if + } } // Set link base @@ -137,7 +139,7 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $extraContent Optional extra HTML content * @return $linkContent Rendered text link content */ - private function renderLinkContentWithTextExtraContent ($linkText, $linkTitle, $extraContent='') { + private function renderLinkContentWithTextExtraContent (string $linkText, string $linkTitle, string $extraContent = '') { // Construct link content $linkContent = sprintf('%s', $this->getLinkBase(), @@ -156,8 +158,8 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $linkName Name of the link we shall generate * @return void */ - protected final function setLinkName ($linkName) { - $this->linkName = (string) $linkName; + protected final function setLinkName (string $linkName) { + $this->linkName = $linkName; } /** @@ -175,8 +177,8 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $linkBase Base of the link we shall generate * @return void */ - protected final function setLinkBase ($linkBase) { - $this->linkBase = (string) $linkBase; + protected final function setLinkBase (string $linkBase) { + $this->linkBase = $linkBase; } /** @@ -199,7 +201,7 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { if ($this->ifGroupOpenedPreviously()) { // Then close it $this->closePreviousGroupByContent(''); - } // END - if + } // Get the content $content = $this->renderContent(); @@ -220,12 +222,12 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $groupCode Code to open and close groups * @return void */ - public function addLinkGroup ($groupId, $groupText, $groupCode = 'div') { + public function addLinkGroup (string $groupId, string $groupText, string $groupCode = 'div') { // Is a group with that name open? if ($this->ifGroupOpenedPreviously()) { // Then close it here $this->closePreviousGroupByContent(''); - } // END - if + } // Generate the group content $content = sprintf('<%s id="group_%s_%s">%s', @@ -249,18 +251,18 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * @return void * @throws NoGroupOpenedException If no previous group was opened */ - public function addLinkNote ($groupId, $groupNote, $groupCode = 'div') { + public function addLinkNote (string $groupId, string $groupNote, string $groupCode = 'div') { // Check if a previous group was opened if ($this->ifGroupOpenedPreviously() === false) { // No group was opened before! throw new NoGroupOpenedException(array($this, $groupNote), self::EXCEPTION_GROUP_NOT_OPENED); - } // END - if + } // Is a previous sub group open? if ($this->ifSubGroupOpenedPreviously()) { // Then close it $this->closePreviousSubGroupByContent(''); - } // END - if + } // Generate the group content $content = sprintf('<%s id="subgroup_%s_%s">%s', @@ -282,12 +284,12 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * @return void * @throws NoGroupOpenedException If no previous group was opened */ - protected function addActionLink ($linkAction, $linkText, $linkTitle) { + protected function addActionLink (string $linkAction, string $linkText, string $linkTitle) { // Check if a previous group was opened if ($this->ifGroupOpenedPreviously() === false) { // No group was opened before! throw new NoGroupOpenedException(array($this, $linkAction . '(' . $linkText . ')'), self::EXCEPTION_GROUP_NOT_OPENED); - } // END - if + } // Default parameter SEPARATOR is & $separator = self::EXTRA_PARAMETER_SEPARATOR; @@ -297,7 +299,7 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { if (count($linkArray) == 0) { // No question mark $separator = self::FIRST_PARAMETER_SEPARATOR; - } // END - if + } // Prepare action $action = sprintf('%saction=%s', @@ -319,12 +321,12 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $languageId Language id string to use * @return void */ - public function addActionLinkById ($linkAction, $languageId) { + public function addActionLinkById (string $linkAction, string $languageId) { // Resolve the language string - $languageResolvedText = $this->getLanguageInstance()->getMessage('link_' . $languageId . '_text'); + $languageResolvedText = FrameworkBootstrap::getLanguageInstance()->getMessage('link_' . $languageId . '_text'); // Resolve the language string - $languageResolvedTitle = $this->getLanguageInstance()->getMessage('link_' . $languageId . '_title'); + $languageResolvedTitle = FrameworkBootstrap::getLanguageInstance()->getMessage('link_' . $languageId . '_title'); // Add the action link $this->addActionLink($linkAction, $languageResolvedText, $languageResolvedTitle); @@ -337,12 +339,12 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $languageId Language id string to use * @return void */ - public function addLinkWithTextById ($languageId) { + public function addLinkWithTextById (string $languageId) { // Resolve the language string - $languageResolvedText = $this->getLanguageInstance()->getMessage('link_' . $languageId . '_text'); + $languageResolvedText = FrameworkBootstrap::getLanguageInstance()->getMessage('link_' . $languageId . '_text'); // Resolve the language string - $languageResolvedTitle = $this->getLanguageInstance()->getMessage('link_' . $languageId . '_title'); + $languageResolvedTitle = FrameworkBootstrap::getLanguageInstance()->getMessage('link_' . $languageId . '_title'); // Now add the link $linkContent = $this->renderLinkContentWithTextExtraContent($languageResolvedText, $languageResolvedTitle);