Commit eb57d99c authored by Jaime L Magiera's avatar Jaime L Magiera
Browse files

more removals

parent 8fd08ace
.DS_Store
\ No newline at end of file
<?php
namespace CSSEditor;
use Omeka\Module\AbstractModule;
use Omeka\Permissions\Assertion\HasSitePermissionAssertion;
use Laminas\EventManager\Event;
use Laminas\Mvc\MvcEvent;
use Laminas\EventManager\SharedEventManagerInterface;
class Module extends AbstractModule
{
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function onBootstrap(MvcEvent $event)
{
parent::onBootstrap($event);
$acl = $this->getServiceLocator()->get('Omeka\Acl');
$acl->allow(
null,
'CSSEditor\Controller\Site\Index'
);
$acl->allow(
null,
'CSSEditor\Controller\Admin\Index'
);
$acl->allow(
null,
'Omeka\Entity\Site',
'css-editor-modify',
new HasSitePermissionAssertion('admin')
);
}
public function addCSS(Event $event)
{
$services = $this->getServiceLocator();
if (!$services->get('Omeka\Status')->isSiteRequest()) {
return;
}
$view = $event->getTarget();
$view->headLink()->appendStylesheet($view->url('site/css-editor', [
'site-slug' => $view->site->slug(),
]));
$siteSettings = $services->get('Omeka\Settings\Site');
$externalCss = $siteSettings->get('css_editor_external_css');
if ($externalCss) {
foreach ($externalCss as $uri) {
$view->headLink()->appendStylesheet($uri);
}
}
}
public function attachListeners(SharedEventManagerInterface $sharedEventManager)
{
$sharedEventManager->attach('*', 'view.layout', [$this, 'addCSS']);
}
}
# CSSEditor
CSSEditor is a module for Omeka S that allows you to provide custom CSS overriding theme styles. You can also include URLs for external CSS, like those hosted by CDNs or used for webfonts.
See the [Omeka S user manual](http://omeka.org/s/docs/user-manual/modules/csseditor/) for user documentation.
## Installation
See general end user documentation for [Installing a module](http://omeka.org/s/docs/user-manual/install/)
.value {
display: flex;
align-items: flex-start;
}
.add-value:before {
margin-right: .25em;
}
.external-css-value:only-child .remove-value {
display: none;
}
\ No newline at end of file
(function($) {
$(document).ready(function() {
$('.add-value').click(function() {
var template = $('.external-css-value').last().clone();
var templateInput = template.find('input');
var fieldCount = templateInput.data('field-count') + 1;
templateInput.attr('name', 'external-css[' + fieldCount + ']');
templateInput.attr('data-field-count', fieldCount);
templateInput.val('');
$('.external-css .values').append(template);
});
$(document).on('click', '.remove-value', function(e) {
e.preventDefault();
if ($('.external-css-value').length > 1) {
$(this).parents('.external-css-value').remove();
}
});
});
})(jQuery)
\ No newline at end of file
<?php
return [
'view_manager' => [
'template_path_stack' => [
OMEKA_PATH . '/modules/CSSEditor/view',
],
],
'controllers' => [
'invokables' => [
'CSSEditor\Controller\Admin\Index' => 'CSSEditor\Controller\Admin\IndexController',
'CSSEditor\Controller\Site\Index' => 'CSSEditor\Controller\Site\IndexController',
],
],
'navigation' => [
'site' => [
[
'label' => 'CSS Editor', // @translate
'route' => 'admin/site/slug/css-editor/default',
'privilege' => 'css-editor-modify',
'action' => 'index',
'useRouteMatch' => true,
'pages' => [
[
'route' => 'admin/site/slug/css-editor/default',
'visible' => false,
],
],
],
],
],
'router' => [
'routes' => [
'admin' => [
'child_routes' => [
'site' => [
'child_routes' => [
'slug' => [
'child_routes' => [
'css-editor' => [
'type' => 'Literal',
'options' => [
'route' => '/css-editor',
'defaults' => [
'__NAMESPACE__' => 'CSSEditor\Controller\Admin',
'controller' => 'index',
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [
'default' => [
'type' => 'Segment',
'options' => [
'route' => '/:action',
'constraints' => [
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
],
],
],
],
],
],
],
],
],
],
],
'site' => [
'child_routes' => [
'css-editor' => [
'type' => 'Segment',
'options' => [
'route' => '/css-editor',
'defaults' => [
'__NAMESPACE__' => 'CSSEditor\Controller\Site',
'controller' => 'index',
'action' => 'index',
],
],
],
],
],
],
],
];
[info]
name = "CSSEditor"
version = "1.3.0"
author = "Omeka Team"
description = "Allows for CSS overrides."
module_link = "https://github.com/omeka-s-modules/CSSEditor"
author_link = "https://omeka.org"
support_link = "https://forum.omeka.org/c/omeka-s/modules"
omeka_version_constraint = "^3.0.0"
<?php
namespace CSSEditor\Controller\Admin;
use Laminas\View\Model\ViewModel;
use Laminas\Mvc\Controller\AbstractActionController;
class FormController extends AbstractActionController
{
public function indexAction()
{
$site = $this->currentSite();
$this->getRequest()->getQuery()->set('site_id', $site->id());
$view = new ViewModel;
$view->setVariable('site', $site);
return $view;
}
}
<?php
namespace CSSEditor\Controller\Admin;
use Omeka\Mvc\Exception;
use Laminas\View\Model\ViewModel;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\Form\Form;
class IndexController extends AbstractActionController
{
public function indexAction()
{
if (!$this->currentSite()->userIsAllowed('css-editor-modify')) {
throw new Exception\PermissionDeniedException(
'User does not have permission to edit CSS' // @translate
);
}
$siteSettings = $this->siteSettings();
$view = new ViewModel();
$form = $this->getForm(Form::class);
if ($this->getRequest()->isPost()) {
$params = $this->params()->fromPost();
if (isset($params['css'])) {
$css = $params['css'];
} else {
$css = '';
}
if (isset($params['external-css'])) {
$externalCss = array_filter($params['external-css']);
} else {
$externalCss = [];
}
$siteSettings->set('css_editor_css', $css);
$siteSettings->set('css_editor_external_css', $externalCss);
$this->messenger()->addSuccess('CSS successfully updated.'); // @translate
}
$css = $siteSettings->get('css_editor_css');
$externalCss = $siteSettings->get('css_editor_external_css');
$view->setVariable('form', $form);
$view->setVariable('css', $css);
$view->setVariable('externalCss', $externalCss);
return $view;
}
}
<?php
namespace CSSEditor\Controller\Site;
use Laminas\Mvc\Controller\AbstractActionController;
class IndexController extends AbstractActionController
{
public function indexAction()
{
$siteSettings = $this->siteSettings();
$response = $this->getResponse();
$response->getHeaders()->addHeaderLine('Content-Type', 'text/css; charset=utf-8');
$response->setContent($this->siteSettings()->get('css_editor_css'));
return $response;
}
}
<?php
$this->headLink()->appendStylesheet($this->assetUrl('css/csseditor.css', 'CSSEditor'));
$this->headScript()->appendFile($this->assetUrl('js/csseditor.js', 'CSSEditor'));
echo $this->pageTitle($this->translate('CSS Editor'));
?>
<?php echo $this->form()->openTag($form); ?>
<div id="page-actions">
<button type="submit"><?php echo $this->translate('Save'); ?></button>
</div>
<div class="field">
<div class="field-meta">
<label for="custom-css"><?php echo $this->translate('CSS'); ?></label>
</div>
<div class="inputs">
<textarea rows="20" name="css" id="css"><?php echo (isset($css)) ? $css : ''; ?></textarea>
</div>
</div>
<div class="field external-css">
<div class="field-meta">
<label id="external-css-label"><?php echo $this->translate('External stylesheets'); ?></label>
</div>
<div class="inputs">
<div class="values">
<?php if (isset($externalCss) && (!empty($externalCss))): ?>
<?php
$externalCssFieldCount = 0;
$externalCssValue = '';
?>
<?php foreach ($externalCss as $uri): ?>
<?php $externalCssValue = $uri; ?>
<?php echo $this->partial('css-editor/external-css', [
'externalCssValue' => $externalCssValue,
'externalCssFieldCount' => $externalCssFieldCount,
]); ?>
<?php $externalCssFieldCount++; ?>
<?php endforeach; ?>
<?php else: ?>
<?php echo $this->partial('css-editor/external-css', [
'externalCssValue' => '',
'externalCssFieldCount' => 0,
]); ?>
<?php endif; ?>
</div>
<button type="button" class="add-value o-icon-add"><?php echo $this->translate('Add another stylesheet'); ?></button>
</div>
</div>
<?php echo $this->form()->closeTag($form); ?>
<div class="value external-css-value">
<div class="input-body">
<input type="text" name="external-css[<?php echo $externalCssFieldCount; ?>]" aria-labelledby="external-css-label" value="<?php echo $externalCssValue; ?>" data-field-count="<?php echo $externalCssFieldCount; ?>">
</div>
<div class="input-footer">
<ul class="actions">
<li><a class="o-icon-delete remove-value" title="Remove value" href="#" aria-label="Remove value"></a></li>
</ul>
</div>
</div>
\ No newline at end of file
This diff is collapsed.
<?php
namespace CSVImport;
use Omeka\Module\AbstractModule;
use Laminas\ModuleManager\ModuleManager;
use Laminas\ServiceManager\ServiceLocatorInterface;
class Module extends AbstractModule
{
public function init(ModuleManager $moduleManager)
{
require_once __DIR__ . '/vendor/autoload.php';
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function install(ServiceLocatorInterface $serviceLocator)
{
$connection = $serviceLocator->get('Omeka\Connection');
$sql = <<<'SQL'
CREATE TABLE csvimport_import (
id INT AUTO_INCREMENT NOT NULL,
job_id INT NOT NULL,
undo_job_id INT DEFAULT NULL,
comment VARCHAR(255) DEFAULT NULL,
resource_type VARCHAR(255) NOT NULL,
has_err TINYINT(1) NOT NULL,
stats LONGTEXT NOT NULL COMMENT '(DC2Type:json_array)',
UNIQUE INDEX UNIQ_17B50881BE04EA9 (job_id),
UNIQUE INDEX UNIQ_17B508814C276F75 (undo_job_id),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;
CREATE TABLE csvimport_entity (
id INT AUTO_INCREMENT NOT NULL,
job_id INT NOT NULL,
entity_id INT NOT NULL,
resource_type VARCHAR(255) NOT NULL,
INDEX IDX_84D382F4BE04EA9 (job_id),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;
ALTER TABLE csvimport_import ADD CONSTRAINT FK_17B50881BE04EA9 FOREIGN KEY (job_id) REFERENCES job (id);
ALTER TABLE csvimport_import ADD CONSTRAINT FK_17B508814C276F75 FOREIGN KEY (undo_job_id) REFERENCES job (id);
ALTER TABLE csvimport_entity ADD CONSTRAINT FK_84D382F4BE04EA9 FOREIGN KEY (job_id) REFERENCES job (id);
SQL;
$sqls = array_filter(array_map('trim', explode(';', $sql)));
foreach ($sqls as $sql) {
$connection->exec($sql);
}
}
public function uninstall(ServiceLocatorInterface $serviceLocator)
{
$connection = $serviceLocator->get('Omeka\Connection');
$sql = <<<'SQL'
ALTER TABLE csvimport_entity DROP FOREIGN KEY FK_84D382F4BE04EA9;
ALTER TABLE csvimport_import DROP FOREIGN KEY FK_17B508814C276F75;
ALTER TABLE csvimport_import DROP FOREIGN KEY FK_17B50881BE04EA9;
DROP TABLE IF EXISTS csvimport_entity;
DROP TABLE IF EXISTS csvimport_import;
SQL;
$sqls = array_filter(array_map('trim', explode(';', $sql)));
foreach ($sqls as $sql) {
$connection->exec($sql);
}
// User settings are not removed here: they belong to the user.
}
public function upgrade($oldVersion, $newVersion, ServiceLocatorInterface $serviceLocator)
{
if (version_compare($oldVersion, '1.1.1-rc.1', '<')) {
$connection = $serviceLocator->get('Omeka\Connection');
$sql = <<<'SQL'
ALTER TABLE csvimport_import ADD stats LONGTEXT NOT NULL COMMENT '(DC2Type:json_array)';
UPDATE csvimport_import SET stats = CONCAT('{"processed":{"', resource_type, '":', added_count, '}}');
ALTER TABLE csvimport_import DROP added_count;
SQL;
$sqls = array_filter(array_map('trim', explode(';', $sql)));
foreach ($sqls as $sql) {
$connection->exec($sql);
}
}
}
}
CSV Import (module for Omeka S)
===============================
[CSV Import] is a module for [Omeka S] and will allow users to import Entities from a simple CSV (comma separated value) file, and then map the CSV column data to Entity. Each row in the file represents metadata for a single Entity.
Furthermore, it’s possible to import directly files in formats [TSV] (tab separated value), a simpler and more efficient format, and [ODS] (OpenDocument Spreadsheet, the ISO standard office format for spreadsheets, managed by [LibreOffice] and a lot of other tools) directly.
Most often, the import will create new Omeka S items. It is also possible to import item sets, media and users, and other modules can add other import types. It’s possible to import mixed resources in one file too.
See the [Omeka S user manual](http://omeka.org/s/docs/user-manual/modules/csvimport/) for user documentation.
Installation
------------
See general end user documentation for [Installing a module](http://omeka.org/s/docs/user-manual/modules/#installing-modules).
To install CSV Import from the source, go to the root of the module, and run `composer install`. Users
using the pre-packaged downloads from the Releases page or the omeka.org module directory don't need
to worry about this step.
To be able to import `ods`, the php extensions `zip` and `xml` should be installed (default in most cases).
Warning
-------
Use it at your own risk.
It’s always recommended to backup your files and your databases and to check your archives regularly so you can roll back if needed.
Troubleshooting
---------------
See online issues on the [Omeka forum] and the [module issues] page on GitHub.
License
-------
This plugin is published under [GNU/GPL v3].
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Contact
-------
Current maintainers:
* Roy Rosenzweig Center for History and New Media
* Daniel Berthereau (see [Daniel-KM] on GitHub)
Copyright
---------
* Copyright Roy Rosenzweig Center for History and New Media, 2015-2019
* Copyright Daniel Berthereau, 2017-2019
[CSV Import]: https://github.com/Omeka-s-modules/CSVImport
[Omeka S]: https://omeka.org/s
[TSV]: https://en.wikipedia.org/wiki/Tab-separated_values
[ODS]: http://opendocumentformat.org/aboutODF
[LibreOffice]: https://www.libreoffice.org
[Omeka forum]: https://forum.omeka.org/c/omeka-s/modules
[module issues]: https://github.com/omeka-s-modules/CSVImport/issues
[GNU/GPL v3]: https://www.gnu.org/licenses/gpl-3.0.html
[Daniel-KM]: https://github.com/Daniel-KM "Daniel Berthereau"
.csv-import-fieldset-label {
display: block;
border-color: rgba(0, 0, 0, 0.08);
border-bottom-width: 0.1875em;
border-bottom-style: solid;
padding-bottom: 0.1875em;
margin-bottom: 0.375em;
font-size: 125%;
}
.csv-import-fieldset-label .collapse,
.csv-import-fieldset-label .expand {
display: block;
float: right;
}
#mapping-data {
margin-top: -24px;
}
#mapping-data .batch-inputs {
display: flex;
align-items: center;
padding: 6px;
background-color: rgba(0,0,0,0.04);
border: 1px solid #dfdfdf;
border-bottom: 0;
border-radius: 3px 3px 0 0;
}
#batch-edit-options {
margin-bottom: 0;
font-size: 14px;
line-height: 24px;
min-height: 0;
padding: 0 6px;
}
#batch-edit-options.inactive {
background-color: rgba(0,0,0,0.04);
box-shadow: 0 0 0 1px rgba(0,0,0,0.15) inset;
color: #a7a7a7;
cursor: default;
}
#mapping-data .batch-inputs ~ table {
border-radius: 0 0 3px 3px;
}
tr.active {
background-color: rgba(0,0,0, .08);
}
tr.mappable td {
vertical-align: top;
}
#mapping-data .select-all,
tr.mappable input[type="checkbox"] {
margin-right: .5em;
}
td.comment {
max-width: 300px;
}
ul.mappings.elements {
list-style: none;
margin: 0;
padding: 0;