<?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.RepositoryCoreComponentExplorer.php 90 2008-01-31 22:02:05Z yannromefort $
*/
//-----------------------------------------------------------------------------
// namespace
if (!defined("DefRepositoryCoreComponentExplorer")) {
//-------------------------------------------------------------------------
// Define
define("DefRepositoryCoreComponentExplorer", "1");
//-------------------------------------------------------------------------
// Include
@require_once (FRAMEWORK_DIR . VIEWHELPER);
//-------------------------------------------------------------------------
// Class
class RepositoryCoreComponentExplorer extends ViewObject {
//---------------------------------------------------------------------
// Constructor
/**
*
* @param integer Repository pkid // foreign key
*
*/
function RepositoryCoreComponentExplorer() {
}
//---------------------------------------------------------------------
// Methods
/*
*
* @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
*
*/
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 FORMVIEW:
/*
* * @see handler RepositoryCoreComponent-form.php
*/
//
/*
* 1- RepositoryCoreComponentType
* 2- ApplicationCodificationSet
*/
//
/*
* 1- RepositoryCoreComponentType
*/
//
@include_once (COMPONENTS_DATA . "data.RepositoryCoreComponentType.php");
//
$componentType = new RepositoryCoreComponentType($this->m_fieldSet["REPCCOTPKID"]);
if ($componentType->selectRow($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
//
$template->assign($componentType->fieldSet());
//
/*
* 2- ApplicationCodificationSet Dropdownlist on status field
*/
//
@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 RepositoryCoreComponent-view.php
*/
//
/*
* 1- RepositoryCoreComponent
* 2- ApplicationCodificationSet
*/
//
/*
* 1- RepositoryCoreComponent
*/
//
@include_once (COMPONENTS_DATA . "data.RepositoryCoreComponent.php");
//
$component = new RepositoryCoreComponent($this->m_fieldSet["REPCCOMPKID"]);
//
if ($component->selectRow($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
//
$template->assign($component->fieldSet());
//
/*
* 2- ApplicationCodificationSet Dropdownlist status
*/
//
@include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
//
$codificationSet = NULL;
$codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
$this->m_blockSet["REPSTATLIST"] = $codificationSetDDL->renderObject($datasource, $codificationSet, $component->get_field_value("REPCCOMSTAT"));
//
unset($codificationSetDDL);
unset($codificationSet);
//
$template->assign($this->m_blockSet);
$template->assign($this->m_fieldSet);
//
/*
* 4- Model Enabled
*/
//
$template->toggle("show", $component->get_field_value("REPCCOTTYPE") == MODEL_ENABLED);
//
break;
case LISTVIEW:
/*
* * @see handler RepositoryCoreComponent-list.php
*/
/*
* 1- RepositoryCoreComponentSet
*/
//
@include_once (COMPONENTS_DATA . "data.RepositoryCoreComponentSet.php");
//
$componentSet = new RepositoryCoreComponentSet($this->m_fieldSet["REPOSITPKID"], $this->m_fieldSet["REPCCOTPKID"]);
if ($componentSet->selectSet($datasource, FOREIGNKEY) == false) return (false);
//
for ($i = 0;$i < $componentSet->rowCount();$i++) {
// select next CoreElementSet row
if ($componentSet->fetchCursorRow($datasource) == false) return (false);
//
$template->select($block);
$template->assign($componentSet->fieldSet());
$template->render($block);
}
//
$template->assign($componentSet->fieldSet());
//
break;
case TREEVIEW:
/*
* @see view.RepositoryExplorer on renderView
*/
//
/*
* 1- RepositoryCoreComponentTypeSet
* 2- RepositoryCoreComponentSet
*/
//
/*
* 1- RepositoryCoreComponentTypeSet
*/
//
@include_once (COMPONENTS_DATA . "data.RepositoryCoreComponentTypeSet.php");
//
$componentTypeSet = new RepositoryCoreComponentTypeSet($this->m_fieldSet["REPOSITPKID"], $this->m_fieldSet["REPTYPEPKID"]);
if ($componentTypeSet->selectSet($datasource, FOREIGNKEY, PRIMARYKEY) == false) return (false);
//
/*
* 2- RepositoryCoreComponentSet
*/
//
@include_once (COMPONENTS_DATA . "data.RepositoryCoreComponentSet.php");
//
for ($i = 0;$i < $componentTypeSet->rowCount();$i++) {
// select next item
if ($componentTypeSet->fetchCursorRow($datasource) == false) return (false);
// render item
$template->select($block[0]);
$template->assign($componentTypeSet->fieldSet());
$template->assign($this->m_fieldSet); // side effect 4 root={REPOSITPKID}
// Render list
$componentSet = new RepositoryCoreComponentSet($this->m_fieldSet["REPOSITPKID"], $componentTypeSet->get_field_value("REPCCOTPKID"));
if ($componentSet->selectSet($datasource) == true) {
//
for ($j = 0;$j < $componentSet->rowCount();$j++) {
// select next item
if ($componentSet->fetchCursorRow($datasource) == false) return (false);
// render item
$template->select($block[1]);
$template->assign($componentSet->fieldSet());
$template->render($block[1]);
}
}
//
$template->render($block[0]);
//
unset($componentSet);
}
//
unset($componentTypeSet);
//
break;
}
//
$template->output($mode);
//
return (true);
}
};
// Class
//-------------------------------------------------------------------------
}
// namespace
//-----------------------------------------------------------------------------
?>