[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [6857] Added a new UI class for BIM
From: |
Petur Thorsteinsson |
Subject: |
[Fmsystem-commits] [6857] Added a new UI class for BIM |
Date: |
Thu, 27 Jan 2011 08:28:59 +0000 |
Revision: 6857
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6857
Author: peturbjorn
Date: 2011-01-27 08:28:59 +0000 (Thu, 27 Jan 2011)
Log Message:
-----------
Added a new UI class for BIM
Modified Paths:
--------------
branches/dev-bim2/property/inc/class.menu.inc.php
Added Paths:
-----------
branches/dev-bim2/property/inc/class.uibim.inc.php
Modified: branches/dev-bim2/property/inc/class.menu.inc.php
===================================================================
--- branches/dev-bim2/property/inc/class.menu.inc.php 2011-01-27 08:27:26 UTC
(rev 6856)
+++ branches/dev-bim2/property/inc/class.menu.inc.php 2011-01-27 08:28:59 UTC
(rev 6857)
@@ -944,7 +944,7 @@
),
'showModels' => array
(
- 'url' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
'property.uiitem.showModels')),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
'property.uibim.showModels')),
'text' => lang('Show Models')
),
'ifc' => array
@@ -954,8 +954,8 @@
),
'upload' => array
(
- 'url' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
'property.uiitem.upload')),
- 'text' => lang('Upload'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
'property.uibim.upload')),
+ 'text' => lang('Upload Model'),
'image' => array('property',
'project_tenant_claim')
)
))
Added: branches/dev-bim2/property/inc/class.uibim.inc.php
===================================================================
--- branches/dev-bim2/property/inc/class.uibim.inc.php
(rev 0)
+++ branches/dev-bim2/property/inc/class.uibim.inc.php 2011-01-27 08:28:59 UTC
(rev 6857)
@@ -0,0 +1,280 @@
+<?php
+phpgw::import_class('phpgwapi.yui');
+phpgw::import_class('property.soitem');
+phpgw::import_class('property.sobim');
+phpgw::import_class('property.sovfs');
+phpgw::import_class('property.sobimmodel');
+phpgw::import_class('property.sobim_converter');
+phpgw::import_class('property.soitem_group');
+phpgw::import_class('property.bobimmodel');
+/*
+ * This class serves as the 'Controller' or 'Container' in a dependancy
injection context
+ */
+interface uibim {
+
+}
+class property_uibim implements uibim {
+ public static $virtualFileSystemPath = "ifc";
+ private $db;
+ /* @var $bocommon property_bocommon */
+ private $bocommon;
+
+ public function __construct() {
+ $this->bocommon = CreateObject('property.bocommon');
+
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
+ $GLOBALS['phpgw_info']['flags']['menu_selection'] =
'property::item::index';
+ $this->db = & $GLOBALS['phpgw']->db;
+ }
+
+ public $public_functions = array
+ (
+ 'index' => true,
+ 'foo' => true,
+ 'showModels' => true,
+ 'getModelsJson' => true,
+ 'removeModelJson' => true,
+ 'getFacilityManagementXmlByModelId' => true,
+ 'upload' => true,
+ 'uploadFile' => true,
+ 'testdata' => true,
+ 'ifc' => true,
+ 'emptydb' => true
+ );
+ private function setupBimCss() {
+ if ( !isset($GLOBALS['phpgw']->css) ||
!is_object($GLOBALS['phpgw']->css) ) {
+ $GLOBALS['phpgw']->css = createObject('phpgwapi.css');
+ }
+
$GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/bim.css');
+ }
+ public function getModelsJson() {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
+ header("Content-type: application/json");
+ $bobimmodel = new bobimmodel_impl();
+ $sobimmodel = new sobimmodel_impl($this->db);
+ $bobimmodel->setSobimmodel($sobimmodel);
+ $output = $bobimmodel->createBimModelList();
+ echo json_encode($output);
+ }
+ /*
+ *
+ */
+ public function removeModelJson($modelId = null) {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
+ header("Content-type: application/json");
+ $output = array();
+ $output["result"] = 1;
+ if($modelId == null) {
+ $modelId = (int) phpgw::get_var("modelId");
+ }
+
+ $bobimmodel = new bobimmodel_impl();
+ $sovfs = new sovfs_impl();
+ $sovfs->setSubModule(self::$virtualFileSystemPath);
+ $bobimmodel->setVfsObject($sovfs);
+ $sobimmodel = new sobimmodel_impl($this->db);
+ $sobimmodel->setModelId($modelId);
+ $bobimmodel->setSobimmodel($sobimmodel);
+ try {
+ $bobimmodel->removeIfcModelByModelId();
+ echo json_encode($output);
+ } catch (InvalidArgumentException $e) {
+ $output["result"] = 0;
+ $output["error"] = "Invalid arguments";
+ $output["exception"] = $e;
+ echo json_encode($output);
+ } catch (ModelDoesNotExistException $e) {
+ $output["result"] = 0;
+ $output["error"] = "Model does not exist!";
+ $output["exception"] = $e;
+ echo json_encode($output);
+ } catch (Exception $e) {
+ $output["result"] = 0;
+ $output["error"] = "General error";
+ $output["exception"] = $e;
+ echo json_encode($output);
+ }
+ }
+
+ public function getFacilityManagementXmlByModelId($modelId = null) {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
+ header("Content-type: application/xml");
+ $restUrl =
"http://localhost:8080/BIM_Facility_Management/rest/uploadIfc";
+ if($modelId == null) {
+ $modelId = (int) phpgw::get_var("modelId");
+ }
+ echo "ModelId is:".$modelId;
+ $bobimmodel = new bobimmodel_impl();
+ $sovfs = new sovfs_impl();
+ $sovfs->setSubModule(self::$virtualFileSystemPath);
+ $bobimmodel->setVfsObject($sovfs);
+ $sobimmodel = new sobimmodel_impl($this->db);
+ $sobimmodel->setModelId($modelId);
+ $bobimmodel->setSobimmodel($sobimmodel);
+ $ifcFileWithRealPath =
$bobimmodel->getIfcFileNameWithRealPath();
+ $xmlResult =
$this->getFacilityManagementXmlFromIfc($ifcFileWithRealPath);
+
+ $bobimitem = new bobimitem_impl();
+ $bobimitem->setModelId($modelId);
+ $bobimitem->setIfcXml($xmlResult);
+ $bobimitem->setSobimitem(new sobimitem_impl($this->db));
+ $bobimitem->setSobimtype(new sobimtype_impl($this->db));
+
+ $bobimitem->loadIfcItemsIntoDatabase();
+
+ }
+
+ private function getFacilityManagementXmlFromIfc($fileWithPath) {
+ $sobim_converter = new sobim_converter_impl();
+ $sobim_converter->setFileToSend($fileWithPath);
+ try {
+ $returnedXml =
$sobim_converter->getFacilityManagementXml();
+ $sxe = simplexml_load_string($returnedXml);
+ return $sxe;
+ } catch ( Exception $e) {
+ echo $e;
+ }
+ }
+
+ public function showModels() {
+ $GLOBALS['phpgw']->js->validate_file( 'yahoo', 'bim.modellist',
'property' );
+ /*$GLOBALS['phpgw_info']['flags']['noheader'] = false;
+ $GLOBALS['phpgw_info']['flags']['nofooter'] = false;
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
+ $GLOBALS['phpgw']->common->phpgw_header(true);*/
+
+
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array('bim_showmodels'));
+ $bobimmodel = new bobimmodel_impl();
+ $sobimmodel = new sobimmodel_impl($this->db);
+ $bobimmodel->setSobimmodel($sobimmodel);
+ $output = $bobimmodel->createBimModelList();
+ $loadingImage =
$GLOBALS['phpgw']->common->find_image('property', 'ajaxLoader.gif');
+ $data = array (
+ 'models' => $output,
+ 'loadingImage' => $loadingImage
+ );
+ $GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('modelData'
=> $data));
+ $this->setupBimCss();
+ // echo '<script type="text/javascript"
src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script>';
+ $ble = <<<HTML
+ <script>YUI().use("event-delegate", function(Y) {
+
+ Y.delegate("click", function(e) {
+
+ // The list item that matched the provided selector is the
+ // default 'this' object
+ Y.log("Default scope: " + this.get("id"));
+
+ // The list item that matched the provided selector is
+ // also available via the event's currentTarget property
+ // in case the 'this' object is overridden in the subscription.
+ Y.log("Clicked list item: " + e.currentTarget.get("id"));
+
+ // The actual click target, which could be the matched item or a
+ // descendant of it.
+ Y.log("Event target: " + e.target);
+
+ // The delegation container is added to the event facade
+ Y.log("Delegation container: " + e.container.get("id"));
+
+
+ }, "#container44", "li");
+
+});</script>
+HTML;
+
+ $someOutput = '<div id="container44"><ul id="list"><li
id="li-1">List Item 1</li>
+ <li id="li-2">List Item 2</li>
+ <li id="li-3">List Item 3</li>
+ <li id="li-4">List Item 4</li>
+ <li id="li-5">List Item 5</li>
+ </ul>
+ </div> <script>doDelegate()</script>';
+ }
+
+ private $form_upload_field_filename ="ifc_file_name";
+ private $form_upload_field_modelname ="ifc_model_name";
+
+ public function upload() {
+ $GLOBALS['phpgw']->xslttpl->add_file(array('bim_upload_ifc'));
+
+ $import_action =
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
'property.uibim.uploadFile', 'id'=> $id));
+ $data = array
+ (
+ 'importfile'
=> $importfile,
+ 'values'
=> $content,
+ 'form_field_modelname' =>
$this->form_upload_field_modelname,
+ 'form_field_filename' =>
$this->form_upload_field_filename,
+ 'import_action'
=> $import_action,
+ 'lang_import_statustext' =>
lang('import to this location from spreadsheet'),
+ 'lang_import'
=> lang('import'),
+ 'lang_cancel'
=> lang('cancel')
+ );
+ $GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('upload' =>
$data));
+ $this->setupBimCss();
+ }
+
+
+ public function uploadFile($uploadedFileArray = null, $modelName =
null, $unitTest = false) {
+ if(!$unitTest) {
+
$GLOBALS['phpgw']->xslttpl->add_file(array('bim_upload_ifc_result'));
+ }
+
+ if(!$uploadedFileArray) {
+ $uploadedFileArray =
$_FILES[$this->form_upload_field_filename];
+ }
+ if(!$modelName) {
+ $modelName =
phpgw::get_var($this->form_upload_field_modelname);
+ }
+ $returnValue = array();
+
+ $filename = $uploadedFileArray['name'];
+ $filenameWithPath = $uploadedFileArray['tmp_name'];
+ $bobimmodel = new bobimmodel_impl();
+ $sovfs = new sovfs_impl($filename, $filenameWithPath,
self::$virtualFileSystemPath);
+ $bobimmodel->setVfsObject($sovfs);
+ $sobimmodel = new sobimmodel_impl($this->db);
+ $bobimmodel->setSobimmodel($sobimmodel);
+ $bobimmodel->setModelName($modelName);
+ $errorMessage = "";
+ $error = false;
+ try {
+ $bobimmodel->addUploadedIfcModel();
+
+ } catch (FileExistsException $e) {
+ $error = true;
+ $errorMessage = "Filename in use! \n Try renaming the
file";
+ if($unitTest) {
+ throw $e;
+ }
+ } catch (Exception $e) {
+ $error = true;
+ $errorMessage = $e->getMessage();
+ if($unitTest) {
+ throw $e;
+ }
+ }
+
+
+ $link_to_models =
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
'property.uibim.showModels'));
+ $link_to_upload =
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
'property.uibim.upload'));
+ $data = array
+ (
+ 'modelName'
=> $modelName,
+ 'error'
=> $error,
+ 'errorMessage'
=> $errorMessage,
+ 'linkToModels'
=> $link_to_models,
+ 'linkToUpload'
=> $link_to_upload
+ );
+
+ if(!$unitTest) {
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('uploadResult' => $data));
+ }
+
+ return $data;
+ }
+
+
+}
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [6857] Added a new UI class for BIM,
Petur Thorsteinsson <=