function __construct($id) { $this->formId = $id; foreach (lizmap::getRepositoryList() as $repo) { $this->data[$repo] = $repo; } }
function __construct($id) { $this->formId = $id; $mydata = array(); foreach (lizmap::getRepositoryList() as $repo) { $mydata[$repo] = $repo; } $this->data = $mydata; }
function __construct($id) { $this->formId = $id; $mydata = array(); foreach (lizmap::getRepositoryList() as $repo) { $rep = lizmap::getRepository($repo); $mydata[$repo] = (string) $rep->getData('label'); } $this->data = $mydata; }
/** * Display a summary of the information taken from the ~ configuration file. * * @return Administration backend for the repositories. */ function index() { $rep = $this->getResponse('html'); // Get repository data $repository = $this->param('repository'); // Get rights for repositories per subject and groups $cnx = jDb::getConnection('jacl2_profile'); $repositories = array(); $data = array(); foreach (lizmap::getRepositoryList() as $repo) { //$sql = " SELECT r.id_aclsbj, group_concat(g.name, ' - ') AS group_names"; $sql = " SELECT r.id_aclsbj, g.name AS group_name"; $sql .= " FROM jacl2_rights r"; $sql .= " INNER JOIN jacl2_group g ON r.id_aclgrp = g.id_aclgrp"; $sql .= " WHERE g.grouptype = 0 AND r.id_aclgrp NOT IN ('" . implode("','", $this->groupBlacklist) . "')"; $sql .= " AND id_aclres=" . $cnx->quote($repo); //$sql.= " GROUP BY r.id_aclsbj;"; $sql .= " ORDER BY g.name"; $rights = $cnx->query($sql); $group_names = array(); foreach ($rights as $r) { if (!array_key_exists($r->id_aclsbj, $group_names)) { $group_names[$r->id_aclsbj] = array(); } $group_names[$r->id_aclsbj][] = $r->group_name; } foreach ($group_names as $k => $v) { $group_names[$k] = implode(' - ', $v); } $rights = (object) $group_names; $repositories[] = lizmap::getRepository($repo); $data[$repo] = $rights; } // Subjects labels $labels = array(); $daosubject = jDao::get('jacl2db~jacl2subject', 'jacl2_profile'); foreach ($daosubject->findAllSubject() as $subject) { $labels[$subject->id_aclsbj] = $this->getLabel($subject->id_aclsbj, $subject->label_key); } // Get Lizmap version from project.xml $xmlPath = jApp::appPath('project.xml'); $xmlLoad = simplexml_load_file($xmlPath); $version = (string) $xmlLoad->info->version; $tpl = new jTpl(); $tpl->assign('services', lizmap::getServices()); $tpl->assign('repositories', $repositories); $tpl->assign('data', $data); $tpl->assign('labels', $labels); $tpl->assign('version', $version); $rep->body->assign('MAIN', $tpl->fetch('config')); $rep->body->assign('selectedMenuItem', 'lizmap_configuration'); return $rep; }
protected function _prepareTpl() { $protocol = jApp::coord()->request->getProtocol(); $this->_tpl->assign('protocol', $protocol); $domain = jApp::coord()->request->getDomainName(); $this->_tpl->assign('domain', $domain); $this->_tpl->assign('auth_url_return', $this->param('auth_url_return')); $this->_tpl->assign('isConnected', jAuth::isConnected()); // Get lizmap services $services = lizmap::getServices(); if ($services->allowUserAccountRequests) { $this->_tpl->assign('allowUserAccountRequests', True); } jClasses::inc('lizmapMainViewItem'); $maps = array(); // Get repository data $repository = $this->param('repository'); $repositories = array(); if ($repository != null && jAcl2::check('lizmap.repositories.view', $repository)) { $repositories[] = $repository; } else { $repositories = lizmap::getRepositoryList(); } // Get excluded project $excludedProject = $this->param('excludedProject'); foreach ($repositories as $r) { if (jAcl2::check('lizmap.repositories.view', $r)) { $lrep = lizmap::getRepository($r); $mrep = new lizmapMainViewItem($r, $lrep->getData('label')); $lprojects = $lrep->getProjects(); // WMS GetCapabilities Url $wmsGetCapabilitiesUrl = jAcl2::check('lizmap.tools.displayGetCapabilitiesLinks', $lrep->getKey()); foreach ($lprojects as $p) { $pOptions = $p->getOptions(); if (property_exists($pOptions, 'hideProject') && $pOptions->hideProject == 'True') { continue; } if ($wmsGetCapabilitiesUrl) { $wmsGetCapabilitiesUrl = $p->getData('wmsGetCapabilitiesUrl'); } if ($lrep->getKey() . '~' . $p->getData('id') != $excludedProject) { $mrep->childItems[] = new lizmapMainViewItem($p->getData('id'), $p->getData('title'), $p->getData('abstract'), $p->getData('proj'), $p->getData('bbox'), jUrl::get('view~map:index', array("repository" => $p->getData('repository'), "project" => $p->getData('id'))), jUrl::get('view~media:illustration', array("repository" => $p->getData('repository'), "project" => $p->getData('id'))), 0, $r, 'map', $wmsGetCapabilitiesUrl); /*} else { $this->_tpl->assign('auth_url_return', jUrl::get('view~map:index', array( "repository"=>$lrep->getKey(), "project"=>$p->getData('id'), ) ) );*/ } } if (count($mrep->childItems) != 0) { usort($mrep->childItems, "mainViewItemSort"); $maps[$r] = $mrep; } } } $items = jEvent::notify('mainviewGetMaps')->getResponse(); foreach ($items as $item) { if ($item->parentId) { if ($item->parentId . '~' . $item->id == $excludedProject) { continue; } if (!isset($maps[$item->parentId])) { $maps[$item->parentId] = new lizmapMainViewItem($item->parentId, '', ''); } $replaced = false; foreach ($maps[$item->parentId]->childItems as $k => $i) { if ($i->id == $item->id) { $maps[$item->parentId]->childItems[$k] = $item; $replaced = true; } } if (!$replaced) { $maps[$item->parentId]->childItems[] = $item; usort($maps[$item->parentId]->childItems, "mainViewItemSort"); } } else { if (isset($maps[$item->id])) { $maps[$item->id]->copyFrom($item); } else { $maps[$item->id] = $item; } } } usort($maps, "mainViewItemSort"); foreach ($maps as $topitem) { usort($topitem->childItems, "mainViewItemSort"); } $this->_tpl->assign('mapitems', $maps); $this->_tpl->assign('onlyMaps', $this->param('onlyMaps', False)); }
/** * Get the jForm for a repository. * */ public static function constructRepositoryForm($rep, $form) { $services = lizmap::getServices(); $rootRepositories = $services->getRootRepositories(); $repositories = array(); foreach (lizmap::getRepositoryList() as $repo) { if ($rep && $rep->getKey() == $repo) { continue; } $repositories[] = lizmap::getRepository($repo); } // reconstruct form fields based on repositoryPropertyList $propertiesOptions = lizmap::getRepositoryPropertiesOptions(); foreach (lizmap::getRepositoryProperties() as $k) { $ctrl = null; if ($propertiesOptions[$k]['fieldType'] == 'checkbox') { $ctrl = new jFormsControlCheckbox($k); } else { if ($k == 'path' && $rootRepositories != '') { if ($rep == null || substr($rep->getPath(), 0, strlen($rootRepositories)) === $rootRepositories) { $ctrl = new jFormsControlMenulist($k); $dataSource = new jFormsStaticDatasource(); $data = array(); $data[''] = ''; if ($dh = opendir($rootRepositories)) { while (($file = readdir($dh)) !== false) { if ($file == '.' || $file == '..') { continue; } $filePath = $rootRepositories . $file . '/'; if (is_dir($filePath)) { $allreadyUsed = False; foreach ($repositories as $repo) { if ($repo->getPath() == $filePath) { $allreadyUsed = True; break; } } if (!$allreadyUsed) { $data[$filePath] = $file; } } } } $dataSource->data = $data; $ctrl->datasource = $dataSource; } else { $ctrl = new jFormsControlHidden($k); } } else { $ctrl = new jFormsControlInput($k); $ctrl->datatype = new jDatatypeString(); } } $ctrl->required = $propertiesOptions[$k]['required']; $ctrl->label = jLocale::get("admin~admin.form.admin_section.repository." . $k . ".label"); $ctrl->size = 100; $form->addControl($ctrl); } if ($rep) { foreach ($rep->getProperties() as $k) { $v = $rep->getData($k); if ($k == 'path' && $rootRepositories != '' && substr($rep->getPath(), 0, strlen($rootRepositories)) === $rootRepositories) { $v = $rep->getPath(); } $form->setData($k, $v); } } return $form; }
protected function _prepareTpl() { $protocol = jApp::coord()->request->getProtocol(); $this->_tpl->assign('protocol', $protocol); $domain = jApp::coord()->request->getDomainName(); $this->_tpl->assign('domain', $domain); $maps = array(); // Get repository data $repository = $this->param('repository'); $repositories = array(); if ($repository != null && jAcl2::check('lizmap.repositories.view', $repository)) { $repositories[] = $repository; } else { $repositories = lizmap::getRepositoryList(); } foreach ($repositories as $r) { if (jAcl2::check('lizmap.repositories.view', $r)) { $lrep = lizmap::getRepository($r); $mrep = new lizmapMainViewItem($r, $lrep->getData('label')); $lprojects = $lrep->getProjects(); foreach ($lprojects as $p) { if (!$p->checkAcl()) { continue; } $mrep->childItems[] = new lizmapMainViewItem($p->getData('id'), $p->getData('title'), $p->getData('abstract'), $p->getData('proj'), $p->getData('bbox'), jUrl::getFull('view~map:index', array("repository" => $p->getData('repository'), "project" => $p->getData('id'))), jUrl::getFull('view~media:illustration', array("repository" => $p->getData('repository'), "project" => $p->getData('id'))), 0, $r, 'map'); } $maps[$r] = $mrep; } } $req = jApp::coord()->request; $items = jEvent::notify('mainviewGetMaps')->getResponse(); foreach ($items as $item) { if ($item->parentId) { if (!isset($maps[$item->parentId])) { $maps[$item->parentId] = new lizmapMainViewItem($item->parentId, '', ''); } $replaced = false; foreach ($maps[$item->parentId]->childItems as $k => $i) { if ($i->id == $item->id) { if (!preg_match('/^http/', $item->img)) { $item->img = $req->getServerURI() . $item->img; } if (!preg_match('/^http/', $item->url)) { $item->url = $req->getServerURI() . $item->url; } $maps[$item->parentId]->childItems[$k] = $item; $replaced = true; } } if (!$replaced) { $maps[$item->parentId]->childItems[] = $item; } } else { if (isset($maps[$item->id])) { $item->img = $maps[$item->id]->img; $maps[$item->id]->copyFrom($item); } else { $maps[$item->id] = $item; } } } usort($maps, "mainViewItemSort"); foreach ($maps as $topitem) { usort($topitem->childItems, "mainViewItemSort"); } $this->_tpl->assign('mapitems', $maps); }