Seite 1 von 2
bug $cfgPath['xmlroot'] fehlt teilweise...
Verfasst: Fr 6. Aug 2004, 11:16
von emergence
ähm ne kleinigkeit...
in grouprights_area.inc.php, rights_area.inc.php
findet sich
ganz korrekt müsste das
Code: Alles auswählen
$main = $plugxml->valueOf($cfgPath['xmlroot'] . $value2['location']);
sein...
in den subnav dateien sollte ebenfalls die auslesemöglichkeit für die plugins mit rein...
somit könnte sich jedes plugin bei den bisherigen bestehenden menüführungen mit einklinken...
sieht folgender massen aus
includes/include*subnav*.php
in all diesen dateien findet sich
sollte aber
Code: Alles auswählen
$caption = $xml->valueOf( $cfgPath['xmlroot'] . $db->f("location") );
sein...
noch eleganter mit plugin berücksichtigung...
Code: Alles auswählen
# Extract caption from
# the xml language file
$caption = $xml->valueOf( $cfgPath['xmlroot'] . $db->f("location") );
ersetzen durch...
Code: Alles auswählen
# Extract caption from the xml language file
# including plugins third level
if(strstr($db->f("location"), ';')) {
$locs = explode(";", $db->f("location"));
$file = trim($locs[0]);
$xpath = trim($locs[1]);
$plugxml->load($cfg["path"]["plugins"].$file);
$caption = $plugxml->valueOf( $cfgPath['xmlroot'] . $xpath );
} else {
$caption = $xml->valueOf($cfgPath['xmlroot'] . $db->f("location"));
}
am begin der jeweiligen datei muss dann nur noch
ergänzt werden...
Verfasst: Fr 6. Aug 2004, 12:08
von emergence
ich häng das mal zusammen...
da die änderungen hand in hand gehen...
ab ->
http://www.contenido.de/forum/viewtopic ... 7236#27236
ich hab das jetzt mal bei einem produktiv system im testlauf...
schaut bis jetzt ganz gut aus...
(mit xml modifikation und neuer xpath routine)
ich überleg mir noch was sodas die lang_*.xml ebenfalls dynamisch nachgeladen werden... falls keine existiert wird die in dem pluginfile -> con_sub_nav definierte verwendet...
@timo wäre schön wenn's das noch in die 4.5.x serie schaffen würde...
Verfasst: Fr 6. Aug 2004, 14:57
von emergence
okay die letzte änderung
ich habs jetzt mal so in einem plugin eingebaut... subnav
so oder so ähnlich könnte man das ganze ja in ne funktion einbauen...
es ist ja unsinnig in jeder subnav den selben code einzubauen... bei einer zeile ist es ja noch okay... egal
diese version nimmt rücksicht auf die bisherige verhaltensweise und versucht die sprache nach backend sprache zu bestimmen...
Code: Alles auswählen
# Extract caption from the xml language file
# including plugins third level
# extended multilang version
if(strstr($db->f("location"), ';')) {
$locs = explode(";", $db->f("location"));
$file = trim($locs[0]);
$xpath = trim($locs[1]);
$filepath = explode('/',$file);
$counter = count($filepath)-1;
if ($filepath[$counter] == "") {
unset($filepath[$counter]);
$counter--;
}
if(strstr($filepath[$counter], '.xml')) {
$filename = $filepath[$counter];
unset($filepath[$counter]);
$counter--;
}
$filepath[($counter+1)] = "";
$filepath = implode("/",$filepath);
if ($plugxml->load($cfg["path"]["plugins"] . $filepath . $cfg['lang'][$belang]) == false)
{
if (!isset($filename)) { $filename = 'lang_en_US.xml'; }
if ($plugxml->load($cfg["path"]["plugins"] . $filepath . $filename) == false)
{
die("Unable to load any XML language file");
}
}
$caption = $plugxml->valueOf( $cfgPath['xmlroot'] . $xpath );
unset($file, $filename, $filepath);
} else {
$caption = $xml->valueOf( $cfgPath['xmlroot'] . $db->f("location") );
}
ach ja in leicht abgewandelter form müsste das auch in die class.navigation.php
muss zweimal eingefügt werden...
beim ersten mal anstelle von $caption -> $main verwenden
beim zweiten mal anstelle con $caption -> $name verwenden und die $db->f
auf $db2->f korrigieren...
das sollte es gewesen sein...
Verfasst: Fr 14. Jan 2005, 17:17
von timo
in grouprights_area.inc.php, rights_area.inc.php
findet sich
Also in der grouprights_area.inc.php habe ich es geändert, in der rights_area.inc.php habe ich es nicht mehr gefunden...wurde wohl mal entfernt?
Das zweite mit der Subnav habe ich auch geändert...hoffentlich geht alles so.
Eine Frage dazu noch: Derzeit gebe ich ja bei der location das ganze folgendermaßen an:
plugins/blabla/xml/blabla.xml;navigation/blabla
an. Wie funktioniert das bei dem neuen System? Geht blabla.xml immer noch? Müssen dann Varianten nach blabla_en.xml benannt sein?
Verfasst: Fr 14. Jan 2005, 17:25
von timo
Ich habe jetzt folgendes Phänomän im Head: Durch die geänderte XML_Doc Klasse wird jetzt überall im Backend "not found" angezeigt...
ich vermute, daß die Prüfung strict ist, d.h. der Pfad "navigation/content/main" wird nicht gefunden, sondern nur "language/navigation/content/main" würde gefunden...das ist ziemlich schlecht, da man überall alles anpassen sollte und auch in Plugins für Projekten das so gemacht wurde (leider)...
Verfasst: Fr 14. Jan 2005, 19:18
von emergence
du hast recht es ist strict...
im cvs_head müsste an sich nur die variable
in config.path.php ergänzt werden...
ich hätte dir sonst morgen ne genaue beschreibung für die änderung zukommen lassen...
Verfasst: Fr 14. Jan 2005, 19:44
von timo
ok ich hab mich da ein wenig reingewühlt
die Funktion findLoosePath sucht innerhalb des Arrays nach der Kombination. Wird eine Teilkomponente nicht gefunden, wird alles vor der Teilkomponente entfernt. d.h. je eindeutiger ein XML-Pfad ist desto einfacher...
findLoosePath wurde nach valueOf eingebaut:
Code: Alles auswählen
function findLoosePath ($aCombination)
{
if (count($aCombination) == 0)
{
return false;
}
$aScope = &$this->parsearray;
foreach ($aCombination as $sKey)
{
if (array_key_exists($sKey, $aScope))
{
$aScope = &$aScope[$sKey];
} else {
array_shift($aCombination);
return $this->findLoosePath($aCombination);
}
}
return ($aCombination);
}
valueOf sieht jetzt so aus:
Code: Alles auswählen
function valueOf($xpath) {
if (!is_array($this->parsearray)) { // build tree once
$this->parse(false);
}
$arr_xpath = explode("/", $xpath);
$keynode = "";
foreach ($arr_xpath as $key => $value) {
$keynode .= "['".$value."']";
$aCombination[] = $value;
}
eval('$value = $this->parsearray'.$keynode.';');
if ($value == NULL)
{
$aLoosePath = $this->findLoosePath($aCombination);
if (is_array($aLoosePath))
{
$keynode = "";
foreach ($aLoosePath as $key => $value) {
$keynode .= "['".$value."']";
}
eval('$value = $this->parsearray'.$keynode.';');
if ($value != NULL)
{
return $value;
}
}
return "Not found";
}
if (is_array($value)) { return "Has children"; }
return $value;
} // end function
scheint auch jetzt zu gehen
Verfasst: Sa 15. Jan 2005, 09:59
von emergence
sehr feine lösung...
ich sehe mir jetzt noch die ganzen include.*_subnav.php noch durch...
aufgrund der änderung kann dann die $cfgPath['xmlroot'] eigentlich überall entfernt werden
muss ich aber erst noch checken...
eine funktion hab ich noch etwas anders umgebaut... sie macht das selbe wie die andere funktion nur etwas eleganter...
Code: Alles auswählen
function characterData($parser, $data) {
// Collect the data onto the end of the current chars it dont collect whitespaces.
$data = eregi_replace ( "[[:space:]]+", " ", $data );
if(trim($data)){
//search for the element path
foreach($this->itemname as $value){
$pos.="[$value]";
}
// looks stupid but is useful to take care of entities, this corrects the line break issue
eval("if (isset(\$this->parsearray$pos)) { \$data = \$this->parsearray$pos.trim(\$data); }");
//set the new data in the parsearray
eval("\$this->parsearray$pos=trim(\$data);");
}
} // end function
Verfasst: Sa 15. Jan 2005, 11:06
von emergence
timo hat geschrieben:ok ich hab mich da ein wenig reingewühlt
die Funktion findLoosePath sucht innerhalb des Arrays nach der Kombination. Wird eine Teilkomponente nicht gefunden, wird alles vor der Teilkomponente entfernt. d.h. je eindeutiger ein XML-Pfad ist desto einfacher...
findLoosePath wurde nach valueOf eingebaut:
Code: Alles auswählen
function findLoosePath ($aCombination)
{
if (count($aCombination) == 0)
{
return false;
}
$aScope = &$this->parsearray;
foreach ($aCombination as $sKey)
{
if (array_key_exists($sKey, $aScope))
{
$aScope = &$aScope[$sKey];
} else {
array_shift($aCombination);
return $this->findLoosePath($aCombination);
}
}
return ($aCombination);
}
ich hab das ganze jetzt mal getestet ohne cfgPath['xmlroot']
das geht nicht bei mir...
deine funktion geht davon aus das die angaben die der user bei xpath macht falsch sind.
du entfernst immer mehr teile des xpath... im endeffekt erhalte ich dennoch ein not found...
die annahme ist das ein teil am beginn des xpath fehlt...
in unserem fall ist das language
d.h an sich müsste man $this->parsearray als grundlage nehmen...
den ersten array also ['language'] übergehen und checken ob dann alle keys vorhanden sind,
falls nicht noch ne ebene runter also ['navigation'] und wieder checken ob alle keys vorhanden sind uswusf
wenn die keys dann vorhanden sind müsste der komplette pfad bis zum ersten match als array zurückgeliefert werden...
hört sich kompliziert an und ist es auch...
ich spiel mich noch ein wenig damit...
Verfasst: Sa 15. Jan 2005, 14:29
von emergence
ich hab das jetzt so umgebaut das findLoosePath
die fehlenden teile am beginn selbstständig ergänzt...
die variable $cfgPath['xmlroot'] kann damit eigentlich komplett aus dem code des cvs_head entfernt werden...
intressant wäre noch ne variante die deine art und weise mit reinkombiniert...
hier beide funktionen
Code: Alles auswählen
/**
* valueOf()
*
* Extract one node value from the XML document.
* Use simplified XPath syntax to specify the node.
* F.e. 'root/test/firstnode'
*
* @return String Value of XML node
*/
function valueOf($xpath) {
if (!is_array($this->parsearray)) { // build tree once
$this->parse(false);
}
$aCombination = explode("/", $xpath);
$keynode = "";
foreach ($aCombination as $key => $value) {
$keynode .= "['".$value."']";
}
eval('$value = $this->parsearray'.$keynode.';');
if ($value == NULL)
{
$aLoosePath = $this->findLoosePath($aCombination);
if (is_array($aLoosePath))
{
$keynode = "";
foreach ($aLoosePath as $key => $value) {
$keynode .= "['".$value."']";
}
eval('$value = $this->parsearray'.$keynode.';');
}
}
if ($value == NULL) { return "Not found"; }
if (is_array($value)) { return "Has children"; }
return $value;
} // end function
/**
* findLoosePath: Finds a path in the XML array
* which matches the given keys
*
* @param aCombination array of keys to test for
* @return false if nothing was found, or the array with the found keys
*/
function findLoosePath ($aCombination, $aScope = true)
{
if (count($aCombination) == 0)
{
return false;
}
$keynode = "";
foreach ($aCombination as $key => $value) {
$keynode .= "['".$value."']";
}
if ($aScope===true) {
$aScope = $this->parsearray;
}
if (!is_array ($aScope)) {
return false;
}
foreach($aScope as $aScopeKey => $aScopeValue) {
if (!is_array ($aScope[$aScopeKey])) {
return false;
}
eval('if (isset ($aScope['.$aScopeKey.']'.$keynode.') ) { $found = true; }');
if ($found) {
$rCombination = array_merge(Array($aScopeKey), $aCombination);
break;
}
$rCombination = $this->findLoosePath($aCombination, $aScopeValue);
if (is_array($rCombination)) {
$rCombination = array_merge(Array($aScopeKey), $rCombination);
break;
}
}
return $rCombination;
}
ach ja bei den einträgen für die subnav bei kategorien(2x) fehlt /content/ nach navigation/
Verfasst: Sa 15. Jan 2005, 14:49
von emergence
noch was in den subnav files fehlt am beginn noch
$plugxml = new XML_Doc;
timo hat geschrieben:
Eine Frage dazu noch: Derzeit gebe ich ja bei der location das ganze folgendermaßen an:
plugins/blabla/xml/blabla.xml;navigation/blabla
an. Wie funktioniert das bei dem neuen System? Geht blabla.xml immer noch? Müssen dann Varianten nach blabla_en.xml benannt sein?
im prinzip ganz einfach
plugins/blabla/xml/blabla.xml;navigation/blabla
es wird zuerst versucht
$cfg["path"]["plugins"] . $filepath . $cfg['lang'][$belang]
zu laden
falls das daneben geht wird kontrolliert ob filename spricht blabla.xml definiert ist falls nicht wird der filename auf lang_en_US.xml gesetzt
und es wird versucht diese zu laden...
eine umbenennung ist somit nicht notwendig...
Verfasst: Sa 15. Jan 2005, 15:30
von emergence
also das letzte
class.navigation.php
$cfgPath['xmlroot'] kann dort auch entfernt werden
rights_area.inc.php und grouprights_area.inc.php
vor
folgendes ergänzen
und etwas weiter unten jeweils diesen code teil verwenden
Code: Alles auswählen
# get areas including plugins
# extended multilang version
if(strstr($value2['location'], ';')) {
$locs = explode(";", $value2['location']);
$file = trim($locs[0]);
$value2['location'] = trim($locs[1]);
$filepath = explode('/',$file);
$counter = count($filepath)-1;
if ($filepath[$counter] == "") {
unset($filepath[$counter]);
$counter--;
}
if(strstr($filepath[$counter], '.xml')) {
$filename = $filepath[$counter];
unset($filepath[$counter]);
$counter--;
}
$filepath[($counter+1)] = "";
$filepath = implode("/",$filepath);
if ($plugxml->load($cfg["path"]["plugins"] . $filepath . $cfg['lang'][$belang]) == false)
{
if (!isset($filename)) { $filename = 'lang_en_US.xml'; }
if ($plugxml->load($cfg["path"]["plugins"] . $filepath . $filename) == false)
{
die("Unable to load $filepath XML language file");
}
}
$main = $plugxml->valueOf( $value2['location'] );
} else {
$main = $xml->valueOf($cfgPath['xmlroot'] . $value2['location']);
}
damit läuft alles wirklich wie am schnürrchen...
Verfasst: Di 18. Jan 2005, 11:53
von timo
emergence hat geschrieben:noch was in den subnav files fehlt am beginn noch
$plugxml = new XML_Doc;
Wie wo? Ich habe mal nach $plugxml gesucht, aber keine Vorkommnisse in den subnav-Files gefunden?
Den Rest habe ich eingebaut, Snapshot wird gerade erzeugt
Verfasst: Di 18. Jan 2005, 11:55
von emergence
ich sehe es mir gleich an...
Verfasst: Di 18. Jan 2005, 12:21
von emergence
timo hat geschrieben:emergence hat geschrieben:noch was in den subnav files fehlt am beginn noch
$plugxml = new XML_Doc;
Wie wo? Ich habe mal nach $plugxml gesucht, aber keine Vorkommnisse in den subnav-Files gefunden?
? in den subnav file befindet sich jetzt überall die erweiterte version
am einfachsten ist es in allen *subnav* files vor
folgendes zu ergänzen
das fehlt momentan, die erweiterte version die etwas weiter unten eingesetzt wird bedient sich $plugxml (und die deklaration fehlt oben noch)
timo hat geschrieben:Den Rest habe ich eingebaut, Snapshot wird gerade erzeugt
das sieht gut aus, bis auf
bei den einträgen für die subnav bei kategorien(2x) fehlt /content/ nach navigation/
d.h
con_nav_sub
navigation/structure/aliases -> navigation/content/structure/aliases
navigation/structure/overview -> navigation/content/structure/overview
zu ändern ist das in setup/sql/base.sql
Code: Alles auswählen
INSERT INTO !PREFIX!_nav_sub VALUES (79, 0, 6, 1, 'navigation/structure/overview', 1);
INSERT INTO !PREFIX!_nav_sub VALUES (80, 0, 84, 1, 'navigation/structure/aliases', 1);
wird zu
Code: Alles auswählen
INSERT INTO !PREFIX!_nav_sub VALUES (79, 0, 6, 1, 'navigation/content/structure/overview', 1);
INSERT INTO !PREFIX!_nav_sub VALUES (80, 0, 84, 1, 'navigation/content/structure/aliases', 1);