diff --git a/.php_cs.cache b/.php_cs.cache new file mode 100644 index 00000000..6c1b5a49 --- /dev/null +++ b/.php_cs.cache @@ -0,0 +1 @@ +{"php":"7.4.3","version":"2.16.4","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":{"allow_single_line_closure":true},"class_definition":{"single_line":true},"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"long"},"binary_operator_spaces":true,"blank_line_after_opening_tag":true,"blank_line_before_statement":true,"cast_spaces":true,"class_attributes_separation":{"elements":["method"]},"concat_space":true,"declare_equal_normalize":true,"function_typehint_space":true,"include":true,"increment_style":true,"lowercase_cast":true,"lowercase_static_reference":true,"magic_constant_casing":true,"magic_method_casing":true,"native_function_casing":true,"native_function_type_declaration_casing":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":true,"no_leading_import_slash":true,"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"allow_mixed":true,"allow_unused_params":true},"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":true,"no_unneeded_curly_braces":{"namespaces":true},"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"no_whitespace_in_blank_line":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"ordered_imports":true,"php_unit_fqcn_annotation":true,"phpdoc_align":{"tags":["method","param","property","return","throws","type","var"]},"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":true,"phpdoc_var_without_name":true,"return_type_declaration":true,"semicolon_after_instruction":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_line_comment_style":true,"single_quote":true,"single_trait_insert_per_statement":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"ternary_operator_spaces":true,"trailing_comma_in_multiline_array":true,"trim_array_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":{"always_move_variable":false,"equal":false,"identical":false,"less_and_greater":null},"align_multiline_comment":true,"array_indentation":true,"combine_consecutive_issets":true,"combine_consecutive_unsets":true,"compact_nullable_typehint":true,"escape_implicit_backslashes":true,"explicit_indirect_variable":true,"explicit_string_variable":true,"fully_qualified_strict_types":true,"heredoc_to_nowdoc":true,"method_chaining_indentation":true,"multiline_comment_opening_closing":true,"multiline_whitespace_before_semicolons":{"strategy":"new_line_for_chained_calls"},"no_alternative_syntax":true,"no_binary_string":true,"no_null_property_initialization":true,"no_short_echo_tag":true,"no_superfluous_elseif":true,"no_useless_else":true,"no_useless_return":true,"php_unit_internal_class":true,"php_unit_method_casing":true,"php_unit_ordered_covers":true,"php_unit_test_class_requires_covers":true,"phpdoc_add_missing_param_annotation":true,"phpdoc_no_empty_return":true,"phpdoc_order":true,"phpdoc_var_annotation_correct_order":true,"return_assignment":true,"no_unneeded_final_method":true},"hashes":{"mapBuilder\/zones\/list_mapcontext.zone.php":3680687115,"mapBuilder\/install\/upgrade_acl.php":3190192383,"mapBuilder\/install\/upgrade_toggleattributetable.php":3302829116,"mapBuilder\/install\/upgrade.php":1187839691,"mapBuilder\/install\/conf\/mapBuilder.ini.php":2668770549,"mapBuilder\/install\/upgrade_createtable.php":3503491225,"mapBuilder\/install\/install.php":3467583771,"mapBuilder\/classes\/mapBuilderView.listener.php":66970557,"mapBuilder\/classes\/listBaseLayer.class.php":2559677211,"mapBuilder\/classes\/listRepositories.class.php":713607706,"mapBuilder\/controllers\/mapcontext.classic.php":2158702172,"mapBuilder\/controllers\/default.classic.php":1609143851}} \ No newline at end of file diff --git a/mapBuilder/classes/listBaseLayer.class.php b/mapBuilder/classes/listBaseLayer.class.php index 56c2f543..1ea78439 100644 --- a/mapBuilder/classes/listBaseLayer.class.php +++ b/mapBuilder/classes/listBaseLayer.class.php @@ -1,44 +1,43 @@ -formId = $id; - - $this->data = array( - 'osmMapnik' => 'OSM Mapnik', - 'osmStamenToner' => 'OSM Stamen Toner', - 'osmCyclemap' => 'OSM Cyclemap', - 'bingStreets' => 'Bing Streets', - 'bingSatellite' => 'Bing Satellite', - 'bingHybrid' => 'Bing Hybrid', - 'ignTerrain' => 'IGN Terrain', - 'ignStreets' => 'IGN Streets', - 'ignSatellite' => 'IGN Satellite', - 'ignCadastral' => 'IGN Cadastral', - 'emptyBaselayer' => jLocale::get('view~dictionnary.baselayer.empty.title') - ); - } - - public function getData($form) - { - return ($this->data); - } - - public function getLabel($key) - { - if(isset($this->data[$key])) - return $this->data[$key]; - else - return null; - } - + protected $formId = 0; + + protected $data = array(); + + public function __construct($id) + { + $this->formId = $id; + + $this->data = array( + 'osmMapnik' => 'OSM Mapnik', + 'osmStamenToner' => 'OSM Stamen Toner', + 'osmCyclemap' => 'OSM Cyclemap', + 'bingStreets' => 'Bing Streets', + 'bingSatellite' => 'Bing Satellite', + 'bingHybrid' => 'Bing Hybrid', + 'ignTerrain' => 'IGN Terrain', + 'ignStreets' => 'IGN Streets', + 'ignSatellite' => 'IGN Satellite', + 'ignCadastral' => 'IGN Cadastral', + 'emptyBaselayer' => jLocale::get('view~dictionnary.baselayer.empty.title'), + ); + } + + public function getData($form) + { + return $this->data; + } + + public function getLabel($key) + { + if (isset($this->data[$key])) { + return $this->data[$key]; + } + + return null; + } } -?> \ No newline at end of file diff --git a/mapBuilder/classes/listRepositories.class.php b/mapBuilder/classes/listRepositories.class.php index d8cd7c43..b0fdaf6e 100644 --- a/mapBuilder/classes/listRepositories.class.php +++ b/mapBuilder/classes/listRepositories.class.php @@ -1,41 +1,40 @@ -formId = $id; + public function __construct($id) + { + $this->formId = $id; - $repositories = array(); + $repositories = array(); - foreach (lizmap::getRepositoryList() as $repositoryName) { - $repository = lizmap::getRepository($repositoryName); - if( jAcl2::check('lizmap.repositories.view', $repository->getKey() )){ - $repositories[$repository->getKey()] = $repository->getData('label'); + foreach (lizmap::getRepositoryList() as $repositoryName) { + $repository = lizmap::getRepository($repositoryName); + if (jAcl2::check('lizmap.repositories.view', $repository->getKey())) { + $repositories[$repository->getKey()] = $repository->getData('label'); + } } - } - $this->data = $repositories; - } + $this->data = $repositories; + } - public function getData($form) - { - return ($this->data); - } + public function getData($form) + { + return $this->data; + } - public function getLabel($key) - { - if(isset($this->data[$key])) - return $this->data[$key]; - else - return null; - } + public function getLabel($key) + { + if (isset($this->data[$key])) { + return $this->data[$key]; + } + return null; + } } -?> \ No newline at end of file diff --git a/mapBuilder/classes/mapBuilderView.listener.php b/mapBuilder/classes/mapBuilderView.listener.php index e20c5c54..0782903e 100644 --- a/mapBuilder/classes/mapBuilderView.listener.php +++ b/mapBuilder/classes/mapBuilderView.listener.php @@ -1,10 +1,12 @@ transform($sourceProj,$destProj,$sourceMinPt); - $destMaxPt = $proj4->transform($sourceProj,$destProj,$sourceMaxPt); - - $extent = implode(", ", array( $destMinPt->x, $destMinPt->y, $destMaxPt->x, $destMaxPt->y )); + $destMinPt = $proj4->transform($sourceProj, $destProj, $sourceMinPt); + $destMaxPt = $proj4->transform($sourceProj, $destProj, $sourceMaxPt); + $extent = implode(', ', array($destMinPt->x, $destMinPt->y, $destMaxPt->x, $destMaxPt->y)); } catch (Exception $e) { // Max extent in EPSG:3857 - $extent = "-20026376.39,-20048966.10,20026376.39,20048966.10"; + $extent = '-20026376.39,-20048966.10,20026376.39,20048966.10'; } - }else{ - jMessage::add(jLocale::get("mapBuilder~default.extent.value.error"), 'error'); - $extent = jLocale::get("mapBuilder~default.extent.value.error"); + } else { + jMessage::add(jLocale::get('mapBuilder~default.extent.value.error'), 'error'); + $extent = jLocale::get('mapBuilder~default.extent.value.error'); } } - + $illustration = jApp::urlBasePath().'themes/'.jApp::config()->theme.'/css/img/250x250_mappemonde.jpg'; jClasses::inc('lizmapMainViewItem'); @@ -64,7 +65,7 @@ function onmainviewGetMaps ($event) { '_map_builder_rep', 'map' ); - $event->add( $mrep ); + $event->add($mrep); } } } diff --git a/mapBuilder/controllers/default.classic.php b/mapBuilder/controllers/default.classic.php index 633871d5..1ba3214a 100644 --- a/mapBuilder/controllers/default.classic.php +++ b/mapBuilder/controllers/default.classic.php @@ -1,32 +1,31 @@ getResponse('redirect'); - $rep->action = 'view~default:index'; - jMessage::add(jLocale::get('view~default.repository.access.denied'), 'error'); - return $rep; + if (!jAcl2::check('mapBuilder.access')) { + $rep = $this->getResponse('redirect'); + $rep->action = 'view~default:index'; + jMessage::add(jLocale::get('view~default.repository.access.denied'), 'error'); + + return $rep; } - $rep = $this->getResponse('html', true);// true désactive le template général + $rep = $this->getResponse('html', true); // true désactive le template général // Get lizmap services $services = lizmap::getServices(); - $title = jLocale::get('mapBuilder~default.app.name');; + $title = jLocale::get('mapBuilder~default.app.name'); $rep->title = $title; $rep->metaViewport = 'initial-scale=1.0, user-scalable=no, width=device-width, shrink-to-fit=no'; @@ -46,22 +45,22 @@ function index() { // Pass some configuration options to the web page through javascript var $lizUrls = array( - "basepath" => jApp::urlBasePath(), - "config" => jUrl::get('lizmap~service:getProjectConfig'), - "wms" => jUrl::get('lizmap~service:index'), - "media" => jUrl::get('view~media:getMedia'), - "mapcontext_add" => jUrl::get('mapBuilder~mapcontext:add'), - "mapcontext_delete" => jUrl::get('mapBuilder~mapcontext:delete'), - "mapcontext_get" => jUrl::get('mapBuilder~mapcontext:get') + 'basepath' => jApp::urlBasePath(), + 'config' => jUrl::get('lizmap~service:getProjectConfig'), + 'wms' => jUrl::get('lizmap~service:index'), + 'media' => jUrl::get('view~media:getMedia'), + 'mapcontext_add' => jUrl::get('mapBuilder~mapcontext:add'), + 'mapcontext_delete' => jUrl::get('mapBuilder~mapcontext:delete'), + 'mapcontext_get' => jUrl::get('mapBuilder~mapcontext:get'), ); // Load lizUrls before mapbuilder. Webpack public path needs it - $rep->addJSCode("var lizUrls = ".json_encode($lizUrls).";", true); + $rep->addJSCode('var lizUrls = '.json_encode($lizUrls).';', true); $rep->addJSLink(jApp::urlBasePath().'mapBuilder/js/mapbuilder.js'); // Read mapBuilder configuration - $readConfigPath = parse_ini_file(jApp::configPath('mapBuilder.ini.php'), True); + $readConfigPath = parse_ini_file(jApp::configPath('mapBuilder.ini.php'), true); // Build repository + project tree for FancyTree $nestedTree = array(); @@ -69,33 +68,33 @@ function index() { $repositoryList = array(); // Get selected repository from ini file if set - if(array_key_exists('repository', $readConfigPath) && !is_null(lizmap::getRepository($readConfigPath['repository']))){ + if (array_key_exists('repository', $readConfigPath) && !is_null(lizmap::getRepository($readConfigPath['repository']))) { $repositoryList[] = $readConfigPath['repository']; - }else{ + } else { $repositoryList = lizmap::getRepositoryList(); } foreach ($repositoryList as $repositoryName) { $repository = lizmap::getRepository($repositoryName); - if( jAcl2::check('lizmap.repositories.view', $repository->getKey() )){ + if (jAcl2::check('lizmap.repositories.view', $repository->getKey())) { $projects = $repository->getProjects(); $projectArray = array(); foreach ($projects as $project) { - $projectArray[] = [ - "title" => $project->getData('title'), - "folder" => true, - "lazy" => true, - "repository" => $repositoryName, - "project" => $project->getKey() - ]; + $projectArray[] = array( + 'title' => $project->getData('title'), + 'folder' => true, + 'lazy' => true, + 'repository' => $repositoryName, + 'project' => $project->getKey(), + ); } - $nestedTree[] = [ - "title" => $repository->getData('label'), - "folder" => true, - "children" => $projectArray - ]; + $nestedTree[] = array( + 'title' => $repository->getData('label'), + 'folder' => true, + 'children' => $projectArray, + ); } } @@ -103,11 +102,11 @@ function index() { $rep->addJSCode('var mapBuilder = {"layerStoreTree": '.json_encode($nestedTree).'};'); // Get original extent from ini file if set - if(array_key_exists('extent', $readConfigPath)){ - $rep->addJSCode("mapBuilder.extent = [".$readConfigPath['extent']."];"); + if (array_key_exists('extent', $readConfigPath)) { + $rep->addJSCode('mapBuilder.extent = ['.$readConfigPath['extent'].'];'); } // Get base layer from ini file if set - if(array_key_exists('baseLayer', $readConfigPath)){ + if (array_key_exists('baseLayer', $readConfigPath)) { $rep->addJSCode("mapBuilder.baseLayer = '".$readConfigPath['baseLayer']."';"); jClasses::inc('mapBuilder~listBaseLayer'); @@ -116,7 +115,7 @@ function index() { $userListBaseLayer = explode(',', $readConfigPath['baseLayer']); foreach ($listBaseLayer as $key => $value) { - if(!in_array($key, $userListBaseLayer)){ + if (!in_array($key, $userListBaseLayer)) { unset($listBaseLayer[$key]); } } @@ -124,43 +123,45 @@ function index() { $rep->body->assign('baseLayer', $listBaseLayer); } // Get default base layer from ini file if set - if(array_key_exists('baseLayerDefault', $readConfigPath)){ + if (array_key_exists('baseLayerDefault', $readConfigPath)) { $rep->body->assign('baseLayerDefault', $readConfigPath['baseLayerDefault']); } // Get base layer key from ini file if set - if(array_key_exists('baseLayerKeyOSMCycleMap', $readConfigPath)){ + if (array_key_exists('baseLayerKeyOSMCycleMap', $readConfigPath)) { $rep->addJSCode("mapBuilder.baseLayerKeyOSMCycleMap = '".$readConfigPath['baseLayerKeyOSMCycleMap']."';"); } // Get base layer key from ini file if set - if(array_key_exists('baseLayerKeyBing', $readConfigPath)){ + if (array_key_exists('baseLayerKeyBing', $readConfigPath)) { $rep->addJSCode("mapBuilder.baseLayerKeyBing = '".$readConfigPath['baseLayerKeyBing']."';"); } // Get base layer key from ini file if set - if(array_key_exists('baseLayerKeyIGN', $readConfigPath)){ + if (array_key_exists('baseLayerKeyIGN', $readConfigPath)) { $rep->addJSCode("mapBuilder.baseLayerKeyIGN = '".$readConfigPath['baseLayerKeyIGN']."';"); } // Get attributeTableTool key from ini file if set - if(array_key_exists('attributeTableTool', $readConfigPath)){ + if (array_key_exists('attributeTableTool', $readConfigPath)) { $rep->body->assign('attributeTableTool', $readConfigPath['attributeTableTool']); } // Get locales $lang = $this->param('lang'); - if(!$lang) - $lang = jLocale::getCurrentLang().'_'.jLocale::getCurrentCountry(); + if (!$lang) { + $lang = jLocale::getCurrentLang().'_'.jLocale::getCurrentCountry(); + } $data = array(); $path = jApp::getModulePath('mapBuilder').'locales/en_US/dictionary.UTF-8.properties'; - if(file_exists($path)){ - $lines = file($path); - foreach ($lines as $lineNumber => $lineContent){ - if(!empty($lineContent) and $lineContent != '\n'){ - $exp = explode('=', trim($lineContent)); - if(!empty($exp[0])) - $data[$exp[0]] = jLocale::get('mapBuilder~dictionary.'.$exp[0], null, $lang); + if (file_exists($path)) { + $lines = file($path); + foreach ($lines as $lineNumber => $lineContent) { + if (!empty($lineContent) and $lineContent != '\n') { + $exp = explode('=', trim($lineContent)); + if (!empty($exp[0])) { + $data[$exp[0]] = jLocale::get('mapBuilder~dictionary.'.$exp[0], null, $lang); + } + } } - } } $rep->addJSCode('var lizDict = '.json_encode($data).';'); @@ -170,7 +171,7 @@ function index() { $rep->body->assign('allowUserAccountRequests', $services->allowUserAccountRequests); // Add Google Analytics ID - if($services->googleAnalyticsID != '' && preg_match("/^UA-\d+-\d+$/", $services->googleAnalyticsID) == 1 ) { + if ($services->googleAnalyticsID != '' && preg_match('/^UA-\\d+-\\d+$/', $services->googleAnalyticsID) == 1) { $rep->body->assign('googleAnalyticsID', $services->googleAnalyticsID); } @@ -180,9 +181,9 @@ function index() { $rep->body->assignZone('LIST_MAPCONTEXT', 'list_mapcontext'); // Override default theme with color set in admin panel - if($cssContent = jFile::read(jApp::varPath('lizmap-theme-config/') . 'theme.css') ){ - $css = ''; - $rep->addHeadContent($css); + if ($cssContent = jFile::read(jApp::varPath('lizmap-theme-config/').'theme.css')) { + $css = ''; + $rep->addHeadContent($css); } return $rep; diff --git a/mapBuilder/controllers/mapcontext.classic.php b/mapBuilder/controllers/mapcontext.classic.php index afabe9f1..f3e3143b 100644 --- a/mapBuilder/controllers/mapcontext.classic.php +++ b/mapBuilder/controllers/mapcontext.classic.php @@ -1,32 +1,29 @@ getResponse('htmlfragment'); // Make sure that it is a POST request. - if(strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') != 0){ + if (strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') != 0) { throw new Exception('Request method must be POST!'); } // Check name - $name = filter_var( $this->param('name'), FILTER_SANITIZE_STRING ); - if( empty($name) ){ + $name = filter_var($this->param('name'), FILTER_SANITIZE_STRING); + if (empty($name)) { jMessage::add('Please give a name', 'error'); - }else{ + } else { $dao = jDao::get('mapBuilder~mapcontext'); $record = jDao::createRecord('mapBuilder~mapcontext'); @@ -36,36 +33,35 @@ function add() { // Access control $record->is_public = false; - if(jAcl2::check('mapBuilder.mapcontext.public.manage')){ + if (jAcl2::check('mapBuilder.mapcontext.public.manage')) { $record->is_public = $this->param('is_public'); } $record->mapcontext = $this->param('mapcontext'); // Save the new mapcontext - $id = Null; - try{ + $id = null; + + try { $id = $dao->insert($record); - }catch(Exception $e){ - jLog::log( 'Error while inserting the mapcontext'); - jLog::log( $e->getMessage()); - jMessage::add( 'Error while inserting the mapcontext', 'error' ); + } catch (Exception $e) { + jLog::log('Error while inserting the mapcontext'); + jLog::log($e->getMessage()); + jMessage::add('Error while inserting the mapcontext', 'error'); } } $rep->addContent(jZone::get('list_mapcontext')); + return $rep; } - /* - * Delete mapcontext by id - * - */ - function delete(){ - + // Delete mapcontext by id + public function delete() + { $rep = $this->getResponse('htmlfragment'); // Make sure that it is a POST request. - if(strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') != 0){ + if (strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') != 0) { throw new Exception('Request method must be POST!'); } @@ -79,19 +75,19 @@ function delete(){ // Conditions to get the mapcontext $daomc = jDao::get('mapBuilder~mapcontext'); $conditions = jDao::createConditions(); - $conditions->addCondition('login','=',$usr_login); - $conditions->addCondition('id','=',$id); + $conditions->addCondition('login', '=', $usr_login); + $conditions->addCondition('id', '=', $id); $mcCount = $daomc->countBy($conditions); - if( $mcCount != 1 ){ + if ($mcCount != 1) { jMessage::add('You can\'t delete this map context or it doesn\'t exist', 'error'); - }else{ - try{ + } else { + try { $daomc->delete($id); - }catch(Exception $e){ - jLog::log( 'Error while deleting the mapcontext'); - jLog::log( $e->getMessage()); - jMessage::add( 'Error while deleting the mapcontext', 'error' ); + } catch (Exception $e) { + jLog::log('Error while deleting the mapcontext'); + jLog::log($e->getMessage()); + jMessage::add('Error while deleting the mapcontext', 'error'); } } @@ -100,11 +96,9 @@ function delete(){ return $rep; } - /* - * Get mapcontext by id - * - */ - function get(){ + // Get mapcontext by id + public function get() + { // Get user $juser = jAuth::getUserSession(); @@ -116,27 +110,27 @@ function get(){ // Conditions to get the bookmark $daomc = jDao::get('mapBuilder~mapcontext'); $conditions = jDao::createConditions(); - $conditions->addCondition('id','=',$id); + $conditions->addCondition('id', '=', $id); // Get map context if saved by logged user or public ones $conditions->startGroup('OR'); - $conditions->addCondition('login','=',$usr_login); - $conditions->addCondition('is_public','=',true); + $conditions->addCondition('login', '=', $usr_login); + $conditions->addCondition('is_public', '=', true); $conditions->endGroup(); $mcCount = $daomc->countBy($conditions); - if( $mcCount != 1 ){ - jMessage::add('You don\'t have access to this map context or it doesn\'t exist' , 'error'); + if ($mcCount != 1) { + jMessage::add('You don\'t have access to this map context or it doesn\'t exist', 'error'); + return $this->error(); - }else{ - $mcList = $daomc->findBy($conditions); - $mcParams = array(); - foreach( $mcList as $mc ){ - $mcParams = json_decode(htmlspecialchars_decode($mc->mapcontext,ENT_QUOTES )); - } - $rep = $this->getResponse('json'); - $rep->data = $mcParams; - return $rep; } - } + $mcList = $daomc->findBy($conditions); + $mcParams = array(); + foreach ($mcList as $mc) { + $mcParams = json_decode(htmlspecialchars_decode($mc->mapcontext, ENT_QUOTES)); + } + $rep = $this->getResponse('json'); + $rep->data = $mcParams; + return $rep; + } } diff --git a/mapBuilder/install/conf/mapBuilder.ini.php b/mapBuilder/install/conf/mapBuilder.ini.php index 8e822c0c..befd063d 100644 --- a/mapBuilder/install/conf/mapBuilder.ini.php +++ b/mapBuilder/install/conf/mapBuilder.ini.php @@ -1,4 +1,4 @@ -; +; ;for security reasons , don't remove or modify the first line ;; if you want the map builder to display only one repository, put its id here. Leave blank to get all repositories. diff --git a/mapBuilder/install/install.php b/mapBuilder/install/install.php index cf071192..5fa147d3 100644 --- a/mapBuilder/install/install.php +++ b/mapBuilder/install/install.php @@ -1,16 +1,16 @@ copyDirectoryContent('../www/css', jApp::wwwPath('mapBuilder/css')); $this->copyDirectoryContent('../www/js/dist', jApp::wwwPath('mapBuilder/js')); @@ -26,15 +26,15 @@ function install() { } // Set ACL - if ($this->firstExec('acl2') ) { + if ($this->firstExec('acl2')) { $this->useDbProfile('auth'); // Add rights group - jAcl2DbManager::addSubjectGroup ('mapBuilder.subject.group', 'mapBuilder~default.acl.subject.group.name'); + jAcl2DbManager::addSubjectGroup('mapBuilder.subject.group', 'mapBuilder~default.acl.subject.group.name'); // Add right subject - jAcl2DbManager::addSubject( 'mapBuilder.access', 'mapBuilder~default.acl.subject.access.name', 'mapBuilder.subject.group'); - jAcl2DbManager::addSubject( 'mapBuilder.mapcontext.public.manage', 'mapBuilder~default.acl.subject.mapcontext.public.manage', 'mapBuilder.subject.group'); + jAcl2DbManager::addSubject('mapBuilder.access', 'mapBuilder~default.acl.subject.access.name', 'mapBuilder.subject.group'); + jAcl2DbManager::addSubject('mapBuilder.mapcontext.public.manage', 'mapBuilder~default.acl.subject.mapcontext.public.manage', 'mapBuilder.subject.group'); // Add rights on group admins jAcl2DbManager::addRight('admins', 'mapBuilder.access'); diff --git a/mapBuilder/install/upgrade.php b/mapBuilder/install/upgrade.php index b334ea28..a11a0793 100644 --- a/mapBuilder/install/upgrade.php +++ b/mapBuilder/install/upgrade.php @@ -1,16 +1,16 @@ copyDirectoryContent('../www/css', jApp::wwwPath('mapBuilder/css'), true); $this->copyDirectoryContent('../www/js/dist', jApp::wwwPath('mapBuilder/js'), true); diff --git a/mapBuilder/install/upgrade_acl.php b/mapBuilder/install/upgrade_acl.php index 4c8b497a..17343e37 100644 --- a/mapBuilder/install/upgrade_acl.php +++ b/mapBuilder/install/upgrade_acl.php @@ -1,30 +1,30 @@ firstExec('acl2') ) { + public function install() + { + if ($this->firstExec('acl2')) { $this->useDbProfile('auth'); // Add rights group - jAcl2DbManager::addSubjectGroup ('mapBuilder.subject.group', 'mapBuilder~default.acl.subject.group.name'); + jAcl2DbManager::addSubjectGroup('mapBuilder.subject.group', 'mapBuilder~default.acl.subject.group.name'); // Add right subject - jAcl2DbManager::addSubject( 'mapBuilder.access', 'mapBuilder~default.acl.subject.access.name', 'mapBuilder.subject.group'); - jAcl2DbManager::addSubject( 'mapBuilder.mapcontext.public.manage', 'mapBuilder~default.acl.subject.mapcontext.public.manage', 'mapBuilder.subject.group'); + jAcl2DbManager::addSubject('mapBuilder.access', 'mapBuilder~default.acl.subject.access.name', 'mapBuilder.subject.group'); + jAcl2DbManager::addSubject('mapBuilder.mapcontext.public.manage', 'mapBuilder~default.acl.subject.mapcontext.public.manage', 'mapBuilder.subject.group'); // Add rights on group admins jAcl2DbManager::addRight('admins', 'mapBuilder.access'); diff --git a/mapBuilder/install/upgrade_createtable.php b/mapBuilder/install/upgrade_createtable.php index b84ce0ce..fec57331 100644 --- a/mapBuilder/install/upgrade_createtable.php +++ b/mapBuilder/install/upgrade_createtable.php @@ -1,23 +1,23 @@ firstDbExec() ) { + if ($this->firstDbExec()) { $this->useDbProfile('jauth'); $this->execSQLScript('sql/mapcontext'); } diff --git a/mapBuilder/install/upgrade_toggleattributetable.php b/mapBuilder/install/upgrade_toggleattributetable.php index a6547e88..6cf896bb 100644 --- a/mapBuilder/install/upgrade_toggleattributetable.php +++ b/mapBuilder/install/upgrade_toggleattributetable.php @@ -1,23 +1,23 @@ setValue('attributeTableTool', 'true'); $ini->save(); } diff --git a/mapBuilder/zones/list_mapcontext.zone.php b/mapBuilder/zones/list_mapcontext.zone.php index c6d529b8..7199b56a 100644 --- a/mapBuilder/zones/list_mapcontext.zone.php +++ b/mapBuilder/zones/list_mapcontext.zone.php @@ -1,52 +1,53 @@ login; - $loggedUser = false; - - // Get user mapcontexts - if($usr_login){ - $loggedUser = true; - - $daomc = jDao::get('mapBuilder~mapcontext'); - $conditions = jDao::createConditions(); - $conditions->addCondition('login','=',$usr_login); - $mcOwnList = $daomc->findBy($conditions); - $mcOwnCount = $daomc->countBy($conditions); - - $this->_tpl->assign('mcOwnList',$mcOwnList); - $this->_tpl->assign('mcOwnCount',$mcOwnCount); - } - - // Get public mapcontexts - $daomc = jDao::get('mapBuilder~mapcontext'); - $conditions = jDao::createConditions(); - // Don't display logged user map context twice - if($usr_login){ - $conditions->addCondition('login','!=',$usr_login); - } - $conditions->addCondition('is_public','=',true); - $mcSharedList = $daomc->findBy($conditions); - $mcSharedCount = $daomc->countBy($conditions); - - // Get html content - $this->_tpl->assign('loggedUser',$loggedUser); - $this->_tpl->assign('mcSharedList',$mcSharedList); - $this->_tpl->assign('mcSharedCount',$mcSharedCount); - } +class list_mapcontextZone extends jZone +{ + protected $_tplname = 'list_mapcontext'; + + protected function _prepareTpl() + { + // Get user + $juser = jAuth::getUserSession(); + $usr_login = $juser->login; + $loggedUser = false; + + // Get user mapcontexts + if ($usr_login) { + $loggedUser = true; + + $daomc = jDao::get('mapBuilder~mapcontext'); + $conditions = jDao::createConditions(); + $conditions->addCondition('login', '=', $usr_login); + $mcOwnList = $daomc->findBy($conditions); + $mcOwnCount = $daomc->countBy($conditions); + + $this->_tpl->assign('mcOwnList', $mcOwnList); + $this->_tpl->assign('mcOwnCount', $mcOwnCount); + } + + // Get public mapcontexts + $daomc = jDao::get('mapBuilder~mapcontext'); + $conditions = jDao::createConditions(); + // Don't display logged user map context twice + if ($usr_login) { + $conditions->addCondition('login', '!=', $usr_login); + } + $conditions->addCondition('is_public', '=', true); + $mcSharedList = $daomc->findBy($conditions); + $mcSharedCount = $daomc->countBy($conditions); + + // Get html content + $this->_tpl->assign('loggedUser', $loggedUser); + $this->_tpl->assign('mcSharedList', $mcSharedList); + $this->_tpl->assign('mcSharedCount', $mcSharedCount); + } }