<?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.OnlineDataResourceExplorer.php 81 2008-01-17 23:08:21Z yannromefort $
*/
//-----------------------------------------------------------------------------
// namespace
if (!defined("DefOnlineDataResourceExplorer")) {
//-------------------------------------------------------------------------
// Define
define("DefOnlineDataResourceExplorer", "1");
//-------------------------------------------------------------------------
// Include
@require_once (FRAMEWORK_DIR . VIEWHELPER);
//-------------------------------------------------------------------------
// Class
class OnlineDataResourceExplorer extends ViewObject {
//---------------------------------------------------------------------
// Constructor
/**
*
* @param
*
*/
function OnlineDataResourceExplorer() {
//
}
//---------------------------------------------------------------------
// 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 RenderFieldList(&$datasource, &$template, $block, $pkid, $path) {
//
if ($datasource->parseObject($path, "table") == true) {
//
while ($node = $datasource->fetchObject($path, "table")) {
//
$nodeName = $node->m_nodeName;
$typeName = $node->m_typeName;
$nodeType = $node->m_nodeType;
$dataPath = $node->m_dataPath;
$dataType = $node->m_dataType;
$dataSize = $node->m_dataSize;
//
$template->select($block);
$template->assign(array(
NodePkid => $pkid,
NodeName => $nodeName,
TypeName => $typeName,
ItemNode => $nodeType,
DataPath => $dataPath,
DataType => $dataType,
DataSize => $dataSize
));
$template->render($block);
}
}
//
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
*
*/
function renderView(&$datasource, &$template, $layout, $block, $view = NULL, $mode = OUTPUT) {
//
if (!is_object($template)) return (false);
//
if (!empty($layout) && ($template->define($layout) == false)) return (false);
//
$template->assign($this->m_fieldSet);
//
@include_once (FRAMEWORK_DIR . "htmldropdownlist.php");
//
switch ($view) {
case NULLVIEW:
/*
* * @see handler ctrl.OnlineDataQueryManager.php
*/
//
break;
case ITEMVIEW:
/*
* * @see handler ctrl.OnlineDataQueryManager.php
*/
/*
* 1- OnlineResource
*/
// =- select PropertyType on primary key ( OBJRESOPKID )
@include_once (COMPONENTS_DATA . "data.OnlineResource.php");
//
$resource = new OnlineResource($this->m_fieldSet["OBJRESOPKID"]);
if ($resource->selectRow($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
//
$template->assign($resource->fieldSet());
//
break;
case LISTVIEW:
/*
* * @see handler ctrl.OnlineDataQueryManager.php
*/
/*
* 1- OnlineResource
*/
// =- select PropertyType on primary key ( OBJRESOPKID )
@include_once (COMPONENTS_DATA . "data.OnlineResource.php");
//
$resource = new OnlineResource($this->m_fieldSet["OBJRESOPKID"]);
if ($resource->selectRow($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
//
$template->assign($resource->fieldSet());
//
$OBJRURLHOST = $resource->get_field_value("OBJRURLHOST");
$OBJRURLPORT = $resource->get_field_value("OBJRURLPORT");
$OBJRURLUSER = $resource->get_field_value("OBJRURLUSER");
$OBJRURLPASS = $resource->get_field_value("OBJRDECPASS");
$OBJRURLNAME = $resource->get_field_value("OBJRURLNAME");
$DIRRACCCODE = $resource->get_field_value("DIRRACCCODE");
//
if ($DIRRACCCODE == "") return (false);
//
$className = $DIRRACCCODE . "Database";
$classFile = @strtolower($DIRRACCCODE) . ".database.php";
//
@include_once (FRAMEWORK_DIR . $classFile);
if (@class_exists($className) == false) return (false);
//
@set_time_limit(180);
//
$database = new $className($OBJRURLHOST, $OBJRURLPORT, $OBJRURLUSER, $OBJRURLPASS, $OBJRURLNAME);
$datalist = $database->select($this->m_fieldSet["DATAQBETEXT"]);
if ($datalist == NULL) {
//
$this->m_errorSet[DATA_SOURCE_ERROR] = true;
//
return (false);
}
//
$template->assign(DataUuid, @md5(uniqid(rand() , 1)));
// 1- Columns header
while (list($index, $field) = $datalist->get_row_fields()) {
//
$template->select("field");
$template->assign(Field, trim($field));
$template->assign(Ordinal, "$index");
$template->render("field");
}
// 2- Rows lines
$ordinal = 0;
$rowindex = 1;
while (list($index, $row) = $datalist->get_row_values()) {
//
$template->select("list");
//
$colindex = 1;
while (list($field, $value) = @each($row)) {
//
$template->select("value");
$template->assign(Value, trim($value));
$template->assign(Ordinal, "$ordinal");
$template->assign(RowIndex, "$rowindex");
$template->assign(ColIndex, "$colindex");
$template->render("value");
//
$ordinal++;
$colindex++;
}
$template->render("list");
//
$rowindex++;
}
//
break;
case TREEVIEW:
/*
* * @see class ProjectsExplorer
*/
/*
* 1- OnlineResource
* 2- ResourceExplorer
*/
/*
* 1- OnlineResource
*/
//
@include_once (COMPONENTS_DATA . "data.OnlineResource.php");
//
$resource = new OnlineResource($this->m_fieldSet["OBJRESOPKID"]);
if ($resource->selectRow($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
//
$template->assign($resource->fieldSet());
//
/*
* 2- ResourceExplorer
*/
//
$OBJRURLHOST = $resource->get_field_value("OBJRURLHOST");
$OBJRURLPORT = $resource->get_field_value("OBJRURLPORT");
$OBJRURLUSER = $resource->get_field_value("OBJRURLUSER");
$OBJRURLPASS = $resource->get_field_value("OBJRDECPASS");
$OBJRURLNAME = $resource->get_field_value("OBJRURLNAME");
$DIRRACCCODE = $resource->get_field_value("DIRRACCCODE");
//
if ($DIRRACCCODE == "") return (false);
//
$className = $DIRRACCCODE . "Explorer";
$classFile = @strtolower($DIRRACCCODE) . ".explorer.php";
//
@include_once (FRAMEWORK_DIR . $classFile);
if (class_exists($className) == false) return (false);
//
@set_time_limit(180);
//
$dataExplorer = new $className($OBJRURLHOST, $OBJRURLPORT, $OBJRURLUSER, $OBJRURLPASS, $OBJRURLNAME);
if ($dataExplorer->parseObject($OBJRURLNAME, "database") == false) {
//
$this->m_errorSet[DATA_SOURCE_ERROR] = true;
//
return (false);
}
//
$nodePkid = 0;
//
$root = $dataExplorer->getObject($OBJRURLNAME, "database");
if (!empty($root)) {
while ($node = $root->fetchElements($OBJRURLNAME, "database")) {
//
$nodePkid++;
//
$nodeName = $node->m_nodeName;
$typeName = $node->m_typeName;
$nodeType = $node->m_nodeType;
$dataPath = $node->m_dataPath;
$dataType = $node->m_dataType;
$dataSize = $node->m_dataSize;
//
$template->select($block[0]);
//
$template->assign(array(
NodePkid => $nodePkid,
NodeName => $nodeName,
TypeName => $typeName,
ItemNode => $nodeType,
DataPath => $dataPath,
DataType => $dataType,
DataSize => $dataSize
));
//
$this->RenderFieldList($dataExplorer, $template, $block[1], $nodePkid, $dataPath);
//
$template->render($block[0]);
}
}
//
break;
case FRAMEVIEW:
/*
* * @see handler ctrl.OnlineDataQueryManager.php
*/
/*
* 1- ObjectoryResource
*/
// =- select PropertyType on primary key ( OBJRESOPKID )
@include_once (COMPONENTS_DATA . "data.ObjectoryResource.php");
//
$resource = new ObjectoryResource($this->m_fieldSet["OBJRESOPKID"]);
if ($resource->selectRow($datasource) == false) {
//
$this->m_errorSet[VIEW_OBJECT_ERROR] = true;
//
return (false);
}
//
$template->assign($resource->fieldSet());
//
break;
case GRIDVIEW:
/*
* * @see handler ctrl.OnlineDataQueryManager.php
*/
//
break;
}
//
$template->output($mode);
//
return (true);
}
};
// Class
//-------------------------------------------------------------------------
}
// namespace
//-----------------------------------------------------------------------------
?>