Thread: [Phpcms-plugins-cvs] navigation4phpCMS navigation4phpcms.php,1.1,1.2
Brought to you by:
mjahn
From: Martin J. <mj...@us...> - 2005-02-23 23:55:53
|
Update of /cvsroot/phpcms-plugins/navigation4phpCMS In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13028 Modified Files: navigation4phpcms.php Log Message: implemented simple lang2links Index: navigation4phpcms.php =================================================================== RCS file: /cvsroot/phpcms-plugins/navigation4phpCMS/navigation4phpcms.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- navigation4phpcms.php 3 Jan 2005 18:21:28 -0000 1.1 +++ navigation4phpcms.php 23 Feb 2005 23:55:42 -0000 1.2 @@ -27,6 +27,9 @@ /* * $Log$ +* Revision 1.2 2005/02/23 23:55:42 mjahn +* implemented simple lang2links +* * Revision 1.1 2005/01/03 18:21:28 mjahn * initial commit * @@ -55,7 +58,29 @@ 'menuId'=>'kreischa.info.photos'); var $I18N_MODE = 'SUFFIX'; + + /** + * template vars for lang2links + */ + var $lang2links_tpl = '<li> <a href="%link" lang="%lc">%lang</a> </li>'; + var $lang2links_tpl_current = '<li> %lang </li>'; + var $langs = array ( + 'da' => 'dansk', + 'de' => 'deutsch', + 'en' => 'english', + 'es' => 'español', + 'fi' => 'suomi', + 'fr' => 'française', + 'it' => 'italiano', + 'nl' => 'nederlands', + 'il' => 'hebrew', + 'ja' => 'japanese', + 'no' => 'norse', + 'se' => 'svenska', + 'pl' => 'polska', + 'pt' => 'portugese' + ); function breadcrumbs () { // breadcrumb link with/without selectbox for last entry @@ -139,7 +164,7 @@ continue; } - if (!preg_match_all ('°(<h([0-9])[^>]*>)(([^<]*)</h\\2>)°im', join ('', (array) $this->_PageContent->{$field}), $erg)) { + if (!preg_match_all ('�(<h([0-9])[^>]*>)(([^<]*)</h\\2>)�im', join ('', (array) $this->_PageContent->{$field}), $erg)) { continue; } @@ -182,7 +207,7 @@ } function langs2links ($useI18N = true) { - global $DEFAULTS; + global $DEFAULTS, $PHP; $out = ''; if ((!isset ($DEFAULTS->I18N) || strtoupper ($DEFAULTS->I18N) !== 'ON') && $useI18N) { @@ -190,35 +215,119 @@ return false; } - switch ($DEFAULTS->I18N_MODE) { - case 'SUFFIX': - $dir = $this->_CheckPage->path.substr ($this->_CheckPage->name, 0, strrpos ($this->_CheckPage->name, '/')); - $filename = substr ($this->_CheckPage->name, strrpos ($this->_CheckPage->name, '/'), 100); - $pre = substr ($filename, 0, strpos ($filename, $this->lang)); - $post = substr ($filename, strpos ($filename, $this->lang) + strlen ($this->lang), strlen ($filename)); - $lang_files = $this->_getDirContent ($_SERVER ['DOCUMENT_ROOT'].$dir, $pre, $post); - break; - case 'DIR': - break; - default:; - } + $ext = strrchr ($this->_CheckPage->name, '.'); + $temp = substr ($this->_CheckPage->name, 0, strrpos ($this->_CheckPage->name, '.')); + $base = substr ($temp, 0, strrpos ($temp, '.')); + $currentlang = strrchr ($temp, '.'); + $currentlang = substr ($currentlang, 1); + $thisdir = $DEFAULTS->DOCUMENT_ROOT.'/'.$this->_CheckPage->path.'/'; + $o = ''; + + foreach ($this->langs as $lc=>$lang) { + if (!file_exists ($thisdir.$base.'.'.$lc.$ext)) { + continue; + } + + if ($lc == $currentlang) { + $o .= str_replace (array ('%lang', '%lc', '%link'), array ($lang, $lc, $this->_CheckPage->path.'/'.$base.'.'.$lc.$ext), $this->lang2links_tpl_current); + } else { + $o .= str_replace (array ('%lang', '%lc', '%link'), array ($lang, $lc, $this->_CheckPage->path.'/'.$base.'.'.$lc.$ext), $this->lang2links_tpl); + } + } /* echo '<!--'; print_r ($lang_files); echo '-->'; */ - $this->_Tags [] = array ('<phpcms:langs2links />', $out); + $this->_Tags [] = array ('<phpcms:langs2links />', $o); return true; } + function logiclinks () { + + $parentClass = substr ($this->_actualClass, 0, strrpos ($this->_actualClass, '.')); + + $o = '<!--'.$parentClass.' = '.$this->_actualClass."-->\n"; + + $firstClass = ''; + $prevClass = ''; + $nextClass = ''; + $lastClass = ''; + + if ($parentClass != $this->_actualClass) { + + $temp = array_flip ($this->_MENU->menuKlasse); + + if (isset ($temp [$parentClass])) { + + $index = $temp [$parentClass]; + + $o .= '<!-- '.$index.'-->'."\n"; + + $temp = array_flip ($this->_MENU->menuFieldNames [$index]); + $classIndex = $temp ['CLASS']; + + $o .= '<!-- '.$classIndex.'-->'."\n"; + + $temp = count ($this->_MENU->menuFieldValues [$index]); + + $o .= '<!-- '.$temp.'-->'."\n"; + + if ($temp > 1) { + + for ($i = 0; $i < $temp; $i++) { + if ($this->_MENU->menuFieldValues [$index] [$i] [$classIndex] != $this->_actualClass) { + continue; + } + + break; + } + + if ($i > 0) { + $firstClass = $this->_MENU->menuFieldValues [$index] [0] [$classIndex]; + $prevClass = $this->_MENU->menuFieldValues [$index] [$i - 1] [$classIndex]; + } + + if ($i + 1 < $temp) { + $nextClass = $this->_MENU->menuFieldValues [$index] [$i + 1] [$classIndex]; + $lastClass = $this->_MENU->menuFieldValues [$index] [$temp - 1] [$classIndex]; + } + } + + if (!isset ($this->_quicklinks [$parentClass])) { + $parentClass = ''; + } + + } else { + $parentClass = ''; + } + + } else { + $parentClass = ''; + } + + $o = ''; + + foreach (array ('first'=>$firstClass, 'prev'=>$prevClass, 'next'=>$nextClass, 'last'=>$lastClass, 'parent'=>$parentClass) as $id=>$class) { + if (trim ($class) == '') { + continue; + } + + $o .= '<link rel="'.$id.'" href="'.$this->_quicklinks [$class] ['LINK'].'" title="'.$this->_quicklinks [$class] ['MNAME_'.$this->lang].'" />'."\n"; + } + + $this->_Tags [] = array ('<phpcms:logiclinks />', $o); + return true; + } + function run () { $this->_getProjectVars (); $this->_parseMenu (); $this->extmenuclass (); $this->breadcrumbs (); - //$this->headerListing (); + $this->logiclinks (); $this->langs2links (); return null; } @@ -236,6 +345,7 @@ $this->_CheckPage =& $CHECK_PAGE; $this->lang = $_GET ['lang']; $this->run (); + unset ($this->_PageContent, $this->_MENU, $this->_Tags, $this->_PHPCMS, $this->_CheckPage, $this->lang); return true; } @@ -261,7 +371,7 @@ // does pattern containt a directory path if (!strstr ($pattern, '/') && !strstr ($pattern, '\\')) { - if (!preg_match ('°'.$pattern.'°ims', $entry, $erg)) { + if (!preg_match ('�'.$pattern.'�ims', $entry, $erg)) { continue; } @@ -333,7 +443,7 @@ $this->_actualClass = $menuFieldValue; } } - unset ($this->_MENU, $menuFieldValue, $num_entries, $i, $j, $k, $classIndex, $linkIndex, $num_menues, $home); + unset ($menuFieldValue, $num_entries, $i, $j, $k, $classIndex, $linkIndex, $num_menues, $home); return null; } |