<?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.ObjectoryComponentExplorer.php 81 2008-01-17 23:08:21Z yannromefort $
*/
//-----------------------------------------------------------------------------
// namespace
if (!defined("DefObjectoryComponentExplorer")) {
//-------------------------------------------------------------------------
// Define
define("DefObjectoryComponentExplorer", "1");
//-------------------------------------------------------------------------
// Include
@require_once (FRAMEWORK_DIR . VIEWHELPER);
//-------------------------------------------------------------------------
// Class
class ObjectoryComponentExplorer extends ViewObject {
//---------------------------------------------------------------------
// Constructor
/**
*
* @param integer Objectory pkid // foreign key
*
*/
function ObjectoryComponentExplorer($OBJECTOPKID = 0) {
//
$this->m_fieldSet["OBJECTOPKID"] = $OBJECTOPKID;
}
//---------------------------------------------------------------------
// 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) {
//
$componentSet = new ObjectoryComponentSet($this->m_fieldSet["OBJECTOPKID"], $value);
if ($componentSet->selectSet($datasource, REFLECTKEY) == true) {
//
for ($i = 0;$i < $componentSet->rowCount();$i++) {
// select next row
if ($componentSet->fetchCursorRow($datasource) == false) return (false);
//
$template->select($block);
$template->assign($componentSet->fieldSet());
$template->render($block);
// select dependent rows
if ($this->renderTree($datasource, $template, $block, $componentSet->get_field_value("OBJCOMPPKID")) == 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 { FORMVIEW, ITEMVIEW, LISTVIEW, TREEVIEW... }
* @param integer outputmode
* @return boolean
*/
function renderView(&$datasource, &$template, $layout, $block, $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);
}
}
//
$template->assign($this->m_fieldSet);
//
@include_once (FRAMEWORK_DIR . "htmldropdownlist.php");
//
switch ($view) {
case ROOTVIEW:
/*
* @see handler ObjectoryComponent-root.php
*/
//
/*
* 1- DirectoryProject
* 2- DirectoryProject
* 3- ApplicationCodificationSet
*/
//
/*
* 1- Objectory
*/
//
@include_once (COMPONENTS_DATA . "data.Objectory.php");
//
$objectory = new Objectory($this->m_fieldSet["OBJECTOPKID"]);
if ($objectory->selectRow($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
//
$template->assign($objectory->fieldSet());
//
/*
* 2- ObjectoryComponentType
*/
//
@include_once (COMPONENTS_DATA . "data.ObjectoryComponentType.php");
//
$type = new ObjectoryComponentType($this->m_fieldSet["OBJCTYPPKID"]);
if ($type->selectRow($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
/*
* 3- ApplicationCodificationSet Dropdownlist status
*/
//
@include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
//
$codificationSet = NULL;
$codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
$this->m_blockSet["OBJSTATLIST"] = $codificationSetDDL->renderObject($datasource, $codificationSet, 1);
//
$template->assign($type->fieldSet());
$template->assign($this->m_blockSet);
//
break;
case FORMVIEW:
/*
* * @see handler ObjectoryComponent-form.php
*/
//
/*
* 1- ObjectoryComponent
* 2- ObjectoryComponentType
* 3- ApplicationCodificationSet
*/
//
/*
* 1- ObjectoryComponent
*/
//
@include_once (COMPONENTS_DATA . "data.ObjectoryComponent.php");
//
$component = new ObjectoryComponent($this->m_fieldSet["OBJCOMPPKID"]);
if ($component->selectRow($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
if ($component->get_field_value("OBJCTYPPKID") == MODEL_TYPE) {
$component->set_field_value("OBJCOMPROOT", $component->get_field_value("OBJCOMPPKID"));
}
//
$template->assign($component->fieldSet());
//
/*
* 2- ObjectoryComponentType Dropdownlist type
*/
//
@include_once (COMPONENTS_DATA . "data.ObjectoryComponentTypeMap.php");
//
$componentTypeSet = new ObjectoryComponentTypeMap($component->get_field_value("OBJCTYPPKID"));
if ($componentTypeSet->selectSet($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
//
$componentTypeDDL = new HTMLDropdownList("kind", "formInput");
$this->m_blockSet["OBJTYPLIST"] = $componentTypeDDL->renderObject($datasource, $componentTypeSet);
//
/*
* 3- ApplicationCodificationSet Dropdownlist status
*/
//
@include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
//
$codificationSet = NULL;
$codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
$this->m_blockSet["OBJSTATLIST"] = $codificationSetDDL->renderObject($datasource, $codificationSet, $component->get_field_value("OBJCOMPSTAT"));
//
$template->assign($this->m_blockSet);
//
break;
case ITEMVIEW:
/*
* * @see handler ObjectoryComponent-view.php
*/
//
/*
* 1- ObjectoryComponent
* 2- ObjectoryComponent Parent
* 3- Namespace
* 4- ApplicationCodificationSet
* 5- ObjectoryComponentTemplate
* 5.1- Status
* 5.2- Language processor
* 5.3- Output mime
* 5.4- Generation mode
* 5.5- Element target
*/
//
/*
* 1- ObjectoryComponent
*/
@include_once (COMPONENTS_DATA . "data.ObjectoryComponent.php");
//
$component = new ObjectoryComponent($this->m_fieldSet["OBJCOMPPKID"]);
if ($component->selectRow($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
//
$template->assign($component->fieldSet());
//
/*
* 2- ObjectoryComponent Parent
*/
//
$parent = new ObjectoryComponent($component->get_field_value("OBJCOMPLINK"));
if ($parent->selectRow($datasource) == true) $this->m_blockSet["OBJLINKTYPE"] = $parent->get_field_value("OBJCTYPTYPE");
//
/*
* 3- Namespace
*/
//
@include_once (COMPONENTS_DATA . "data.ObjectoryComponentNamespace.php");
//
$namespace = new ObjectoryComponentNamespace($component->get_field_value("OBJCOMPROOT") , $component->get_field_value("OBJCTYPPKID"));
if ($namespace->selectSet($datasource, REFLECTKEY) == true) {
//
@include_once (COMPONENTS_HTML . "html.ObjectoryComponentNamespaceDDL.php");
//
$namespaceDDL = new ObjectoryComponentNamespaceDDL("link", "formInput", $component->get_field_value("OBJCOMPPKID") , $component->get_field_value("OBJCOMPROOT") , $component->get_field_value("OBJCTYPPKID"));
$this->m_blockSet["OBJCOMPLIST"] = $namespaceDDL->renderObject($datasource, $namespace, $component->get_field_value("OBJCOMPLINK"));
}
//
unset($namespace);
unset($namespaceDDL);
//
/*
* 4- ApplicationCodificationSet Dropdownlists
*/
//
@include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
//
$codificationSet = NULL;
$codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
$this->m_blockSet["OBJSTATLIST"] = $codificationSetDDL->renderObject($datasource, $codificationSet, $component->get_field_value("OBJCOMPSTAT"));
unset($codificationSetDDL);
unset($codificationSet);
//
if ($component->get_field_value("OBJCTYPTYPE") == MODEL_FILE_TYPE) {
//
/*
* 5.1- ObjectoryComponentTemplate
*/
//
@include_once (COMPONENTS_DATA . "data.ObjectoryComponentTemplate.php");
//
$componentTemplate = new ObjectoryComponentTemplate($this->m_fieldSet["OBJCOMPPKID"], false);
if ($componentTemplate->selectRow($datasource) == true) {
//
$template->assign("OBJFILELANG", $componentTemplate->get_field_value("OBJFILELANG"));
$template->toggle("dbug", $componentTemplate->get_field_value("OBJMAKEMODE") == DYNAMIC_TYPE);
}
//
// 5.2- Language processor
$codificationSet = NULL;
$codificationSetDDL = new ApplicationCodificationDDL("lang", "formInput", 6);
$this->m_blockSet["LangList"] = $codificationSetDDL->renderObject($datasource, $codificationSet, $componentTemplate->get_field_value("OBJFILELANG"));
unset($codificationSetDDL);
unset($codificationSet);
//
// 5.3- Output mime
$codificationSet = NULL;
$codificationSetDDL = new ApplicationCodificationDDL("mime", "formInput", 7);
$this->m_blockSet["MimeList"] = $codificationSetDDL->renderObject($datasource, $codificationSet, $componentTemplate->get_field_value("OBJMAKEMIME"));
unset($codificationSetDDL);
unset($codificationSet);
//
// 5.4- Generation mode
$codificationSet = NULL;
$codificationSetDDL = new ApplicationCodificationDDL("mode", "formInput", 5);
$this->m_blockSet["ModeList"] = $codificationSetDDL->renderObject($datasource, $codificationSet, $componentTemplate->get_field_value("OBJMAKEMODE"));
unset($codificationSetDDL);
unset($codificationSet);
//
// 5.5- Element Type target
//
@include_once (COMPONENTS_HTML . "html.ObjectoryElementTargetDDL.php");
//
$targetSet = NULL;
$targetSetDDL = new ObjectoryElementTargetDDL("goal", "formInput", $component->get_field_value("REPTYPEPKID"));
$this->m_blockSet["OBJTYPELIST"] = $targetSetDDL->renderObject($datasource, $targetSet, $componentTemplate->get_field_value("OBJETYPPKID"));
unset($targetSetDDL);
unset($targetSet);
//
unset($componentTemplate);
}
//
$template->assign($this->m_blockSet);
//
break;
case LISTVIEW:
/*
* * @see handler ObjectoryComponent-list.php
*/
//
break;
case TREEVIEW:
/*
* * @see class ProjectsExplorer
*/
/*
* 1- ObjectoryComponentSet
*/
//
@include_once (COMPONENTS_DATA . "data.ObjectoryComponentSet.php");
//
$componentSet = new ObjectoryComponentSet($this->m_fieldSet["OBJECTOPKID"]);
if ($componentSet->selectSet($datasource, FOREIGNKEY, FOREIGNKEY) == true) {
//
for ($i = 0;$i < $componentSet->rowCount();$i++) {
// select next row
if ($componentSet->fetchCursorRow($datasource) == false) return (false);
//
$template->select($block[0]);
$template->assign($componentSet->fieldSet());
// select ObjectoryComponentSet dependent rows
if ($this->renderTree($datasource, $template, $block[1], $componentSet->get_field_value("OBJCOMPPKID")) == false) {
//
return (false);
}
//
$template->render($block[0]);
}
}
//
break;
case FRAMEVIEW:
/*
* * @see handler ObjectoryComponent-test.php
*/
//
/*
* 1- ObjectoryComponent
*/
@include_once (COMPONENTS_DATA . "data.ObjectoryComponent.php");
//
$component = new ObjectoryComponent($this->m_fieldSet["OBJCOMPPKID"]);
if ($component->selectRow($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
//
$template->assign($component->fieldSet());
//
break;
case TESTVIEW:
/*
* * @see handler ObjectoryComponent-DBUG.php
*/
//
/*
* 1- ObjectoryElement
*/
@include_once (COMPONENTS_DATA . "data.ObjectoryElement.php");
//
$element = new ObjectoryElement($this->m_fieldSet["OBJELEMPKID"]);
if ($element->selectRow($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
//
$template->assign($element->fieldSet());
$template->assign($this->m_fieldSet);
//
break;
case CODEVIEW:
/*
* * @see handler ObjectoryComponent-code.php
*/
/*
* 1- ObjectoryComponentTemplate
*/
//
@include_once (COMPONENTS_DATA . "data.ObjectoryComponentTemplate.php");
//
$component = new ObjectoryComponentTemplate($this->m_fieldSet["OBJCOMPPKID"]);
if ($component->selectRow($datasource) == false) {
//
return (false);
}
//
//
$OBJFILETEXT = $component->get_field_value("OBJFILETEXT");
if (empty($OBJFILETEXT)) {
//
return (false);
}
//
$OBJFILEMIME = $component->get_field_value("OBJFILEMIME");
//
header("Content-Type: " . $OBJFILEMIME . "\n ");
header("Content-Transfer-Encoding: 8bit\n");
header("Content-length: " . strlen($OBJFILETEXT) . "\n");
//
return (print ($OBJFILETEXT));
//
break;
}
//
$template->output($mode);
//
return (true);
}
};
// Class
//-------------------------------------------------------------------------
}
// namespace
//-----------------------------------------------------------------------------
?>