<?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: viewtemplate.model.php 81 2008-01-17 23:08:21Z yannromefort $
*/
// Comments
//
// This work is derived from class.FastTemplate.php3 version 1.1.0 as
// available from http://www.thewebmasters.net/. That work makes
// reference to the "GNU General Artistic License". In correspondence
// with the author, the intent was to use the GNU General Public License;
// this work does the same.
//-----------------------------------------------------------------------------
// namespace
if (!defined("DefViewTemplateModel")) {
//-------------------------------------------------------------------------
// Define
define("DefViewTemplateModel", "1");
//-------------------------------------------------------------------------
// Class
class ViewTemplateModel {
//---------------------------------------------------------------------
// Attributes
/**
* Template Model layout name
* @var string
* @see ViewTemplateModel
*/
var $m_layout;
/**
* Template Model parent
* @var string
* @see ViewTemplateModel
*/
var $m_parent;
/**
* Template Model insets
* @var array
* @see ViewTemplateModel
*/
var $m_insets = array();
/**
* Template Model source
* @var string
* @see ViewTemplateModel
*/
var $m_source = NULL;
/**
* Template Model output
* @var string
*/
var $m_output = NULL;
/**
* Template Model field tags
* @var array
* @see parseFields
*/
var $m_fields = array();
/**
* Template Model status
* @var boolean
*/
var $m_status = 0;
//---------------------------------------------------------------------
// Constructor
/**
* Constructor
* @access public
* @param string layout name
* @param string source string
* @param array insets array
*/
function ViewTemplateModel($layout, $parent, $source, $insets) {
//
$this->m_layout = $layout;
$this->m_parent = $parent;
$this->m_source = $source;
$this->m_insets = $insets;
//
$this->parseFields();
}
//---------------------------------------------------------------------
// Methods
/**
* Retrieve layout fields names
* @access private
* @return boolean Return flag
*/
function parseFields() {
// Parse fields name
@preg_match_all("|{(\S*)}|sU", $this->m_source, $fields);
$fields = $fields[1];
// Create fields array
if (count($fields)) {
foreach($fields as $field) $this->m_fields[$field] = "";
}
//
return (true);
}
/**
* Set field value
* @access public
* @param string field name
* @param string field value
* @return boolean Return flag
*/
function setValue($field, $value) {
//
/* 2002/04/06 : inherit problem with undefined field
if (!isset($this->m_fields[$field]))
return( false );
*/
//
$this->m_fields[$field] = $value;
//
return (true);
}
};
// Class
//-------------------------------------------------------------------------
}
// namespace
//-----------------------------------------------------------------------------
?>