diff --git a/CHANGELOG.md b/CHANGELOG.md index 19e3279..8825fef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ ### Changelog ### +### 02.09.2016 Version 0.4 ### + +- Zeichenbegrenzung wird jetzt auch beim edit direkt (fast) richtig angezeigt +- "Staus" Spalte sortierbar gemacht ### 30.08.2016 Version 0.3 ### diff --git a/README.md b/README.md index d31932f..6c32ccb 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ Zu jeder Sprache kann ein Begriff mit einer kurzen Definition und einer etwas längeren Beschreibung angegeben werden. -+ neu angelegte Einträge müssen in der übersichtliste extra aktiviert werden -* ein Begriff wird immer in allen Sprachen angelegt ++ neu angelegte Einträge müssen in der übersichtliste extra aktiviert werden. +* ein Begriff wird immer in allen Sprachen angelegt. * ein Begriff wird immer in allen Sprachen gelöscht! * sofern eine Sprache glöscht wird werden auch alle Einträge der Glossar Tabelle für diese Sprache gelöscht. * wird eine Sprache hinzugefügt werden alle Glossareinträge der "Hauptspreache" kopiert und inaktiv gesetzt. diff --git a/lib/glossar/glossar.php b/lib/glossar/glossar.php index 93453f2..9cc906b 100644 --- a/lib/glossar/glossar.php +++ b/lib/glossar/glossar.php @@ -1,51 +1,46 @@ setQuery('SELECT * FROM ' . \rex::getTable('glossar') . ' WHERE clang_id=?', [\rex_clang::getStartId()]); - $fields = $firstLang->getFieldnames(); - - $newLang = \rex_sql::factory(); - $newLang->setDebug(false); - foreach ($firstLang as $firstLangEntry) { - $newLang->setTable(\rex::getTable('glossar')); - - foreach ($fields as $key => $value) { - if ($value == 'pid') { - echo ''; - } elseif ($value == 'active') { - $newLang->setValue('active', 0); - } elseif ($value == 'clang_id') { - $newLang->setValue('clang_id', $ep->getParam('clang')->getId()); - } else { - $newLang->setValue($value, $firstLangEntry->getValue($value)); - } - } - - $newLang->insert(); + public static function clangAdded(\rex_extension_point $ep) + { + $firstLang = \rex_sql::factory(); + $firstLang->setQuery('SELECT * FROM ' . \rex::getTable('glossar') . ' WHERE clang_id=?', [\rex_clang::getStartId()]); + $fields = $firstLang->getFieldnames(); + + $newLang = \rex_sql::factory(); + $newLang->setDebug(false); + foreach ($firstLang as $firstLangEntry) { + $newLang->setTable(\rex::getTable('glossar')); + + foreach ($fields as $key => $value) { + if ($value == 'pid') { + echo ''; + } elseif ($value == 'active') { + $newLang->setValue('active', 0); + } elseif ($value == 'clang_id') { + $newLang->setValue('clang_id', $ep->getParam('clang')->getId()); + } else { + $newLang->setValue($value, $firstLangEntry->getValue($value)); } - } - - public static function clangDeleted(\rex_extension_point $ep) - { - $deleteLang = \rex_sql::factory(); - $deleteLang->setQuery('DELETE FROM ' . \rex::getTable('glossar') . ' WHERE clang_id=?', [$ep->getParam('clang')->getId()]); - } - - public static function glossarFormControlElement(\rex_extension_point $ep) - { - if (! \rex::getUser()->getComplexPerm('clang')->hasAll()) { - $subject = $ep->getSubject(); - unset($subject['delete']); - $ep->setSubject($subject); - } - } - + } + $newLang->insert(); + } +} + public static function clangDeleted(\rex_extension_point $ep) + { + $deleteLang = \rex_sql::factory(); + $deleteLang->setQuery('DELETE FROM ' . \rex::getTable('glossar') . ' WHERE clang_id=?', [$ep->getParam('clang')->getId()]); + } + + public static function glossarFormControlElement(\rex_extension_point $ep) + { + if (! \rex::getUser()->getComplexPerm('clang')->hasAll()) { + $subject = $ep->getSubject(); + unset($subject['delete']); + $ep->setSubject($subject); + } + } } diff --git a/package.yml b/package.yml index c5611c3..2328f3f 100644 --- a/package.yml +++ b/package.yml @@ -1,8 +1,8 @@ package: glossar -version: '0.3' +version: '0.4' author: Oliver Kreischer supportpage: https://github.com/olien/glossar/issues -compile: 0 +compile: 1 page: title: 'translate:glossar' diff --git a/pages/info.changelog.php b/pages/info.changelog.php index 063545b..7f99164 100644 --- a/pages/info.changelog.php +++ b/pages/info.changelog.php @@ -1,5 +1,4 @@ setVar('title',$this->i18n('glossar_info_cangelog_title')); $fragment->setVar('body', $content, false); echo '
'.$fragment->parse('core/page/section.php').'
'; - - diff --git a/pages/info.modules.php b/pages/info.modules.php index 389c553..2848f4d 100644 --- a/pages/info.modules.php +++ b/pages/info.modules.php @@ -1,6 +1,5 @@ Hier folgen noch einige Ausgaben und Erklärungen @@ -10,9 +9,7 @@ /redaxo/src/addons/glossar/data/glossar_listenansicht_modulausgabe.php -eine Modulausgabe (Listenansicht) welches auf einem Modul von Thomas Skerbis basiert. - -"; +eine Modulausgabe (Listenansicht) welches auf einem Modul von Thomas Skerbis basiert."; $fragment = new rex_fragment(); $fragment->setVar('title', $this->i18n('glossar_info_modules_title')); diff --git a/pages/info.readme.php b/pages/info.readme.php index 3eefba7..cefea0f 100644 --- a/pages/info.readme.php +++ b/pages/info.readme.php @@ -1,5 +1,4 @@ setVar('title', $this->i18n('glossar_info_readme_title')); $fragment->setVar('body', $content, false); echo '
'.$fragment->parse('core/page/section.php').'
'; -echo ''; diff --git a/pages/main.php b/pages/main.php index a73fa56..0908a7b 100644 --- a/pages/main.php +++ b/pages/main.php @@ -1,19 +1,15 @@ isAvailable()) { - if (!rex_redactor2::profileExists('simple')) { + if (!rex_redactor2::profileExists('simple')) { rex_redactor2::insertProfile('simple', $this->i18n('glossar_redactorinfo'), '300', '800', 'relative', 'bold,italic,underline,deleted,quote,sub,sup,code,unorderedlist,grouplink[internal|external|mailto]'); } $editor = 'redactorEditor2-simple'; } -// ************************************* // MarkItUp -// ************************************* if(rex_addon::get('rex_markitup')->isAvailable()) { if (!rex_markitup::profileExists('simple')) { rex_markitup::insertProfile ('simple', $this->i18n('glossar_markitupinfo'), 'textile', 300, 800, 'relative', 'bold,italic,underline,deleted,quote,sub,sup,code,unorderedlist,grouplink[internal|external|mailto]'); @@ -21,11 +17,9 @@ $editor = 'markitupEditor-simple'; } - $content = ''; $message = ''; - $pid = rex_request('pid', 'int'); $term_id = rex_request('term_id', 'int'); $func = rex_request('func', 'string'); @@ -35,152 +29,132 @@ $error = ''; $success = ''; - if ($func == 'delete' && $term_id > 0) { - $deleteTerm = rex_sql::factory(); - $deleteTerm->setQuery('DELETE FROM ' . rex::getTable('glossar') . ' WHERE id=?', [$term_id]); - $success = $this->i18n('term_deleted'); - - $func = ''; - unset($term_id); + $deleteTerm = rex_sql::factory(); + $deleteTerm->setQuery('DELETE FROM ' . rex::getTable('glossar') . ' WHERE id=?', [$term_id]); + $success = $this->i18n('term_deleted'); + $func = ''; + unset($term_id); } - - - if ($func == 'setstatus') { - $sql = rex_sql::factory(); - $status = (rex_request('oldstatus', 'int') + 1) % 2; - $query = "SELECT `term`, `active` FROM rex_glossar WHERE `pid` ='" . addslashes($oid) . "' "; + $sql = rex_sql::factory(); + $status = (rex_request('oldstatus', 'int') + 1) % 2; + $query = "SELECT `term`, `active` FROM rex_glossar WHERE `pid` ='" . addslashes($oid) . "' "; + $sql->setQuery($query); + if ($sql->getRows() == 1) { + $term = $sql->getValue('term'); + $query = "UPDATE rex_glossar SET `active` = '$status' WHERE `pid` ='" . addslashes($oid) . "' "; $sql->setQuery($query); - if ($sql->getRows() == 1) { - $term = $sql->getValue('term'); - $query = "UPDATE rex_glossar SET `active` = '$status' WHERE `pid` ='" . addslashes($oid) . "' "; - $sql->setQuery($query); - } - $msg = $status == 1 ? 'glossar_status_activated' : 'glossar_status_deactivated'; - echo rex_view::success($this->i18n($msg)); - $func = ''; + } + $msg = $status == 1 ? 'glossar_status_activated' : 'glossar_status_deactivated'; + echo rex_view::success($this->i18n($msg)); + $func = ''; } - if ($func == '') { - $title = $this->i18n('glossar_title'); - - $list = rex_list::factory('SELECT `pid`, `id`, `term`, `definition`, `description`, `active` FROM ' . rex::getTable('glossar') . ' WHERE `clang_id`="' . $clang_id . '" ORDER BY id DESC'); - $list->addTableAttribute('class', 'table-striped'); - - + $title = $this->i18n('glossar_title'); + $list = rex_list::factory('SELECT `pid`, `id`, `term`, `definition`, `description`, `active` FROM ' . rex::getTable('glossar') . ' WHERE `clang_id`="' . $clang_id . '" ORDER BY id DESC'); + $list->addTableAttribute('class', 'table-striped'); - $tdIcon = ''; - $thIcon = rex::getUser()->getComplexPerm('clang')->hasAll() ? 'i18n('add'), 'add') . '>' : ''; + $tdIcon = ''; + $thIcon = rex::getUser()->getComplexPerm('clang')->hasAll() ? 'i18n('add'), 'add') . '>' : ''; $list->addColumn($thIcon, $tdIcon, 0, ['###VALUE###', '###VALUE###']); - $list->setColumnParams($thIcon, ['func' => 'edit', 'pid' => '###pid###']); - - - $list->removeColumn('pid'); - $list->removeColumn('description'); - - $list->setColumnSortable('id'); - $list->setColumnLabel('id', 'ID'); - $list->setColumnLayout('id', ['###VALUE###', '###VALUE###']); - $list->setColumnParams('id', ['func' => 'edit', 'pid' => '###pid###']); - - $list->setColumnSortable('term'); - $list->setColumnLabel('term', $this->i18n('glossar_label_term')); - $list->setColumnLayout('term', ['###VALUE###', '###VALUE###']); - $list->setColumnParams('term', ['func' => 'edit', 'pid' => '###pid###']); - - - $list->setColumnLabel('definition', $this->i18n('glossar_label_definition')); - $list->setColumnLayout('definition', ['###VALUE###', '###VALUE###']); - - $list->setColumnLabel('active', $this->i18n('glossar_func_header')); - $list->setColumnParams('active', ['func' => 'setstatus', 'oldstatus' => '###active###', 'oid' => '###pid###']); - $list->setColumnLayout('active', ['###VALUE###', '###VALUE###']); - $list->setColumnFormat('active', 'custom', function($params) { - $list = $params['list']; - if ($list->getValue('active') == 1) { - $str = $list->getColumnLink('active', ' ' . $this->i18n('glossar_status_aktiviert') . ''); - } else { - $str = $list->getColumnLink('active', ' ' . $this->i18n('glossar_status_deaktiviert') . ''); - } - return $str; - }); + $list->setColumnParams($thIcon, ['func' => 'edit', 'pid' => '###pid###']); + + $list->removeColumn('pid'); + $list->removeColumn('description'); + + $list->setColumnSortable('id'); + $list->setColumnLabel('id', 'ID'); + $list->setColumnLayout('id', ['###VALUE###', '###VALUE###']); + $list->setColumnParams('id', ['func' => 'edit', 'pid' => '###pid###']); + + $list->setColumnSortable('term'); + $list->setColumnLabel('term', $this->i18n('glossar_label_term')); + $list->setColumnLayout('term', ['###VALUE###', '###VALUE###']); + $list->setColumnParams('term', ['func' => 'edit', 'pid' => '###pid###']); + + $list->setColumnLabel('definition', $this->i18n('glossar_label_definition')); + $list->setColumnLayout('definition', ['###VALUE###', '###VALUE###']); + + $list->setColumnSortable('active'); + $list->setColumnLabel('active', $this->i18n('glossar_func_header')); + $list->setColumnParams('active', ['func' => 'setstatus', 'oldstatus' => '###active###', 'oid' => '###pid###']); + $list->setColumnLayout('active', ['###VALUE###', '###VALUE###']); + $list->setColumnFormat('active', 'custom', function($params) { + $list = $params['list']; + if ($list->getValue('active') == 1) { + $str = $list->getColumnLink('active', ' ' . $this->i18n('glossar_status_aktiviert') . ''); + } else { + $str = $list->getColumnLink('active', ' ' . $this->i18n('glossar_status_deaktiviert') . ''); + } + return $str; +}); + $list->addColumn('edit', ' ' . $this->i18n('glossar_edit')); + $list->setColumnLabel('edit', ''); + $list->setColumnLayout('edit', ['###VALUE###', '###VALUE###']); + $list->setColumnParams('edit', ['func' => 'edit', 'pid' => '###pid###']); - $list->addColumn('edit', ' ' . $this->i18n('glossar_edit')); - $list->setColumnLabel('edit', ''); - $list->setColumnLayout('edit', ['###VALUE###', '###VALUE###']); - $list->setColumnParams('edit', ['func' => 'edit', 'pid' => '###pid###']); + $list->addColumn('delete', ' ' . $this->i18n('glossar_delete')); + $list->setColumnLabel('delete', $this->i18n('function')); + $list->setColumnLayout('delete', ['', '###VALUE###']); + $list->setColumnParams('delete', ['func' => 'delete', 'term_id' => '###id###']); + $list->addLinkAttribute('delete', 'data-confirm', $this->i18n('delete') . ' ?'); - $list->addColumn('delete', ' ' . $this->i18n('glossar_delete')); - $list->setColumnLabel('delete', $this->i18n('function')); - $list->setColumnLayout('delete', ['', '###VALUE###']); - $list->setColumnParams('delete', ['func' => 'delete', 'term_id' => '###id###']); - $list->addLinkAttribute('delete', 'data-confirm', $this->i18n('delete') . ' ?'); + $content .= $list->get(); - $content .= $list->get(); + $fragment = new rex_fragment(); + $fragment->setVar('title', $title); + $fragment->setVar('content', $content, false); + $content = $fragment->parse('core/page/section.php'); - $fragment = new rex_fragment(); - $fragment->setVar('title', $title); - $fragment->setVar('content', $content, false); - $content = $fragment->parse('core/page/section.php'); } else { - $title = $func == 'edit' ? $this->i18n('glossar_title_edit') : $this->i18n('glossar_title_add'); - - // \rex_extension::register('REX_FORM_CONTROL_FIELDS', '\Glossar\Extension::glossarFormControlElement'); - - $form = rex_form::factory(rex::getTable('glossar'), '', 'pid = ' . $pid,'post', false); - $form->addParam('pid', $pid); - $form->setApplyUrl(rex_url::currentBackendPage()); - $form->setLanguageSupport('id', 'clang_id'); - - $form->setEditMode($func == 'edit'); - - $field = $form->addTextField('term', rex_request('term', 'string', null)); - $field->setLabel($this->i18n('glossar_label_term')); - $field->getValidator()->add('notEmpty', $this->i18n('glossar_error_empty_term')); - $field = $form->addTextAreaField('definition'); - $field->setLabel($this->i18n('glossar_label_definition')); - $field->setAttribute('onKeyDown', 'limitText(this,this.form.countdown,250)'); - $field->setAttribute('onKeyDown', 'limitText(this,this.form.countdown,250)'); - $field->setAttribute('id', 'def'); - $field->setPrefix(''.$this->i18n('glossar_max_characters').' '); - $field->getValidator()->add('notEmpty', $this->i18n('glossar_error_empty_definition')); + $title = $func == 'edit' ? $this->i18n('glossar_title_edit') : $this->i18n('glossar_title_add'); + $form = rex_form::factory(rex::getTable('glossar'), '', 'pid = ' . $pid,'post', false); + $form->addParam('pid', $pid); + $form->setApplyUrl(rex_url::currentBackendPage()); + $form->setLanguageSupport('id', 'clang_id'); - $field = $form->addTextAreaField('description'); - $field->setAttribute('class', $editor); - $field->setAttribute('id', ' value-1'); - $field->setAttribute('style', 'width: 100%; margin-top: -10px; padding: 10px;'); - $field->setLabel($this->i18n('glossar_label_description')); + $form->setEditMode($func == 'edit'); - /* - $field = $form->addSelectField('active'); - $field->setLabel($this->i18n('glossar_label_active')); - $select = $field->getSelect(); - $select->addOption($this->i18n('yes'), 1); - $select->addOption($this->i18n('no'), 0); - $select->setSize(1); - */ + $field = $form->addTextField('term', rex_request('term', 'string', null)); + $field->setLabel($this->i18n('glossar_label_term')); + $field->getValidator()->add('notEmpty', $this->i18n('glossar_error_empty_term')); - $content .= $form->get(); + $field = $form->addTextAreaField('definition'); + $field->setLabel($this->i18n('glossar_label_definition')); + $field->setAttribute('onKeyDown', 'limitText(this,this.form.countdown,250)'); + $field->setAttribute('onKeyDown', 'limitText(this,this.form.countdown,250)'); + $field->setAttribute('id', 'def'); + $field->setPrefix(''.$this->i18n('glossar_max_characters').' '); + $field->getValidator()->add('notEmpty', $this->i18n('glossar_error_empty_definition')); - $fragment = new rex_fragment(); - $fragment->setVar('class', 'edit', false); - $fragment->setVar('title', "$title"); - $fragment->setVar('body', $content, false); - $content = $fragment->parse('core/page/section.php'); + $field = $form->addTextAreaField('description'); + $field->setAttribute('class', $editor); + $field->setAttribute('id', ' value-1'); + $field->setAttribute('style', 'width: 100%; margin-top: -10px; padding: 10px;'); + $field->setLabel($this->i18n('glossar_label_description')); + $content .= $form->get(); + $fragment = new rex_fragment(); + $fragment->setVar('class', 'edit', false); + $fragment->setVar('title', "$title"); + $fragment->setVar('body', $content, false); + $content = $fragment->parse('core/page/section.php'); } echo $message; echo '
'.$content.'
'; ?>