<?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.studio
* @copyright Copyright (c) 2006 Entier Studio team. All rights reserved.
* @version $Id: view.RepositoryModelResourceExplorer.php 81 2008-01-17 23:08:21Z yannromefort $
*/
//-----------------------------------------------------------------------------
// namespace
if (!defined("DefRepositoryModelResourceExplorer")) {
//-------------------------------------------------------------------------
// Define
define("DefRepositoryModelResourceExplorer", "1");
define(ROOTVIEW, 10);
//-------------------------------------------------------------------------
// Include
@require_once (FRAMEWORK_DIR . VIEWHELPER);
//-------------------------------------------------------------------------
// Class
class RepositoryModelResourceExplorer extends ViewObject {
//---------------------------------------------------------------------
// Constructor
/**
*
* @param integer Repository pkid // foreign key
*/
function RepositoryModelResourceExplorer() {
}
//---------------------------------------------------------------------
// Methods
/**
*
* @access private
*
* @param object DataSource object
* @param object ViewTemplate object
* @param string layout name is a template file name or a layer name in a template file
* @param string block name in layout
* @return boolean
*/
function renderTree(&$datasource, &$template, $block, $value) {
//
$resourceSet = new RepositoryModelResourceSet($this->m_fieldSet["DIRRESOPKID"], $value);
if ($resourceSet->selectSet($datasource, REFLECTKEY, NATURALKEY) == true) {
//
for ($i = 0;$i < $resourceSet->rowCount();$i++) {
// select next row
if ($resourceSet->fetchCursorRow($datasource) == false) return (false);
//
$template->select($block);
$template->assign($resourceSet->fieldSet());
$template->render($block);
// select dependent rows
if ($this->renderTree($datasource, $template, $block, $resourceSet->get_field_value("REPMRESPKID")) == false) return (false);
}
}
//
return (true);
}
/**
*
* @access public
*
* @param object DataSource object
* @param object ViewTemplate object
* @param string layout name is a template file name or a layer name in a template file
* @param string block name in layout
* @param integer view type { ITEMVIEW, LISTVIEW, TREEVIEW }
* @param integer outputmode
* @return boolean
*/
function renderView(&$datasource, &$template, $layout, $block = NULL, $view = NULL, $mode = OUTPUT) {
//
if (!is_object($template)) {
//
$this->m_errorSet[VIEW_SYSTEM_ERROR] = true;
//
return (false);
}
//
if (!empty($layout) && ($template->define($layout) == false)) {
//
$this->m_errorSet[VIEW_LAYOUT_ERROR] = $layout;
//
return (false);
}
//
/*
* *- Error management
*/
//
if ($this->get_error_count() > 0) {
//
@include_once (FRAMEWORK_VIEW . "view.ErrorMessage.php");
//
$errorMessage = new ErrorMessage($this->errorSet());
if ($errorMessage->renderView($template, $block, $view) == false) {
//
$this->m_errorSet[VIEW_RENDER_ERROR] = true;
//
return (false);
}
}
//
@include_once (FRAMEWORK_DIR . "htmldropdownlist.php");
//
switch ($view) {
case FORMVIEW:
/*
* @see handler ctrl.RepositoryModelResource.php
*/
//
/*
*
* 1- DirectoryResource
* 2- RepositoryModelResourceType
* 3- RepositoryCoreElementSet
* 4- ApplicationCodificationSet
*
*/
//
/*
* 1- DirectoryResource
*/
//
@include_once (COMPONENTS_DATA . "data.DirectoryResource.php");
//
$resource = new DirectoryResource($this->m_fieldSet["DIRRESOPKID"]);
if ($resource->selectRow($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
//
$template->assign($resource->fieldSet());
//
/*
* 2- RepositoryModelResourceType
*
*/
//
@include_once (COMPONENTS_DATA . "data.RepositoryModelResourceType.php");
//
$resourceType = new RepositoryModelResourceType($this->m_fieldSet["REPMRETPKID"]);
if ($resourceType->selectRow($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
//
$template->assign($resourceType->fieldSet());
//
/*
* 3- RepositoryCoreElementSet Dropdownlist
*/
//
@include_once (COMPONENTS_DATA . "data.RepositoryCoreElementSet.php");
//
$resourceSet = new RepositoryCoreElementSet($this->m_fieldSet["REPOSITPKID"], $resourceType->get_field_value("REPCELTPKID"));
if ($resourceSet->selectSet($datasource, FOREIGNKEY, PRIMARYKEY) == false) {
//
$this->m_errorSet[HTML_OBJECT_ERROR] = true;
//
return (false);
}
//
$resourceTypeDDL = new HTMLDropdownList("kind", "formInput");
$this->m_blockSet[REPCELELIST] = $resourceTypeDDL->renderObject($datasource, $resourceSet);
//
/*
* 4- ApplicationCodificationSet Status Dropdownlist
*/
//
@include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
//
$codificationSet = NULL;
$codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
$this->m_blockSet["REPSTATLIST"] = $codificationSetDDL->renderObject($datasource, $codificationSet, 1);
//
$template->assign($this->m_fieldSet);
$template->assign($this->m_blockSet);
//
break;
case ITEMVIEW:
/*
* @see handler ctrl.RepositoryModelResource.php
*/
//
/*
* 1- RepositoryModelResource
* 2- RepositoryModelResource Parent
* 3- ApplicationCodificationSet
* 4- RepositoryModelResourceTypeSet
* 5- RepositoryModelResourcePropertyList
*/
//
/*
* 1- RepositoryModelResource
*/
//
@include_once (COMPONENTS_DATA . "data.RepositoryModelResource.php");
//
$resource = new RepositoryModelResource($this->m_fieldSet["REPMRESPKID"]);
if ($resource->selectRow($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
//
$template->assign($resource->fieldSet());
//
/*
* 2- RepositoryModelResource Parent
*/
//
$parent = new RepositoryModelResource($resource->get_field_value("REPMRESLINK"));
if ($parent->selectRow($datasource) == true) {
$this->m_blockSet["REPLINKVIEW"] = "view";
$this->m_blockSet["REPLINKPKID"] = $parent->get_field_value("REPMRESPKID");
} else {
$this->m_blockSet["REPLINKVIEW"] = "root";
$this->m_blockSet["REPLINKPKID"] = $resource->get_field_value("DIRRESOPKID");
}
//
/*
* 3- ApplicationCodificationSet
* Status Dropdownlist
*/
//
@include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
//
$codificationSet = NULL;
$codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
$this->m_blockSet["REPSTATLIST"] = $codificationSetDDL->renderObject($datasource, $codificationSet, $resource->get_field_value("REPMRESSTAT"));
//
$template->assign($this->m_blockSet);
//
/*
* 4- RepositoryModelResourceTypeMap
*/
//
@include_once (COMPONENTS_DATA . "data.RepositoryModelResourceTypeMap.php");
//
$resourceTypeSet = new RepositoryModelResourceTypeMap($resource->get_field_value("REPMRETPKID"));
if ($resourceTypeSet->selectSet($datasource) == true) {
//
$template->select("show");
//
for ($i = 0;$i < $resourceTypeSet->rowCount();$i++) {
//
if ($resourceTypeSet->fetchCursorRow($datasource) == false) return (false);
//
$template->select("menu");
$template->assign($resourceTypeSet->fieldSet());
$template->render("menu");
}
$template->render("show");
}
//
//
/*
* 5- RepositoryModelResourcePropertyList
*/
//
@include_once (COMPONENTS_VIEW . "view.RepositoryModelResourcePropertyList.php");
//
$propertyList = new RepositoryModelResourcePropertyList();
$propertyList->set_field_value("REPMELTPKID", $resource->get_field_value("REPMELTPKID"));
$propertyList->set_field_value("REPMRESPKID", $resource->get_field_value("REPMRESPKID"));
if ($propertyList->renderView($datasource, $template, "prop", "prop", LISTVIEW, RENDER) == false) {
//
$this->m_errorSet[VIEW_RENDER_ERROR] = true;
//
return (false);
}
//
break;
case TREEVIEW:
/*
* @see handler ctrl.RepositoryModelResource.php
*/
/*
* 1- DirectoryResource
*/
//
@include_once (COMPONENTS_DATA . "data.DirectoryResource.php");
//
$resource = new DirectoryResource($this->m_fieldSet["DIRRESOPKID"]);
if ($resource->selectRow($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
//
$template->assign($resource->fieldSet());
$template->assign($this->m_fieldSet); // side effect 4 REPOSITPKID
//
/*
* 2- RepositoryModelResourceSet Tree
*/
//
@include_once (COMPONENTS_DATA . "data.RepositoryModelResourceSet.php");
//
$resourceSet = new RepositoryModelResourceSet($this->m_fieldSet["DIRRESOPKID"]);
if ($resourceSet->selectSet($datasource) == true) {
//
for ($i = 0;$i < $resourceSet->rowCount();$i++) {
// select next row
if ($resourceSet->fetchCursorRow($datasource) == false) return (false);
//
$template->select($block);
$template->assign($resourceSet->fieldSet());
$template->render($block);
// select dependent rows
if ($this->renderTree($datasource, $template, $block, $resourceSet->get_field_value("REPMRESPKID")) == false) return (false);
}
}
//
break;
case FRAMEVIEW:
/*
* * @see handler ctrl.RepositoryModelResource.php
*/
/*
* 1- DirectoryResource
*/
//
@include_once (COMPONENTS_DATA . "data.DirectoryResource.php");
//
$resource = new DirectoryResource($this->m_fieldSet["DIRRESOPKID"]);
if ($resource->selectRow($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
//
$template->assign($resource->fieldSet());
$template->assign($this->m_fieldSet); // side effect 4 REPOSITPKID
//
break;
}
//
$template->output($mode);
//
return (true);
}
};
// Class
//-------------------------------------------------------------------------
}
// namespace
//-----------------------------------------------------------------------------
?>