├── install.php ├── uninstall.php ├── package.yml ├── update.php ├── README.md ├── .github └── workflows │ └── publish-to-redaxo-org.yml ├── lang ├── en_gb.lang ├── sv_se.lang ├── it_it.lang ├── pt_br.lang ├── de_de.lang └── es_es.lang ├── pages ├── index.php └── profiles.php ├── LICENSE └── boot.php /install.php: -------------------------------------------------------------------------------- 1 | setQuery('DROP TABLE IF EXISTS ' . rex::getTablePrefix() . 'articlepresets_profiles'); 5 | -------------------------------------------------------------------------------- /package.yml: -------------------------------------------------------------------------------- 1 | package: article_presets 2 | version: '1.3.0' 3 | author: Friends Of REDAXO 4 | supportpage: github.com/FriendsOfREDAXO/article_presets 5 | 6 | page: 7 | title: 'translate:title' 8 | perm: article_presets[] 9 | pjax: true 10 | icon: rex-icon fa-files-o 11 | subpages: 12 | profiles: { title: 'translate:profiles', perm: article_presets[profiles] } 13 | 14 | requires: 15 | redaxo: '>=5.1.0' 16 | php: 17 | version: '>7.4' -------------------------------------------------------------------------------- /update.php: -------------------------------------------------------------------------------- 1 | ensureColumn(new rex_sql_column('id', 'int(11) unsigned', false, null, 'auto_increment')) 5 | ->ensureColumn(new rex_sql_column('name', 'varchar(30)', false, '')) 6 | ->ensureColumn(new rex_sql_column('categories', 'mediumtext')) 7 | ->ensureColumn(new rex_sql_column('templates', 'varchar(255)')) 8 | ->ensureColumn(new rex_sql_column('articlereference', 'int(10) unsigned')) 9 | ->setPrimaryKey('id') 10 | ->ensure(); 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Article Presets 2 | 3 | Artikelvorlagen automatisch einfügen,entsprechend festgelegter Kategorien oder Templates. 4 | 5 | Es können Artikel zentral hinterlegt werden, die bei Anlage eines neuen Artikels als Vorlage dienen sollen. 6 | 7 | **Beispiel:** 8 | In der Kategorie News sollen alle Inhalte den gleichen Aufbau habem. 9 | - Titel 10 | - Slideshow 11 | - Fleßtext 12 | - Autor 13 | 14 | Ein solcher Artikel kann vorab erstellt werden. Sobald die Redaktion einen neuen Artikel in der Newskategorie erstellt, wird diese Vorlage übernommen. 15 | -------------------------------------------------------------------------------- /.github/workflows/publish-to-redaxo-org.yml: -------------------------------------------------------------------------------- 1 | # Instructions: https://github.com/FriendsOfREDAXO/installer-action/ 2 | 3 | name: Publish to REDAXO.org 4 | on: 5 | release: 6 | types: 7 | - published 8 | 9 | jobs: 10 | redaxo_publish: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | - uses: FriendsOfREDAXO/installer-action@v1 15 | with: 16 | myredaxo-username: ${{ secrets.MYREDAXO_USERNAME }} 17 | myredaxo-api-key: ${{ secrets.MYREDAXO_API_KEY }} 18 | description: ${{ github.event.release.body }} 19 | version: ${{ github.event.release.tag_name }} 20 | 21 | -------------------------------------------------------------------------------- /lang/en_gb.lang: -------------------------------------------------------------------------------- 1 | article_presets_title = Article presets 2 | 3 | #subpage profiles 4 | article_presets_profiles = Profile 5 | article_presets_profiles_norowsmessage = No profiles found 6 | 7 | article_presets_profiles_column_name = Name 8 | 9 | article_presets_profiles_formcaption_add = Add profile 10 | article_presets_profiles_formcaption_edit = Edit profile 11 | 12 | article_presets_profiles_label_name = Name 13 | article_presets_profiles_label_description = Description 14 | article_presets_profiles_label_categories = Categories 15 | article_presets_profiles_label_templates = Templates 16 | article_presets_profiles_label_articlereference = Article template -------------------------------------------------------------------------------- /lang/sv_se.lang: -------------------------------------------------------------------------------- 1 | article_presets_title = Article presets 2 | 3 | #subpage profiles 4 | article_presets_profiles = Profiler 5 | article_presets_profiles_norowsmessage = Inga profiler hittades 6 | 7 | article_presets_profiles_column_name = Namn 8 | 9 | article_presets_profiles_formcaption_add = Tillfoga profil 10 | article_presets_profiles_formcaption_edit = Redigera profil 11 | 12 | article_presets_profiles_label_name = Namn 13 | article_presets_profiles_label_description = Beskrivning 14 | article_presets_profiles_label_categories = Kategorier 15 | article_presets_profiles_label_templates = Mallar 16 | article_presets_profiles_label_articlereference = Artikelmall -------------------------------------------------------------------------------- /lang/it_it.lang: -------------------------------------------------------------------------------- 1 | article_presets_title = 2 | 3 | #subpage profiles 4 | article_presets_profiles = profilo 5 | article_presets_profiles_norowsmessage = Non é stato trovato nessun profilo 6 | 7 | article_presets_profiles_column_name = nome 8 | 9 | article_presets_profiles_formcaption_add = aggiungi profilo 10 | article_presets_profiles_formcaption_edit = modifica profilo 11 | 12 | article_presets_profiles_label_name = nome 13 | article_presets_profiles_label_description = descrizione 14 | article_presets_profiles_label_categories = categoria 15 | article_presets_profiles_label_templates = templates 16 | article_presets_profiles_label_articlereference = articolo modello -------------------------------------------------------------------------------- /lang/pt_br.lang: -------------------------------------------------------------------------------- 1 | article_presets_title = Article presets 2 | 3 | #subpage profiles 4 | article_presets_profiles = Perfil 5 | article_presets_profiles_norowsmessage = Nenhum perfil encontrado 6 | 7 | article_presets_profiles_column_name = Nome 8 | 9 | article_presets_profiles_formcaption_add = Adicionar perfil 10 | article_presets_profiles_formcaption_edit = Editar perfil 11 | 12 | article_presets_profiles_label_name = Nome 13 | article_presets_profiles_label_description = Descrição 14 | article_presets_profiles_label_categories = Categorias 15 | article_presets_profiles_label_templates = Templates 16 | article_presets_profiles_label_articlereference = Templates de artigo -------------------------------------------------------------------------------- /lang/de_de.lang: -------------------------------------------------------------------------------- 1 | article_presets_title = Article Presets 2 | 3 | #subpage profiles 4 | article_presets_profiles = Profile 5 | article_presets_profiles_norowsmessage = Es wurden keine Profile gefunden 6 | 7 | article_presets_profiles_column_name = Name 8 | 9 | article_presets_profiles_formcaption_add = Profil hinzufügen 10 | article_presets_profiles_formcaption_edit = Profil editieren 11 | 12 | article_presets_profiles_label_name = Name 13 | article_presets_profiles_label_description = Beschreibung 14 | article_presets_profiles_label_categories = Kategorien 15 | article_presets_profiles_label_templates = Templates 16 | article_presets_profiles_label_articlereference = Artikelvorlage -------------------------------------------------------------------------------- /lang/es_es.lang: -------------------------------------------------------------------------------- 1 | article_presets_title = Presets de artículos 2 | 3 | #subpage profiles 4 | article_presets_profiles = Perfil 5 | article_presets_profiles_norowsmessage = No se encontraron perfiles 6 | 7 | article_presets_profiles_column_name = Nombre 8 | 9 | article_presets_profiles_formcaption_add = Añadir perfil 10 | article_presets_profiles_formcaption_edit = Editar perfil 11 | 12 | article_presets_profiles_label_name = Nombre 13 | article_presets_profiles_label_description = Descripción 14 | article_presets_profiles_label_categories = Categorías 15 | article_presets_profiles_label_templates = Plantillas 16 | article_presets_profiles_label_articlereference = Plantilla del artículo -------------------------------------------------------------------------------- /pages/index.php: -------------------------------------------------------------------------------- 1 | i18n('title')); // $this->i18n('title') ist eine Kurzform für rex_i18n::msg('dummy_title') 9 | 10 | // Die Subpages werden nicht mehr über den "subpage"-Parameter gesteuert, sondern mit über "page" (getrennt mit einem Slash, z. B. page=dummy/config) 11 | // Die einzelnen Teile des page-Pfades können mit der folgenden Funktion ausgelesen werden. 12 | $subpage = rex_be_controller::getCurrentPagePart(2); 13 | 14 | // Subpages können über diese Methode eingebunden werden. So ist sichergestellt, dass auch Subpages funktionieren, 15 | // die von anderen Addons/Plugins hinzugefügt wurden 16 | rex_be_controller::includeCurrentPageSubPath(); 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Friends Of REDAXO 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /boot.php: -------------------------------------------------------------------------------- 1 | getParams(); 6 | 7 | $sql = rex_sql::factory(); 8 | $profiles = $sql->getArray('SELECT * FROM `'.rex::getTablePrefix().'articlepresets_profiles`'); 9 | unset($sql); 10 | 11 | foreach ($profiles as $profile) { 12 | $copyStatusCategories = true; 13 | $copyStatusTemplates = true; 14 | 15 | if ('' != $profile['categories']) { 16 | $profile['categories'] = explode('|', substr($profile['categories'], 1, -1)); 17 | 18 | if (!in_array($params['data']['category_id'], $profile['categories'])) { 19 | $copyStatusCategories = false; 20 | } 21 | } 22 | 23 | if ('' != $profile['templates']) { 24 | $profile['templates'] = explode('|', substr($profile['templates'], 1, -1)); 25 | 26 | if (!in_array($params['data']['template_id'], $profile['templates'])) { 27 | $copyStatusTemplates = false; 28 | } 29 | } 30 | 31 | if (rex_addon::get('metainfo')->isAvailable()) { 32 | // Start - get all metainfo-fields 33 | $sql = rex_sql::factory(); 34 | $fields = array_column($sql->getArray('SHOW COLUMNS FROM `'.rex::getTablePrefix().'article` WHERE `Field` like "art_%"'), 'Field'); 35 | unset($sql); 36 | // End - get all metainfo-fields 37 | 38 | rex_article_service::copyMeta($profile['articlereference'], $params['id'], $params['clang'], $params['clang'], $fields); 39 | } 40 | 41 | if ($copyStatusCategories && $copyStatusTemplates) { 42 | rex_content_service::copyContent($profile['articlereference'], $params['id'], $params['clang'], $params['clang']); 43 | } 44 | } 45 | }); 46 | } 47 | -------------------------------------------------------------------------------- /pages/profiles.php: -------------------------------------------------------------------------------- 1 | addTableAttribute('class', 'table-striped'); 8 | $list->setNoRowsMessage($this->i18n('profiles_norowsmessage')); 9 | // icon column 10 | $thIcon = ''; 11 | $tdIcon = ''; 12 | $list->addColumn($thIcon, $tdIcon, 0, ['###VALUE###', '###VALUE###']); 13 | $list->setColumnParams($thIcon, ['func' => 'edit', 'id' => '###id###']); 14 | $list->setColumnLabel('name', $this->i18n('profiles_column_name')); 15 | $list->setColumnParams('name', ['id' => '###id###', 'func' => 'edit']); 16 | $list->removeColumn('id'); 17 | $content = $list->get(); 18 | $fragment = new rex_fragment(); 19 | $fragment->setVar('content', $content, false); 20 | $content = $fragment->parse('core/page/section.php'); 21 | echo $content; 22 | } elseif ('add' == $func || 'edit' == $func) { 23 | $id = rex_request('id', 'int'); 24 | if ('edit' == $func) { 25 | $formLabel = $this->i18n('profiles_formcaption_edit'); 26 | } elseif ('add' == $func) { 27 | $formLabel = $this->i18n('profiles_formcaption_add'); 28 | } 29 | $form = rex_form::factory(rex::getTablePrefix().'articlepresets_profiles', '', 'id='.$id); 30 | // Start - add name-field 31 | $field = $form->addTextField('name'); 32 | $field->setLabel($this->i18n('profiles_label_name')); 33 | // End - add name-field 34 | // Start - add categories-field 35 | $field = $form->addSelectField('categories'); 36 | $field->setLabel($this->i18n('profiles_label_categories')); 37 | $field->setSelect(new rex_category_select()); 38 | $select = $field->getSelect(); 39 | $select->setMultiple(); 40 | $select->setSize(10); 41 | // End - add categories-field 42 | // Start - add templates-field 43 | $field = $form->addSelectField('templates'); 44 | $field->setLabel($this->i18n('profiles_label_templates')); 45 | $select = $field->getSelect(); 46 | $select->setMultiple(); 47 | $select->setSize(10); 48 | $select->addSqlOptions('SELECT `name`, `id` FROM `'.rex::getTablePrefix().'template` ORDER BY `name` ASC'); 49 | // End - add templates-field 50 | // Start - add article_reference-field 51 | $field = $form->addLinkmapField('articlereference'); 52 | $field->setLabel($this->i18n('profiles_label_articlereference')); 53 | // End - add article_reference-field 54 | if ('edit' == $func) { 55 | $form->addParam('id', $id); 56 | } 57 | $content = $form->get(); 58 | $fragment = new rex_fragment(); 59 | $fragment->setVar('class', 'edit', false); 60 | $fragment->setVar('title', $formLabel, false); 61 | $fragment->setVar('body', $content, false); 62 | $content = $fragment->parse('core/page/section.php'); 63 | echo $content; 64 | } 65 | --------------------------------------------------------------------------------