[Nextcms-commits] CVS: nextcms class.Extension.php,1.1.1.1,1.2 class.Page.php,1.5,1.6 class.Site.php
Status: Alpha
Brought to you by:
andrejb
|
From: Andrej B. <an...@us...> - 2002-07-14 13:54:36
|
Update of /cvsroot/nextcms/nextcms
In directory usw-pr-cvs1:/tmp/cvs-serv2268
Modified Files:
class.Extension.php class.Page.php class.Site.php
processor.conf.php-dist processor.php utils.php xml.php
Log Message:
* added parameter support for extensions (works for content files only)
* added three new extensions
* FileModTime for the modification time of a specific file
* Filesize for the size of a specific file
* TextReader for the content of a specific text file
Index: class.Extension.php
===================================================================
RCS file: /cvsroot/nextcms/nextcms/class.Extension.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** class.Extension.php 19 Mar 2002 17:51:04 -0000 1.1.1.1
--- class.Extension.php 14 Jul 2002 13:54:32 -0000 1.2
***************
*** 7,11 ****
}
! function getCode() {
return "nothing implemented yet";
}
--- 7,11 ----
}
! function getCode($paramList) {
return "nothing implemented yet";
}
Index: class.Page.php
===================================================================
RCS file: /cvsroot/nextcms/nextcms/class.Page.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** class.Page.php 27 May 2002 23:50:10 -0000 1.5
--- class.Page.php 14 Jul 2002 13:54:32 -0000 1.6
***************
*** 105,109 ****
$keywords = array();
! $keywordlists = array_reverse($this->site->xmltree->getAncestorOrSelf($pagenode_path, "/site[1]/pages[1]", "page", "keywords"));
foreach($keywordlists as $keywordlist)
--- 105,109 ----
$keywords = array();
! $keywordlists = array_reverse($this->site->xmltree->getAncestorOrSelfLimited($pagenode_path, "/site[1]/pages[1]", "page", "keywords"));
foreach($keywordlists as $keywordlist)
***************
*** 117,121 ****
$this->keywords = implode(", ", $keywords);
! $site_pagetree = array_reverse($this->site->xmltree->getAncestorOrSelf($pagenode_path, "/site[1]/pages[1]", "page"));
$docache = false;
--- 117,121 ----
$this->keywords = implode(", ", $keywords);
! $site_pagetree = array_reverse($this->site->xmltree->getAncestorOrSelfLimited($pagenode_path, "/site[1]/pages[1]", "page"));
$docache = false;
***************
*** 168,188 ****
}
- function getPageLocationCode() {
- // get pagepath code
- $site_pagetree = array_reverse($this->site->xmltree->getAncestorOrSelf($this->pagenode_path, "/site[1]/pages[1]", "page"));
- $prechars = "";
- $location = "";
- foreach ($site_pagetree as $entry) {
- $nodeatt = &$this->site->xmltree->getAttributes($entry);
- $docfile = $this->site->getVirtualUrlByPath($entry);
-
- $docname = $nodeatt["name"];
- $location .= $prechars . "<a href=\"$docfile\" class=\"location\">$docname</a>";
- $prechars = " > ";
- }
-
- return $location;
- }
-
function getFieldCode($field_name, $param_list) {
// replace predifined fields in the template with data
--- 168,171 ----
***************
*** 214,221 ****
break;
- case "location":
- return $this->getPageLocationCode();
- break;
-
case "keywords":
return $this->keywords;
--- 197,200 ----
***************
*** 419,429 ****
break;
case "ext":
! if (($type == CLOSED_TAG) || ($type == END_TAG)) {
! $ext_instance = $this->loadExtention($node['attributes']['name']);
if (isset($ext_instance)) {
! $startcode = $ext_instance->getCode();
! $startcode;
}
}
--- 398,424 ----
break;
+ case "parameter":
+ return "";
+ break;
+
case "ext":
! if (($type == CLOSED_TAG) || ($type == START_TAG)) {
! if (isset($node['attributes']['name']))
! $ext_instance = $this->loadExtention($node['attributes']['name']);
! else
! return "";
!
! $nodepath = $node['parent'] . '/' . 'ext[' . $node['uniquenum'] . ']';
! $children = $this->content->xmltree->getChild($nodepath, 'parameter');
! foreach ($children as $child) {
! $attrList = $this->content->xmltree->getAttributes($child);
! if (!isset($attrList['name']) || !isset($attrList['value']))
! printError("Ein ext Tag wurde falsch verwendet.\n\n" . "Es sollte wie folgt aussehen: \n" .
! "<ext name=\"extension\">\n<parameter name=\"file\" value=\"filename\"/>\n</ext>");
! $paramList[$attrList['name']] = $attrList['value'];
! }
if (isset($ext_instance)) {
! $startcode = $ext_instance->getCode($paramList);
}
}
Index: class.Site.php
===================================================================
RCS file: /cvsroot/nextcms/nextcms/class.Site.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** class.Site.php 27 May 2002 23:50:10 -0000 1.7
--- class.Site.php 14 Jul 2002 13:54:32 -0000 1.8
***************
*** 120,123 ****
--- 120,127 ----
}
+ function getLocationNodes($path) {
+ return $this->xmltree->getAncestorOrSelf($this->page->pagenode_path, "page");
+ }
+
/**
* setTemplate() gets all the template information out of the site XMLTree
***************
*** 156,160 ****
if (empty($template_id)) {
! $parents = $this->xmltree->getAncestorOrSelf($nodepath, '/pages[1]', false, 'template');
if (!empty($parents))
$template_id = $this->xmltree->getAttribute($parents[0], 'template');
--- 160,164 ----
if (empty($template_id)) {
! $parents = $this->xmltree->getAncestorOrSelfLimited($nodepath, '/site[1]/pages[1]', null, 'template');
if (!empty($parents))
$template_id = $this->xmltree->getAttribute($parents[0], 'template');
Index: processor.conf.php-dist
===================================================================
RCS file: /cvsroot/nextcms/nextcms/processor.conf.php-dist,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** processor.conf.php-dist 27 May 2002 23:50:10 -0000 1.8
--- processor.conf.php-dist 14 Jul 2002 13:54:32 -0000 1.9
***************
*** 40,43 ****
--- 40,47 ----
'sitemap' => "$this->EXTENSION_DIR/sitemap.php",
'index' => "$this->EXTENSION_DIR/index.php"
+ 'location' => "$this->EXTENSION_DIR/location.php"
+ 'TextReader' => "$EXTENSION_DIR/textreader.php",
+ 'Filesize' => "$EXTENSION_DIR/filesize.php",
+ 'FileModTime' => "$EXTENSION_DIR/filemodtime.php",
);
Index: processor.php
===================================================================
RCS file: /cvsroot/nextcms/nextcms/processor.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** processor.php 28 May 2002 00:48:48 -0000 1.6
--- processor.php 14 Jul 2002 13:54:32 -0000 1.7
***************
*** 67,71 ****
$get_vars = $GLOBALS['HTTP_GET_VARS'];
- $vurl = $get_vars['file'];
$url = parse_url($get_vars['file']);
--- 67,70 ----
***************
*** 75,82 ****
$get_vars = array();
$get_vars['file'] = $url['path'];
-
$input_vars = array_merge($get_vars, $GLOBALS['HTTP_POST_VARS']);
if (!isset($document_root)) {
include_once('utils.php');
--- 74,84 ----
$get_vars = array();
$get_vars['file'] = $url['path'];
$input_vars = array_merge($get_vars, $GLOBALS['HTTP_POST_VARS']);
+ $vurl = $url['path'];
+ if (!empty($get_vars['show']))
+ $vurl .= "?show=" . $get_vars['show'];
+
if (!isset($document_root)) {
include_once('utils.php');
***************
*** 87,90 ****
--- 89,97 ----
if (!isset($input_vars['show'])) $input_vars['show'] = "";
if (!isset($input_vars['action'])) $input_vars['action'] = "";
+
+ if (strpos($file, '..') !== false) {
+ include_once('utils.php');
+ printError("Queries with relative file path are not allowed.");
+ }
}
?>
Index: utils.php
===================================================================
RCS file: /cvsroot/nextcms/nextcms/utils.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** utils.php 30 Apr 2002 23:58:18 -0000 1.4
--- utils.php 14 Jul 2002 13:54:32 -0000 1.5
***************
*** 139,142 ****
--- 139,143 ----
function printError($errormsg) {
+ $errormsg = nl2br($errormsg);
print "<html><head><meta name=\"ROBOTS\" content=\"NOINDEX, NOFOLLOW\" /><title>Process Error</title></head>\n";
print "<body bgcolor=\"#EEEEEE\">\n";
Index: xml.php
===================================================================
RCS file: /cvsroot/nextcms/nextcms/xml.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** xml.php 27 May 2002 23:50:10 -0000 1.3
--- xml.php 14 Jul 2002 13:54:32 -0000 1.4
***************
*** 3,23 ****
define('XML_TEXT', 4);
class XMLTree {
! var $topnode;
! var $treepath;
! var $xml_parser;
! var $nodes;
! var $root;
! var $ids;
! var $tmpdata;
! function XMLTree() {
! $this->treepath = "";
! $this->node = NULL;
! $this->nodes = NULL;
! $this->root = NULL;
! $this->ids = NULL;
! $this->tmpdata = "";
! }
// tree navigation and modification part
--- 3,60 ----
define('XML_TEXT', 4);
+ /**
+ * XMLTree is the representation of an XML-Document.
+ *
+ * The Class can be used to retrieve data from XML-Documents. It parses the document
+ * saves it's structure in an associative array and has a set of methodes to work
+ * with this structure.
+ *
+ * @version $Revision$
+ * @author Andrej Bisin <An...@Bi...>
+ * @access public
+ */
+
class XMLTree {
! /**
! * This associateve array contains a list of all document nodes.
! *
! * @var array
! */
! var $nodes = array();
! /**
! * Path of the current bide
! *
! * @var string
! */
! var $treepath = '';
!
! /**
! * Refercence to our XML parser.
! *
! * @var resource
! */
! var $xml_parser = NULL;
!
! /**
! * The path to the root element
! *
! * @var string
! */
! var $root = '';
!
! /**
! * Counter of the occurrence number of specific node names.
! *
! * @var array
! */
! var $ids = array();
!
! /**
! * Temporary space for text data.
! *
! * @var string
! */
! var $tmpdata = '';
// tree navigation and modification part
***************
*** 35,45 ****
}
} else {
! foreach ($nodelist as $nodepath) {
! if (($this->nodes[$nodepath]['name'] == $tagname) &&
! (isset($this->nodes[$nodepath]['attributes'][$attname]))) {
! if (empty($attvalue)) {
! array_push($new_nodelist, $nodepath);
! } else if ($this->nodes[$nodepath]['attributes'][$attname] == $attvalue) {
! array_push($new_nodelist, $nodepath);
}
}
--- 72,98 ----
}
} else {
! if (is_array($attname)) {
! foreach ($nodelist as $nodepath) {
! if ($this->nodes[$nodepath]['name'] == $tagname) {
! $bad = false;
! foreach ($attname as $key => $val) {
! if (!empty($attvalue))
! if ($this->nodes[$nodepath]['attributes'][$key] != $val)
! $bad = true;
! }
!
! if (!$bad)
! array_push($new_nodelist, $nodepath);
! }
! }
! } else {
! foreach ($nodelist as $nodepath) {
! if (($this->nodes[$nodepath]['name'] == $tagname) &&
! (isset($this->nodes[$nodepath]['attributes'][$attname]))) {
! if (empty($attvalue)) {
! array_push($new_nodelist, $nodepath);
! } else if ($this->nodes[$nodepath]['attributes'][$attname] == $attvalue) {
! array_push($new_nodelist, $nodepath);
! }
}
}
***************
*** 47,56 ****
}
} else {
! foreach ($nodelist as $nodepath) {
! if (isset($this->nodes[$nodepath]['attributes'][$attname])) {
! if (empty($attvalue)) {
array_push($new_nodelist, $nodepath);
! } else if ($this->nodes[$nodepath]['attributes'][$attname] == $attvalue) {
array_push($new_nodelist, $nodepath);
}
}
--- 100,123 ----
}
} else {
! if (is_array($attname)) {
! foreach ($nodelist as $nodepath) {
! $bad = false;
! foreach ($attname as $key => $val) {
! if (!empty($attvalue))
! if ($this->nodes[$nodepath]['attributes'][$key] != $val)
! $bad = true;
! }
!
! if (!$bad)
array_push($new_nodelist, $nodepath);
! }
! } else if (!empty($attname)) {
! foreach ($nodelist as $nodepath) {
! if (isset($this->nodes[$nodepath]['attributes'][$attname])) {
! if (empty($attvalue)) {
! array_push($new_nodelist, $nodepath);
! } else if ($this->nodes[$nodepath]['attributes'][$attname] == $attvalue) {
array_push($new_nodelist, $nodepath);
+ }
}
}
***************
*** 86,89 ****
--- 153,166 ----
}
+ /**
+ * Returns the value of an attribute.
+ *
+ * @access public
+ * @param string $path The full document path of the node, from which the attribute
+ * should be retrieved.
+ * @param string $name The name of attribute, which should be retrieved.
+ * @return string The attribute value.
+ * @see getAttributes(), setAttribute()
+ */
function getAttribute($path, $name) {
if (isset($this->nodes[$path]['attributes'][$name]))
***************
*** 91,94 ****
--- 168,181 ----
}
+ /**
+ * Set attributes to a node.
+ *
+ * @access private
+ * @param string $path The full document path of the node, the attribute
+ * should be added to.
+ * @param string $name The name of attribute, which should be set.
+ * @param string $value The value of attribute, which should be set.
+ * @see getAttribute(), getAttributes()
+ */
function setAttribute($path, $name, $value) {
if (isset($this->nodes[$path]['attributes'][$name]))
***************
*** 96,99 ****
--- 183,196 ----
}
+ /**
+ * Retrieves a list of all attributes of a node.
+ *
+ * @access public
+ * @param string $path The full document path of the node, from which the attributes
+ * should be retrieved.
+ * @return array The returned associative array contains all attributes of the
+ * specified node.
+ * @see getAttribute(), setAttribute()
+ */
function getAttributes($path) {
if (isset($this->nodes[$path]))
***************
*** 101,104 ****
--- 198,209 ----
}
+ /**
+ * Returns the name of the xml node.
+ *
+ * @access public
+ * @param string $path The full document path of the node, from which the name
+ * should be retrieved.
+ * @return string The returned string contains the name of the node.
+ */
function getName($path) {
if (isset($this->nodes[$path]))
***************
*** 106,127 ****
}
function getDepth($path) {
return $this->nodes[$path]['depth'];
}
function getNode($path, $recursive, $tagname = "", $attname = "", $attvalue = "") {
return $this->getNeededNodes($this->getAllNodes($path, $recursive), $tagname, $attname, $attvalue);
}
! function getAncestorOrSelf($path, $dstpath = null, $tagname = "", $attname = "", $attvalue = "") {
$nodelist = array();
! if (isset($dstpath)) {
! while ($path != $dstpath) {
! array_push($nodelist, $path);
! $path = $this->nodes[$path]['parent'];
! if (empty($path)) break;
! }
! } else {
$path = $this->nodes[$path]['parent'];
array_push($nodelist, $path);
--- 211,297 ----
}
+ /**
+ * Returns depth level the is xml tree.
+ *
+ * @access public
+ * @param string $path The full document path of the node, from which the depth
+ * level should be retrieved.
+ * @return integer The returned integer contains the depth level of the specified
+ * node.
+ */
function getDepth($path) {
return $this->nodes[$path]['depth'];
}
+ /**
+ * Returns all subnodes.
+ *
+ * @access private
+ * @return array The returned array represents a set of document nodes.
+ */
function getNode($path, $recursive, $tagname = "", $attname = "", $attvalue = "") {
return $this->getNeededNodes($this->getAllNodes($path, $recursive), $tagname, $attname, $attvalue);
}
!
! /**
! * Returns all child nodes.
! *
! * @access public
! * @return array The returned array represents a set of document nodes.
! */
! function getChild($path, $tagname = "", $attname = "", $attvalue = "") {
! return $this->getNeededNodes($this->getAllNodes($path, false), $tagname, $attname, $attvalue);
! }
!
! /**
! * Returns all descendent nodes.
! *
! * @access public
! * @return array The returned array represents a set of document nodes.
! */
! function getDescendant($path, $tagname = "", $attname = "", $attvalue = "") {
! return $this->getNeededNodes($this->getAllNodes($path, true), $tagname, $attname, $attvalue);
! }
!
! /**
! * Returns all descendent plus the self node.
! *
! * @access public
! * @return array The returned array represents a set of document nodes.
! */
! function getDescendantOrSelf($path, $tagname = "", $attname = "", $attvalue = "") {
! return array_merge(array($path), $this->getNeededNodes($this->getAllNodes($path, true), $tagname, $attname, $attvalue));
! }
!
! /**
! * Returns all ancestor nodes.
! *
! * @access public
! * @return array The returned array represents a set of document nodes.
! */
! function getAncestor($path, $tagname = "", $attname = "", $attvalue = "") {
$nodelist = array();
! while (!empty($path)) {
! $path = $this->nodes[$path]['parent'];
! array_push($nodelist, $path);
! }
!
! return $this->getNeededNodes($nodelist, $tagname, $attname, $attvalue);
! }
!
! /**
! * Returns all ancestor plus the self node.
! *
! * @access public
! * @return array The returned array represents a set of document nodes.
! */
! function getAncestorOrSelf($path, $tagname = "", $attname = "", $attvalue = "") {
! $nodelist = array();
!
! array_push($nodelist, $path);
!
! while (!empty($path)) {
$path = $this->nodes[$path]['parent'];
array_push($nodelist, $path);
***************
*** 131,134 ****
--- 301,343 ----
}
+ /**
+ * Returns all ancestor plus the self node between $path and $dstpath.
+ *
+ * @access public
+ * @return array The returned array represents a set of document nodes.
+ */
+ function getAncestorOrSelfLimited($path, $dstpath = null, $tagname = "", $attname = "", $attvalue = "") {
+ $nodelist = array();
+
+ array_push($nodelist, $path);
+
+ while ($path != $dstpath) {
+ $path = $this->nodes[$path]['parent'];
+ array_push($nodelist, $path);
+ if (empty($path)) break;
+ }
+
+ return $this->getNeededNodes($nodelist, $tagname, $attname, $attvalue);
+ }
+
+ /**
+ * Returns the self node.
+ *
+ * @access public
+ * @return array The returned array represents a set of document nodes.
+ */
+ function getSelf($path, $tagname = "", $attname = "", $attvalue = "") {
+ if (!empty($tagname) || !empty($attname) || !empty($attvalue))
+ return $this->getNeededNodes(array($path), $tagname, $attname, $attvalue);
+ else
+ return array($path);
+ }
+
+ /**
+ * Returns the parent node.
+ *
+ * @access public
+ * @return array The returned array represents a set of document nodes.
+ */
function getParent($path, $tagname = "", $attname = "", $attvalue = "") {
$nodelist[0] = $this->nodes[$path]['parent'];
***************
*** 136,143 ****
--- 345,365 ----
}
+ /**
+ * Returns all sibling nodes.
+ *
+ * @access public
+ * @return array The returned array represents a set of document nodes.
+ */
+
function getSibling($path, $tagname = "", $attname = "", $attvalue = "") {
return $this->getNeededNodes($this->getAllNodes($this->nodes[$path]['parent'], false), $tagname, $attname, $attvalue);
}
+ /**
+ * Returns the node text data.
+ *
+ * @access public
+ * @return string
+ */
function getTagData($path, $recursive = false) {
$data = array();
***************
*** 154,157 ****
--- 376,385 ----
// parser part
+ /**
+ * Parses the XML-Document given by string.
+ *
+ * @access public
+ */
+
function parseXML($xmlstring, $withdata = true, $filename = "") {
$this->xml_parser = xml_parser_create();
***************
*** 186,189 ****
--- 414,423 ----
}
+ /**
+ * Parses the XML-Document given by filename.
+ *
+ * @access public
+ */
+
function parseXMLFile($xml_filename, $withdata = true) {
$this->parseXML(join("", file($xml_filename)));
***************
*** 191,197 ****
/**
! * serialize() serializes the XMLTree
*
! * @access public
*/
--- 425,432 ----
/**
! * Serializes the XMLTree.
*
! * @access public
! * @return string
*/
***************
*** 291,294 ****
--- 526,539 ----
}
}
+
+ /**
+ * Adds a new node to the XMLTree.
+ *
+ * @access private
+ * @param string
+ * @param string
+ * @param integer
+ * @return string Full document path to the added node.
+ */
function addNode($path, $name, $type) {
|