Revision: 131
http://newsphp.svn.sourceforge.net/newsphp/?rev=131&view=rev
Author: christoph_berg
Date: 2007-08-31 11:00:29 -0700 (Fri, 31 Aug 2007)
Log Message:
-----------
Added missing style factory class
Added Paths:
-----------
trunk/jasmine/classes/StyleFactory.class.php
Added: trunk/jasmine/classes/StyleFactory.class.php
===================================================================
--- trunk/jasmine/classes/StyleFactory.class.php (rev 0)
+++ trunk/jasmine/classes/StyleFactory.class.php 2007-08-31 18:00:29 UTC (rev 131)
@@ -0,0 +1,68 @@
+<?php
+/**
+ * This file implements the Jasmine::StyleFactory class.
+ *
+ * @author PHPNews Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU General Public Licence
+ * @copyright (c) 2005-2006 PHPNews Team
+ * @version 0.1.0
+ * @package Jasmine
+ */
+
+require_once('Factory.class.php');
+require_once('Style.class.php');
+
+/**
+ * The StyleFactory Object Class
+ *
+ * This factory constructs an extension of type Style
+ *
+ * @author PHPNews Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU General Public Licence
+ * @copyright (c) 2005-2006 PHPNews Team
+ * @version 0.1.0
+ * @package Jasmine
+ */
+final class StyleFactory extends Factory
+{
+ /**
+ * Creates a Style object from a given XML file
+ *
+ * @param filename string Filename of the XML document to load
+ * @return Extension of type Style
+ */
+ public function createFromXml($filename)
+ {
+ // Get extension path from filename
+ $this->extPath = dirname($filename);
+
+ // Get common data
+ $cdata =& $this->getCommonDataFromXml($filename);
+
+ $stylesheet = Core::getXmlParser()->getAttributeValue('extension', 'stylesheet');
+
+ // Create the Style using collected data and return it
+ return new $cdata['name']($cdata['name'], $cdata['version'], $cdata['installed'], $stylesheet, $cdata['description'], $cdata['image']);
+ }
+
+ /**
+ * Creates a theme object from an associative array (key => value)
+ *
+ * @param $data array Associative data array
+ * @throws NoSuchArrayKeyException if a needed key is not found in the array
+ */
+ public function createFromArray(array& $data)
+ {
+ // Get common data
+ $cdata =& $this->getCommonDataFromArray($data);
+
+ // Set active to default value, if it is not given
+ if (!isset($cdata['stylesheet']))
+ {
+ throw new NoSuchArrayKeyException('stylesheet');
+ }
+
+ // Create the Module using collected data and return it
+ return new $cdata['name']($cdata['name'], $cdata['version'], $cdata['installed'], $cdata['activated'], $cdata['description'], $cdata['image']);
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|