@macmukka
It is time to start playing with 1.3.5 (trunk 2007-09-19). I did and I dived into the source. Especially regarding the article alias issue which is not finished in this release. As far as I pointed out the approach of Oliver for this feature seems to be that the link for the article link will generate depending of the article category:
Code: Select all
Site Structure + Aricle:
-Category1 (alias: c1)
-Category2 (alias: c2)
-Category21 (alias: c21)
-Article1_C21 (alias: a1c21)
-Article2_C21 (alias: a2c21)
-Category22 (alias: c22)
-Category3 (alias: c3)
-Category4 (alias: c4)
If I am correct in my assumption then the complete link respective alias for the articles will be:
Code: Select all
Article1_C21 = /c2/c21/a1c21
Article2_C21 = /c2/c21/a2c21
My approach is to generate an article link which is decopled from the article category:
Code: Select all
Site Structure + Aricle:
-Category1 (alias: /c1/)
-Category2 (alias: /c2/)
-Category21 (alias: /c2/c21/)
-Article1_C21 (alias: /c2/c21/a1c21/)
-Article2_C21 (alias: /c2/c21/a2c21/)
-Category22 (alias: /c2/c22/)
-Category3 (alias: /c3/)
-Category4 (alias: /c4/)
Therefore I made first some modifications which enables to key in '/' in corresponding alias fields on article and structure level:
Code: Select all
****************************************************
* File: include/inc_js/phpwcms.js
*
* org: str = str.replace(/[^a-z0-9_\-]/g,'');
* wak: str = str.replace(/[^a-z0-9_\-/]/g,'');
*
****************************************************
function create_alias(str,encoding,ucfirst)
{
str = str.toUpperCase();
str = str.toLowerCase();
str = str.replace(/[\u00E0\u00E1\u00E2\u00E3\u00E5]/g,'a');
str = str.replace(/[\u00E7]/g,'c');
str = str.replace(/[\u00E8\u00E9\u00EA\u00EB]/g,'e');
str = str.replace(/[\u00EC\u00ED\u00EE\u00EF]/g,'i');
str = str.replace(/[\u00F2\u00F3\u00F4\u00F5\u00F8]/g,'o');
str = str.replace(/[\u00F9\u00FA\u00FB]/g,'u');
str = str.replace(/[\u00FD\u00FF]/g,'y');
str = str.replace(/[\u00F1]/g,'n');
str = str.replace(/[\u0153\u00F6]/g,'oe');
str = str.replace(/[\u00E6\u00E4]/g,'ae');
str = str.replace(/[\u00DF]/g,'ss');
// additional German "Umlaute"
str = str.replace(/[\u00FC]/g,'ue');
str = str.replace(/[ ]/g,'-');
str = str.replace(/[^a-z0-9_\-/]/g,'');
str = Trim(str);
if (ucfirst == 1) {
c = str.charAt(0);
str = c.toUpperCase()+str.slice(1);
}
return str;
}
****************************************************
* File: include/inc_act/act_structure.php
*
* org: $alias = get_alnum_dashes($alias, true);
* wak: removed
*
****************************************************
function proof_alias($acat_id, $alias) {
$alias = clean_slweg($alias, 150);
if(empty($alias)) $alias = clean_slweg($_POST["acat_name"], 150);
if($alias == 'index' && $acat_id != 'index') {
$alias = 'index'.date('jny');
} elseif($alias == 'aid') {
$alias = 'aid'.date('jny');
} elseif($alias == 'id') {
$alias = 'id'.date('jny');
}
$sql = "SELECT COUNT(acat_id) FROM ".DB_PREPEND."phpwcms_articlecat WHERE acat_id != ".intval($acat_id);
$sql .= " AND acat_alias='".aporeplace($alias)."'";
if( _dbQuery($sql, 'COUNT') ) {
$sql = "SELECT count(*) FROM ".DB_PREPEND."phpwcms_articlecat WHERE acat_id != ".intval($acat_id);
$sql .= " AND acat_alias LIKE '".aporeplace($alias)."%'";
if($count_alias = _dbQuery($sql, 'COUNT')) {
$alias .= '-' . $count_alias;
}
}
return $alias;
}
To enable phpWCMS to find the correct article based on article alias I enhanced the index.php:
Code: Select all
****************************************************
* File: index.php
****************************************************
...
// some initial actions
cleanupPOSTandGET();
define('FE_CURRENT_URL', PHPWCMS_URL . 'index.php' . buildGlobalGET('getQuery'));
/**
* @titel: wakGetArticleIdByArticleAlias
* @description: extracts article id based on an article alias
* @author: Wolfgang Kubens
* @last modified: 2007.09.29 updated for 1.3.5
* 2006.01.17 created for 1.2.6
* @parameters: String $alias
* @returns: String $id
*/
function wakGetArticleIdByArticleAlias($alias) {
$id = null;
$sql = 'SELECT article_id FROM '.DB_PREPEND.'phpwcms_article WHERE article_alias = "'.$alias.'" AND article_deleted=0 AND article_public = 1 AND article_aktiv=1 LIMIT 1';
if($result = mysql_query($sql)) {
if($row = mysql_fetch_row($result)) {
$id = $row[0];
}
mysql_free_result($result);
}
return $id;
}
// if set by buildGlobalGET
// then quit
if (!isset($GLOBALS['_getVar']) || !isset($GLOBALS['_getVar']['aid'])) {
$_GET['aid'] = wakGetArticleIdByArticleAlias($_SERVER['QUERY_STRING']);
}
//script caching to allow header redirect
//if($phpwcms["compress_page"] && isset($_SESSION['session_is_set'])) {
// ob_start("ob_gzhandler"); //with old style GZ Compression
//} else {
// $_SESSION['session_is_set'] = true;
ob_start(); //without Compression (or use browsers default)
//}
...
Finally for those who needs find below apache rewrite rule for this:
Code: Select all
RewriteEngine on
RewriteLogLevel 3
RewriteLog logs/phpwcms.ROOT.1.3.5.rewrite.log
RewriteRule ^(.*)/$ /index.php?$1/ [L]
Normally I do not prefere to enhance core files, but may this is interesting for some of us who are waiting for next release with the same patience as I do
Br
Wolfgang