Beispiel #1
0
 /**
  * Creates a raw Link for the portal (just the href)
  *
  * @param string $strPageI
  * @param string $strPageE
  * @param string $strAction
  * @param string $strParams
  * @param string $strSystemid
  * @param string $strLanguage
  * @param string $strSeoAddon Only used if using mod_rewrite
  * @return string
  */
 public static function getLinkPortalHref($strPageI, $strPageE = "", $strAction = "", $strParams = "", $strSystemid = "", $strLanguage = "", $strSeoAddon = "")
 {
     $strReturn = "";
     $bitInternal = true;
     //return "#" if neither an internal nor an external page is set
     if ($strPageI == "" && $strPageE == "") {
         return "#";
     }
     //Internal links are more important than external links!
     if ($strPageI == "" && $strPageE != "") {
         $bitInternal = false;
     }
     //create an array out of the params
     if ($strSystemid != "") {
         $strParams .= "&systemid=" . $strSystemid;
         $strSystemid = "";
     }
     $arrParams = self::parseParamsString($strParams, $strSystemid);
     // any anchors set to the page?
     $strAnchor = "";
     if (uniStrpos($strPageI, "#") !== false) {
         //get anchor, remove anchor from link
         $strAnchor = urlencode(uniSubstr($strPageI, uniStrpos($strPageI, "#") + 1));
         $strPageI = uniSubstr($strPageI, 0, uniStrpos($strPageI, "#"));
     }
     //urlencoding
     $strPageI = urlencode($strPageI);
     $strAction = urlencode($strAction);
     //more than one language installed?
     if ($strLanguage == "" && self::getIntNumberOfPortalLanguages() > 1) {
         $strLanguage = self::getStrPortalLanguage();
     } else {
         if ($strLanguage != "" && self::getIntNumberOfPortalLanguages() <= 1) {
             $strLanguage = "";
         }
     }
     $strHref = "";
     if ($bitInternal) {
         //check, if we could use mod_rewrite
         $bitRegularLink = true;
         if (class_module_system_setting::getConfigValue("_system_mod_rewrite_") == "true") {
             $strAddKeys = "";
             //used later to add seo-relevant keywords
             $objPage = class_module_pages_page::getPageByName($strPageI);
             if ($objPage !== null) {
                 if ($strLanguage != "") {
                     $objPage->setStrLanguage($strLanguage);
                     $objPage->initObject();
                 }
                 $strAddKeys = $objPage->getStrSeostring() . ($strSeoAddon != "" && $objPage->getStrSeostring() != "" ? "-" : "") . urlSafeString($strSeoAddon);
                 if (uniStrlen($strAddKeys) > 0 && uniStrlen($strAddKeys) <= 2) {
                     $strAddKeys .= "__";
                 }
                 //trim string
                 $strAddKeys = uniStrTrim($strAddKeys, 100, "");
                 if ($strLanguage != "") {
                     $strHref .= $strLanguage . "/";
                 }
                 $strPath = $objPage->getStrPath();
                 if ($strPath == "") {
                     $objPage->updatePath();
                     $strPath = $objPage->getStrPath();
                     $objPage->updateObjectToDb();
                 }
                 if ($strPath != "") {
                     $strHref .= $strPath . "/";
                 }
             }
             //ok, here we go. schema for rewrite_links: pagename.addKeywords.action.systemid.language.html
             //but: special case: just pagename & language
             if ($strAction == "" && $strSystemid == "" && $strAddKeys == "") {
                 $strHref .= $strPageI . ".html";
             } elseif ($strAction == "" && $strSystemid == "") {
                 $strHref .= $strPageI . ($strAddKeys == "" ? "" : "." . $strAddKeys) . ".html";
             } elseif ($strAction != "" && $strSystemid == "") {
                 $strHref .= $strPageI . "." . $strAddKeys . "." . $strAction . ".html";
             } else {
                 $strHref .= $strPageI . "." . $strAddKeys . "." . $strAction . "." . $strSystemid . ".html";
             }
             //params?
             if (count($arrParams) > 0) {
                 $strHref .= "?" . implode("&amp;", $arrParams);
             }
             // add anchor if given
             if ($strAnchor != "") {
                 $strHref .= "#" . $strAnchor;
             }
             //plus the domain as a prefix
             $strHref = "_webpath_" . "/" . $strHref;
             $bitRegularLink = false;
         }
         if ($bitRegularLink) {
             $strHref = "_indexpath_" . "?" . ($strPageI != "" ? "page=" . $strPageI : "") . "" . ($strSystemid != "" ? "&amp;systemid=" . $strSystemid : "") . ($strAction != "" ? "&amp;action=" . $strAction : "") . ($strLanguage != "" ? "&amp;language=" . $strLanguage : "") . (count($arrParams) > 0 ? "&amp;" . implode("&amp;", $arrParams) : "") . ($strAnchor != "" ? "#" . $strAnchor : "") . "";
         }
     } else {
         $strHref = $strPageE;
     }
     $strReturn .= $strHref;
     return $strReturn;
 }
 /**
  * @param string $strSeostring
  * @return void
  */
 public function setStrSeostring($strSeostring)
 {
     //Remove permitted characters
     $this->strSeostring = urlSafeString($strSeostring);
 }