public function testCall() { jClasses::inc('jelix_tests~testCache'); $myClass = new testCache(); $returnData = jCache::call(array('testCache', 'staticMethod'), array(1, 2), 0, $this->profile); $this->assertTrue($returnData == 3); $dataCached = jCache::get(md5(serialize(array('testCache', 'staticMethod')) . serialize(array(1, 2))), $this->profile); $this->assertTrue($dataCached == $returnData); try { jCache::call(array('testCache', 'missingStaticMethod'), null, 0, $this->profile); $this->fail(); } catch (jException $e) { $this->pass(); } $returnData = jCache::call(array($myClass, 'method'), array(1, 2), 0, $this->profile); $this->assertTrue($returnData == 3); $dataCached = jCache::get(md5(serialize(array($myClass, 'method')) . serialize(array(1, 2))), $this->profile); $this->assertTrue($dataCached == $returnData); try { jCache::call(array($myClass, 'missingMethod'), null, 0, $this->profile); $this->fail(); } catch (jException $e) { $this->pass(); } $returnData = jCache::call('testFunction', array(1, 2), 0, $this->profile); $this->assertTrue($returnData == 3); $dataCached = jCache::get(md5(serialize('testFunction') . serialize(array(1, 2))), $this->profile); $this->assertTrue($dataCached == $returnData); try { jCache::call('testFunction_missing', null, 0, $this->profile); $this->fail(); } catch (jException $e) { $this->pass(); } }
protected function _prepareTpl() { jClasses::inc('masterAdminMenuItem'); $menu = array(); $menu['toplinks'] = new masterAdminMenuItem('toplinks', '', ''); $dashboard = new masterAdminMenuItem('dashboard', jLocale::get('gui.menu.item.dashboard'), jUrl::get('default:index')); $dashboard->icon = $GLOBALS['gJConfig']->urlengine['jelixWWWPath'] . 'design/images/dashboard.png'; $menu['toplinks']->childItems[] = $dashboard; $menu['system'] = new masterAdminMenuItem('system', jLocale::get('gui.menu.item.system'), '', 100); $items = jEvent::notify('masteradminGetMenuContent')->getResponse(); foreach ($items as $item) { if ($item->parentId) { if (!isset($menu[$item->parentId])) { $menu[$item->parentId] = new masterAdminMenuItem($item->parentId, '', ''); } $menu[$item->parentId]->childItems[] = $item; } else { if (isset($menu[$item->id])) { $menu[$item->id]->copyFrom($item); } else { $menu[$item->id] = $item; } } } usort($menu, "masterAdminItemSort"); foreach ($menu as $topitem) { usort($topitem->childItems, "masterAdminItemSort"); } $this->_tpl->assign('menuitems', $menu); $this->_tpl->assign('selectedMenuItem', $this->param('selectedMenuItem', '')); }
/** * function to manage data before assigning to the template of its zone */ protected function _prepareTpl() { jClasses::inc('havefnubb~hfnuMenuItem'); $admin = jAcl2::check('hfnu.admin.index'); $menu = array(); $items = jEvent::notify('hfnuGetMenuContent', array('admin' => $admin))->getResponse(); foreach ($items as $item) { if ($item->parentId) { if (!isset($menu[$item->parentId])) { $menu[$item->parentId] = new hfnuMenuItem($item->parentId, '', ''); } $menu[$item->parentId]->childItems[] = $item; } else { if (isset($menu[$item->id])) { $menu[$item->id]->copyFrom($item); } else { $menu[$item->id] = $item; } } } usort($menu, "hfnuItemSort"); foreach ($menu as $topitem) { usort($topitem->childItems, "hfnuItemSort"); } $this->_tpl->assign('menuitems', $menu); $this->_tpl->assign('selectedMenuItem', $this->param('selectedMenuItem', '')); }
protected function _prepareTpl() { jClasses::inc('masterAdminMenuItem'); $items = jEvent::notify('masteradminGetInfoBoxContent')->getResponse(); usort($items, "masterAdminItemSort"); $this->_tpl->assign('infoboxitems', $items); $this->_tpl->assign('user', jAuth::getUserSession()); }
/** * @param array $params plugin parameters for the current action * @return null or jSelectorAct if action should change */ public function beforeAction($params) { $selector = null; $floodok = true; if (isset($params['check.flood']) && $params['check.flood'] && $this->config['time_interval']) { jClasses::inc('havefnubb~flood'); $hasflood = flood::check($this->config['time_interval'], $this->config['only_same_ip']); if ($hasflood) { if ($this->config['on_error'] == 1 || !jApp::coord()->request->isAllowedResponse('jResponseRedirect')) { throw new jException("havefnubb~flood.elapsed_time_between_two_post"); } else { $selector = new jSelectorAct($this->config['on_error_action']); } } } return $selector; }
protected function _prepareTpl() { jClasses::inc('masterAdminMenuItem'); $menu = array(); $menu['toplinks'] = new masterAdminMenuItem('toplinks', '', ''); if (!isset(jApp::config()->master_admin['disable_dashboard_menu']) || !jApp::config()->master_admin['disable_dashboard_menu']) { $dashboard = new masterAdminMenuItem('dashboard', jLocale::get('gui.menu.item.dashboard'), jUrl::get('default:index')); $dashboard->icon = jApp::config()->urlengine['jelixWWWPath'] . 'design/images/dashboard.png'; $menu['toplinks']->childItems[] = $dashboard; } $menu['refdata'] = new masterAdminMenuItem('refdata', jLocale::get('gui.menu.item.refdata'), '', 80); $menu['system'] = new masterAdminMenuItem('system', jLocale::get('gui.menu.item.system'), '', 100); $items = jEvent::notify('masteradminGetMenuContent')->getResponse(); foreach ($items as $item) { if ($item->parentId) { if (!isset($menu[$item->parentId])) { $menu[$item->parentId] = new masterAdminMenuItem($item->parentId, '', ''); } $isRedefining = false; foreach ($menu[$item->parentId]->childItems as $child) { if ($child->id == $item->id) { $child->copyFrom($item); $isRedefining = true; break; } } if (!$isRedefining) { $menu[$item->parentId]->childItems[] = $item; } } else { if (isset($menu[$item->id])) { $menu[$item->id]->copyFrom($item); } else { $menu[$item->id] = $item; } } } usort($menu, "masterAdminItemSort"); foreach ($menu as $topitem) { usort($topitem->childItems, "masterAdminItemSort"); } $this->_tpl->assign('menuitems', $menu); $this->_tpl->assign('selectedMenuItem', $this->param('selectedMenuItem', '')); }
function onHfnuSearchEngineDeleteContent($event) { $id = $event->getParam('id'); $dataSource = $event->getParam('datasource'); if ($id == '' or $dataSource == '') { return; } $strId = ''; if (is_array($id)) { for ($i = 0; $i < count($id); $i++) { $strId .= $id[$i]; } } else { $strId = $id; } jClasses::inc('hfnusearch~search_index'); $service = new search_index($strId, $ds); $service->searchEngineDelete(); }
/** * @param array $params plugin parameters for the current action * @return null or jSelectorAct if action should change */ public function beforeAction($params) { $selector = null; $banok = false; if (isset($params['banuser.check'])) { jClasses::inc('havefnubb~bans'); $banok = bans::check(); } if ($banok) { // disconnect the user if he was connected jAuth::logout(); if ($this->config['on_error'] == 1 || !jApp::coord()->request->isAllowedResponse('jResponseRedirect')) { throw new jException(jLocale::get("havefnubb~ban.you.are.banned")); } else { $selector = new jSelectorAct($this->config['on_error_action']); } } return $selector; }
protected function getcapabilities() { //Get Cache $cacheId = $this->repository->getKey() . '_' . $this->project->getKey() . '_WMTS'; $hash = jCache::get($cacheId . '_hash'); $newhash = md5_file(realpath($this->repository->getPath()) . '/' . $this->project->getKey() . ".qgs"); $tileMatrixSetList = jCache::get($cacheId . '_tilematrixsetlist'); $layers = jCache::get($cacheId . '_layers'); if (!$tileMatrixSetList || !$layers || $hash != $newhash) { $wmsRequest = new lizmapWMSRequest($this->project, array('service' => 'WMS', 'request' => 'GetCapabilities')); $wmsResult = $wmsRequest->process(); $wms = $wmsResult->data; $wms_xml = simplexml_load_string($wms); $wms_xml->registerXPathNamespace("wms", "http://www.opengis.net/wms"); $wms_xml->registerXPathNamespace("xlink", "http://www.w3.org/1999/xlink"); jClasses::inc("lizmap~lizmapTiler"); $tileMatrixSetList = lizmapTiler::getTileMatrixSetList($this->project, $wms_xml); $cfgLayers = $this->project->getLayers(); $layers = array(); foreach ($cfgLayers as $n => $l) { $cfgl = $l; if ($l->cached == 'True' && $l->singleTile != 'True' && strtolower($l->name) != 'overview') { $layers[] = lizmapTiler::getLayerTileInfo($l->name, $this->project, $wms_xml, $tileMatrixSetList); } } jCache::set($cacheId . '_hash', $newhash, 3600); jCache::set($cacheId . '_tilematrixsetlist', $tileMatrixSetList, 3600); jCache::set($cacheId . '_layers', $layers, 3600); } $sUrl = jUrl::getFull("lizmap~service:index", array("repository" => $this->repository->getKey(), "project" => $this->project->getKey())); $tpl = new jTpl(); $tpl->assign('url', $sUrl); $tpl->assign('repository', $this->param('repository')); $tpl->assign('project', $this->param('project')); $tpl->assign('tileMatrixSetList', $tileMatrixSetList); $tpl->assign('layers', $layers); return (object) array('code' => 200, 'mime' => 'text/xml', 'data' => $tpl->fetch('lizmap~wmts_capabilities'), 'cached' => False); }
public function getProjects() { $projects = array(); if ($dh = opendir($this->getPath())) { $cfgFiles = array(); $qgsFiles = array(); while (($file = readdir($dh)) !== false) { if (substr($file, -3) == 'cfg') { $cfgFiles[] = $file; } if (substr($file, -3) == 'qgs') { $qgsFiles[] = $file; } } closedir($dh); jClasses::inc('lizmap~lizmapProject'); foreach ($qgsFiles as $qgsFile) { if (in_array($qgsFile . '.cfg', $cfgFiles)) { $projects[] = new lizmapProject(substr($qgsFile, 0, -4), $this); } } } return $projects; }
function single() { $rep = $this->_prepareResponse(); $module = $this->param('mod'); $testname = $this->param('test'); if (isset($this->testsList[$module])) { $reporter = jClasses::create("junittests~jtextrespreporter"); jClasses::inc('junittests~junittestcase'); jClasses::inc('junittests~junittestcasedb'); $reporter->setResponse($rep); foreach ($this->testsList[$module] as $test) { if ($test[1] == $testname) { $group = new GroupTest('"' . $module . '" module , ' . $test[2]); $group->addTestFile($GLOBALS['gJConfig']->_modulesPathList[$module] . 'tests/' . $test[0]); jContext::push($module); $result = $group->run($reporter); if (!$result) { $rep->setExitCode(jResponseCmdline::EXIT_CODE_ERROR); } jContext::pop(); break; } } } else { $rep->addContent("\n" . 'no tests for "' . $module . '" module.' . "\n"); } return $this->_finishResponse($rep); }
<?php /** * Manage OGC request. * @package lizmap * @subpackage lizmap * @author 3liz * @copyright 2015 3liz * @link http://3liz.com * @license Mozilla Public License : http://www.mozilla.org/MPL/ */ jClasses::inc('lizmap~lizmapProxy'); class lizmapOGCRequest { protected $project = null; protected $repository = null; protected $params = null; protected $services = null; protected $tplExceptions = null; /** * constructor * project : the project has a lizmapProject Class * params : the params array */ public function __construct($project, $params) { //print_r( $project != null ); $this->project = $project; $this->repository = $project->getRepository(); $this->services = lizmap::getServices(); $params['map'] = realpath($this->repository->getPath()) . '/' . $project->getKey() . ".qgs";
/** * Dynamically add controls to the form based on QGIS layer information * * @param object $form Jelix form to add controls to. * @return modified form. */ private function addFormControls($form) { // Get fields data from the edition database $layerXmlZero = $this->layerXml[0]; $_datasource = $layerXmlZero->xpath('datasource'); $datasource = (string) $_datasource[0]; $s_provider = $layerXmlZero->xpath('provider'); $this->provider = (string) $s_provider[0]; $this->getDataFields($datasource); // Get QGIS fields extra information from XML for the layer // edittypes and categories $edittypesXml = $layerXmlZero->edittypes[0]; $_categoriesXml = $layerXmlZero->xpath('renderer-v2/categories'); $categoriesXml = Null; if (isset($_categoriesXml[0])) { $categoriesXml = $_categoriesXml[0]; } // Get proj4 string $proj4 = (string) $layerXmlZero->srs->spatialrefsys->proj4; $this->proj4 = $proj4; // Get layer srid $srid = (int) $layerXmlZero->srs->spatialrefsys->srid; $this->srid = $srid; // Loop through the table fields // and create a form control if needed jClasses::inc('lizmap~qgisFormControl'); $this->formControls = array(); $layerName = $this->layerName; $capabilities = $this->project->getEditionLayers()->{$layerName}->capabilities; $toDeactivate = array(); $toSetReadOnly = array(); foreach ($this->dataFields as $fieldName => $prop) { // Create new control from qgis edit type $aliasXml = Null; if ($layerXmlZero->aliases) { $aliasesZero = $layerXmlZero->aliases[0]; $aliasXml = $aliasesZero->xpath("alias[@field='{$fieldName}']"); } $edittype = null; if ($edittypesXml) { $edittype = $edittypesXml->xpath("edittype[@name='{$fieldName}']"); } $this->formControls[$fieldName] = new qgisFormControl($fieldName, $edittype, $aliasXml, $categoriesXml, $prop); if (($this->formControls[$fieldName]->fieldEditType == 15 or $this->formControls[$fieldName]->fieldEditType == 'ValueRelation') and $this->formControls[$fieldName]->valueRelationData) { // Fill comboboxes of editType "Value relation" from relation layer // Query QGIS Server via WFS $this->fillControlFromValueRelationLayer($fieldName); } else { if ($this->formControls[$fieldName]->fieldEditType == 8 or $this->formControls[$fieldName]->fieldEditType == 'FileName' or $this->formControls[$fieldName]->fieldEditType == 'Photo') { // Add Hidden Control for upload // help to retrieve file path $hiddenCtrl = new jFormsControlHidden($fieldName . '_hidden'); $form->addControl($hiddenCtrl); $toDeactivate[] = $fieldName . '_choice'; } } // Add the control to the form $form->addControl($this->formControls[$fieldName]->ctrl); // Set readonly if needed $form->setReadOnly($fieldName, $this->formControls[$fieldName]->isReadOnly); // Hide when no modify capabilities, only for UPDATE cases ( when $this->featureId control exists ) if (!empty($this->featureId) and strtolower($capabilities->modifyAttribute) == 'false' and $fieldName != $this->geometryColumn) { if ($prop->primary) { $toSetReadOnly[] = $fieldName; } else { $toDeactivate[] = $fieldName; } } } // Hide when no modify capabilities, only for UPDATE cases ( when $this->featureId control exists ) if (!empty($this->featureId) && strtolower($capabilities->modifyAttribute) == 'false') { foreach ($toDeactivate as $de) { if ($form->getControl($de)) { $form->deactivate($de, true); } } foreach ($toSetReadOnly as $de) { if ($form->getControl($de)) { $form->setReadOnly($de, true); } } } if (!$this->primaryKeys) { jMessage::add("The table " . $this->table . " has no primary keys. The edition tool needs a primary key on the table to be defined.", "error"); return false; } return True; }
<?php /** * @package HeleneKling * @subpackage HeleneKling * @author zoolonly * @copyright 2009 zoolonly * @link http://www.yourwebsite.undefined * @license All right reserved */ jClasses::inc('Album'); jClasses::inc('Image'); jClasses::inc('Painting'); jClasses::inc('jPicasa'); jClasses::inc('OnDiskVideosService'); class basicGalleryCtrl extends jControllerDaoCrud { public $pluginParams = array('*' => array('auth.required' => true, 'zf.active' => true), 'albums' => array('auth.required' => false), 'images' => array('auth.required' => false), 'index' => array('auth.required' => false), 'search' => array('auth.required' => false), 'addComment' => array('auth.required' => false), 'viewComment' => array('auth.required' => false)); function index() { $rep = $this->getResponse('redirect'); $rep->action = 'basicGallery:albums'; return $rep; } function albums() { $rep = $this->getResponse('html'); $tpl = new Jtpl(); $picasaService = new jPicasa(); $tpl->assign('albums', $picasaService->albums()); $rep->body->assign('MAIN', $tpl->fetch('albums_html'));
function single() { $conf = jApp::config(); if (!isset($conf->enableTests) || !$conf->enableTests) { // security $rep = $this->getResponse('html', true); $rep->title = 'Error'; $rep->setHttpStatus('404', 'Not found'); $rep->addContent('<p>404 Not Found</p>'); return $rep; } $rep = $this->_prepareResponse(); $module = $this->param('mod'); $testname = $this->param('test'); if (isset($this->testsList[$module])) { $reporter = jClasses::create("junittests~jhtmlrespreporter"); jClasses::inc('junittests~junittestcase'); jClasses::inc('junittests~junittestcasedb'); $reporter->setResponse($rep); foreach ($this->testsList[$module] as $test) { if ($test[1] == $testname) { $group = new TestSuite('"' . $module . '" module , ' . $test[2]); $group->addFile($conf->_modulesPathList[$module] . 'tests/' . $test[0]); jApp::pushCurrentModule($module); $group->run($reporter); jApp::popCurrentModule(); break; } } } else { $rep->body->assign('MAIN', '<p>no tests for "' . $module . '" module.</p>'); } return $this->_finishResponse($rep); }
/** * Get layer tile info. * */ public static function getLayerTileInfo($layerName, $project, $wms_xml, $tileMatrixSetList) { $DOTS_PER_INCH = 72; $METERS_PER_INCH = 0.0254000508001016; $INCHES_PER_UNIT = array('inches' => 1.0, 'ft' => 12.0, 'mi' => 63360.0, 'm' => 39.37, 'km' => 39370, 'dd' => 4374754, 'yd' => 36); $INCHES_PER_UNIT["in"] = $INCHES_PER_UNIT['inches']; $INCHES_PER_UNIT["degrees"] = $INCHES_PER_UNIT['dd']; $INCHES_PER_UNIT["nmi"] = 1852 * $INCHES_PER_UNIT['m']; $tileWidth = 256.0; $tileHeight = 256.0; $rootLayer = $wms_xml->xpath("//wms:Capability/wms:Layer"); if (!$rootLayer || count($rootLayer) == 0) { return null; } $rootLayer = $rootLayer[0]; $rootExtent = array((double) $rootLayer->EX_GeographicBoundingBox->westBoundLongitude, (double) $rootLayer->EX_GeographicBoundingBox->southBoundLatitude, (double) $rootLayer->EX_GeographicBoundingBox->eastBoundLongitude, (double) $rootLayer->EX_GeographicBoundingBox->northBoundLatitude); $opt = $project->getOptions(); $scales = array_merge(array(), $opt->mapScales); rsort($scales); $layers = $project->getLayers(); $layer = $layers->{$layerName}; $xmlLayer = $wms_xml->xpath('//wms:Layer/wms:Name[. ="' . $layer->name . '"]/parent::*'); if (!$rootLayer || count($rootLayer) == 0) { return null; } $xmlLayer = $xmlLayer[0]; $layerExtent = null; $xmlLayers = $wms_xml->xpath('//wms:Layer/wms:Name[. ="' . $layer->name . '"]/parent::*//wms:Layer'); foreach ($xmlLayers as $xmlcLayer) { if (!property_exists($xmlcLayer, 'Layer')) { if ($layerExtent == null) { $layerExtent = array((double) $xmlcLayer->EX_GeographicBoundingBox->westBoundLongitude, (double) $xmlcLayer->EX_GeographicBoundingBox->southBoundLatitude, (double) $xmlcLayer->EX_GeographicBoundingBox->eastBoundLongitude, (double) $xmlcLayer->EX_GeographicBoundingBox->northBoundLatitude); } else { if ($layerExtent[0] > (double) $xmlcLayer->EX_GeographicBoundingBox->westBoundLongitude) { $layerExtent[0] = (double) $xmlcLayer->EX_GeographicBoundingBox->westBoundLongitude; } if ($layerExtent[1] > (double) $xmlcLayer->EX_GeographicBoundingBox->southBoundLatitude) { $layerExtent[1] = (double) $xmlcLayer->EX_GeographicBoundingBox->southBoundLatitude; } if ($layerExtent[2] < (double) $xmlcLayer->EX_GeographicBoundingBox->eastBoundLongitude) { $layerExtent[2] = (double) $xmlcLayer->EX_GeographicBoundingBox->eastBoundLongitude; } if ($layerExtent[3] < (double) $xmlcLayer->EX_GeographicBoundingBox->northBoundLatitude) { $layerExtent[3] = (double) $xmlcLayer->EX_GeographicBoundingBox->northBoundLatitude; } } } } if ($layerExtent == null) { $layerExtent = array((double) $xmlLayer->EX_GeographicBoundingBox->westBoundLongitude, (double) $xmlLayer->EX_GeographicBoundingBox->southBoundLatitude, (double) $xmlLayer->EX_GeographicBoundingBox->eastBoundLongitude, (double) $xmlLayer->EX_GeographicBoundingBox->northBoundLatitude); } // cannot be extra rootExtent if ($layerExtent[0] < $rootExtent[0]) { $layerExtent[0] = $rootExtent[0]; } if ($layerExtent[1] < $rootExtent[1]) { $layerExtent[1] = $rootExtent[1]; } if ($layerExtent[2] > $rootExtent[2]) { $layerExtent[2] = $rootExtent[2]; } if ($layerExtent[3] > $rootExtent[3]) { $layerExtent[3] = $rootExtent[3]; } $lowerCorner = (object) array('x' => $layerExtent[0], 'y' => $layerExtent[1]); $upperCorner = (object) array('x' => $layerExtent[2], 'y' => $layerExtent[3]); $opt = $project->getOptions(); jClasses::inc("proj4php~proj4php"); $proj4 = new Proj4php(); Proj4php::$defs[$opt->projection->ref] = $opt->projection->proj4; $sourceProj = new Proj4phpProj('EPSG:4326', $proj4); $tileMatrixSetLinkList = array(); foreach ($tileMatrixSetList as $tileMatrixSet) { $destProj = new Proj4phpProj($tileMatrixSet->ref, $proj4); $sourceMinPt = new proj4phpPoint($layerExtent[0], $layerExtent[1]); $destMinPt = $proj4->transform($sourceProj, $destProj, $sourceMinPt); $sourceMaxPt = new proj4phpPoint($layerExtent[2], $layerExtent[3]); $destMaxPt = $proj4->transform($sourceProj, $destProj, $sourceMaxPt); $extent = array($destMinPt->x, $destMinPt->y, $destMaxPt->x, $destMaxPt->y); $tileMatrixList = $tileMatrixSet->tileMatrixList; $tileMatrixLimits = array(); foreach ($tileMatrixList as $k => $tileMatrix) { $maxScale = $layer->maxScale; /* if ( $maxScale > $scales[0] ) $maxScale = $scales[0]; * */ $minScale = $layer->minScale; /* if ( $minScale < $scales[ count($scales) - 1 ] ) $minScale = $scales[ count($scales) - 1 ]; * */ if ($tileMatrix->scaleDenominator <= $maxScale && $tileMatrix->scaleDenominator >= $minScale) { $res = $tileMatrix->resolution; $minCol = floor(($extent[0] - $tileMatrix->left) / ($tileWidth * $res)); $maxCol = floor(($extent[2] - $tileMatrix->left) / ($tileWidth * $res)); $minRow = floor(($tileMatrix->top - $extent[3]) / ($tileHeight * $res)); $maxRow = floor(($tileMatrix->top - $extent[1]) / ($tileHeight * $res)); $tileMatrixLimits[] = (object) array('id' => $k, 'minRow' => $minRow, 'maxRow' => $maxRow, 'minCol' => $minCol, 'maxCol' => $maxCol); } } $tileMatrixSetLink = (object) array('ref' => $tileMatrixSet->ref, 'tileMatrixLimits' => null); $tileMatrixSetLink->tileMatrixLimits = $tileMatrixLimits; $tileMatrixSetLinkList[] = $tileMatrixSetLink; } $l = (object) array('id' => $layer->id, 'name' => $layer->name, 'title' => $layer->title, 'abstract' => $layer->abstract, 'imageFormat' => $layer->imageFormat, 'lowerCorner' => $lowerCorner, 'upperCorner' => $upperCorner, 'minScale' => $layer->minScale, 'maxScale' => $layer->maxScale, 'tileMatrixSetLinkList' => null); $l->tileMatrixSetLinkList = $tileMatrixSetLinkList; return $l; }
public function getDefaultBottomDockable() { jClasses::inc('view~lizmapMapDockItem'); $dockable = array(); $configOptions = $this->getOptions(); $bp = jApp::config()->urlengine['basePath']; if ($this->hasAttributeLayers()) { $form = jForms::create('view~attribute_layers_option'); $assign = array('form' => $form); $tpl = new jTpl(); $dockable[] = new lizmapMapDockItem('attributeLayers', jLocale::get('view~map.attributeLayers.navbar.title'), array('view~map_attributeLayers', $assign), 1, '', $bp . 'js/attributeTable.js'); } return $dockable; }
/** * Get a log item * @param string $key Key of the log item to get * */ public static function getLogItem($key) { if (!in_array($key, self::$logItems)) { if (!in_array($key, self::getLogItemList())) { return null; } } jClasses::inc('lizmap~lizmapLogItem'); return new lizmapLogItem($key); }
<?php /** * @package HeleneKling * @subpackage HeleneKling * @author zoolonly * @copyright 2009 zoolonly * @link http://www.yourwebsite.undefined * @license All right reserved */ jClasses::inc('PagesService'); class defaultCtrl extends jController { /** * */ public $pluginParams = array('*' => array('auth.required' => true, 'zf.active' => true), 'index' => array('auth.required' => false), 'viewPage' => array('auth.required' => false), 'login' => array('auth.required' => false), 'albums' => array('auth.required' => false)); function index() { $rep = $this->getResponse('redirect'); $rep->action = 'default:viewPage'; $rep->params['page'] = 'index'; return $rep; } function viewPage() { $page = $this->param('page'); $pageSrv = new PagesService(); $text = $pageSrv->getPage($page); $tpl = new jTpl(); $tpl->assign('text', $text);
function testOutputListboxClassDatasource() { $ctrl = new jFormsControllistbox('listboxclass'); $ctrl->datatype = new jDatatypeString(); $ctrl->label = 'Votre choix'; jClasses::inc('mydatasource'); $ctrl->datasource = new mydatasource(0); $this->form->addControl($ctrl); ob_start(); $this->builder->outputControl($ctrl); $out = ob_get_clean(); $result = '<select name="listboxclass" id="' . $this->formname . '_listboxclass" class="jforms-ctrl-listbox" size="4">' . "\n"; $result .= '<option value="aaa">label for aaa</option>' . "\n"; $result .= '<option value="bbb">label for bbb</option>' . "\n"; $result .= '<option value="ccc">label for ccc</option>' . "\n"; $result .= '<option value="ddd">label for ddd</option>' . "\n"; $result .= '</select>' . "\n"; $this->assertEqualOrDiff($result, $out); $this->assertEqualOrDiff('c = new jFormsControlString(\'listboxclass\', \'Votre choix\'); c.errInvalid=\'"Votre choix" field is invalid\'; jForms.tForm.addControl(c); ', $this->builder->getJsContent()); }
/** * to answer to jcommunity_registration_prepare_save event * @param object $event the given event to answer to */ function onjcommunity_registration_prepare_save($event) { $user = $event->getParam('user'); // check if the user try to register with a banned domain jClasses::inc('havefnubb~bans'); // $return is false when the domain of the email is not banned // otherwise ; $return contain the message of the ban $return = bans::checkDomain($user->email); if (is_string($return)) { $event->Add(array('errorRegistration' => $return)); } else { $event->Add(array('errorRegistration' => '')); } }
<?php /** * @package HeleneKling * @subpackage HeleneKling * @author zoolonly * @copyright 2009 zoolonly * @link http://www.yourwebsite.undefined * @license All right reserved */ jClasses::inc('EmailService'); jClasses::inc('jPicasa~jPicasa'); jClasses::inc('jPicasa~Painting'); class defaultCtrl extends jController { public $pluginParams = array('*' => array('auth.required' => true, 'zf.active' => true), 'index' => array('auth.required' => false), 'newPaintingsLetter' => array('zf.active' => true), 'getEmails' => array('auth.required' => false), 'sendViaGoogle' => array('auth.required' => false), 'getLogs' => array('auth.required' => false), 'getNbSent' => array('auth.required' => false), 'clearLogs' => array('auth.required' => false)); function index() { $tpl = new jTpl(); $rep = $this->getResponse('html'); $rep->body->assign('MAIN', $tpl->fetch('index')); return $rep; } function newletter() { $rep = $this->getResponse('html'); $tpl = new jTpl(); $form = jForms::create('NewsLetter~news'); $tpl->assign('form', $form); $rep->body->assign('MAIN', $tpl->fetch('new')); return $rep;
function GetTile() { jClasses::inc('lizmap~lizmapWMTSRequest'); $wmsRequest = new lizmapWMTSRequest($this->project, $this->params); $result = $wmsRequest->process(); $rep = $this->getResponse('binary'); $rep->mimeType = $result->mime; $rep->content = $result->data; $rep->doDownload = false; $rep->outputFileName = 'qgis_server_wmts_tile_' . $this->repository->getKey() . '_' . $this->project->getKey(); $rep->setHttpStatus($result->code, ''); if (!preg_match('/^image/', $result->mime)) { return $rep; } // HTTP browser cache expiration time $layername = $this->params["layer"]; $lproj = lizmap::getProject($this->repository->getKey() . '~' . $this->project->getKey()); $configLayers = $lproj->getLayers(); if (property_exists($configLayers, $layername)) { $configLayer = $configLayers->{$layername}; if (property_exists($configLayer, 'clientCacheExpiration')) { $clientCacheExpiration = (int) $configLayer->clientCacheExpiration; $rep->setExpires("+" . $clientCacheExpiration . " seconds"); } } return $rep; }
<?php /** * @package amigatlk * @subpackage amigatlk * @author Bruno Ethvignot <bruno at tlk dot biz> * @copyright TLK Games * @created 2013-04-01 * @date 2013-05-19 * @link http://amiga.tlk.fr/ * @license All rights reserved */ jClasses::inc('content'); class games extends content { private function getGamesPath() { return jApp::appPath('games'); } public function getProduct($name) { $game = $this->getContent($name); $game->code = $name; $screenshots = trim(array_shift($game->content)); if (empty($screenshots)) { $game->screenshots = array(); } else { $game->screenshots = explode(",", $screenshots); } // JLog::dump($game); return $game;
<?php /** * @package havefnubb * @subpackage hfnusearch * @author FoxMaSk * @copyright 2008-2011 FoxMaSk * @link http://havefnubb.org * @licence http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file */ /** * Class that manage specific behavior of the search engine for HaveFnuBB */ jClasses::inc('hfnusearch~search_index'); class search_index_havefnubb extends search_index { /** * default searchEngineRun methode which make a search from the engine by querying the table define in the dao of the hfnusearch.ini.php file * @param object $event */ function searchEngineRun($event) { $cleaner = jClasses::getService('hfnusearch~cleaner'); $words = $cleaner->stemPhrase($event->getParam('string')); $page = (int) $event->getParam('page'); $limit = (int) $event->getParam('limit'); $id_forum = (int) $event->getParam('id_forum'); // no words ; go back with nothing :P if (!$words) { return array('count' => 0, 'result' => array()); }
/** * */ function seeding() { $fakeServer = new jelix\FakeServerConf\ApacheMod(jApp::wwwPath(), '/index.php'); $forced = $this->option('-f'); $verbose = $this->option('-v'); $rep = $this->getResponse(); // cmdline response by default $project = lizmap::getProject($this->param('repository') . '~' . $this->param('project')); // Project not found if (!$project) { $rep->addContent("The project has not be found!\n"); return $rep; } $repository = $project->getRepository(); jClasses::inc('lizmap~lizmapWMTSRequest'); $cacheId = $repository->getKey() . '_' . $project->getKey() . '_WMTS'; $tileMatrixSetList = jCache::get($cacheId . '_tileMatrixSetList'); if (!$tileMatrixSetList) { $request = new lizmapWMTSRequest($project, array('service' => 'WMTS', 'request' => 'GetCapabilities')); $result = $request->process(); $tileMatrixSetList = jCache::get($cacheId . '_tileMatrixSetList'); } $layers = $tileMatrixSetList = jCache::get($cacheId . '_layers'); $layerIds = explode(',', $this->param('layers')); $selectedLayers = array(); foreach ($layers as $l) { if (in_array('*', $layerIds) || in_array($l->name, $layerIds)) { $selectedLayers[] = $l; } } // Layer not found if (count($selectedLayers) == 0) { $rep->addContent("The layers '" . implode(',', $layerIds) . "' have not be found!\n"); return $rep; } foreach ($selectedLayers as $layer) { $TileMatrixSetId = $this->param('TileMatrixSet'); $tileMatrixSetLink = null; foreach ($layer->tileMatrixSetLinkList as $tms) { if ($tms->ref == $TileMatrixSetId) { $tileMatrixSetLink = $tms; break; } } // TileMatrixSet not found if (!$tileMatrixSetLink) { $rep->addContent("The TileMatrixSet '" . $TileMatrixSetId . "' has not be found!\n"); continue; } $TileMatrixMin = (int) $this->param('TileMatrixMin'); $TileMatrixMax = (int) $this->param('TileMatrixMax'); // count tiles $tileCount = 0; foreach ($tileMatrixSetLink->tileMatrixLimits as $tileMatrixLimit) { if ($tileMatrixLimit->id >= $TileMatrixMin && $tileMatrixLimit->id <= $TileMatrixMax) { $tmCount = ($tileMatrixLimit->maxRow - $tileMatrixLimit->minRow + 1) * ($tileMatrixLimit->maxCol - $tileMatrixLimit->minCol + 1); if ($verbose) { $rep->addContent($tmCount . ' tiles to generate for "' . $layer->name . '" "' . $TileMatrixSetId . '" "' . $tileMatrixLimit->id . '"' . "\n"); } $tileCount += $tmCount; } } if ($verbose) { $rep->addContent($tileCount . ' tiles to generate for "' . $layer->name . '" "' . $TileMatrixSetId . '" between "' . $TileMatrixMin . '" and "' . $TileMatrixMax . '"' . "\n"); } // generate tiles $rep->addContent("Start generation\n"); $rep->addContent("================\n"); $tileProgress = 0; $tileStepHeight = max(5.0, floor(5 * 100 / $tileCount)); $tileStep = $tileStepHeight; foreach ($tileMatrixSetLink->tileMatrixLimits as $tileMatrixLimit) { if ($tileMatrixLimit->id >= $TileMatrixMin && $tileMatrixLimit->id <= $TileMatrixMax) { $row = (int) $tileMatrixLimit->minRow; //$rep->addContent( $tileMatrixLimit->id.' '.$tileMatrixLimit->minRow.' '.$tileMatrixLimit->maxRow.' '.$tileMatrixLimit->minCol.' '.$tileMatrixLimit->maxCol."\n"); while ($row <= $tileMatrixLimit->maxRow) { $col = (int) $tileMatrixLimit->minCol; while ($col <= $tileMatrixLimit->maxCol) { $request = new lizmapWMTSRequest($project, array('service' => 'WMTS', 'version' => '1.0.0', 'request' => 'GetTile', 'layer' => $layer->name, 'format' => $layer->imageFormat, 'TileMatrixSet' => $TileMatrixSetId, 'TileMatrix' => $tileMatrixLimit->id, 'TileRow' => $row, 'TileCol' => $col)); if ($forced) { $request->setForceRequest(True); } $result = $request->process(); //$rep->addContent($layer->name.' '.$layer->imageFormat.' '.$TileMatrixSetId.' '.$tileMatrixLimit->id.' '.$row.' '.$col.' '.$result->code."\n"); $col += 1; $tileProgress += 1; if ($verbose && $tileProgress * 100 / $tileCount >= $tileStep) { $tileStep = floor($tileProgress * 100 / $tileCount); $rep->addContent('Progression: ' . $tileStep . '%, ' . $tileProgress . ' tiles generated on ' . $tileCount . ' tiles' . "\n"); $tileStep = $tileStep + $tileStepHeight; } } $row += 1; } } } $rep->addContent("================\n"); $rep->addContent("End generation\n"); } return $rep; }
function single() { $rep = $this->_prepareResponse(); $module = $this->param('mod'); $testname = $this->param('test'); $category = $this->category ? ' ' . $this->category : ''; if (isset($this->testsList[$module])) { $reporter = jClasses::create($this->responseType); jClasses::inc('junittests~junittestcase'); jClasses::inc('junittests~junittestcasedb'); $reporter->setResponse($rep); foreach ($this->testsList[$module] as $test) { if ($test[1] == $testname) { $group = new TestSuite('"' . $module . '" module , ' . $test[2]); $group->addFile(jApp::config()->_modulesPathList[$module] . 'tests/' . $test[0]); jApp::pushCurrentModule($module); $result = $group->run($reporter); if (!$result) { $rep->setExitCode(jResponseCmdline::EXIT_CODE_ERROR); } jApp::popCurrentModule(); break; } } } else { $this->output("\n" . 'no' . $category . ' tests for "' . $module . '" module.' . "\n"); } return $this->_finishResponse($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)); }
<?php /** * Manage OGC request. * @package lizmap * @subpackage lizmap * @author 3liz * @copyright 2015 3liz * @link http://3liz.com * @license Mozilla Public License : http://www.mozilla.org/MPL/ */ jClasses::inc('lizmap~lizmapProxy'); jClasses::inc('lizmap~lizmapOGCRequest'); class lizmapWMSRequest extends lizmapOGCRequest { protected $tplExceptions = 'lizmap~wms_exception'; private $forceRequest = False; public function getForceRequest() { return $this->forceRequest; } public function setForceRequest($forced) { return $this->forceRequest = $forced; } protected function getcapabilities() { $result = parent::getcapabilities(); if ($result->cached) { return $result; }
protected function _prepareTpl() { $protocol = jApp::coord()->request->getProtocol(); $this->_tpl->assign('protocol', $protocol); $domain = jApp::coord()->request->getDomainName(); $this->_tpl->assign('domain', $domain); 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(); } 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) { $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); }