<?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.OnlineDataResourceExporter.php 94 2008-02-03 23:35:48Z yannromefort $
*/
//-----------------------------------------------------------------------------
// namespace
if (!defined("DefOnlineDataResourceExporter")) {
//-------------------------------------------------------------------------
// Define
define("DefOnlineDataResourceExporter", "1");
define(PANEVIEW, 20);
//-------------------------------------------------------------------------
// Include
@require_once (FRAMEWORK_DIR . VIEWHELPER);
//-------------------------------------------------------------------------
// Class
class OnlineDataResourceExporter extends ViewObject {
//---------------------------------------------------------------------
// Constructor
/**
*
* @param
*
*/
function OnlineDataResourceExporter() {
//
}
//---------------------------------------------------------------------
// 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);
//
@include_once (FRAMEWORK_DIR . "htmldropdownlist.php");
//
switch ($view) {
case ITEMVIEW:
/*
* * @see handler ctrl.OnlineDataResourceExport-view.php
*/
/*
* 1- ObjectoryElement
* 2- ObjectoryResource
*/
//
/*
* 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- ObjectoryResource
*/
//
@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());
//
switch ($this->m_fieldSet["TMPTYPENAME"]) {
case "table":
//
if ($element->get_field_value("OBJETYPPKID") == PACKAGE_TYPE) $template->assign($this->m_fieldSet);
//
break;
case "field":
//
if ($element->get_field_value("OBJETYPPKID") == CLASS_TYPE) $template->assign($this->m_fieldSet);
//
break;
}
//
break;
case TREEVIEW:
/*
* * @see class OnlineDataResourceExport-tree
*/
//
/*
* 1- OnlineResource
* 2- ObjectoryElement
* 3- ResourceExplorer
*/
//
/*
* 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());
//
/*
* 2- 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);
}
//
$this->m_fieldSet["OBJLINKPKID"] = $element->get_field_value("OBJELEMPKID");
$this->m_fieldSet["OBJLINKTYPE"] = $element->get_field_value("OBJETYPPKID");
//
$template->assign($this->m_fieldSet);
//
/*
* 3- 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) {
//
$this->m_errorSet[DATA_SOURCE_ERROR] = true;
//
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.OnlineDataResourceExport-frame
*/
//
/*
* 1- ObjectoryElement
* 2- ObjectoryResource
*/
//
/*
* 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- ObjectoryResource
*/
//
@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());
//
$template->assign($this->m_fieldSet);
//
break;
case MENUVIEW:
/*
* * @see handler ctrl.OnlineDataResourceExport-menu
*/
//
/*
* 1- ObjectoryElement
* 2- ObjectoryResource
* 3- TemporaryElementSet
*/
//
/*
* 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- ObjectoryResource
*/
//
@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());
//
$template->assign($this->m_fieldSet);
/*
* 3- TemporaryElementSet
*/
//
@include_once (COMPONENTS_DATA . "data.TemporaryElementSet.php");
//
$elementSet = new TemporaryElementSet($element->get_field_value("OBJELEMPKID"));
if ($elementSet->selectSet($datasource) == true) $template->toggle("proc", true);
//
break;
case PANEVIEW:
/*
* * @see handler ctrl.OnlineDataResourceExport-pane
*/
//
/*
* 1- ObjectoryElement
* 2- ObjectoryResource
* 3- TemporaryElementSet
* 4- OnlineResource
* 5-
*/
//
/*
* 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- ObjectoryResource
*/
//
@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());
//
$template->assign($this->m_fieldSet);
//
/*
* 3- Procedure step
*/
switch ($this->m_fieldSet["TMPPROCSTEP"]) {
case 0: // delete all temporary tables
/*
* 3.0.1- TemporaryElementSet
*/
//
@include_once (COMPONENTS_DATA . "data.TemporaryElementSet.php");
// Multi-tables DELETE Query in TemporaryElementSet
$elementSet = new TemporaryElementSet($element->get_field_value("OBJELEMPKID"));
$elementSet->deleteSet($datasource);
//
break;
case 1: // insert a model in temporary tables
/*
* 3.1.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);
}
//
$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) {
//
$this->m_errorSet[DATA_SOURCE_ERROR] = true;
//
return (false);
}
//
@set_time_limit(180);
//
$TMPNODENAME = $this->m_fieldSet["TMPNODENAME"];
$TMPTYPENAME = $this->m_fieldSet["TMPTYPENAME"];
$TMPNODEPATH = $this->m_fieldSet["TMPNODEPATH"];
//
$dataExplorer = new $className($OBJRURLHOST, $OBJRURLPORT, $OBJRURLUSER, $OBJRURLPASS, $OBJRURLNAME);
//
if ($dataExplorer->parseObject($TMPNODEPATH, $TMPTYPENAME) == false) {
//
$this->m_errorSet[DATA_SOURCE_ERROR] = true;
//
return (false);
}
//
$directory = $dataExplorer->getObject($TMPNODEPATH, $TMPTYPENAME);
if (!isset($directory)) {
//
$this->m_errorSet[DATA_SOURCE_ERROR] = true;
//
return (false);
}
//
/*
* 3.1.2- OnlineDataResourceToTemporaryImport
*/
//
$element->set_field_value("OBJELEMNAME", $this->m_fieldSet["TMPPREFNAME"]);
$element->set_field_value("OBJELEMCODE", $this->m_fieldSet["TMPPREFCODE"]);
$element->set_field_value("OBJELEMINAM", $this->m_fieldSet["TMPPREFINAM"]);
//
@include_once (COMPONENTS_PROC . "proc.OnlineDataResourceToTemporaryImport.php");
//
$importator = new OnlineDataResourceToTemporaryImport();
$importator->set_option_value("USEPREFNAME", $this->m_fieldSet["USEPREFNAME"]);
$importator->set_option_value("USEPREFCODE", $this->m_fieldSet["USEPREFCODE"]);
$importator->set_option_value("USEPREFINAM", $this->m_fieldSet["USEPREFINAM"]);
if ($importator->import(
$datasource,
$directory,
$resource->fieldSet(),
$element->fieldSet()) == false) {
//
$this->m_errorSet[PROC_OBJECT_ERROR] = true;
//
return (false);
}
//
break;
}
//
break;
}
//
$template->output($mode);
//
return (true);
}
};
// Class
//-------------------------------------------------------------------------
}
// namespace
//-----------------------------------------------------------------------------
?>