Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/gerald1974/avalon.cat/monografics/panell/lib/Framework.php on line 55

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/gerald1974/avalon.cat/monografics/panell/lib/Framework.php:55) in /home/gerald1974/avalon.cat/monografics/panell/lib/Framework.php on line 59

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/gerald1974/avalon.cat/monografics/panell/lib/Framework.php:55) in /home/gerald1974/avalon.cat/monografics/panell/lib/Framework.php on line 59

Deprecated: Function split() is deprecated in /home/gerald1974/avalon.cat/monografics/lib/publicController.php on line 34

Deprecated: Function split() is deprecated in /home/gerald1974/avalon.cat/monografics/lib/publicController.php on line 54
/** * Class XMLTemplate * Wrapper for content templating.... * Gets a template definition, parses it, and generates xml content .... or parses xml content... * @version 1.0b * @author Jordi collel * */ //echo "Tests
"; //set_include_path('../:./' ); AutoLoader::load('XML/Serializer'); AutoLoader::load('XML/Unserializer'); //require_once('XML/Serializer.php'); //require_once('XML/Unserializer.php'); class XMLTemplate { public $_defaultOptions = array( 'factory'=>'File', 'tpl'=>'tema', 'tpl_path'=>'' ); private $_factory; private $_templateKey; private $_template; private $_fields; private $_properties; private $_content = array(); private $_pt; private $_data; public function __construct($data=null, $options) { $this->_defaultOptions = array_merge($this->_defaultOptions, $options); $this->_templateKey = $this->_defaultOptions['tpl_path'] . $this->_defaultOptions['tpl']; // Factory load of template file definition $factory_file = 'XMLTemplate' . $this->_defaultOptions['factory']; try { require_once 'XMLContent/' . $factory_file . '.php'; $this->_factory = new $factory_file( $this->_templateKey ); } catch (Exception $e) { throw new Exception('Unable to load:' . $e->getMessage() ); } // Parse template data $unserializer = new XML_Unserializer( array( 'complexType' => 'array', "ignoreKeys" => array("item") )); $unserializer->unserialize( $this->_factory->getTemplate() ); $this->_template = $unserializer->getUnserializedData(); $this->_parseFields(); // Si $data if(isset($data) && !is_array($data)): $unserializer->unserialize( $data ); $this->_content = $unserializer->getUnserializedData(); endif; //return $this->_content; } private function _parseFields() { $this->_fields = array(); foreach($this->_template['fields'] as $tp): $this->_fields[$tp['field']] = array( "label"=>$tp['label'], "type"=>$tp['type'] ); endforeach; $this->_properties = $this->_template['properties']; } public function getFields() { //var_dump($this->_template); return array_keys($this->_fields); } public function getField($key) { return (object) $this->_fields[$key]; } public function addContent( $arr ) { //Log::write( 'Titulo ' . $arr['title'] ); foreach($this->getFields() as $ff): if(isset($arr[$ff])) $this->_content[$ff] = $arr[$ff]; else $this->_content[$ff] = ""; endforeach; } public function toXML() { $serializer = new XML_Serializer(array( "indent" => "\t", // indent with tabs "linebreak" => "\n", // use UNIX line breaks "rootName" => "xml", // root tag "defaultTagName" => "item", //tag for values with numeric keys "typeHints"=>true )); $serializer->serialize($this->_content); return $serializer->getSerializedData(); } public function getNumFields() { return count($this->getFields()); } public function __get($key) { if(isset( $this->_content[$key] )) return $this->_content[$key]; elseif( isset( $this->_properties[$key] ) ) return $this->_properties[$key]; else return false; } } /* TESTS // Template demo title text content richtext $ct = array( 'title'=> 'LALALALALALLALALA', 'content'=> '

This is a content

This is antohter content

' ); $scope = ""; $test = new XMLTemplate( null, array( 'tpl'=>'tema', 'tpl_path'=>'../../app/conf/' ) ); echo $test->getFields() . "
"; // Array echo "Camps: " . implode(",", $test->getFields()) . "
"; echo "

TEst 2: adding content
...............
"; $test->addContent($ct); echo htmlentities( $test->toXML() ); $ct2 = $test->toXML(); echo "

TEst 3: getting content
...............
"; echo "Val for title: " . $test->title . "
"; echo "Val for content: " . $test->content . "
"; echo "

TEst 4: getting setted content
...............
"; $test2 = new XMLTemplate( $ct2, array( 'tpl'=>'tema', 'tpl_path'=>'../../app/conf/' ) ); echo "Val for title: " . $test2->title . "
"; echo "Val for content: " . $test2->content . "
"; echo "Field title is " . $test2->getField('title')->type . "
"; echo "Field title is " . $test2->getField('title')->label . "
"; */
Warning: Cannot modify header information - headers already sent by (output started at /home/gerald1974/avalon.cat/monografics/panell/lib/Framework.php:55) in /home/gerald1974/avalon.cat/monografics/lib/publicController.php on line 163
AVALON / Monogràfics / Elaboració de projectes - Bibliografia

Elaboració de projectes


Fatal error: Method View::__toString() must not throw an exception in /home/gerald1974/avalon.cat/monografics/layouts/interior.php on line 0