Location: PHPKode > projects > Entier Studio > entierstudio/framework/model.element.php
<?php
/**
 * Entier Studio
 *
 * LICENSE
 *
 *	Copyright 2006 Entier Studio team.
 *
 *	Licensed under the Apache License, Version 2.0 (the "License");
 *	you may not use this file except in compliance with the License.
 *	You may obtain a copy of the License at
 *
 *		http://www.apache.org/licenses/LICENSE-2.0
 *
 *	Unless required by applicable law or agreed to in writing, software
 *	distributed under the License is distributed on an "AS IS" BASIS,
 *	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *	See the License for the specific language governing permissions and
 *	limitations under the License.
 *
 * @package    entier.framework
 * @copyright  Copyright (c) 2006 Entier Studio team. All rights reserved.
 * @version	   $Id: model.element.php 81 2008-01-17 23:08:21Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefModelElement")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefModelElement", "1");
    //-------------------------------------------------------------------------
    //	Class ModelElement
    class ModelElement {
        //---------------------------------------------------------------------
        //	Attributes
        
        /**
         * Element node name
         * @var	string
         */
        var $m_nodeName;
        /**
         * Element type name
         * @var	string
         */
        var $m_typeName;
        /**
         * Element node type
         * @var	integer
         */
        var $m_nodeType;
        /**
         * Element data path
         * @var	string
         */
        var $m_dataPath;
        /**
         * Element data type
         * @var	integer
         */
        var $m_dataType;
        /**
         * Element size
         * @var	integer
         */
        var $m_dataSize;
        /**
         * Element options flags
         * @var	string
         */
        var $m_dataProp;
        /**
         * dependent nodes
         * @var	array
         */
        var $m_nodeList = array();
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         * Constructor
         * @access	public
         * @param	string	Node name
         * @param	string	Type name
         * @param	integer	Node type
         * @param	string	Data Path
         * @param	string	Data Type
         * @param	integer	Data Size
         * @param	string	Data Properties
         */
        function ModelElement($nodeName, $typeName, $nodeType, $dataPath = "", $dataType = "", $dataSize = 1, $dataProp = NULL) {
            //
            $this->m_nodeName = $nodeName;
            $this->m_typeName = $typeName;
            $this->m_nodeType = $nodeType;
            $this->m_dataPath = $dataPath;
            $this->m_dataType = $dataType;
            $this->m_dataSize = $dataSize;
            $this->m_dataProp = $dataProp;
        }
        //---------------------------------------------------------------------
        //	Properties
        /*
        * @return	boolean
        */
        function equals($path = "", $type = "") {
            return (($this->m_dataPath == $path) && ($this->m_typeName == $type));
        }
        /*
        * @return	array
        */
        function elements() {
            //
            if (is_array($this->m_nodeList)) return ($this->m_nodeList);
            //
            return (NULL);
        }
        /*
        * @param	string
        * @param	variant
        * @return	boolean
        */
        function addElement($field, $value) {
            //
            if (@is_array($this->m_nodeList)) {
                $this->m_nodeList[$field] = $value;
                //
                return (true);
            }
            //
            return (false);
        }
        /**
         *
         * @return	boolean
         */
        function sortElements() {
            //
            if (is_array($this->m_nodeList)) return (@ksort($this->m_nodeList));
            //
            return (false);
        }
        /**
         *
         * @return	boolean
         */
        function fetchElements($path = "", $type = "") {
            //
            if ($this->equals($path, $type) == false) return (false);
            //
            if ($this->sizeOfElements() == 0) return (false);
            //
            $current = @each($this->m_nodeList);
            //
            return ($current ? current($current) : $current);
        }
        /**
         *
         * @return	boolean
         */
        function resetElements() {
            //
            if (is_array($this->m_nodeList)) return (@reset($this->m_nodeList));
            //
            return (false);
        }
        /**
         *
         * @return	integer	Count
         */
        function sizeOfElements() {
            //
            if (is_array($this->m_nodeList)) return (@sizeof($this->m_nodeList));
            //
            return (0);
        }
    };
    //	Class
    //-------------------------------------------------------------------------
    
}
//	namespace
//-----------------------------------------------------------------------------
?>
Return current item: Entier Studio