Location: PHPKode > projects > Mocovie web framework > mocovi/library/filesystems/FS.php
<?php
/**
 *  Copyright (C) 2010  Kai Dorschner
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @author Kai Dorschner <the-hide@address.com>
 * @copyright Copyright 2010, Kai Dorschner
 * @license http://www.gnu.org/licenses/gpl.html GPLv3
 * @package mocovi
 * @subpackage filesystems
 */

/**
 * Require MvcException.
 */
class_exists('MvcException')	or require $GLOBALS['library'].'autoload/MvcException.php';

/**
 * Abstract Filesystem
 *
 * @package mocovi
 * @subpackage filesystems
 */
abstract class FS
{
	/**
	 * Contains the Path to the source file or database
	 *
	 * @access protected
	 */
	protected $source;

	/**
	 * Contains all found references in the filesystem.
	 *
	 * @var object
	 * @access private
	 */
	protected $references;

	protected $redirect = true;

	const DEFAULT_LANGUAGE	= 'de';
	const DEFAULT_MEDIA		= 'html';
	const DEFAULT_THEME		= 'default';


	/**
	 * Set database source.
	 *
	 * @return void
	 */
	abstract public function __construct($source);

	/**
	 * Returns the model-node.
	 *
	 * @access public
	 * @param string $path Contains the XQuery
	 * @return DomDocument The model node
	 */
	abstract public function getModel($path = '/');

	/**
	 * Returns keyword-node.
	 *
	 * @access public
	 * @param string $path Contains the XQuery
	 * @return Array Keywords
	 */
	abstract public function getKeywords($path = '/');

	/**
	 * Returns a list of a virtual directory.
	 *
	 * @access public
	 * @param string $path Contains the XQuery
	 * @return array List of all elements in the directory
	 */
	abstract public function getList($path = '/');

	/**
	 * Returns the theme of a model.
	 * 
	 * @access public
	 * @param string $path Contains the XQuery
	 * @return string Name of current theme in the model
	 */
	abstract public function getTheme($path = '/');

	/**
	 * Returns the name alias of a virtual file.
	 *
	 * @access public
	 * @param string $path Contains the XQuery
	 * @return string Alias name of the file
	 */
	abstract public function getAlias($path = '/');

	/**
	 * Returns the filename of a virtual file.
	 *
	 * @access public
	 * @param string $path Contains the XQuery
	 * @return string Name of the file
	 */
	abstract public function getName($path = '/');

	/**
	 * Returns wether the the file is redirected and the redirect position.
	 *
	 * @access public
	 * @param string $path Contains the XQuery
	 * @return string Redirected file location.
	 */
	abstract public function getRedirect($path = '/');

	/**
	 * Returns the user defined priority of a file.
	 *
	 * @param string $path Contains the XQuery
	 * @return string Priority value (from 0.1 to 1.0) of current file
	 */
	abstract public function getPriority($path = '/');

	/**
	 * Returns the date of last modification of a file.
	 *
	 * @param string $path Contains the XQuery
	 * @return string Returns the value of lastModified attribute
	 */
	abstract public function getLastModified($path = '/');

	/**
	 * Returns the name of the author of a file.
	 *
	 * @param string $path Contains the XQuery
	 * @return string Returns the name of the author
	 */
	abstract public function getAuthor($path = '/');


	/**
	 * Returns the language if a file.
	 *
	 * @param string $path Contains the XQuery
	 * @return string Returns the language
	 */
	abstract public function getPageTranslation($path = '/');

	/**
	 * Returns all defined translation XML files based in the header of the filesystem.
	 *
	 * @access public
	 * @return array All translation files.
	 */
	abstract public function getFilesystemTranslations();

	/**
	 * Returns the default language set in the filesystem.
	 *
	 * @access public
	 * @return string The default language.
	 */
	abstract public function getDefaultLanguage();

	/**
	 * Returns the default theme set in the filesystem.
	 *
	 * @access public
	 * @return string The default theme.
	 */
	abstract public function getDefaultTheme();

	/**
	 * Returns the default media set in the filesystem.
	 *
	 * @access public
	 * @return string The default media.
	 */
	abstract public function getDefaultMedia();

	abstract public function getPath(DomElement $node);

	/**
	 * Returns wether the query is a file or not.
	 *
	 * @access public
	 * @return boolean Query is file or not.
	 */
	abstract public function isFile($path);

	/**
	 * Deactivate redirecting
	 *
	 */
	public function noRedirect()
	{
		$this->redirect = false;
	}

	/**
	 * Returns all references in the filesystem as an object type of XmlNodeList.
	 *
	 * @access private
	 * @return XmlNodeList Containts all XML references.
	 */
	abstract protected function getReferences();

	/**
	 * Parses the model-DOM for internal node-references and replaces them.
	 *
	 * The reference nodes are searched by the NameSpace URI defined in the 
	 * {@see $referenceNameSpace} property. The ref-attribute selects the internal reference
	 * node, clones and replaces itself with it.
	 *
	 * @access private
	 * @return void
	 * @see $dom
	 */
	abstract protected function setReferences();

	/**
	 * Cleaning up the model-DOM.
	 *
	 * Deletes all references.
	 *
	 * @access private
	 * @param DomDocument $dom Contains the model-DOM.
	 * @return void
	 */
	abstract protected function deleteReferences();

	/**
	 * Prepares a path for get requests like getAuthor().
	 *
	 * @param string $path Contains the normal path
	 * @return string Returns the prepared path
	 */
	abstract protected function preparePath($path);

	public function getSourcePath()
	{
		return $this->source;
	}

	public function getSourceFile()
	{
		return basename($this->source);
	}
}
Return current item: Mocovie web framework