PHP Classes

File: OCFLib.php

Recommend this page to a friend!
  Classes of Eugene Panin   OCFLib   OCFLib.php   Download  
File: OCFLib.php
Role: ???
Content type: text/plain
Description: OCF library
Class: OCFLib
Author: By
Last change:
Date: 22 years ago
Size: 5,301 bytes
 

Contents

Class file image Download
<? class OCFParser { var $debug = 0; var $rootNode; function OCFParser($xmlfile='',$debug=0) { if ($debug<>0) { $this->debug = $debug; } if ($xmlfile) { $this->loadMenuFromOCF($xmlfile); } } function &getMenu() { return $this->rootNode; } function loadMenuFromOCF($xmlfile='') { if (file_exists($xmlfile)) { $doc = xmldocfile ($xmlfile); } else { return false; } $root = $doc->root(); $submenu =& $this->_processChildren(&$root); $this->rootNode =& $submenu; #echo gettype($submenu); return true; } function &_processChildren(&$current) { #echo "{$current->name}---<br>\n"; $children = $current->children(); if ($children) foreach ($children as $key=>$node) { if (($node->type == XML_ELEMENT_NODE) && in_array($node->name,array("category","catalog","product","attr"))) { $m =& $this->_processChildren(&$node); #echo get_class($m)."<br>"; if ($m) $submenus[] =& $m; } } if ($current->name == 'attr') { $leaf = new LeafItem($current->getattr('value')); return $leaf; } if ($current->name == 'product') { if ($submenus) { $leaf =& $submenus[0]; $leaf->setName($current->getattr('name')); } return $leaf; } if ($current->name == 'category') { #echo "node: ".$current->name." - ".$current->getattr('name')."<br>\n"; $menu = new Menu($current->getattr('name'),$current->getattr('id')); if ($submenus) { $menu->addItem(&$submenus); } return $menu; } if ($current->name == 'catalog') { return $submenus[0]; } } } class OCFCatalog { var $categories = array(); function addCategory(&$prm) { $this->categories[] =& $prm; } function &getCategories() { return $this->categories; } } class OCFCategory { var $subcategories = array(); var $products = array(); var $attributes= array(); var $parameters = array(); var $links = array(); var $name = ''; var $id = ''; function setName($val='') { $this->name = $val; } function getName() { return $this->name; } function setID($val='') { $this->id = $val; } function getID() { return $this->id; } function addCategory(&$prm) { $this->subcategories[] =& $prm; } function &getCategories() { return $this->subcategories; } function addLink(&$prm) { $this->links[] =& $prm; } function &getLinks() { return $this->links; } function addProduct(&$prm) { $this->products[] =& $prm; } function &getProducts() { return $this->products; } function addParameter(&$prm) { $this->parameters[] =& $prm; } function &getParameters() { return $this->parameters; } function addAttribute(&$attr) { $this->attributes[] =& $attr; } function &getAttributes() { return $this->attributes; } } class OCFProduct { var $attributes = array(); var $parameters = array(); var $name = ''; var $id = ''; function setID($val='') { $this->id = $val; } function getID() { return $this->id; } function setName($val='') { $this->name = $val; } function getName() { return $this->name; } function addParameter(&$prm) { $this->parameters[] =& $prm; } function &getParameters() { return $this->parameters; } function addAttribute(&$attr) { $this->attributes[] =& $attr; } function &getAttributes() { return $this->attributes; } } class OCFAttribute { var $name = ''; var $valueType = ''; var $value = ''; var $required = 0; var $id = ''; function setID($val='') { $this->id = $val; } function getID() { return $this->id; } function setName($val='') { $this->name = $val; } function getName() { return $this->name; } function setValue($val='') { $this->value = $val; } function getValue() { return $this->value; } function setValueType($val='') { $this->valueType = $val; } function getValueType() { return $this->valueType; } function setRequired() { $this->required = 1; } function setNotRequired() { return $this->required = 0; } } class OCFParameter { var $name = ''; var $valueType = ''; var $value = ''; var $id = ''; function setID($val='') { $this->id = $val; } function getID() { return $this->id; } function setName($val='') { $this->name = $val; } function getName() { return $this->name; } function setValue($val='') { $this->value = $val; } function getValue() { return $this->value; } function setValueType($val='') { $this->valueType = $val; } function getValueType() { return $this->valueType; } } class OCFLink { var $type = ''; var $value = ''; var $name = ''; var $id = ''; function setID($val='') { $this->id = $val; } function getID() { return $this->id; } function setName($val='') { $this->name = $val; } function getName() { return $this->name; } function setValue($val='') { $this->value = $val; } function getValue() { return $this->value; } function setType($val='') { $this->type = $val; } function getType() { return $this->type; } } ?>