diff --git a/.gitignore b/.gitignore index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..fb23a1f31378cce575900e083e4179591effa425 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,6 @@ +vas/rest/class/* +vas/rest/class/!*/ +vas/rest/class/!*.* +vas/sql/* +vas/sql/!*/ +vas/sql/!*.* diff --git a/_install/client/fileToDelete.txt b/_install/client/fileToDelete.txt new file mode 100644 index 0000000000000000000000000000000000000000..ca3a9114882b45d4b55b25a40380235fc553ceb9 --- /dev/null +++ b/_install/client/fileToDelete.txt @@ -0,0 +1,4 @@ +javascript/externs/formreader/formreader.js +javascript/externs/formreader/formreaderCtrl.js +javascript/externs/formreader/formreaderDrtv.js +javascript/externs/formreader/formreaderSrvc.js \ No newline at end of file diff --git a/_install/client/folderToDelete.txt b/_install/client/folderToDelete.txt new file mode 100644 index 0000000000000000000000000000000000000000..a0e7984dc0bc0ee6987ebffa481549c126c7ef9b --- /dev/null +++ b/_install/client/folderToDelete.txt @@ -0,0 +1,8 @@ +javascript/app +javascript/require +javascript/test +javascript/externs/openLayers/ol +javascript/externs/openLayers/ol.ext +javascript/externs/studio/properties +javascript/externs/studio/javascript +modules/vitis/javascript \ No newline at end of file diff --git a/_install/client/listModuleApache.txt b/_install/client/listModuleApache.txt new file mode 100644 index 0000000000000000000000000000000000000000..2c0309e320b509b2ba74dc5f3ddd6a211245e922 --- /dev/null +++ b/_install/client/listModuleApache.txt @@ -0,0 +1,5 @@ +alias +deflate +headers +rewrite +ssl \ No newline at end of file diff --git a/_install/vas/apache.conf b/_install/vas/apache.conf new file mode 100644 index 0000000000000000000000000000000000000000..2281b2e2673c513df20924e94a224bfa45673fad --- /dev/null +++ b/_install/vas/apache.conf @@ -0,0 +1,70 @@ +PassEnv TEMP +Alias /rest[ENV] "[VASDIRECTORY]/rest" + <Directory "[VASDIRECTORY]/rest"> + <FilesMatch ".+\.ph(p[345]?|t|tml)$"> + SetHandler application/x-httpd-php_vitis[ENV] + </FilesMatch> + AllowOverride FileInfo + Options FollowSymLinks + Require all granted + <Files ~ "\.(map|log|inc|php)$"> + Order allow,deny + Deny from all + </Files> + </Directory> + +Alias /doc[ENV] "[VASDIRECTORY]/doc" + <Directory "[VASDIRECTORY]/doc"> + <FilesMatch ".+\.ph(p[345]?|t|tml)$"> + SetHandler application/x-httpd-php_vitis[ENV] + </FilesMatch> + AllowOverride FileInfo + Options FollowSymLinks + Require all granted + </Directory> + +Alias /public[ENV] "[VASDIRECTORY]/public" + <Directory "[VASDIRECTORY]/public"> + AllowOverride FileInfo + Options FollowSymLinks + Require all granted + <Files ~ "\.(map|inc|php)$"> + Order allow,deny + Deny from all + </Files> + SetHandler application/x-download + </Directory> +Alias /ws_data[ENV] "[VASDIRECTORY]/ws_data" + <Directory "[VASDIRECTORY]/ws_data"> + AllowOverride All + Options FollowSymLinks + Require all granted + <Files ~ "\.(map|log|inc|php)$"> + Order allow,deny + Deny from all + </Files> + SetHandler application/x-download + </Directory> +Alias /proxy[ENV] "[VASDIRECTORY]/util/proxy" + <Directory "[VASDIRECTORY]/util/proxy"> + <FilesMatch ".+\.ph(p[345]?|t|tml)$"> + SetHandler application/x-httpd-php_vitis[ENV] + </FilesMatch> + AllowOverride FileInfo + Options FollowSymLinks + Require all granted + <Files ~ "\.(map|log|inc)$"> + Order allow,deny + Deny from all + </Files> + </Directory> +Alias /printserver[ENV] "[VASDIRECTORY]/util/printserver" + <Directory "[VASDIRECTORY]/util/printserver"> + AllowOverride FileInfo + Options FollowSymLinks + Require all granted + <Files ~ "\.(map|log|inc|php)$"> + Order allow,deny + Deny from all + </Files> + </Directory> \ No newline at end of file diff --git a/_install/vas/listModuleApache.txt b/_install/vas/listModuleApache.txt new file mode 100644 index 0000000000000000000000000000000000000000..c2626d946f4a9bbaad4d7ca16423af23007c0ca3 --- /dev/null +++ b/_install/vas/listModuleApache.txt @@ -0,0 +1,16 @@ +actions +alias +cgi +deflate +headers +ldap +rewrite +ssl +proxy +proxy_ajp +proxy_connect +proxy_fcgi +proxy_ftp +proxy_http +proxy_scgi +proxy_wstunnel \ No newline at end of file diff --git a/client/javascript/externs/formReader/formReaderDrtv.js b/client/javascript/externs/formReader/formReaderDrtv.js index 283bbc430a4b12761af760ab9563956ee0ac3e1e..48e7a37a22b78e1f1154bcaec9471d51e4a1c3a5 100644 --- a/client/javascript/externs/formReader/formReaderDrtv.js +++ b/client/javascript/externs/formReader/formReaderDrtv.js @@ -176,6 +176,8 @@ formReader.formReaderDirective = function ($q, formReaderService, propertiesSrvc } }); }); + } else { + console.error('Error: form not valid'); } }; @@ -711,6 +713,9 @@ formReader.appFormFieldSpecificParamsDrtv = function ($timeout, $translate, prop $(element)["datetimepicker"](oOptions); // Si sélection d'une date : mise à jour du modèle (NE PAS SUPPRIMER!). + $(element).on("dp.hide", function (e) { + scope["oFormValues"][scope["sFormDefinitionName"]][element[0].name] = element[0].value; + }); $(element).on("dp.change", function (e) { scope["oFormValues"][scope["sFormDefinitionName"]][element[0].name] = element[0].value; }); @@ -2151,8 +2156,8 @@ formReader.appSubformGridDrtv = function ($timeout, $translate, propertiesSrvc, // Récupère lélément en sélectionné formReaderService['getWebServiceData'](oFormWebService).then(function (aResult) { - var oSubformDefinition = aResult[0]['bo_json_form']; + var sSubformJSDefinition = aResult[0]['bo_json_form_js']; var oSubformValues = {}; var sModalId = 'formreader_' + scope['sFormUniqueName'] + '_grid_subform_modal'; @@ -2219,7 +2224,7 @@ formReader.appSubformGridDrtv = function ($timeout, $translate, propertiesSrvc, } }); - formReaderService['showModalSubform'](sModalId, oSubformScope, oSubformDefinition, sSubformDefinitionName, oSubformValues); + formReaderService['showModalSubform'](sModalId, oSubformScope, oSubformDefinition, sSubformDefinitionName, oSubformValues, sSubformJSDefinition); }); }; @@ -2247,6 +2252,7 @@ formReader.appSubformGridDrtv = function ($timeout, $translate, propertiesSrvc, }; var sModalId = 'formreader_' + scope['sFormUniqueName'] + '_grid_subform_modal'; var oSubformDefinition = oBusinessObject['json_form'][0]; + var sSubformJSDefinition = oBusinessObject['json_form_js']; var sSubformDefinitionName = 'insert'; // Grise le champ contenant la valeur du parent @@ -2288,7 +2294,7 @@ formReader.appSubformGridDrtv = function ($timeout, $translate, propertiesSrvc, }); }); }; - formReaderService['showModalSubform'](sModalId, oSubformScope, oSubformDefinition, sSubformDefinitionName, oSubformValues); + formReaderService['showModalSubform'](sModalId, oSubformScope, oSubformDefinition, sSubformDefinitionName, oSubformValues, sSubformJSDefinition); }; /** diff --git a/client/javascript/externs/formReader/formReaderSrvc.js b/client/javascript/externs/formReader/formReaderSrvc.js index 6ca6ef291e6a45bdf3b6298b998729bd7abddef5..613652f9c35ccf385e3b72c1c26432d8e0e8a09f 100644 --- a/client/javascript/externs/formReader/formReaderSrvc.js +++ b/client/javascript/externs/formReader/formReaderSrvc.js @@ -1230,15 +1230,15 @@ formReader.formReaderService = function ($translate, $rootScope, $q, $log, $time * @param {object} oSubformDefinition * @param {object} oSubformDefinitionName * @param {object} oSubformValues + * @param {string|null} sSubformJSDefinition */ - "showModalSubform": function (sModalId, oSubformScope, oSubformDefinition, oSubformDefinitionName, oSubformValues) { + "showModalSubform": function (sModalId, oSubformScope, oSubformDefinition, oSubformDefinitionName, oSubformValues, sSubformJSDefinition) { $log.log("showModalSubform"); var sToken = this['sToken']; var oProperties = this['oProperties']; - if (goog.isDefAndNotNull(oSubformScope['loadSubForm'])) { - + var loadForm = function(){ oSubformScope['loadSubForm']({ 'sFormDefinitionName': oSubformDefinitionName, 'oFormDefinition': oSubformDefinition, @@ -1246,6 +1246,30 @@ formReader.formReaderService = function ($translate, $rootScope, $q, $log, $time 'oProperties': oProperties, 'sToken': sToken }); + } + + if (goog.isDefAndNotNull(oSubformScope['loadSubForm'])) { + + if (goog.isDefAndNotNull(sSubformJSDefinition)) { + var sUrl = sSubformJSDefinition; + oVmap.log("initHtmlForm : javascript assoc. to : " + sUrl); + loadExternalJs([sUrl], { + "callback": function () { + loadForm(); + try { + if (goog.isDef(constructor_form)) { + constructor_form(oSubformScope, sUrl); + } + } catch (e) { + oVmap.log("constructor_form does not exist"); + } + }, + "async": true, + "scriptInBody": true + }); + } else { + loadForm(); + } $('#' + sModalId).modal('show'); } diff --git a/vas/doc/index.phtml b/vas/doc/index.phtml index 086cb768856aca4ecc21b4767186d05547388f71..d4fedf02fc3fd79b18c6da0ffab7f8110a02c8e3 100755 --- a/vas/doc/index.phtml +++ b/vas/doc/index.phtml @@ -1,6 +1,9 @@ <?php session_start(); -require_once '../rest/conf/properties.inc'; + +$_SERVER['VAS_PATH'] = pathinfo(dirname($_SERVER['SCRIPT_FILENAME']))['dirname']; + +require_once $_SERVER['VAS_PATH'] . '/rest/conf/properties.inc'; function returnOverview($sFolder, $parent) { $aModules = array(); @@ -17,10 +20,12 @@ function returnOverview($sFolder, $parent) { } } } + return $aModules; } -$aOverview = returnOverview(__DIR__ . "/../rest/ws", ""); +$aOverview = returnOverview($_SERVER['VAS_PATH'] . "/rest/ws", ""); +error_log('$aOverview: '. print_r($aOverview, true)); ?> <!DOCTYPE html> @@ -59,7 +64,7 @@ $aOverview = returnOverview(__DIR__ . "/../rest/ws", ""); sToken = json.PrivateToken.token; } else { sToken = code[0].outerText.split('<token>')[1].split('</token>')[0]; - } + } if (sToken != "") { $("input[name='token']").each(function () { $(this).attr("value", sToken); @@ -154,4 +159,3 @@ foreach ($aOverview as $key => $value) { </div> </body> </html> - diff --git a/vas/doc/swagger.php b/vas/doc/swagger.php index 3437171a291a5f277b6518b72ff0afdd04f8dab5..aca8acffc87a164aedf500bb1f31effd57cf8e5c 100755 --- a/vas/doc/swagger.php +++ b/vas/doc/swagger.php @@ -1,8 +1,9 @@ <?php +$_SERVER['VAS_PATH'] = pathinfo(dirname($_SERVER['SCRIPT_FILENAME']))['dirname']; header('Content-Type: application/json'); -require_once "../rest/conf/properties.inc"; +require_once $_SERVER['VAS_PATH'] . "/rest/conf/properties.inc"; require("vendor/autoload.php"); -$swagger = \Swagger\scan('../rest/ws/'.$_REQUEST['service']); +$swagger = \Swagger\scan($_SERVER['VAS_PATH'] . '/rest/ws/'.$_REQUEST['service']); $aServer = explode("://", $properties["web_server_name"]); $swagger = str_replace("[service_alias]", $properties["services_alias"], $swagger); $swagger = str_replace("[protocol]", $aServer[0], $swagger); diff --git a/vas/rest/index.phtml b/vas/rest/index.phtml index 86af3b21c85db3857e6e5be0ffccaae43e8a50f7..d4b4cffa2cb95cad6d52b949c6476345429ae154 100755 --- a/vas/rest/index.phtml +++ b/vas/rest/index.phtml @@ -1,5 +1,7 @@ <?php +$_SERVER['VAS_PATH'] = pathinfo(dirname($_SERVER['SCRIPT_FILENAME']))['dirname']; + require_once("class/vitis_lib/VitisError.class.inc"); require_once("class/vmlib/cryptUtil.inc"); require_once("conf/properties.inc"); @@ -199,4 +201,4 @@ function customErrorHandler ($errno, $errstr, $errfile, $errline, $context){ } include ("index.vhtml"); -?> \ No newline at end of file +?> diff --git a/vas/rest/ws/vitis/Properties.class.inc b/vas/rest/ws/vitis/Properties.class.inc index d363c98601beb319ee43bce3dd2da87b4d247c80..c7f65b413b16534d0349e47a7b9a0a420d1ba76a 100755 --- a/vas/rest/ws/vitis/Properties.class.inc +++ b/vas/rest/ws/vitis/Properties.class.inc @@ -14,7 +14,7 @@ require_once(__DIR__ . '/../../class/vmlib/BdDataAccess.inc'); * \brief This file contains the Properties php class * * This class defines the rest api for properties - * + * */ class Properties extends Vitis { /** @@ -53,7 +53,7 @@ class Properties extends Vitis { } /** - * @SWG\Get(path="/properties", + * @SWG\Get(path="/properties", * tags={"Properties"}, * summary="Get properties", * description="Request to get properties", @@ -75,7 +75,7 @@ class Properties extends Vitis { */ /** - * + * * @return properties */ function GET() { @@ -85,19 +85,19 @@ class Properties extends Vitis { } else { $this->aFields = $this->aProperties; } - require_once __DIR__ . "/../../conf/version.inc"; + require_once dirname($_SERVER['SCRIPT_FILENAME']) . "/conf/version.inc"; if (VM_STATUS != "STABLE") { $this->aFields['VM_STATUS'] = "UNSTABLE"; } else { $this->aFields['VM_STATUS'] = "STABLE"; - if ($pointeur = opendir(__DIR__ . "/../../conf/")) { + if ($pointeur = opendir(dirname($_SERVER['SCRIPT_FILENAME']) . "/conf/")) { while (($fichier = readdir($pointeur)) !== false) { if (($fichier != '.') && ($fichier != '..')) { - if (is_dir(__DIR__ . "/../../conf/" . $fichier)) { - $sTexte = file_get_contents(__DIR__ . "/../../conf/" . $fichier . "/version.inc"); + if (is_dir(dirname($_SERVER['SCRIPT_FILENAME']) . "/conf/" . $fichier)) { + $sTexte = file_get_contents(dirname($_SERVER['SCRIPT_FILENAME']) . "/conf/" . $fichier . "/version.inc"); if (strpos($sTexte, "define (\"VM_STATUS\", \"STABLE\");") == false) { $this->aFields['VM_STATUS'] = "UNSTABLE"; @@ -216,7 +216,7 @@ class Properties extends Vitis { * description="Poprerties Response", * @SWG\Schema(ref="#/definitions/properties") * ), - * + * * ) */ @@ -299,7 +299,7 @@ class Properties extends Vitis { // Message de retour $aMessage = array('status' => REQUEST_SUCCESS); - // Ouverture de php + // Ouverture de php $sPropertiesFile = PHP_START . PHP_EOL; // Texte à ajouter avant le tableau des properties @@ -343,14 +343,14 @@ class Properties extends Vitis { $sPropertiesFile .= PROPERTIES_FOOTER . PHP_EOL; } - // Fermeture de php + // Fermeture de php $sPropertiesFile .= PHP_END; // Sauve le fichier (LOCK_EX = accés exclusif au fichier) if ($this->aValues['module_name'] == 'vitis') - $sPathProperties = __DIR__ . '/../../conf/properties.inc'; + $sPathProperties = dirname($_SERVER['SCRIPT_FILENAME']) . '/conf/properties.inc'; else - $sPathProperties = __DIR__ . '/../../conf/' . $this->aValues['module_name'] . '/properties.inc'; + $sPathProperties = dirname($_SERVER['SCRIPT_FILENAME']) . '/conf/' . $this->aValues['module_name'] . '/properties.inc'; // if (file_put_contents($sPathProperties, $sPropertiesFile, LOCK_EX) === false) $aReturn = array('status' => 0, 'message' => "FORM_ERROR_FILE_WRITING_CONFIGURATION"); @@ -424,4 +424,4 @@ class Properties extends Vitis { } -?> \ No newline at end of file +?> diff --git a/vas/rest/ws/vitis/Versions.class.inc b/vas/rest/ws/vitis/Versions.class.inc index 62b9cfcc9ef13f02c3b310d0543c4d4228ee40e3..3a20a659f09122d360298d4fcc72dc131f54231b 100755 --- a/vas/rest/ws/vitis/Versions.class.inc +++ b/vas/rest/ws/vitis/Versions.class.inc @@ -1,204 +1,202 @@ -<?php - -require_once 'Vitis.class.inc'; -require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc'; -require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc'; - -/** - * \file versions.class.inc - * \class Versions - * - * \author Yoann Perollet <yoann.perollet@veremes.com>. - * - * \brief This file contains the Versions php class - * - * This class defines the rest api for versions - * - */ -class Versions extends Vitis { - /** - * @SWG\Definition( - * definition="/versions", - * allOf={ - * @SWG\Schema(ref="#/definitions/versions") - * } - * ) - * @SWG\Tag( - * name="Versions", - * description="Operations about versions" - * ) - */ - - /** - * construct - * @param type $aPath url of the request - * @param type $aValues parameters of the request - * @param type $versions ptroperties - */ - function __construct($aPath, $aValues, $properties) { - $this->aValues = $aValues; - $this->aPath = $aPath; - $this->aProperties = $properties; - if (!empty($this->aValues['token'])) { - $this->oConnection = new Connection($this->aValues, $this->aProperties); - } - } - - /** - * @SWG\Get(path="/versions", - * tags={"Versions"}, - * summary="Get versions", - * description="Request to get versions", - * operationId="GET", - * produces={"application/xml", "application/json", "application/x-vm-json"}, - * @SWG\Parameter( - * name="token", - * in="query", - * description="user token", - * required=false, - * type="string" - * ), - * @SWG\Response( - * response=200, - * description="Poprerties Response", - * @SWG\Schema(ref="#/definitions/versions") - * ) - * ) - */ - - /** - * - * @return versions - */ - function GET() { - if ($this->oConnection->oError == null) { - $this->getVersion(); - if (!empty($this->aValues['token']) && in_array("vitis_admin", $this->oConnection->aPrivileges)) { - - //$this->aFields = $this->aVersions; - $this->aFields['php_version'] = phpversion(); - - //*** PDO - $bPdo = false; - if (extension_loaded('pdo')) - $bPdo = true; - else - $bVeremap = false; - $this->aFields['pdo_extension_loaded'] = $bPdo; - - //*** PDO Postgresql - $bPdoPgsql = false; - if (extension_loaded('pdo_pgsql')) - $bPdoPgsql = true; - else - $bVeremap = false; - $this->aFields['pdo_pgsql_extension_loaded'] = $bPdoPgsql; - - //*** Curl - $bCurl = false; - if (extension_loaded('curl')) - $bCurl = true; - else - $bVeremap = false; - $this->aFields['curl_extension_loaded'] = $bCurl; - - //*** Xsl - $bXsl = false; - if (extension_loaded('xsl')) - $bXsl = true; - $this->aFields['xsl_extension_loaded'] = $bXsl; - - //*** Ldap - $bLdap = false; - if (extension_loaded('ldap')) - $bLdap = true; - $this->aFields['ldap_extension_loaded'] = $bLdap; - - // OS. - $this->aFields['os_version'] = php_uname(); - - // Info disque. - $this->aFields['disk_free_space'] = round(disk_free_space("/") / 1073741824) . ' Go'; - $this->aFields['disk_total_space'] = round(disk_total_space("/") / 1073741824) . ' Go'; - - // - $this->aFields['server_software'] = $_SERVER['SERVER_SOFTWARE']; - $this->aFields['server_addr'] = $_SERVER['SERVER_ADDR']; - $this->aFields['server_name'] = $_SERVER['SERVER_NAME']; - $this->aFields['server_port'] = $_SERVER['SERVER_PORT']; - - //** Postgresql et Postgis - $bPostgresql = false; - $bPostgis = false; - if (!$this->oConnection->oBd->erreurRencontree) { - $bPostgresql = true; - $sSql = "SHOW server_version"; - $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, array()); - $oPgVersion = $this->oConnection->oBd->objetSuivant($oPDOresult); - $sPostgresql = $oPgVersion->server_version; - $this->aFields['postgresql_version'] = $sPostgresql; - $this->oConnection->oBd->fermeResultat(); - - $aVersion = explode(".", $sPostgresql); - $bExtension = false; - if ($aVersion[0] >= 9) { - if ($aVersion[1] >= 1) { - $bExtension = true; - } - } - if ($bExtension == true) { - $sSql = "SELECT default_version FROM pg_catalog.pg_available_extensions where name = 'postgis';"; - $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, array()); - if ($aPostgis = $this->oConnection->oBd->ligneSuivante($oPDOresult)) { - $bPostgis = true; - $sPostgis = $aPostgis['default_version']; - } else { - $bPostgis = false; - } - } else { - $sSql = "SELECT datname FROM pg_catalog.pg_database where datname = 'template_postgis_20';"; - $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, array()); - if ($aPostgis = $this->oConnection->oBd->ligneSuivante($oPDOresult)) { - $bPostgis = true; - $sPostgis = '2.0'; - } else { - $bPostgis = false; - } - } - $this->aFields['postgis_version'] = $sPostgis; - $this->oConnection->oBd->fermeResultat(); - $sSql = 'SELECT distinct module_id from [sSchemaFramework].vm_mode'; - $aParams['sSchemaFramework'] = array('value' => $this->aProperties['schema_framework'], 'type' => 'schema_name'); - $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, $aParams); - while ($aLigne = $this->oConnection->oBd->ligneSuivante($oPDOresult)) { - $aModules[] = $aLigne['module_id']; - } - $iRecordset = $this->oConnection->oBd->fermeResultat(); - } - $this->aFields['postgresql'] = $bPostgresql; - $this->aFields['postgis'] = $bPostgis; - - // Recherche de mise à jour - // - if (!empty($this->aValues['app'])) { - $sUrl = "http://update.veremes.net/vai/" . $this->aValues['app'] . ".json"; - $json = file_get_contents($sUrl); - $data = json_decode($json, TRUE); - $this->aFields['appVersion'] = $data['version']; - } - } - $aXmlRacineAttribute['status'] = 1; - $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - } else { - http_response_code(403); - $aXmlRacineAttribute['status'] = 0; - $this->aFields['errorMessage'] = "ERROR : invalid token"; - $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - } - - return $sMessage; - } - -} - +<?php + +require_once 'Vitis.class.inc'; +require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc'; +require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc'; + +/** + * \file versions.class.inc + * \class Versions + * + * \author Yoann Perollet <yoann.perollet@veremes.com>. + * + * \brief This file contains the Versions php class + * + * This class defines the rest api for versions + * + */ +class Versions extends Vitis { + /** + * @SWG\Definition( + * definition="/versions", + * allOf={ + * @SWG\Schema(ref="#/definitions/versions") + * } + * ) + * @SWG\Tag( + * name="Versions", + * description="Operations about versions" + * ) + */ + + /** + * construct + * @param type $aPath url of the request + * @param type $aValues parameters of the request + * @param type $versions ptroperties + */ + function __construct($aPath, $aValues, $properties) { + $this->aValues = $aValues; + $this->aPath = $aPath; + $this->aProperties = $properties; + if (!empty($this->aValues['token'])) { + $this->oConnection = new Connection($this->aValues, $this->aProperties); + } + } + + /** + * @SWG\Get(path="/versions", + * tags={"Versions"}, + * summary="Get versions", + * description="Request to get versions", + * operationId="GET", + * produces={"application/xml", "application/json", "application/x-vm-json"}, + * @SWG\Parameter( + * name="token", + * in="query", + * description="user token", + * required=false, + * type="string" + * ), + * @SWG\Response( + * response=200, + * description="Poprerties Response", + * @SWG\Schema(ref="#/definitions/versions") + * ) + * ) + */ + + /** + * + * @return versions + */ + function GET() { + if ($this->oConnection->oError == null) { + $this->getVersion(); + if (!empty($this->aValues['token']) && in_array("vitis_admin", $this->oConnection->aPrivileges)) { + + //$this->aFields = $this->aVersions; + $this->aFields['php_version'] = phpversion(); + + //*** PDO + $bPdo = false; + if (extension_loaded('pdo')) + $bPdo = true; + else + $bVeremap = false; + $this->aFields['pdo_extension_loaded'] = $bPdo; + + //*** PDO Postgresql + $bPdoPgsql = false; + if (extension_loaded('pdo_pgsql')) + $bPdoPgsql = true; + else + $bVeremap = false; + $this->aFields['pdo_pgsql_extension_loaded'] = $bPdoPgsql; + + //*** Curl + $bCurl = false; + if (extension_loaded('curl')) + $bCurl = true; + else + $bVeremap = false; + $this->aFields['curl_extension_loaded'] = $bCurl; + + //*** Xsl + $bXsl = false; + if (extension_loaded('xsl')) + $bXsl = true; + $this->aFields['xsl_extension_loaded'] = $bXsl; + + //*** Ldap + $bLdap = false; + if (extension_loaded('ldap')) + $bLdap = true; + $this->aFields['ldap_extension_loaded'] = $bLdap; + + // OS. + $this->aFields['os_version'] = php_uname(); + + // Info disque. + $this->aFields['disk_free_space'] = round(disk_free_space("/") / 1073741824) . ' Go'; + $this->aFields['disk_total_space'] = round(disk_total_space("/") / 1073741824) . ' Go'; + + // + $this->aFields['server_software'] = $_SERVER['SERVER_SOFTWARE']; + $this->aFields['server_addr'] = $_SERVER['SERVER_ADDR']; + $this->aFields['server_name'] = $_SERVER['SERVER_NAME']; + $this->aFields['server_port'] = $_SERVER['SERVER_PORT']; + + //** Postgresql et Postgis + $bPostgresql = false; + $bPostgis = false; + if (!$this->oConnection->oBd->erreurRencontree) { + $bPostgresql = true; + $sSql = "SHOW server_version"; + $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, array()); + $oPgVersion = $this->oConnection->oBd->objetSuivant($oPDOresult); + $sPostgresql = $oPgVersion->server_version; + $this->aFields['postgresql_version'] = $sPostgresql; + $this->oConnection->oBd->fermeResultat(); + + $aVersion = explode(".", $sPostgresql); + $bExtension = false; + if ($aVersion[0] . $aVersion[1] >= 91) { + $bExtension = true; + } + if ($bExtension == true) { + $sSql = "SELECT default_version FROM pg_catalog.pg_available_extensions where name = 'postgis';"; + $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, array()); + if ($aPostgis = $this->oConnection->oBd->ligneSuivante($oPDOresult)) { + $bPostgis = true; + $sPostgis = $aPostgis['default_version']; + } else { + $bPostgis = false; + } + } else { + $sSql = "SELECT datname FROM pg_catalog.pg_database where datname = 'template_postgis_20';"; + $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, array()); + if ($aPostgis = $this->oConnection->oBd->ligneSuivante($oPDOresult)) { + $bPostgis = true; + $sPostgis = '2.0'; + } else { + $bPostgis = false; + } + } + $this->aFields['postgis_version'] = $sPostgis; + $this->oConnection->oBd->fermeResultat(); + $sSql = 'SELECT distinct module_id from [sSchemaFramework].vm_mode'; + $aParams['sSchemaFramework'] = array('value' => $this->aProperties['schema_framework'], 'type' => 'schema_name'); + $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, $aParams); + while ($aLigne = $this->oConnection->oBd->ligneSuivante($oPDOresult)) { + $aModules[] = $aLigne['module_id']; + } + $iRecordset = $this->oConnection->oBd->fermeResultat(); + } + $this->aFields['postgresql'] = $bPostgresql; + $this->aFields['postgis'] = $bPostgis; + + // Recherche de mise à jour + // + if (!empty($this->aValues['app'])) { + $sUrl = "http://update.veremes.net/vai/" . $this->aValues['app'] . ".json"; + $json = file_get_contents($sUrl); + $data = json_decode($json, TRUE); + $this->aFields['appVersion'] = $data['version']; + } + } + $aXmlRacineAttribute['status'] = 1; + $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); + } else { + http_response_code(403); + $aXmlRacineAttribute['status'] = 0; + $this->aFields['errorMessage'] = "ERROR : invalid token"; + $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); + } + + return $sMessage; + } + +} + ?> \ No newline at end of file diff --git a/vas/util/printserver/client/map/map.js b/vas/util/printserver/client/map/map.js index 2a870d9a00d0935c5b31cc776ac42210b8d84ed9..d6dcd882b6e15b31919e02a1799a6bb2b0212263 100755 --- a/vas/util/printserver/client/map/map.js +++ b/vas/util/printserver/client/map/map.js @@ -7,7 +7,7 @@ PrintMap = function (opt_options) { var this_ = this; - + this.mapSize = [document.getElementById('map').offsetWidth, document.getElementById('map').offsetHeight]; this.tileSize = (isDef(window.oProperties.print.tile_size) && window.oProperties.print.features_zoom >= 0) ? window.oProperties.print.tile_size : 2048; @@ -29,7 +29,7 @@ PrintMap = function (opt_options) { this.mapJsonParser = new MapJSON({ 'properties': window.oProperties }); - + this.view = this.mapJsonParser.getViewFromDef(this.mapDefinition, { 'size': this.mapSize, 'tileSize': [this.tileSize, this.tileSize] @@ -39,13 +39,13 @@ PrintMap = function (opt_options) { this.extent = this.getExtent(opt_options); - this.tileGrid = this.getTileGridFromDefinition(this.tileSize); - + this.tileGrid = this.getTileGridFromDefinition(this.tileSize); + this.layers = this.mapJsonParser.getLayersFromDef(this.mapDefinition, { 'size': this.mapSize, 'tileSize': [this.tileSize, this.tileSize] }); - + this.map = this.setMap(this.layers, this.view); this.featuresOverlay = this.setFeaturesOverlay(this.map); @@ -63,6 +63,9 @@ PrintMap = function (opt_options) { // Supprime tous les controls par défaut this.removeMapControls(); + // Taille des icones en fonction de la résolution demandée + this.setMapSymbolsResolution(this.map, this.resolutionCoeff) + // Si aucune étendue a été donnée et que seul un point a été donné, alors zoom sur this.defaultScale if (!isDef(opt_options.extent) && !isDef(this.features)) { if (this.features.length === 1 && this.features[0].getGeometry().getType() === 'Point') { @@ -310,7 +313,7 @@ PrintMap.prototype.getFeaturesFromEWKT = function (aEWKTFeatures) { }; /** - * Return true if EWKTGeom is an EWKT geometry + * Return true if EWKTGeom is an EWKT geometry * @param {string} EWKTGeom * @returns {boolean} */ @@ -367,4 +370,21 @@ PrintMap.prototype.getGeomFromEWKT = function (EWKTGeom, proj) { return null; } -}; \ No newline at end of file +}; + +/** + * For WMS layers set MAP.RESOLUTION and MAP.DEFRESOLUTION to rise the symbols size + * + * @param {object} olMap + * @param {integer} resolutionCoeff + */ +PrintMap.prototype.setMapSymbolsResolution = function (olMap, resolutionCoeff) { + + var newRes = resolutionCoeff * 72; + var aLayers = olMap.getLayers().getArray(); + for (var i = 0; i < aLayers.length; i++) { + if (aLayers[i].get('type') === 'imagewms' || aLayers[i].get('type') === 'tilewms') { + aLayers[i].getSource().updateParams({'MAP.RESOLUTION': newRes, 'MAP.DEFRESOLUTION': 72}); + } + } +}