{CATEGORY} | -- |
{ITEMNAME} | -{CHECKBOX} | -
{CATEGORY} | -{ACTIONS} | -
{ITEMNAME} | -{ACTION_CREATE} {ACTION_RENAME} {ACTION_ONOFFLINE} {ACTION_MOVE_UP} {ACTION_MOVE_DOWN} {ACTION_DELETE} | -
" . print_r($sPath, true) . ""; - - return $sPath; - } - - /** - * Return full CONTENIDO url from single anchor - * - * @param array $aMatches [0] = complete anchor, [1] = pre arguments, [2] = anchor name, [3] = post arguments - * @return string New anchor - */ - public static function rewriteHtmlAnchor(array $aMatches = array()) { - global $artname, $sess, $idart, $idcat, $client, $lang; - - // set article name - $sArtParam = ''; - if (isset($artname) && strlen($artname) > 0) { - $sArtParam = '&idart=' . (int) $idart; - } - - // check for additional parameter in url - $aParamsToIgnore = array('idcat', 'idart', 'lang', 'client', 'idcatart', 'changelang', 'changeclient', 'idartlang', 'parts', 'artname'); - $sOtherParams = ''; - - if (isset($_GET) && count($_GET) > 0) { - foreach ($_GET as $key => $value) { - if (!in_array($key, $aParamsToIgnore) && strlen(trim($value)) > 0) { - $aNoAnchor = explode('#', $value); - $sOtherParams .= '&' . urlencode(urldecode($key)) . '=' . urlencode(urldecode($value)); - } - } - } - - $url = $sess->url( - 'front_content.php?' . 'idcat=' . (int) $idcat . '&client=' . (int) $client . - '&changelang=' . (int) $lang . $sArtParam . $sOtherParams . '#' . $aMatches[2] - ); - - $sNewUrl = ''; - - return $sNewUrl; - } - - /** - * Return full CONTENIDO url from single anchor - * - * @param array $aMatches [0] = complete anchor, [1] = pre arguments, [2] = anchor name, [3] = post arguments - * @param bool $bXHTML Flag to return XHTML valid url - * @return string New anchor - */ - public static function contenidoHtmlAnchor(array $aMatches = array(), $bXHTML = true) { - global $sess; - - $aParams = array(); - $sAmpersand = $bXHTML ? '&' : '&'; - - foreach ($_GET as $key => $value) { - $aNoAnchor = explode('#', $value); - $aParams[] = urlencode(urldecode($key)) . '=' . urlencode(urldecode($aNoAnchor[0])); - } - - $url = $sess->url('front_content.php?' . implode($sAmpersand, $aParams) . '#' . $aMatches[2]); - $sNewUrl = ''; - - return $sNewUrl; - } - - /** - * Get article websafe name from article id and language id. - * - * @param int $iArtId Article id - * @param int $iLangId Language id - * @return string Article websafe name - */ - public static function getArtWebsafeName($iArtId = 0, $iLangId = 0) { - global $cfg; - - $iArtId = (int) $iArtId; - $iLangId = (int) $iLangId; - $sql = "SELECT urlname FROM " . $cfg['tab']['art_lang'] . " WHERE " - . "idart = " . $iArtId . " AND idlang = " . $iLangId; - if ($aData = mr_queryAndNextRecord($sql)) { - return $aData['urlname']; - } - return null; - } - - /** - * Get article websafe name from idartlang. - * - * @param int $iArtLangId idartlang - * @return string Article websafe name - */ - public static function getArtLangWebsafeName($iArtLangId = 0) { - global $cfg; - - $iArtLangId = (int) $iArtLangId; - $sql = "SELECT urlname FROM " . $cfg['tab']['art_lang'] . " WHERE idartlang = " . $iArtLangId; - if ($aData = mr_queryAndNextRecord($sql)) { - return $aData['urlname']; - } - return null; - } - - /** - * Get name of client by id. - * - * @param int $clientId Client id - * @return string Client name - */ - public static function getClientName($clientId = 0) { - global $cfg; - - $clientId = (int) $clientId; - $key = 'clientname_by_clientid_' . $clientId; - - if (isset(self::$_lookupTable[$key])) { - return self::$_lookupTable[$key]; - } - - $sql = "SELECT name FROM " . $cfg['tab']['clients'] . " WHERE idclient = " . $clientId; - if ($aData = mr_queryAndNextRecord($sql)) { - $clientName = $aData['name']; - } else { - $clientName = ''; - } - - self::$_lookupTable[$key] = $clientName; - return $clientName; - } - - /** - * Get client id from client name - * - * @param string $sClientName Client name - * @return int Client id - */ - public static function getClientId($sClientName = '') { - global $cfg; - - $sClientName = strtolower(self::$_db->escape($sClientName)); - $key = 'clientid_by_name_' . $sClientName; - - if (isset(self::$_lookupTable[$key])) { - return self::$_lookupTable[$key]; - } - - $sql = "SELECT idclient FROM " . $cfg['tab']['clients'] . " WHERE LOWER(name) = '" . $sClientName . "' OR LOWER(name) = '" . urldecode($sClientName) . "'"; - - if ($aData = mr_queryAndNextRecord($sql)) { - $clientId = $aData['idclient']; - } else { - $clientId = false; - } - - self::$_lookupTable[$key] = $clientId; - return $clientId; - } - - /** - * Checks if client id exists - * - * @param int $clientId - * @return bool - */ - public static function clientIdExists($clientId) { - global $cfg; - - $clientId = (int) $clientId; - $key = 'clientid_exists_' . $clientId; - - if (isset(self::$_lookupTable[$key])) { - return self::$_lookupTable[$key]; - } - - $sql = "SELECT idclient FROM " . $cfg['tab']['clients'] . " WHERE idclient = " . $clientId; - if ($aData = mr_queryAndNextRecord($sql)) { - $exists = true; - } else { - $exists = false; - } - - self::$_lookupTable[$key] = $exists; - return $exists; - } - - /** - * Returns name of language by id. - * - * @param int $languageId Language id - * @return string Lanuage name - */ - public static function getLanguageName($languageId = 0) { - global $cfg; - - $languageId = (int) $languageId; - $key = 'languagename_by_id_' . $languageId; - - if (isset(self::$_lookupTable[$key])) { - return self::$_lookupTable[$key]; - } - - $sql = "SELECT name FROM " . $cfg['tab']['lang'] . " WHERE idlang = " . $languageId; - if ($aData = mr_queryAndNextRecord($sql)) { - $languageName = $aData['name']; - } else { - $languageName = ''; - } - - self::$_lookupTable[$key] = $languageName; - return $languageName; - } - - /** - * Checks if language id exists - * - * @param int $languageId Language id - * @return bool - */ - public static function languageIdExists($languageId) { - global $cfg; - - $languageId = (int) $languageId; - $key = 'languageid_exists_' . $languageId; - - if (isset(self::$_lookupTable[$key])) { - return self::$_lookupTable[$key]; - } - - $sql = "SELECT idlang FROM " . $cfg['tab']['lang'] . " WHERE idlang = " . $languageId; - if ($aData = mr_queryAndNextRecord($sql)) { - $exists = true; - } else { - $exists = false; - } - - self::$_lookupTable[$key] = $exists; - return $exists; - } - - /** - * Get language id from language name thanks to Nicolas Dickinson for multi - * Client/Language BugFix - * - * @param string $sLanguageName Language name - * @param int $iClientId Client id - * @return int Language id - */ - public static function getLanguageId($sLanguageName = '', $iClientId = 1) { - global $cfg; - - $sLanguageName = strtolower(self::$_db->escape($sLanguageName)); - $iClientId = (int) $iClientId; - $key = 'langid_by_langname_clientid_' . $sLanguageName . '_' . $iClientId; - - if (isset(self::$_lookupTable[$key])) { - return self::$_lookupTable[$key]; - } - - $sql = "SELECT l.idlang FROM " . $cfg['tab']['lang'] . " as l " - . "LEFT JOIN " . $cfg['tab']['clients_lang'] . " AS cl ON l.idlang = cl.idlang " - . "WHERE cl.idclient = " . $iClientId . " AND (LOWER(l.name) = '" . $sLanguageName . "' " - . "OR LOWER(l.name) = '" . urldecode($sLanguageName) . "')"; - if ($aData = mr_queryAndNextRecord($sql)) { - $languageId = $aData['idlang']; - } else { - $languageId = 0; - } - - self::$_lookupTable[$key] = $languageId; - return $languageId; - } - - /** - * Splits passed argument into scheme://host and path/query. - * - * Example: - * input = http://host/front_content.php?idcat=123 - * return = array('htmlpath' => 'http://host', 'url' => 'front_content.php?idcat=123') - * - * @param string $url URL to split - * @return array Assoziative array including the two parts: - * - array('htmlpath' => $path, 'url' => $url) - */ - public static function getClientFullUrlParts($url) { - global $cfgClient, $client; - - $clientPath = $cfgClient[$client]['path']['htmlpath']; - - if (stristr($url, $clientPath) !== false) { - // url includes full html path (scheme host path, etc.) - $url = str_replace($clientPath, '', $url); - $htmlPath = $clientPath; - $aComp = parse_url($htmlPath); - - // check if path matches to defined rootdir from cl-mod-rewrite conf - if (isset($aComp['path']) && $aComp['path'] !== parent::getConfig('rootdir')) { - // replace not matching path agaings configured one - // this will replace e. g. "http://host/cms/" against "http://host/" - $htmlPath = str_replace($aComp['path'], parent::getConfig('rootdir'), $htmlPath); - if (substr($htmlPath, strlen($htmlPath) - 1) == '/') { - // remove last slash - $htmlPath = substr($htmlPath, 0, strlen($htmlPath) - 1); - } - } - } else { - $htmlPath = ''; - } - return array('htmlpath' => $htmlPath, 'url' => $url); - } - - /** - * Function to preclean a url. - * - * Removes absolute path declaration '/front_content.php' or relative path - * definition to actual dir './front_content.php', ampersand entities '&' - * and returns a url like 'front_content.php?idart=12&idlang=1' - * - * @param string $url Url to clean - * @return string Cleaned Url - */ - public static function urlPreClean($url) { - // some preparation of different front_content.php occurence - if (strpos($url, './front_content.php') === 0) { - $url = str_replace('./front_content.php', 'front_content.php', $url); - } elseif (strpos($url, '/front_content.php') === 0) { - $url = str_replace('/front_content.php', 'front_content.php', $url); - } - $url = str_replace('&', '&', $url); - return $url; - } - - /** - * Method to reset all aliases in categories. - * - * Clears all urlname entries in cat_lang table, and sets the value for all - * existing entries. - * - * @deprecated see ModRewrite::recreateCategoriesAliases(); - */ - public static function resetCategoriesAliases() { - self::recreateCategoriesAliases(); - } - - /** - * Recreates all or only empty aliases in categories table. - * - * @param bool $bOnlyEmpty Flag to reset only empty items - */ - public static function recreateCategoriesAliases($bOnlyEmpty = false) { - global $cfg; - - $db = new DB_Contenido(); - - $aCats = array(); - - // get all or only empty categories - $sql = "SELECT name, idcat, idlang FROM " . $cfg['tab']['cat_lang']; - if ($bOnlyEmpty === true) { - $sql .= " WHERE urlname IS NULL OR urlname = '' OR urlpath IS NULL OR urlpath = ''"; - } - - $db->query($sql); - while ($db->next_record()) { - //set new alias - self::setCatWebsafeName($db->f('name'), $db->f('idcat'), $db->f('idlang')); - $aCats[] = array('idcat' => $db->f('idcat'), 'idlang' => $db->f('idlang')); - } - - foreach ($aCats as $p => $item) { - self::setCatUrlPath($item['idcat'], $item['idlang']); - } - - unset($db, $aCats); - } - - /** - * Returns list of all empty category aliases - * - * @param bool $bOnlyNumber - * @return array|int - */ - public static function getEmptyCategoriesAliases($bOnlyNumber = true) { - global $cfg; - - $db = new DB_Contenido(); - $return = ($bOnlyNumber) ? 0 : array(); - - // get all empty categories - $sql = "SELECT name, idcat, idlang FROM " . $cfg['tab']['cat_lang']; - $sql .= " WHERE urlname IS NULL OR urlname = '' OR urlpath IS NULL OR urlpath = ''"; - - $db->query($sql); - - if ($bOnlyNumber) { - $return = (int) $db->num_rows(); - } else { - while ($db->next_record()) { - $return[] = array($db->f('name'), $db->f('idcat'), $db->f('idlang')); - } - } - - unset($db); - return $return; - } - - /** - * Method to reset all aliases in articles. - * - * Clears all urlname entries in art_lang table, and sets the value for all - * existing entries. - * - * @deprecated see ModRewrite::recreateArticlesAliases(); - */ - public static function resetArticlesAliases() { - self::recreateArticlesAliases(); - } - - /** - * Recreates all or only empty urlname entries in art_lang table. - * - * @param bool $bOnlyEmpty Flag to reset only empty items - */ - public static function recreateArticlesAliases($bOnlyEmpty = false) { - global $cfg; - - $db = new DB_Contenido(); - - // get all or only empty articles - $sql = "SELECT title, idart, idlang FROM " . $cfg['tab']['art_lang']; - if ($bOnlyEmpty === true) { - $sql .= " WHERE urlname IS NULL OR urlname = ''"; - } - $db->query($sql); - - while ($db->next_record()) { - //set new alias - self::setArtWebsafeName($db->f('title'), $db->f('idart'), $db->f('idlang')); - } - - unset($db); - } - - /** - * Returns list of all empty article aliases - * - * @param bool $bOnlyNumber - * @return array|int - */ - public static function getEmptyArticlesAliases($bOnlyNumber = true) { - global $cfg; - - $db = new DB_Contenido(); - $return = ($bOnlyNumber) ? 0 : array(); - - // get all empty articles - $sql = "SELECT title, idart, idlang FROM " . $cfg['tab']['art_lang']; - $sql .= " WHERE urlname IS NULL OR urlname = ''"; - - $db->query($sql); - if ($bOnlyNumber) { - $return = (int) $db->num_rows(); - } else { - while ($db->next_record()) { - $return[] = array($db->f('title'), $db->f('idart'), $db->f('idlang')); - } - } - - unset($db); - return $return; - } - - /** - * Method to reset all aliases (categories and articles). - * - * Shortcut to recreateCategoriesAliases() and recreateArticlesAliases() - */ - public static function resetAliases() { - self::recreateCategoriesAliases(); - self::recreateArticlesAliases(); - } - - /** - * Recreate all or only empty aliases (categories and articles). - * - * Shortcut to recreateCategoriesAliases() and recreateArticlesAliases() - * - * @param bool $bOnlyEmpty Flag to reset only empty items - */ - public static function recreateAliases($bOnlyEmpty = false) { - self::recreateCategoriesAliases($bOnlyEmpty); - self::recreateArticlesAliases($bOnlyEmpty); - } - - /** - * Used to postprocess resolved path - * - * Error site handling if category not found - * - * if percentage == 100 and there is no 100 percentage result value, - * error site will be shown - can be adjust by user settings for - * smooth similar effects - 80 to 95 will be best but have to check by user - * - * @deprecated Is no more used - * - * @param array $results Pathresolver results array - * @return mixed Categoryid or false - */ - public static function getIdFromPathresolverResult($results) { - $iMinPercentage = (int) parent::getConfig('category_resolve_min_percentage', 0); - $catId = key($results); - if ($iMinPercentage > 0 && $results[$catId] < $iMinPercentage) { - return false; - } else { - return $catId; - } - } - - /** - * Returns .htaccess related assoziative info array - * - * @return array - */ - public static function getHtaccessInfo() { - global $cfgClient, $client, $cfg; - - $arr = array( - 'contenido_full_path' => str_replace('\\', '/', realpath($cfg['path']['contenido'] . '../') . '/'), - 'client_full_path' => $cfgClient[$client]['path']['frontend'], - ); - $arr['in_contenido_path'] = is_file($arr['contenido_full_path'] . '.htaccess'); - $arr['in_client_path'] = is_file($arr['client_full_path'] . '.htaccess'); - $arr['has_htaccess'] = ($arr['in_contenido_path'] || $arr['in_client_path']); - - return $arr; - } - -} diff --git a/conlite/plugins/cl-mod-rewrite/classes/class.modrewritebase.php b/conlite/plugins/cl-mod-rewrite/classes/class.modrewritebase.php deleted file mode 100644 index 0284fd2..0000000 --- a/conlite/plugins/cl-mod-rewrite/classes/class.modrewritebase.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright four for business AG
DebuggerFactory::getDebugger('visible_adv')
.
- *
- * @param mixed $mVar The variable to dump
- * @param string $sLabel Describtion for passed $mVar
- */
- public static function add($mVar, $sLabel = '') {
- if (!self::$_bEnabled) {
- return;
- }
- DebuggerFactory::getDebugger('visible_adv')->add($mVar, $sLabel);
- }
-
- /**
- * Returns output of all added variables to debug.
- * @return string
- */
- public static function getAll() {
- if (!self::$_bEnabled) {
- return '';
- }
-
- ob_start();
- DebuggerFactory::getDebugger('visible_adv')->showAll();
- $output = ob_get_contents();
- ob_end_clean();
- return $output;
- }
-
- /**
- * Logs variable to debugger.
- * Wrapper for cDebug::getDebugger(cDebug::DEBUGGER_FILE)
.
- *
- * @param mixed $mVar The variable to log the contents
- * @param string $sLabel Describtion for passed $mVar
- */
- public static function log($mVar, $sLabel = '') {
- if (!self::$_bEnabled) {
- return;
- }
-
- DebuggerFactory::getDebugger('file')->show($mVar, $sLabel);
- }
-
-}
diff --git a/conlite/plugins/cl-mod-rewrite/classes/class.modrewritetest.php b/conlite/plugins/cl-mod-rewrite/classes/class.modrewritetest.php
deleted file mode 100644
index 5801ea7..0000000
--- a/conlite/plugins/cl-mod-rewrite/classes/class.modrewritetest.php
+++ /dev/null
@@ -1,300 +0,0 @@
-
- * @copyright four for business AG
- * $arr[idcat] = Category dataset
- * $arr[idcat]['articles'][idart] = Article dataset
- *
- */
- public function fetchFullStructure($idclient = null, $idlang = null) {
- global $client, $lang;
-
- $db = new DB_Contenido();
- $db2 = new DB_Contenido();
-
- if (!$idclient || (int) $idclient == 0) {
- $idclient = $client;
- }
- if (!$idlang || (int) $idlang == 0) {
- $idlang = $lang;
- }
-
- $aTab = $this->_aCfgTab;
-
- $aStruct = array();
-
- $sql = "SELECT
- *
- FROM
- " . $aTab['cat_tree'] . " AS a,
- " . $aTab['cat_lang'] . " AS b,
- " . $aTab['cat'] . " AS c
- WHERE
- a.idcat = b.idcat AND
- c.idcat = a.idcat AND
- c.idclient = '" . $idclient . "' AND
- b.idlang = '" . $idlang . "'
- ORDER BY
- a.idtree";
-
- $db->query($sql);
-
- $counter = 0;
-
- while ($db->next_record()) {
-
- if (++$counter == $this->_iMaxItems) {
- break; // break this loop
- }
-
- $idcat = $db->f('idcat');
- $aStruct[$idcat] = $db->Record;
- $aStruct[$idcat]['articles'] = array();
-
- $sql2 = "SELECT
- *
- FROM
- " . $aTab['cat_art'] . " AS a,
- " . $aTab['art'] . " AS b,
- " . $aTab['art_lang'] . " AS c
- WHERE
- a.idcat = '" . $idcat . "' AND
- b.idart = a.idart AND
- c.idart = a.idart AND
- c.idlang = '" . $idlang . "' AND
- b.idclient = '" . $idclient . "'
- ORDER BY
- c.title ASC";
-
- $db2->query($sql2);
-
- while ($db2->next_record()) {
- $idart = $db2->f('idart');
- $aStruct[$idcat]['articles'][$idart] = $db2->Record;
- if (++$counter == $this->_iMaxItems) {
- break 2; // break this and also superior loop
- }
- }
- }
-
- return $aStruct;
- }
-
- /**
- * Creates an URL using passed data.
- *
- * The result is used to generate seo urls...
- *
- * @param array $arr Assoziative array with some data as follows:
- *
- * $arr['idcat']
- * $arr['idart']
- * $arr['idcatart']
- * $arr['idartlang']
- *
- * @param string $type Either 'c' or 'a' (category or article). If set to
- * 'c' only the parameter idcat will be added to the URL
- */
- public function composeURL($arr, $type) {
- $type = ($type == 'a') ? 'a' : 'c';
-
- $param = array();
-
- if ($type == 'c') {
- $param[] = 'idcat=' . $arr['idcat'];
- } else {
- if (mr_getRequest('idart')) {
- $param[] = 'idart=' . $arr['idart'];
- }
- if (mr_getRequest('idcat')) {
- $param[] = 'idcat=' . $arr['idcat'];
- }
- if (mr_getRequest('idcatart')) {
- $param[] = 'idcatart=' . $arr['idcatart'];
- }
- if (mr_getRequest('idartlang')) {
- $param[] = 'idartlang=' . $arr['idartlang'];
- }
- }
- $param[] = 'foo=bar';
- return 'front_content.php?' . implode('&', $param);
- }
-
- /**
- * Resolves variables of an page (idcat, idart, idclient, idlang, etc.) by
- * processing passed url using ModRewriteController
- *
- * @param string $url Url to resolve
- * @return array Assoziative array with resolved data
- */
- public function resolveUrl($url) {
- // some globals to reset
- $aGlobs = array(
- 'mr_preprocessedPageError', 'idart', 'idcat'
- );
- foreach ($aGlobs as $p => $k) {
- if (isset($GLOBALS[$k])) {
- unset($GLOBALS[$k]);
- }
- }
-
- $aReturn = array();
-
- // create an mod rewrite controller instance and execute processing
- $oMRController = new ModRewriteController($url);
- $oMRController->execute();
-
- if ($oMRController->errorOccured()) {
-
- // an error occured (idcat and or idart couldn't catched by controller)
- $aReturn['mr_preprocessedPageError'] = 1;
- $aReturn['error'] = $oMRController->getError();
-
- $this->_sResolvedUrl = '';
- $this->_bRoutingFound = false;
- } else {
-
- // set some global variables
-
- $this->_sResolvedUrl = $oMRController->getResolvedUrl();
- $this->_bRoutingFound = $oMRController->getRoutingFoundState();
-
- if ($oMRController->getClient()) {
- $aReturn['client'] = $oMRController->getClient();
- }
-
- if ($oMRController->getChangeClient()) {
- $aReturn['changeclient'] = $oMRController->getChangeClient();
- }
-
- if ($oMRController->getLang()) {
- $aReturn['lang'] = $oMRController->getLang();
- }
-
- if ($oMRController->getChangeLang()) {
- $aReturn['changelang'] = $oMRController->getChangeLang();
- }
-
- if ($oMRController->getIdArt()) {
- $aReturn['idart'] = $oMRController->getIdArt();
- }
-
- if ($oMRController->getIdCat()) {
- $aReturn['idcat'] = $oMRController->getIdCat();
- }
-
- if ($oMRController->getPath()) {
- $aReturn['path'] = $oMRController->getPath();
- }
- }
-
- return $aReturn;
- }
-
- /**
- * Creates a readable string from passed resolved data array.
- *
- * @param array Assoziative array with resolved data
- * @return string Readable resolved data
- */
- public function getReadableResolvedData(array $data) {
- // compose resolved string
- $ret = '';
- foreach ($data as $k => $v) {
- $ret .= $k . '=' . $v . '; ';
- }
- $ret = substr($ret, 0, strlen($ret) - 2);
- return $ret;
- }
-
-}
diff --git a/conlite/plugins/cl-mod-rewrite/classes/class.modrewriteurlstack.php b/conlite/plugins/cl-mod-rewrite/classes/class.modrewriteurlstack.php
deleted file mode 100644
index dbfd893..0000000
--- a/conlite/plugins/cl-mod-rewrite/classes/class.modrewriteurlstack.php
+++ /dev/null
@@ -1,319 +0,0 @@
-
- * @copyright four for business AG
- * // get the instance
- * $oMRUrlStack = ModRewriteUrlStack::getInstance();
- *
- * // add several urls to fill the stack
- * $oMRUrlStack->add('front_content.php?idcat=123');
- * $oMRUrlStack->add('front_content.php?idart=321');
- * $oMRUrlStack->add('front_content.php?idcatart=213');
- * $oMRUrlStack->add('front_content.php?idcatlang=213');
- * $oMRUrlStack->add('front_content.php?idartlang=312');
- *
- * // now the first call will get the pretty path and names from database at one go
- * $aPrettyParts = $oMRUrlStack->getPrettyUrlParts('front_content.php?idcat=123');
- * echo $aPrettyParts['urlpath']; // something like 'Main-category-name/Category-name/Another-category-name/'
- * echo $aPrettyParts['urlname']; // something like 'Name-of-an-article'
- *
- *
- * @author Murat Purc
- * $arr['urlpath']
- * $arr['urlname']
- *
- */
- public function getPrettyUrlParts($url) {
- $url = ModRewrite::urlPreClean($url);
- if (!isset($this->_aUrls[$url])) {
- $this->add($url);
- }
-
- $sStackId = $this->_aUrls[$url];
- if (!isset($this->_aStack[$sStackId]['urlpath'])) {
- $this->_chunkSetPrettyUrlParts($sStackId);
- }
- $aPretty = array(
- 'urlpath' => $this->_aStack[$sStackId]['urlpath'],
- 'urlname' => $this->_aStack[$sStackId]['urlname']
- );
- return $aPretty;
- }
-
- /**
- * Extracts passed url using parse_urla and adds also the 'params' array to it
- *
- * @param string Url, like front_content.php?idcat=123...
- * @return array Components containing result of parse_url with additional
- * 'params' array
- */
- private function _extractUrl($url) {
- $aUrl = @parse_url($url);
- if (isset($aUrl['query'])) {
- $aUrl['query'] = str_replace('&', '&', $aUrl['query']);
- parse_str($aUrl['query'], $aUrl['params']);
- }
- if (!isset($aUrl['params']) && !is_array($aUrl['params'])) {
- $aUrl['params'] = array();
- }
- return $aUrl;
- }
-
- /**
- * Extracts article or category related parameter from passed params array
- * and generates an identifier.
- *
- * @param array $aParams Parameter array
- * @return string Composed stack id
- */
- private function _makeStackId(array $aParams) {
- # idcatart
- if ((int) mr_arrayValue($aParams, 'idart') > 0) {
- $sStackId = 'idart_' . $aParams['idart'] . '_lang_' . $aParams['lang'];
- } elseif ((int) mr_arrayValue($aParams, 'idartlang') > 0) {
- $sStackId = 'idartlang_' . $aParams['idartlang'];
- } elseif ((int) mr_arrayValue($aParams, 'idcatart') > 0) {
- $sStackId = 'idcatart_' . $aParams['idcatart'] . '_lang_' . $aParams['lang'];
- } elseif ((int) mr_arrayValue($aParams, 'idcat') > 0) {
- $sStackId = 'idcat_' . $aParams['idcat'] . '_lang_' . $aParams['lang'];
- } elseif ((int) mr_arrayValue($aParams, 'idcatlang') > 0) {
- $sStackId = 'idcatlang_' . $aParams['idcatlang'];
- } else {
- $sStackId = 'lang_' . $aParams['lang'];
- }
- return $sStackId;
- }
-
- /**
- * Main function to get the urlparts of urls.
- *
- * Composes the query by looping thru stored but non processed urls, executes
- * the query and adds the (urlpath and urlname) result to the stack.
- *
- * @param type $sStackId
- * @return type
- */
- private function _chunkSetPrettyUrlParts($sStackId) {
- // collect stack parameter to get urlpath and urlname
- $aStack = array();
- foreach ($this->_aStack as $stackId => $item) {
- if (!isset($item['urlpath'])) {
- // pretty url is to create
- $aStack[$stackId] = $item;
- }
- }
-
- // now, it's time to compose the where clause of the query
- $sWhere = '';
- foreach ($aStack as $stackId => $item) {
-
- if ($stackId == $sStackId) {
- $aP = $item['params'];
- if ((int) mr_arrayValue($aP, 'idart') > 0) {
- $sWhere .= '(al.idart = ' . $aP['idart'] . ' AND al.idlang = ' . $aP['lang'] . ') OR ';
- } elseif ((int) mr_arrayValue($aP, 'idartlang') > 0) {
- $sWhere .= '(al.idartlang = ' . $aP['idartlang'] . ') OR ';
- } elseif ((int) mr_arrayValue($aP, 'idcat') > 0) {
- $sWhere .= '(cl.idcat = ' . $aP['idcat'] . ' AND cl.idlang = ' . $aP['lang'] . ' AND cl.startidartlang = al.idartlang) OR ';
- } elseif ((int) mr_arrayValue($aP, 'idcatart') > 0) {
- $sWhere .= '(ca.idcatart = ' . $aP['idcatart'] . ' AND ca.idart = al.idart AND al.idlang = ' . $aP['lang'] . ') OR ';
- } elseif ((int) mr_arrayValue($aP, 'idcatlang') > 0) {
- $sWhere .= '(cl.idcatlang = ' . $aP['idcatlang'] . ' AND cl.startidartlang = al.idartlang) OR ';
- }
- }
- }
- if ($sWhere == '') {
- return;
- }
- $sWhere = cString::getPartOfString($sWhere, 0, -4);
- $sWhere = str_replace(' OR ', " OR \n", $sWhere);
-
- // compose query and execute it
- $sql = <<'; - print_r($aMR['cl-mod-rewrite']); - echo ''; - $sMsg = i18n("Configuration has not been saved, because of enabled debugging", "cl-mod-rewrite"); - echo $this->_notifyBox('info', $sMsg); - return; - } - - $bSeparatorModified = $this->_separatorModified($aMR['cl-mod-rewrite']); - - if (mr_setConfiguration($this->_client, $aMR)) { - $sMsg = i18n("Configuration has been saved", "cl-mod-rewrite"); - if ($bSeparatorModified) { - mr_loadConfiguration($this->_client, true); - } - $this->_oView->content_before .= $this->_notifyBox('info', $sMsg); - } else { - $sMsg = i18n("Configuration could not saved. Please check write permissions for %s ", "cl-mod-rewrite"); - $sMsg = sprintf($sMsg, $options['key']); - $this->_oView->content_before .= $this->_notifyBox('error', $sMsg); - } - } - - /** - * Checks, if any sseparators setting is modified or not - * @param array $aNewCfg New configuration send by requests. - * @return bool - */ - protected function _separatorModified($aNewCfg) { - $aCfg = ModRewrite::getConfig(); - - if ($aCfg['category_seperator'] != $aNewCfg['category_seperator']) { - return true; - } elseif ($aCfg['category_word_seperator'] != $aNewCfg['category_word_seperator']) { - return true; - } elseif ($aCfg['article_seperator'] != $aNewCfg['article_seperator']) { - return true; - } elseif ($aCfg['article_word_seperator'] != $aNewCfg['article_word_seperator']) { - return true; - } - return false; - } - - /** - * Does some checks like 'is_start_compatible' check. - * Adds notifications, if something will went wrong... - */ - protected function _doChecks() { - // Check for not supported '$cfg["is_start_compatible"] = true;' mode - if (!empty($this->_cfg['is_start_compatible']) && true === $this->_cfg['is_start_compatible']) { - $sMsg = i18n("Your Contenido installation runs with the setting 'is_start_compatible'. This plugin will not work properly in this mode.
'; - - $oMRUrlStack = ModRewriteUrlStack::getInstance(); - - // first loop to add urls to mr url stack - foreach ($aTests as $p => $v) { - $oMRUrlStack->add($v['url']); - } - - $successCounter = 0; - $failCounter = 0; - - // second loop to do the rest - foreach ($aTests as $p => $v) { - $url = mr_buildNewUrl($v['url']); - $arr = $oMRTest->resolveUrl($url); - $error = ''; - $resUrl = $oMRTest->getResolvedUrl(); - $color = 'green'; - - if ($url !== $resUrl) { - if ($oMRTest->getRoutingFoundState()) { - $successCounter++; - $resUrl = 'route to -> ' . $resUrl; - } else { - $color = 'red'; - $failCounter++; - } - } else { - $successCounter++; - } - - // @todo: translate - if (isset($arr['error'])) { - switch ($arr['error']) { - case ModRewriteController::ERROR_CLIENT: - $error = 'client'; - break; - case ModRewriteController::ERROR_LANGUAGE: - $error = 'language'; - break; - case ModRewriteController::ERROR_CATEGORY: - $error = 'category'; - break; - case ModRewriteController::ERROR_ARTICLE: - $error = 'article'; - break; - case ModRewriteController::ERROR_POST_VALIDATION: - $error = 'validation'; - break; - } - } - - $pref = str_repeat(' ', $v['level']); - - // render resolve information for current item - $itemTpl = $this->_oView->lng_result_item_tpl; - $itemTpl = str_replace('{pref}', $pref, $itemTpl); - $itemTpl = str_replace('{name}', $v['name'], $itemTpl); - $itemTpl = str_replace('{url_in}', $v['url'], $itemTpl); - $itemTpl = str_replace('{url_out}', $url, $itemTpl); - $itemTpl = str_replace('{color}', $color, $itemTpl); - $itemTpl = str_replace('{url_res}', $resUrl, $itemTpl); - $itemTpl = str_replace('{err}', $error, $itemTpl); - $itemTpl = str_replace('{data}', $oMRTest->getReadableResolvedData($arr), $itemTpl); - - $this->_oView->content .= "\n" . $itemTpl . "\n"; - } - $this->_oView->content .= ''; - - $totalTime = sprintf('%.4f', (getmicrotime() - $startTime)); - - // render information about current test - $msg = $this->_oView->lng_result_message_tpl; - $msg = str_replace('{time}', $totalTime, $msg); - $msg = str_replace('{num_urls}', ($successCounter + $failCounter), $msg); - $msg = str_replace('{num_success}', $successCounter, $msg); - $msg = str_replace('{num_fail}', $failCounter, $msg); - - $this->_oView->content = $msg . $this->_oView->content; - } - -} diff --git a/conlite/plugins/cl-mod-rewrite/classes/controller/class.modrewrite_controller_abstract.php b/conlite/plugins/cl-mod-rewrite/classes/controller/class.modrewrite_controller_abstract.php deleted file mode 100644 index cf1bb01..0000000 --- a/conlite/plugins/cl-mod-rewrite/classes/controller/class.modrewrite_controller_abstract.php +++ /dev/null @@ -1,226 +0,0 @@ - - * @copyright four for business AG
- Copyright © 2009 Ara Abcarians. aToolTip was built for use with jQuery by Ara Abcarians. -
- -
-
This work is licensed under a Creative Commons Attribution 3.0 Unported License.
-
"+ tipContent +"
"+ tipContent +"
close"+c+"
"+c+"