<?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
* @version $Id: view.ObjectoryElementExplorer.php 90 2008-01-31 22:02:05Z yannromefort $
* @copyright Copyright (c) 2006 Entier Studio team. All rights reserved.
*/
//-----------------------------------------------------------------------------
// namespace
if (!defined("DefObjectoryElementExplorer")) {
//-------------------------------------------------------------------------
// Define
define("DefObjectoryElementExplorer", "1");
//-------------------------------------------------------------------------
// Include
@require_once (FRAMEWORK_DIR . VIEWHELPER);
//-------------------------------------------------------------------------
// Class
class ObjectoryElementExplorer extends ViewObject {
//---------------------------------------------------------------------
// Constructor
/**
*
* @param integer Objectory pkid // foreign key
*
*/
function ObjectoryElementExplorer($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
*
*/
function renderTree(&$datasource, &$template, $block, $value) {
//
$elementSet = new ObjectoryElementSet($this->m_fieldSet["OBJECTOPKID"], $value);
if ($elementSet->selectSet($datasource, REFLECTKEY, REFLECTKEY) == true) {
//
for ($i = 0;$i < $elementSet->rowCount();$i++) {
// select next ObjectoryElementSet row
if ($elementSet->fetchCursorRow($datasource) == false) return (false);
//
$template->select($block);
$template->assign($elementSet->fieldSet());
$template->render($block);
// select ObjectoryElementSet dependent rows
if ($this->renderTree($datasource, $template, $block, $elementSet->get_field_value("OBJELEMPKID")) == 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);
}
}
//
switch ($view) {
case ROOTVIEW:
/*
* @see handler ObjectoryElement-root.php
*/
//
/*
* 1- DirectoryProject
* 2- 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- 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);
//
unset($codificationSetDDL);
unset($codificationSet);
//
$template->assign($this->m_blockSet);
$template->assign($this->m_fieldSet);
//
break;
case FORMVIEW:
/*
* * @see handler ObjectoryElement-form.php
*/
//
/*
* 1- ObjectoryElement
* 2- ObjectoryElementType
* 3- ApplicationCodificationSet
*/
//
/*
* 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);
}
//
if ($element->get_field_value("OBJETYPPKID") == MODEL_TYPE) {
$element->set_field_value("OBJELEMROOT", $element->get_field_value("OBJELEMPKID"));
}
//
$template->assign($element->fieldSet());
//
/*
* 2- ObjectoryElementType Dropdownlist type
*/
//
@include_once (FRAMEWORK_DIR . "htmldropdownlist.php");
@include_once (COMPONENTS_DATA . "data.ObjectoryElementTypeMap.php");
//
$elementTypeMap = new ObjectoryElementTypeMap($element->get_field_value("OBJETYPPKID"));
if ($elementTypeMap->selectSet($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
//
$elementTypeSetDDL = new HTMLDropdownList("type", "formInput");
$this->m_blockSet["OBJELEMTYPE"] = $elementTypeSetDDL->renderObject($datasource, $elementTypeMap);
//
unset($elementTypeSetDDL);
unset($elementTypeMap);
//
/*
* 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, $element->get_field_value("OBJELEMSTAT"));
//
unset($codificationSetDDL);
unset($codificationSet);
//
$template->assign($this->m_blockSet);
//
break;
case ITEMVIEW:
/*
* * @see handler ObjectoryElement-view.php
*/
//
/*
* 1- ObjectoryElement
* 2- ApplicationCodificationSet
* 3- Namespace
* 4- References
* 5- Attributes
* 6- Constraints
* 7- Resources
*/
//
/*
* 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());
//
/*
* 2- 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, $element->get_field_value("OBJELEMSTAT"));
//
unset($codificationSetDDL);
unset($codificationSet);
//
/*
* 3- Namespace
*/
//
$parentElement = new ObjectoryElement($element->get_field_value("OBJELEMLINK"));
if ($parentElement->selectRow($datasource) == true)
$this->m_blockSet["OBJLINKTYPE"] = $parentElement->get_field_value("OBJETYPPKID");
//
if ($element->get_field_value("OBJETYPNASP") == 1) {
// navigation in namespace
@include_once (COMPONENTS_DATA . "data.ObjectoryElementNamespace.php");
//
$namespace = new ObjectoryElementNamespace($element->get_field_value("OBJELEMROOT"));
if ($namespace->selectSet($datasource, REFLECTKEY) == true) {
//
@include_once (COMPONENTS_HTML . "html.ObjectoryElementNamespaceDDL.php");
//
$namespaceDDL = new ObjectoryElementNamespaceDDL("link", "formInput", $element->get_field_value("OBJELEMPKID") , $element->get_field_value("OBJELEMROOT") , $element->get_field_value("OBJETYPPKID"));
$this->m_blockSet["OBJELEMLIST"] = $namespaceDDL->renderObject($datasource, $namespace, $element->get_field_value("OBJELEMLINK"));
}
//
unset($namespace);
unset($namespaceDDL);
} else {
// namespace is parent name
$this->m_blockSet["OBJELEMNASP"] = $parentElement->get_field_value("OBJELEMNAME");
}
//
/*
* 4- References
*/
//
switch ($element->get_field_value("OBJETYPPKID")) {
case PARAMETER_TYPE: // Parameter attribute
case ASSOCIATIONEND_TYPE: // Association end
/*
* 4.1 - ObjectoryReferenceType
*/
//
@include_once (COMPONENTS_DATA . "data.ObjectoryElementReferenceType.php");
//
$referenceType = new ObjectoryElementReferenceType($element->get_field_value("OBJETYPPKID"));
if ($referenceType->selectRow($datasource, FOREIGNKEY) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
/*
* 4.2 - ObjectoryElementReference
*/
//
@include_once (COMPONENTS_DATA . "data.ObjectoryElementReference.php");
//
$reference = new ObjectoryElementReference(0, $this->m_fieldSet["OBJELEMPKID"]);
$reference->selectRow($datasource, FOREIGNKEY);
//
/*
* 4.3 - ObjectoryElementReferenceSetDDL dropdownlist : end1 reference
*/
//
@include_once (COMPONENTS_HTML . "html.ObjectoryElementReferenceSetDDL.php");
//
$referenceSet = NULL;
$referenceSetDDL = new ObjectoryElementReferenceSetDDL(
"end1",
"formInput",
(
($element->get_field_value("OBJETYPPKID") == ASSOCIATIONEND_TYPE)?
$element->get_field_value("OBJELEMROOT") :
$parentElement->get_field_value("OBJELEMLINK")
),
$referenceType->get_field_value("OBJETYPRKEY") ,
$referenceType->get_field_value("OBJETYPLINK"));
$this->m_blockSet["OBJEREFLIST"] = $referenceSetDDL->renderObject(
$datasource,
$referenceSet,
$reference->get_field_value("OBJELEMRFID"));
//
break;
}
//
/*
* 5- ObjectoryElementAttributeValueList
*/
//
switch ($element->get_field_value("OBJETYPPKID")) {
case MODEL_TYPE:
case PACKAGE_TYPE:
case CLASS_TYPE:
case INTERFACE_TYPE:
case ATTRIBUTE_TYPE:
case OPERATION_TYPE:
case ASSOCIATION_TYPE:
//
@include_once (COMPONENTS_VIEW . "view.ObjectoryElementAttributeValueList.php");
//
$attributeList = new ObjectoryElementAttributeValueList();
$attributeList->set_field_value("REPCELTPKID", $element->get_field_value("REPCELTPKID"));
$attributeList->set_field_value("OBJELEMPKID", $element->get_field_value("OBJELEMPKID"));
$attributeList->renderView($datasource, $template, "prop1", "prop1", LISTVIEW, RENDER);
//
break;
}
//
/*
* 6- ObjectoryElementConstraintValueList
*/
//
switch ($element->get_field_value("OBJETYPPKID")) {
case PACKAGE_TYPE:
case CLASS_TYPE:
case INTERFACE_TYPE:
case ATTRIBUTE_TYPE:
case OPERATION_TYPE:
case PARAMETER_TYPE:
case ASSOCIATION_TYPE:
case ASSOCIATIONEND_TYPE:
//
@include_once (COMPONENTS_VIEW . "view.ObjectoryElementConstraintValueList.php");
//
$constraintList = new ObjectoryElementConstraintValueList();
$constraintList->set_field_value("REPMELTPKID", $element->get_field_value("REPMELTPKID"));
$constraintList->set_field_value("OBJELEMPKID", $element->get_field_value("OBJELEMPKID"));
$constraintList->renderView($datasource, $template, "prop2", "prop2", LISTVIEW, RENDER);
//
break;
}
//
/*
* 7- Resources
*/
//
switch ($element->get_field_value("OBJETYPPKID")) {
case MODEL_TYPE:
//
break;
case PACKAGE_TYPE:
case CLASS_TYPE:
//
@include_once (COMPONENTS_DATA . "data.ObjectoryResourceSet.php");
//
$resourceSet = new ObjectoryResourceSet($element->get_field_value("DIRPROJPKID") , DATARESOURCE);
if ($resourceSet->selectSet($datasource, FOREIGNKEY) == true) {
//
for ($i = 0;$i < $resourceSet->rowCount();$i++) {
// select next item
if ($resourceSet->fetchCursorRow($datasource) == false)
return (false);
// render item
$template->select("menu1");
$template->assign($resourceSet->fieldSet());
$template->render("menu1");
}
}
//
break;
}
//
$template->assign($this->m_blockSet);
//
break;
case LISTVIEW:
/*
* @see handler ObjectoryElement-grid.php
*/
//
@include_once (COMPONENTS_DATA . "data.ObjectoryContainedElementSet.php");
//
$containedElementSet = new ObjectoryContainedElementSet($this->m_fieldSet["OBJELEMLINK"]);
if ($containedElementSet->selectSet($datasource, REFLECTKEY, REFLECTKEY) == true) {
//
$template->assign($this->m_fieldSet);
//
for ($i = 0;$i < $containedElementSet->rowCount();$i++) {
// select next row
if ($containedElementSet->fetchCursorRow($datasource) == false) return (false);
//
$template->select($block);
$template->assign($containedElementSet->fieldSet());
$template->render($block);
}
}
//
break;
case TREEVIEW:
/*
* @see class ProjectsExplorer
*/
/*
* 1- ObjectoryElementSet
*/
//
@include_once (COMPONENTS_DATA . "data.ObjectoryElementSet.php");
//
$elementSet = new ObjectoryElementSet($this->m_fieldSet["OBJECTOPKID"]);
if ($elementSet->selectSet($datasource, FOREIGNKEY, FOREIGNKEY) == false) return (false);
//
$template->assign($this->m_fieldSet);
//
for ($i = 0;$i < $elementSet->rowCount();$i++) {
// select next row
if ($elementSet->fetchCursorRow($datasource) == false) return (false);
//
$template->select($block[0]);
$template->assign($elementSet->fieldSet());
// select dependent rows
if ($this->renderTree($datasource, $template, $block[1], $elementSet->get_field_value("OBJELEMPKID")) == false) return (false);
//
$template->render($block[0]);
}
//
break;
}
//
$template->output($mode);
//
return (true);
}
};
// Class
//-------------------------------------------------------------------------
}
// namespace
//-----------------------------------------------------------------------------
?>