diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..22d6f3c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +language: php + +php: + - 5.2 + - 5.3 + #- 5.4 + +env: + - OMEKA_BRANCH=stable-1.5 + #- OMEKA_BRANCH=master + +before_script: + - ./travis_setup.sh + +script: ./travis_tests.sh + +notifications: + irc: "irc.freenode.org#slab" diff --git a/.tx/config b/.tx/config new file mode 100644 index 0000000..56149c0 --- /dev/null +++ b/.tx/config @@ -0,0 +1,8 @@ +[main] +host = https://www.transifex.com + +[neatline.neatline-maps] +file_filter = languages/.po +source_file = languages/template.pot +source_lang = en + diff --git a/NeatlineMapsPlugin.php b/NeatlineMapsPlugin.php index 7167ee1..8c19444 100644 --- a/NeatlineMapsPlugin.php +++ b/NeatlineMapsPlugin.php @@ -18,7 +18,9 @@ class NeatlineMapsPlugin 'public_append_to_items_show', 'before_delete_item', 'public_theme_header', - 'admin_theme_header' + 'admin_theme_header', + 'initialize', + 'define_acl' ); private static $_filters = array( @@ -201,20 +203,41 @@ public function defineRoutes($router) public function afterSaveFormItem($item, $post) { - if (!isset($_FILES['file']) - || count($_FILES['file']['size']) == 1 - && empty($_FILES['file']['size'][0]) - ) { + $hasTiff = false; + if (isset($_FILES['file'])) { - // Create/update/delete WMS. - $this->servicesTable->createOrUpdate( - $item, - $post['address'], - $post['layers'] - ); + $fcount = count($_FILES['file']['name']); + for ($i=0; $i<$fcount; $i++) { + $hasTiff = $hasTiff || + (!empty($_FILES['file']['size'][$i]) && + $_FILES['file']['type'][$i] == 'image/tiff'); + } } + if (!$hasTiff) { + $this->_createOrUpdateWMS($item, $post); + } + + } + + + /** + * This creates or updates the WMS server on an item. + * + * @param Item $item The item. + * @param array $post The complete $_POST. + * + * @return void + * @author Eric Rochester + **/ + protected function _createOrUpdateWMS($item, $post) + { + $this->servicesTable->createOrUpdate( + $item, + $post['address'], + $post['layers'] + ); } /** @@ -338,6 +361,47 @@ public function adminThemeHeader($request) } + /** + * Initialization. + * + * Adds translation source. + * + * @return void. + */ + public function initialize() + { + add_translation_source(dirname(__FILE__) . '/languages'); + } + + /** + * Define the ACL + */ + public function defineAcl($acl) + { + $resourceName = 'NeatlineMaps_Servers'; + + $resourceList = array( + $resourceName => array( + 'add', + 'browse', + 'edit', + 'delete', + 'show', + 'active' + ) + ); + + if (!$acl->has($resourceName)) { + $acl->loadResourceList($resourceList); + foreach ($resourceList as $resource => $privileges) { + $acl->deny(null, $resource); + $acl->allow('super', $resource); + $acl->allow('admin', $resource); + } + } + + + } /** * Filter callbacks: @@ -354,7 +418,10 @@ public function adminThemeHeader($request) public function adminNavigationMain($tabs) { - $tabs[__('Neatline Maps')] = uri('neatline-maps'); + if (has_permission('NeatlineMaps_Servers', 'browse')) { + $tabs['Neatline Maps'] = uri('neatline-maps'); + } + return $tabs; } diff --git a/README.md b/README.md index ad9864d..c266242 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Neatline Maps +[![Build Status](https://secure.travis-ci.org/scholarslab/NeatlineMaps.png)](http://travis-ci.org/scholarslab/NeatlineMaps) + Working with geospatial data can be difficult. The NeatlineMaps plugin allows you to upload georeferenced maps to the popular open source [Geoserver][geoserver], allowing you not only to use your data easily in Omeka, @@ -151,13 +153,38 @@ Neatline will automatically render the map on the exhibit. In this way, you can configure any combination of WMS maps in the exhibit by activating or deactivating the Omeka items associated with that exhibit. +### Migrating Data to Another Server + +Often when developing a site, it's useful to be able to work on a separate +server running GeoServer, whether on your laptop or on a staging site. You can +easily migrate this information to your production server. GeoServer keeps all +configuration and data in its [data directory][geoserver-data]. To find where +this is, go into GeoServer and click the *Server Status* link at the top of the +left column. The first item on the status page is the location of the data +directory. + +![GeoServer Data Directory](http://neatline.org/wp-content/uploads/2012/08/geoserver-data-dir.png) + +Now after you install GeoServer on the final server, you can copy the data +directory from the old server onto the new server and have access to your data. + ## Support We use an [issue tracker][issues] for feedback on issues and requested improvements. If you have general questions, you may also post them to the [Omeka Forums][forums]  or the [Omeka Developers Group][groups]. +## Credits + +### Translations + +* Martin Liebeskind (German) +* Gillian Price (Spanish) +* Oguljan Reyimbaeva (Russian) +* Katina Rogers (French) + [geoserver]: http://geoserver.org +[geoserver-data]: http://docs.geoserver.org/latest/en/user/datadirectory/index.html [neatline-maps-download]: http://neatline.scholarslab.org/plugins/neatline-maps [ogc]: http://www.opengeospatial.org/ [gmaps]: http://maps.google.com/ diff --git a/controllers/ServersController.php b/controllers/ServersController.php index cb6a8ea..96b8f7a 100644 --- a/controllers/ServersController.php +++ b/controllers/ServersController.php @@ -1,5 +1,5 @@ serversTable = $this->getTable('NeatlineMapsServer'); - } - /** - * Show servers. - * - * @return void - */ - public function browseAction() - { - $this->view->servers = $this->serversTable->findAll(); + $modelName = 'NeatlineMapsServer'; + if (version_compare(OMEKA_VERSION, '2.0-dev', '>=')) { + $this->_helper->db->setDefaultModelName($modelName); + } else { + $this->_modelClass = $modelName; + } + + try { + $this->_table = $this->getTable($modelName); + $this->aclResource = $this->findById(); + } catch (Omeka_Controller_Exception_404 $e) {} + } /** @@ -57,7 +59,7 @@ public function addAction() if ($form->isValid($post)) { // Create server. - $this->serversTable->updateServer($server, $post); + $this->_table->updateServer($server, $post); // Redirect to browse. $this->redirect->goto('browse'); @@ -85,9 +87,7 @@ public function editAction() { // Get server. - $server = $this->serversTable->find( - $this->_request->getParam('id') - ); + $server = $this->findById(); // Get form. $form = new ServerForm; @@ -112,7 +112,7 @@ public function editAction() if ($form->isValid($post)) { // Create server. - $this->serversTable->updateServer($server, $post); + $this->_table->updateServer($server, $post); // Redirect to browse. $this->redirect->goto('browse'); @@ -131,30 +131,6 @@ public function editAction() } - /** - * Delete server. - * - * @return void - */ - public function deleteAction() - { - - // Get server. - $server = $this->serversTable->find( - $this->_request->getParam('id') - ); - - // If a form as been posted. - if ($this->_request->isPost()) { - $server->delete(); - $this->redirect->goto('browse'); - } - - // Push server to view. - $this->view->server = $server; - - } - /** * Set server active. * @@ -164,9 +140,7 @@ public function activeAction() { // Get server. - $server = $this->serversTable->find( - $this->_request->getParam('id') - ); + $server = $this->findById(); // Set active and save. $server->active = 1; @@ -177,4 +151,11 @@ public function activeAction() } + /** + * Sets the delete confirm message + */ + protected function _getDeleteConfirmMessage($server) + { + return __('This will permanently delete the %s server.', $server->name); + } } diff --git a/forms/ServerForm.php b/forms/ServerForm.php index e43f8bf..f2505ec 100644 --- a/forms/ServerForm.php +++ b/forms/ServerForm.php @@ -1,5 +1,5 @@ , 2012. +# Martin Liebeskind , 2012. +msgid "" +msgstr "" +"Project-Id-Version: Neatline\n" +"Report-Msgid-Bugs-To: http://github.com/scholarslab/\n" +"POT-Creation-Date: 2012-06-22 11:30-0500\n" +"PO-Revision-Date: 2012-08-28 18:57+0000\n" +"Last-Translator: Martin Liebeskind \n" +"Language-Team: German (Germany) (http://www.transifex.com/projects/p/neatline/language/de_DE/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: de_DE\n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" + +#: NeatlineMapsPlugin.php:451 +msgid "Web Map Service" +msgstr "Web Kartendienst" + +#: controllers/ServersController.php:159 +#, php-format +msgid "This will permanently delete the %s server." +msgstr "Dies löscht den %s Server unwiderruflich." + +#: forms/ServerForm.php:35 +msgid "An internal (non-public) identifier for the server." +msgstr "Eine interne (nicht öffentliche) Kennung für den Server." + +#: forms/ServerForm.php:42 +msgid "Enter a name." +msgstr "Bitte einen Namen eingeben." + +#: forms/ServerForm.php:51 views/admin/servers/browse.php:41 +msgid "URL" +msgstr "URL" + +#: forms/ServerForm.php:52 +msgid "The location of the server." +msgstr "Die Adresse des Servers." + +#: forms/ServerForm.php:59 +msgid "Enter a URL." +msgstr "Bitte eine URL eingeben." + +#: forms/ServerForm.php:75 views/admin/servers/browse.php:42 +msgid "Workspace" +msgstr "Arbeitsbereich" + +#: forms/ServerForm.php:76 +msgid "Enter the Geoserver workspace." +msgstr "Bitte den Geoserver Arbeitsbereich eingeben." + +#: forms/ServerForm.php:83 +msgid "Enter a workspace." +msgstr "Bitte einen Arbeitsbereich eingeben." + +#: forms/ServerForm.php:93 +msgid "Enter the Geoserver username." +msgstr "Bitte den Benutzernamen des Geoservers eingeben." + +#: forms/ServerForm.php:100 +msgid "Enter a username." +msgstr "Bitte einen Benutzernamen eingeben" + +#: forms/ServerForm.php:110 +msgid "Enter the Geoserver password." +msgstr "Bitte das Passwort des Geoservers eingeben." + +#: forms/ServerForm.php:118 +msgid "Enter a password." +msgstr "Bitte ein Passwort eingeben." + +#: forms/ServerForm.php:128 +msgid "Should this server be used to handle new GeoTiff uploads?" +msgstr "Soll dieser Server zur Verwendung von GeoTiff-Uploads benutzt werden?" + +#: forms/ServerForm.php:134 +msgid "Save" +msgstr "Speichern" + +#: models/NeatlineMapsServer.php:103 +msgid "Online" +msgstr "Online" + +#: models/NeatlineMapsServer.php:104 +msgid "Offline" +msgstr "Offline" + +#: models/NeatlineMapsServer.php:105 +msgid "Authentication Error" +msgstr "Authentifizierungfehler" + +#: views/admin/items/_serviceForm.php:17 +msgid "WMS Address" +msgstr "WMS Adresse" + +#: views/admin/items/_serviceForm.php:21 +msgid "Enter the WMS address of the map." +msgstr "Bitte die WMS Adresse der Karte eingeben." + +#: views/admin/items/_serviceForm.php:25 +msgid "Layers" +msgstr "Ebenen" + +#: views/admin/items/_serviceForm.php:29 +msgid "Enter a comma-delimited list of layers." +msgstr "Bitte eine komma-separierte Liste von Ebenen eingeben." + +#: views/admin/servers/add.php:17 +msgid "Neatline Maps | Create Server" +msgstr "Neatline Maps | Server erstellen" + +#: views/admin/servers/add.php:24 views/admin/servers/browse.php:25 +#: views/admin/servers/edit.php:24 +msgid "Create a Server" +msgstr "Einen Server erstellen" + +#: views/admin/servers/browse.php:18 +msgid "Neatline Maps | Browse Servers" +msgstr "Neatline Maps | Server durchsuchen" + +#: views/admin/servers/browse.php:40 +msgid "Server" +msgstr "Server" + +#: views/admin/servers/browse.php:43 +msgid "Status" +msgstr "Status" + +#: views/admin/servers/browse.php:45 +msgid "Actions" +msgstr "Aktionen" + +#: views/admin/servers/browse.php:69 +msgid "Set Active" +msgstr "Aktivieren" + +#: views/admin/servers/browse.php:85 +msgid "There are no servers yet." +msgstr "Zurzeit sind keine Server konfiguriert." + +#: views/admin/servers/browse.php:86 +msgid "Create one!" +msgstr "Erstelle einen!" + +#: views/admin/servers/edit.php:17 +msgid "Neatline Maps | Edit Server" +msgstr "Neatline Maps | Server bearbeiten" diff --git a/languages/es.mo b/languages/es.mo new file mode 100644 index 0000000..70379f4 Binary files /dev/null and b/languages/es.mo differ diff --git a/languages/es.po b/languages/es.po new file mode 100644 index 0000000..4c372c5 --- /dev/null +++ b/languages/es.po @@ -0,0 +1,151 @@ +# Translation for the Neatline Time plugin for Omeka. +# +# Translators: +# , 2012. +msgid "" +msgstr "" +"Project-Id-Version: Neatline\n" +"Report-Msgid-Bugs-To: http://github.com/scholarslab/\n" +"POT-Creation-Date: 2012-06-22 11:30-0500\n" +"PO-Revision-Date: 2012-08-20 17:13+0000\n" +"Last-Translator: gbp2q \n" +"Language-Team: Spanish (http://www.transifex.com/projects/p/neatline/language/es/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: es\n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" + +#: NeatlineMapsPlugin.php:451 +msgid "Web Map Service" +msgstr "Servicio de mapa del web." + +#: controllers/ServersController.php:159 +#, php-format +msgid "This will permanently delete the %s server." +msgstr "Esto borrará peramentemente el %s servidor." + +#: forms/ServerForm.php:35 +msgid "An internal (non-public) identifier for the server." +msgstr "Un identificador interno (no público) para el servidor. " + +#: forms/ServerForm.php:42 +msgid "Enter a name." +msgstr "Inscriba un nombre. " + +#: forms/ServerForm.php:51 views/admin/servers/browse.php:41 +msgid "URL" +msgstr "URL" + +#: forms/ServerForm.php:52 +msgid "The location of the server." +msgstr "La locación del servidor." + +#: forms/ServerForm.php:59 +msgid "Enter a URL." +msgstr "Inscriba un URL." + +#: forms/ServerForm.php:75 views/admin/servers/browse.php:42 +msgid "Workspace" +msgstr "Espacio de trabajo." + +#: forms/ServerForm.php:76 +msgid "Enter the Geoserver workspace." +msgstr "Inscriba el espacio de trabajo para el Geoserver." + +#: forms/ServerForm.php:83 +msgid "Enter a workspace." +msgstr "Inscriba un espacio de trabajo. " + +#: forms/ServerForm.php:93 +msgid "Enter the Geoserver username." +msgstr "Inscriba un nombre de usuario para el Geoserver. " + +#: forms/ServerForm.php:100 +msgid "Enter a username." +msgstr "Inscriba un nombre de usuario. " + +#: forms/ServerForm.php:110 +msgid "Enter the Geoserver password." +msgstr "Inscriba la contraseña para el Geoserver." + +#: forms/ServerForm.php:118 +msgid "Enter a password." +msgstr "Inscriba una contraseña. " + +#: forms/ServerForm.php:128 +msgid "Should this server be used to handle new GeoTiff uploads?" +msgstr "¿Se debe usar este servidor para nuevos cargos de GeoTiff?" + +#: forms/ServerForm.php:134 +msgid "Save" +msgstr "Guardar." + +#: models/NeatlineMapsServer.php:103 +msgid "Online" +msgstr "Conectado" + +#: models/NeatlineMapsServer.php:104 +msgid "Offline" +msgstr "Desconectado" + +#: models/NeatlineMapsServer.php:105 +msgid "Authentication Error" +msgstr "Error autenticación" + +#: views/admin/items/_serviceForm.php:17 +msgid "WMS Address" +msgstr "Dirección del WMS." + +#: views/admin/items/_serviceForm.php:21 +msgid "Enter the WMS address of the map." +msgstr "Inscriba la dirección del WMS del mapa. " + +#: views/admin/items/_serviceForm.php:25 +msgid "Layers" +msgstr "Capas." + +#: views/admin/items/_serviceForm.php:29 +msgid "Enter a comma-delimited list of layers." +msgstr "Inscriba una lista de capas que sean delimitados por comas." + +#: views/admin/servers/add.php:17 +msgid "Neatline Maps | Create Server" +msgstr "Mapas de Neatline | Crear servidor" + +#: views/admin/servers/add.php:24 views/admin/servers/browse.php:25 +#: views/admin/servers/edit.php:24 +msgid "Create a Server" +msgstr "Crear servidor." + +#: views/admin/servers/browse.php:18 +msgid "Neatline Maps | Browse Servers" +msgstr "Mapas de Neatline | Explorar servidores" + +#: views/admin/servers/browse.php:40 +msgid "Server" +msgstr "Servidor" + +#: views/admin/servers/browse.php:43 +msgid "Status" +msgstr "Estatus" + +#: views/admin/servers/browse.php:45 +msgid "Actions" +msgstr "Acciones" + +#: views/admin/servers/browse.php:69 +msgid "Set Active" +msgstr "Poner activo" + +#: views/admin/servers/browse.php:85 +msgid "There are no servers yet." +msgstr "No hay servidores todavía." + +#: views/admin/servers/browse.php:86 +msgid "Create one!" +msgstr "¡Crear uno!" + +#: views/admin/servers/edit.php:17 +msgid "Neatline Maps | Edit Server" +msgstr "Mapas de Neatline | Editar servidor " diff --git a/languages/fr.mo b/languages/fr.mo new file mode 100644 index 0000000..300dbf1 Binary files /dev/null and b/languages/fr.mo differ diff --git a/languages/fr.po b/languages/fr.po new file mode 100644 index 0000000..23bbcd1 --- /dev/null +++ b/languages/fr.po @@ -0,0 +1,152 @@ +# Translation for the Neatline Time plugin for Omeka. +# +# Translators: +# Jeremy Boggs , 2012. +# , 2012. +msgid "" +msgstr "" +"Project-Id-Version: Neatline\n" +"Report-Msgid-Bugs-To: http://github.com/scholarslab/\n" +"POT-Creation-Date: 2012-06-22 11:30-0500\n" +"PO-Revision-Date: 2012-08-20 16:52+0000\n" +"Last-Translator: Jeremy Boggs \n" +"Language-Team: French (http://www.transifex.com/projects/p/neatline/language/fr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: fr\n" +"Plural-Forms: nplurals=2; plural=(n > 1)\n" + +#: NeatlineMapsPlugin.php:451 +msgid "Web Map Service" +msgstr "Web Map Service" + +#: controllers/ServersController.php:159 +#, php-format +msgid "This will permanently delete the %s server." +msgstr "Cette action supprimera définitivement le serveur %s" + +#: forms/ServerForm.php:35 +msgid "An internal (non-public) identifier for the server." +msgstr "Un identifiant à l'usage interne (privé) pour le serveur." + +#: forms/ServerForm.php:42 +msgid "Enter a name." +msgstr "Indiquez le nom." + +#: forms/ServerForm.php:51 views/admin/servers/browse.php:41 +msgid "URL" +msgstr "URL" + +#: forms/ServerForm.php:52 +msgid "The location of the server." +msgstr "La localisation du serveur." + +#: forms/ServerForm.php:59 +msgid "Enter a URL." +msgstr "Indiquez l'URL." + +#: forms/ServerForm.php:75 views/admin/servers/browse.php:42 +msgid "Workspace" +msgstr "Espace de travail" + +#: forms/ServerForm.php:76 +msgid "Enter the Geoserver workspace." +msgstr "Indiquez l'espace du travail Geoserver" + +#: forms/ServerForm.php:83 +msgid "Enter a workspace." +msgstr "Indiquez un espace de travail." + +#: forms/ServerForm.php:93 +msgid "Enter the Geoserver username." +msgstr "Indiquez un nom d'utilisateur pour Geoserver." + +#: forms/ServerForm.php:100 +msgid "Enter a username." +msgstr "Indiquez un nom d'utilisateur." + +#: forms/ServerForm.php:110 +msgid "Enter the Geoserver password." +msgstr "Indiquez le mot de passe pour Geoserver." + +#: forms/ServerForm.php:118 +msgid "Enter a password." +msgstr "Choisissez un mot de passe." + +#: forms/ServerForm.php:128 +msgid "Should this server be used to handle new GeoTiff uploads?" +msgstr "Voulez-vous utiliser ce serveur pour gérer des nouveaux objets GeoTiff téléchargés?" + +#: forms/ServerForm.php:134 +msgid "Save" +msgstr "Enregistrer" + +#: models/NeatlineMapsServer.php:103 +msgid "Online" +msgstr "En ligne" + +#: models/NeatlineMapsServer.php:104 +msgid "Offline" +msgstr "Déconnecté" + +#: models/NeatlineMapsServer.php:105 +msgid "Authentication Error" +msgstr "Erreur d'authentification" + +#: views/admin/items/_serviceForm.php:17 +msgid "WMS Address" +msgstr "Adresse WMS" + +#: views/admin/items/_serviceForm.php:21 +msgid "Enter the WMS address of the map." +msgstr "Indiquez l'adresse WMS de la carte." + +#: views/admin/items/_serviceForm.php:25 +msgid "Layers" +msgstr "Calques" + +#: views/admin/items/_serviceForm.php:29 +msgid "Enter a comma-delimited list of layers." +msgstr "Indiquez une liste de calques separées par virgules." + +#: views/admin/servers/add.php:17 +msgid "Neatline Maps | Create Server" +msgstr "Neatline Maps | Créer un serveur" + +#: views/admin/servers/add.php:24 views/admin/servers/browse.php:25 +#: views/admin/servers/edit.php:24 +msgid "Create a Server" +msgstr "Créez un serveur" + +#: views/admin/servers/browse.php:18 +msgid "Neatline Maps | Browse Servers" +msgstr "Neatline Maps | Feuilleter des serveurs" + +#: views/admin/servers/browse.php:40 +msgid "Server" +msgstr "Serveur" + +#: views/admin/servers/browse.php:43 +msgid "Status" +msgstr "Statut" + +#: views/admin/servers/browse.php:45 +msgid "Actions" +msgstr "Actions" + +#: views/admin/servers/browse.php:69 +msgid "Set Active" +msgstr "Définir comme actif" + +#: views/admin/servers/browse.php:85 +msgid "There are no servers yet." +msgstr "Il n'existe pas de serveurs." + +#: views/admin/servers/browse.php:86 +msgid "Create one!" +msgstr "Créez-en un!" + +#: views/admin/servers/edit.php:17 +msgid "Neatline Maps | Edit Server" +msgstr "Neatline Maps | Modifier le serveur" diff --git a/languages/ru.mo b/languages/ru.mo new file mode 100644 index 0000000..a269629 Binary files /dev/null and b/languages/ru.mo differ diff --git a/languages/ru.po b/languages/ru.po new file mode 100644 index 0000000..3f180e9 --- /dev/null +++ b/languages/ru.po @@ -0,0 +1,151 @@ +# Translation for the Neatline Time plugin for Omeka. +# +# Translators: +# , 2012. +msgid "" +msgstr "" +"Project-Id-Version: Neatline\n" +"Report-Msgid-Bugs-To: http://github.com/scholarslab/\n" +"POT-Creation-Date: 2012-06-22 11:30-0500\n" +"PO-Revision-Date: 2012-08-30 18:59+0000\n" +"Last-Translator: Oguljan \n" +"Language-Team: Russian (http://www.transifex.com/projects/p/neatline/language/ru/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: ru\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n" + +#: NeatlineMapsPlugin.php:451 +msgid "Web Map Service" +msgstr "Сервис веб-карт" + +#: controllers/ServersController.php:159 +#, php-format +msgid "This will permanently delete the %s server." +msgstr "Это приведет к безвозвратному удалению сервера %s." + +#: forms/ServerForm.php:35 +msgid "An internal (non-public) identifier for the server." +msgstr "Внутренний (не общественный) идентификатор сервера." + +#: forms/ServerForm.php:42 +msgid "Enter a name." +msgstr "Введите имя." + +#: forms/ServerForm.php:51 views/admin/servers/browse.php:41 +msgid "URL" +msgstr "URL" + +#: forms/ServerForm.php:52 +msgid "The location of the server." +msgstr "Местоположение сервера." + +#: forms/ServerForm.php:59 +msgid "Enter a URL." +msgstr "Введите URL." + +#: forms/ServerForm.php:75 views/admin/servers/browse.php:42 +msgid "Workspace" +msgstr "Рабочая область памяти" + +#: forms/ServerForm.php:76 +msgid "Enter the Geoserver workspace." +msgstr "Введите рабочую область Geoserver." + +#: forms/ServerForm.php:83 +msgid "Enter a workspace." +msgstr "Введите рабочую область." + +#: forms/ServerForm.php:93 +msgid "Enter the Geoserver username." +msgstr "Введите имя пользователя в Geoserver." + +#: forms/ServerForm.php:100 +msgid "Enter a username." +msgstr "Введите имя пользователя." + +#: forms/ServerForm.php:110 +msgid "Enter the Geoserver password." +msgstr "Введите пароль в Geoserver." + +#: forms/ServerForm.php:118 +msgid "Enter a password." +msgstr "Введите пароль." + +#: forms/ServerForm.php:128 +msgid "Should this server be used to handle new GeoTiff uploads?" +msgstr "Следует ли использовать этот сервер для обработки вновь загружаемых данных в формате GeoTiff? " + +#: forms/ServerForm.php:134 +msgid "Save" +msgstr "Сохранить" + +#: models/NeatlineMapsServer.php:103 +msgid "Online" +msgstr "Онлайн" + +#: models/NeatlineMapsServer.php:104 +msgid "Offline" +msgstr "Офлайн" + +#: models/NeatlineMapsServer.php:105 +msgid "Authentication Error" +msgstr "Ошибка при попытке аутентификации" + +#: views/admin/items/_serviceForm.php:17 +msgid "WMS Address" +msgstr "WMS-адрес" + +#: views/admin/items/_serviceForm.php:21 +msgid "Enter the WMS address of the map." +msgstr "Введите WMS-адрес карты." + +#: views/admin/items/_serviceForm.php:25 +msgid "Layers" +msgstr "Слои" + +#: views/admin/items/_serviceForm.php:29 +msgid "Enter a comma-delimited list of layers." +msgstr "Введите список слоев, разделенных запятыми." + +#: views/admin/servers/add.php:17 +msgid "Neatline Maps | Create Server" +msgstr "Карты Neatline | Создать сервер" + +#: views/admin/servers/add.php:24 views/admin/servers/browse.php:25 +#: views/admin/servers/edit.php:24 +msgid "Create a Server" +msgstr "Создать сервер" + +#: views/admin/servers/browse.php:18 +msgid "Neatline Maps | Browse Servers" +msgstr "Карты Neatline | Просмотреть серверы" + +#: views/admin/servers/browse.php:40 +msgid "Server" +msgstr "Сервер" + +#: views/admin/servers/browse.php:43 +msgid "Status" +msgstr "Статус" + +#: views/admin/servers/browse.php:45 +msgid "Actions" +msgstr "Действия" + +#: views/admin/servers/browse.php:69 +msgid "Set Active" +msgstr "Установка активна" + +#: views/admin/servers/browse.php:85 +msgid "There are no servers yet." +msgstr "Серверов пока не имеется." + +#: views/admin/servers/browse.php:86 +msgid "Create one!" +msgstr "Создайте!" + +#: views/admin/servers/edit.php:17 +msgid "Neatline Maps | Edit Server" +msgstr "Карты Neatline | Редактировать сервер" diff --git a/languages/template.pot b/languages/template.pot index 2693104..4e45213 100644 --- a/languages/template.pot +++ b/languages/template.pot @@ -15,12 +15,13 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: NeatlineMapsPlugin.php:357 -msgid "Neatline Maps" +#: NeatlineMapsPlugin.php:451 +msgid "Web Map Service" msgstr "" -#: NeatlineMapsPlugin.php:384 -msgid "Web Map Service" +#: controllers/ServersController.php:159 +#, php-format +msgid "This will permanently delete the %s server." msgstr "" #: forms/ServerForm.php:35 @@ -79,6 +80,18 @@ msgstr "" msgid "Save" msgstr "" +#: models/NeatlineMapsServer.php:103 +msgid "Online" +msgstr "" + +#: models/NeatlineMapsServer.php:104 +msgid "Offline" +msgstr "" + +#: models/NeatlineMapsServer.php:105 +msgid "Authentication Error" +msgstr "" + #: views/admin/items/_serviceForm.php:17 msgid "WMS Address" msgstr "" @@ -100,7 +113,7 @@ msgid "Neatline Maps | Create Server" msgstr "" #: views/admin/servers/add.php:24 views/admin/servers/browse.php:25 -#: views/admin/servers/delete.php:24 views/admin/servers/edit.php:24 +#: views/admin/servers/edit.php:24 msgid "Create a Server" msgstr "" @@ -120,36 +133,18 @@ msgstr "" msgid "Actions" msgstr "" -#: views/admin/servers/browse.php:61 -msgid "Online" -msgstr "" - -#: views/admin/servers/browse.php:63 -msgid "Offline" -msgstr "" - -#: views/admin/servers/browse.php:70 +#: views/admin/servers/browse.php:69 msgid "Set Active" msgstr "" -#: views/admin/servers/browse.php:86 +#: views/admin/servers/browse.php:85 msgid "There are no servers yet." msgstr "" -#: views/admin/servers/browse.php:87 +#: views/admin/servers/browse.php:86 msgid "Create one!" msgstr "" -#: views/admin/servers/delete.php:17 -#, php-format -msgid "Neatline Maps | Delete Server %s" -msgstr "" - -#: views/admin/servers/delete.php:30 -#, php-format -msgid "This will permanently delete the %s server." -msgstr "" - #: views/admin/servers/edit.php:17 msgid "Neatline Maps | Edit Server" msgstr "" diff --git a/lib/GeoserverMap_Abstract.php b/lib/GeoserverMap_Abstract.php index 42806ae..2414def 100644 --- a/lib/GeoserverMap_Abstract.php +++ b/lib/GeoserverMap_Abstract.php @@ -1,5 +1,5 @@ epsg); - if ($espgNumber[1] >= 4000 && $espgNumber[1] <= 5000) { - $string = implode(',', array( - min($minys), - min($minxes), - max($maxys), - max($maxxes))); - } + if (count($minxes) > 0) { + // Check for reverse axis order. + $espgNumber = explode(':', $this->epsg); + if ($espgNumber[1] >= 4000 && $espgNumber[1] <= 5000) { + $string = implode(',', array( + min($minys), + min($minxes), + max($maxys), + max($maxxes))); + } - // If not between 4000 and 5000, do normal order. - else { - $string = implode(',', array( - min($minxes), - min($minys), - max($maxxes), - max($maxys))); + // If not between 4000 and 5000, do normal order. + else { + $string = implode(',', array( + min($minxes), + min($minys), + max($maxxes), + max($maxys))); + } + } else { + $string = '0,0,0,0'; } return $string; diff --git a/models/NeatlineMapsServer.php b/models/NeatlineMapsServer.php index 73ca6b6..478a7e0 100644 --- a/models/NeatlineMapsServer.php +++ b/models/NeatlineMapsServer.php @@ -1,5 +1,5 @@ _getHttpCode() == 200); + } - $ch = curl_init($this->url . '/rest/workspaces'); - - $authString = $this->username . ':' . $this->password; - curl_setopt($ch, CURLOPT_USERPWD, $authString); + /** + * Tries to contact the GeoServer and authenticate and returns the HTTP + * status code. + * + * @return int $code The HTTP status code. + * @author Eric Rochester + **/ + protected function _getHttpCode() + { + $ch = curl_init($this->url . '/rest/workspaces'); + curl_setopt($ch, CURLOPT_USERPWD, "{$this->username}:{$this->password}"); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/xml')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); - $successCode = 200; $buffer = curl_exec($ch); - $info = curl_getinfo($ch); + $info = curl_getinfo($ch); + $code = $info['http_code']; - return ($info['http_code'] == $successCode); + return $code; + } + + /** + * This returns a string indicating the server's status and a CSS class for + * the wrapping element. + * + * Currently, this is one of these values: + * + * * 'Online': Everything's just great; + * * 'Offline': I can't even talk to the server; or + * * 'Authentication Error': The server doesn't recognize me or my + * password. + * + * Actually, it returns those values after they've been translated for the + * viewer's current locale. + * + * @return array An array with two keys: 'class' for the class for the span + * and 'message' for the translated string. + * @author Eric Rochester + **/ + public function getStatusDisplay() + { + $online = __('Online'); + $offline = __('Offline'); + $authErr = __('Authentication Error'); + + switch ($this->_getHttpCode()) { + case 200: + $status = $online; + $class = 'online'; + break; + + case 401: + case 403: + $status = $authErr; + $class = 'offline'; + break; + + default: + $status = $offline; + $class = 'offline'; + break; + } + return array( + 'class' => $class, + 'message' => $status + ); } /** @@ -126,4 +184,17 @@ public function parentSave() parent::save(); } + /** + * Required by Zend_Acl_Resource_Interface. + * + * Identifies records as relating to the NeatlineMaps_Servers ACL + * resource. + * + * @return string + */ + public function getResourceId() + { + return self::RESOURCE_ID; + } + } diff --git a/models/NeatlineMapsServerTable.php b/models/NeatlineMapsServerTable.php index 98310f5..227d737 100644 --- a/models/NeatlineMapsServerTable.php +++ b/models/NeatlineMapsServerTable.php @@ -1,5 +1,5 @@ setUpPlugin(); + } + + /** + * Data for testAcl + */ + public function acl() + { + return array( + // $isAllowed, $role, $privilege + array(false, null, 'add'), + array(false, null, 'edit'), + array(false, null, 'browse'), + array(false, null, 'delete'), + array(false, null, 'active'), + array(false, null, 'show'), + array(false, 'researcher', 'add'), + array(false, 'researcher', 'edit'), + array(false, 'researcher', 'browse'), + array(false, 'researcher', 'delete'), + array(false, 'researcher', 'active'), + array(false, 'researcher', 'show'), + array(false, 'contributor', 'add'), + array(false, 'contributor', 'edit'), + array(false, 'contributor', 'browse'), + array(false, 'contributor', 'delete'), + array(false, 'contributor', 'active'), + array(false, 'contributor', 'show'), + array(true, 'admin', 'add'), + array(true, 'admin', 'edit'), + array(true, 'admin', 'browse'), + array(true, 'admin', 'delete'), + array(true, 'admin', 'active'), + array(true, 'admin', 'show'), + array(true, 'super', 'add'), + array(true, 'super', 'edit'), + array(true, 'super', 'browse'), + array(true, 'super', 'delete'), + array(true, 'super', 'active'), + array(true, 'super', 'show') + ); + } + + public function assertPreConditions() + { + $this->assertTrue($this->acl->has(self::RESOURCE)); + } + + /** + * @dataProvider acl + */ + public function testAcl($isAllowed, $role, $privilege = null) + { + $this->assertEquals($isAllowed, + $this->acl->isAllowed($role, self::RESOURCE, $privilege)); + } +} diff --git a/tests/integration/ItemsControllerTest.php b/tests/integration/ItemsControllerTest.php index 77efe1d..2462b13 100644 --- a/tests/integration/ItemsControllerTest.php +++ b/tests/integration/ItemsControllerTest.php @@ -1,5 +1,5 @@ __server(); - $server2 = $this->__server(); - - // Form post. - $this->request->setMethod('POST') - ->setPost(array() - ); - - // Capture starting count. - $count = $this->serversTable->count(); - - // Delete. - $this->dispatch('neatline-maps/delete/' . $server1->id); - - // Check count-1. - $this->assertEquals($this->serversTable->count(), $count-1); - - // Check correct deletion. - $this->assertNull($this->serversTable->find($server1->id)); - $this->assertNotNull($this->serversTable->find($server2->id)); - - } - } diff --git a/tests/mocks/FileMock.php b/tests/mocks/FileMock.php index cb8a73d..5157f00 100644 --- a/tests/mocks/FileMock.php +++ b/tests/mocks/FileMock.php @@ -1,5 +1,5 @@ + + + + integration + unit + + + + diff --git a/tests/unit/NeatlineMapsServerTableTest.php b/tests/unit/NeatlineMapsServerTableTest.php index 680c188..91a4f3f 100644 --- a/tests/unit/NeatlineMapsServerTableTest.php +++ b/tests/unit/NeatlineMapsServerTableTest.php @@ -1,5 +1,5 @@ - + diff --git a/views/admin/servers/_header.php b/views/admin/servers/_header.php index 610fd1c..3533597 100644 --- a/views/admin/servers/_header.php +++ b/views/admin/servers/_header.php @@ -1,5 +1,5 @@ - 0): ?> + 0): ?> @@ -49,7 +49,7 @@ - +
name; ?>
@@ -57,11 +57,10 @@
url; ?> namespace; ?> - isOnline()): ?> - - - - + getStatusDisplay(); ?> + + + active): ?> diff --git a/views/admin/servers/delete.php b/views/admin/servers/delete.php deleted file mode 100644 index 2f64e32..0000000 --- a/views/admin/servers/delete.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @author David McClure - * @copyright 2012 The Board and Visitors of the University of Virginia - * @license http://www.apache.org/licenses/LICENSE-2.0.html Apache 2 License - */ -?> - -name); -head(array('content_class' => 'neatline', 'title' => $title)); -?> - -partial('servers/_header.php', array( - 'title' => $title, - 'add_button_uri' => 'neatline-maps/add', - 'add_button_text' => __('Create a Server') -)); ?> - -
- -

-

name); ?>

- -
-
- -
-
- -
- - diff --git a/views/admin/servers/edit.php b/views/admin/servers/edit.php index d2a7f17..2e2d600 100644 --- a/views/admin/servers/edit.php +++ b/views/admin/servers/edit.php @@ -1,5 +1,5 @@