├── uninstall.php ├── .gitignore ├── package.yml ├── update.php ├── README.md ├── LICENSE ├── lang └── de_de.lang └── pages └── system.clear_content.php /uninstall.php: -------------------------------------------------------------------------------- 1 | =7.3' -------------------------------------------------------------------------------- /update.php: -------------------------------------------------------------------------------- 1 | getVersion() liefert die noch aktuell installierte Version 10 | 11 | if (rex_version::compare($this->getVersion(), '1.1', '<')) { 12 | // Änderungen für Nutzer die von Versionen kleiner 1.1 kommen 13 | } 14 | 15 | if (rex_version::compare($this->getVersion(), '1.2', '<')) { 16 | // Änderungen für Nutzer die von Versionen kleiner 1.2 kommen 17 | } 18 | 19 | // DB-Anpassungen: 20 | // rex_sql_table::get(rex::getTable('my_table')) 21 | // ->ensureColumn(new rex_sql_column('new_column', 'varchar(255)')) 22 | // ->alter() 23 | // ; 24 | 25 | // Update kann abgebrochen werden: 26 | // throw new rex_functional_exception('Fehlermeldung'); 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Info 2 | 3 | Ich werde demnächst das AddOn weiter entwicklen. Sofern es Wünsche gibt bitte unbedingt als Issue eintragen. 4 | 5 | --- 6 | 7 | ## Clear-Content 8 | 9 | Das AddOn ermöglicht es Inhalte einer bestehenden REDAXO Webseite zu löschen. 10 | 11 | ### Funktionen 12 | - alle Inhalte (Sprachen werden berücksichtigt) löschen 13 | - alle Kategorien und Artikel (in allen Sprachen) löschen 14 | - Kategorien inkl. Unterkategorien löschen 15 | - alle Medienkategorien löschen 16 | - alle Medien löschen 17 | 18 | 19 | --- 20 | 21 | **Fehler, Ideen und Wünsche bitte als Issue schreiben:** 22 | 23 | https://github.com/FriendsOfREDAXO/clear_content/issues 24 | 25 | --- 26 | 27 | ### Autor 28 | 29 | **Friends Of REDAXO** 30 | 31 | * http://www.redaxo.org 32 | * https://github.com/FriendsOfREDAXO 33 | 34 | **Projekt-Lead** 35 | 36 | [getaweb.de / Oliver Kreischer](https://getaweb.de) 37 | 38 | 39 | 40 | 41 | --- 42 | 43 | * Idee und Realisierung der ersten Version: [getaweb.de / Oliver Kreischer](http://getaweb.de) 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 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 | -------------------------------------------------------------------------------- /lang/de_de.lang: -------------------------------------------------------------------------------- 1 | clear_content = Clear-Content 2 | 3 | cc_readme = Readme 4 | 5 | cc_legend_slices = Inhalte (Slices) 6 | cc_config_checkbox_slices = Inhalte löschen 7 | cc_del_success_slices = Alle Inhalte wurden gelöscht 8 | 9 | cc_config_checkbox_slices_all = Alle Inhalte löschen 10 | cc_info1_slices = Inhalte der Sprache 11 | cc_info2_slices = löschen 12 | 13 | cc_del_success_slices1 = Alle Inhalte der Sprache 14 | cc_del_success_slices2 = wurden gelöscht 15 | 16 | cc_legend_categories_articles = Kategorien und Artikel 17 | cc_config_checkbox_categories_articles = alle Kategorien und Artikel (in allen Sprachen) löschen 18 | cc_del_success_categories_articles = Alle Kategorien und Artikel wurden gelöscht 19 | 20 | cc_legend_specific_category_articles = Bestimmte Artikel inkl. Inhalte (in allen Sprachen) löschen 21 | cc_select_specific_category_articles = Kategorie 22 | cc_del_success_specific_category_articles = Kategorie %s wurde gelöscht 23 | 24 | cc_legend_specific_articles = Bestimmte und Artikel inkl. Inhalte (in allen Sprachen) löschen 25 | cc_select_specific_articles = Artikel 26 | cc_del_success_specific_articles = Artikel %s wurde gelöscht 27 | 28 | 29 | cc_legend_media = Medien 30 | cc_config_checkbox_media_cats = alle Medienkategorien löschen 31 | cc_del_success_media_cats = Alle Medienkategorien wurden gelöscht 32 | 33 | cc_config_checkbox_media = alle Medien löschen 34 | cc_del_success_media = Alle Medien wurden gelöscht 35 | 36 | cc_config_clear = Inhalte unwiderruflich löschen 37 | cc_config_clear_confirmation = Die Auswahl wird unwiderruflich gelöscht und kann nicht rückgängig gemacht werden. Ein Backup wird dringend empfohlen! 38 | -------------------------------------------------------------------------------- /pages/system.clear_content.php: -------------------------------------------------------------------------------- 1 | getCategoryId(); 14 | 15 | //DELETE IF ROOT ARTICLE 16 | if ($category_id === 0) { 17 | rex_article_service::deleteArticle($article_id); 18 | return null; 19 | } 20 | //GET CHILDD CATEGORIES 21 | $children = rex_category::get($category_id)->getChildren(); 22 | if ($children) { 23 | foreach ($children as $child) { 24 | //GET ARTICLES FOR CHILD 25 | $articles = $child->getArticles(); 26 | if ($articles) { 27 | foreach ($articles as $article) { 28 | if ($article && !$article->isStartArticle()) { 29 | //DELETE ALL NON START ARTICLES 30 | rex_article_service::deleteArticle($article->getId()); 31 | } 32 | } 33 | } 34 | if (0 === count($child->getChildren())) { 35 | //DELETE CAT AND START ARTICLE OF CAT 36 | rex_category_service::deleteCategory($child->getId()); 37 | } else { 38 | //RECURSE IF THERE ARE MORE CHILDREN 39 | deleteCategory($child->getId()); 40 | } 41 | } 42 | } 43 | //DELETE ARTICLES AND THE CAT ITSELF 44 | if (!rex_article::get($category_id)->isSiteStartArticle() && !rex_article::get($category_id)->isNotFoundArticle()) { 45 | $articles = rex_category::get($category_id)->getArticles(); 46 | if ($articles) { 47 | foreach ($articles as $article) { 48 | if ($article && !$article->isStartArticle()) { 49 | rex_article_service::deleteArticle($article->getId()); 50 | } 51 | } 52 | } 53 | rex_category_service::deleteCategory($category_id); 54 | } 55 | return $category_id; 56 | } 57 | } 58 | 59 | $content = ''; 60 | $buttons = ''; 61 | 62 | // Einstellungen speichern 63 | if (rex_post('formsubmit', 'string') === '1') { 64 | 65 | 66 | $addon->setConfig(rex_post('config', [ 67 | ['checkbox_slices_all', 'string'], 68 | ['checkbox_categories_articles', 'string'], 69 | ['specific_category_articles', 'string'], 70 | ['checkbox_media_cats', 'string'], 71 | ['checkbox_media', 'string'], 72 | ['checkbox_slices_all', 'string'] 73 | ])); 74 | 75 | 76 | foreach (rex_clang::getAll(false) as $lang) { 77 | $lang_id = $lang->getValue('id'); 78 | $addon->setConfig(rex_post('config', [ 79 | ['checkbox_slices_lang_'.$lang_id, 'string'] 80 | ])); 81 | } 82 | 83 | $sql = rex_sql::factory(); 84 | 85 | // Slices 86 | if ($addon->getConfig('checkbox_slices_all') === '1' ) { 87 | 88 | if (rex_sql_table::get(rex::getTablePrefix() .'article_slice_history')->exists()) { 89 | $sql->setquery("TRUNCATE TABLE ". rex::getTablePrefix() ."article_slice_history"); 90 | } 91 | 92 | if (rex_sql_table::get(rex::getTablePrefix() .'article_slice')->exists()) { 93 | $sql->setquery("TRUNCATE TABLE ". rex::getTablePrefix() ."article_slice"); 94 | } 95 | 96 | echo rex_view::success($addon->i18n('cc_del_success_slices')); 97 | } 98 | 99 | if ($addon->getConfig('checkbox_slices_all') !== '1' ) { 100 | foreach (rex_clang::getAll(false) as $lang) { 101 | $lang_id = $lang->getValue('id'); 102 | $lang_name = $lang->getValue('name'); 103 | if ($addon->getConfig('checkbox_slices_lang_' . $lang_id) === $lang) { 104 | 105 | 106 | if (rex_sql_table::get(rex::getTablePrefix() .'article_slice')->exists()) { 107 | $sql->setquery('DELETE FROM '. rex::getTablePrefix() .'article_slice WHERE clang_id !=:cid', array('cid'=> $lang_id)); 108 | 109 | } 110 | 111 | if (rex_sql_table::get(rex::getTablePrefix() .'article_slice_history')->exists()) { 112 | $sql->setquery('DELETE FROM '. rex::getTablePrefix() .'article_slice_history WHERE clang_id !=:cid', array('cid'=> $lang_id)); 113 | } 114 | 115 | echo rex_view::success($addon->i18n('cc_del_success_slices1').' '.$lang_name.' '.$addon->i18n('cc_del_success_slices2')); 116 | } 117 | } 118 | } 119 | 120 | // Kategorien und Artikel löschen 121 | if ($addon->getConfig('checkbox_categories_articles') === '1') { 122 | 123 | if (rex_sql_table::get(rex::getTablePrefix() .'article')->exists()) { 124 | $sql->setquery("TRUNCATE TABLE ". rex::getTablePrefix() ."article"); 125 | } 126 | if (rex_sql_table::get(rex::getTablePrefix() .'article_slice')->exists()) { 127 | $sql->setquery("TRUNCATE TABLE ". rex::getTablePrefix() ."article_slice"); 128 | } 129 | if (rex_sql_table::get(rex::getTablePrefix() .'article_slice_history')->exists()) { 130 | $sql->setquery("TRUNCATE TABLE ". rex::getTablePrefix() ."article_slice_history"); 131 | } 132 | echo rex_view::success($addon->i18n('cc_del_success_categories_articles')); 133 | } 134 | 135 | // Bestimmte Kategorie und Artikel rekursiv löschen 136 | if ($addon->getConfig('specific_category_articles') > 0) { 137 | 138 | $article_id = $addon->getConfig('specific_category_articles'); 139 | $deleted_category_id = deleteCategory($article_id); 140 | echo rex_view::success(sprintf($addon->i18n('cc_del_success_specific_category_articles'), $deleted_category_id)); 141 | } 142 | 143 | // Medienkategorien löschen 144 | if ($addon->getConfig('checkbox_media_cats') === '1') { 145 | 146 | if (rex_sql_table::get(rex::getTablePrefix() .'media_category')->exists()) { 147 | $sql->setquery("TRUNCATE TABLE ". rex::getTablePrefix() ."media_category"); 148 | $sql->setquery("UPDATE ". rex::getTablePrefix() ."media SET category_id = 0"); 149 | } 150 | echo rex_view::success($addon->i18n('cc_del_success_media_cats')); 151 | } 152 | 153 | // Medien löschen 154 | if ($addon->getConfig('checkbox_media') === '1') { 155 | // rex_dir::deleteIterator(rex_finder::factory(rex_path::media())->ignoreFiles('.redaxo')); 156 | rex_dir::deleteIterator(rex_finder::factory(rex_path::media()) 157 | ->filesOnly() 158 | ->ignoreFiles('.redaxo') 159 | ); 160 | $sql = rex_sql::factory(); 161 | 162 | if (rex_sql_table::get(rex::getTablePrefix() .'media')->exists()) { 163 | $sql->setquery("TRUNCATE TABLE ". rex::getTablePrefix() ."media"); 164 | $sql->setquery("UPDATE ". rex::getTablePrefix() ."media SET category_id = 0"); 165 | 166 | } 167 | echo rex_view::success($addon->i18n('cc_del_success_media')); 168 | } 169 | 170 | foreach (rex_clang::getAll(false) as $lang) { 171 | $lang_id = $lang->getValue('id'); 172 | $addon->setConfig('checkbox_slices_lang_'.$lang_id) === ''; 173 | } 174 | 175 | $addon->setConfig('checkbox_categories_articles') === ''; 176 | $addon->setConfig('checkbox_media_cats') === ''; 177 | $addon->setConfig('checkbox_media') === ''; 178 | $addon->setConfig('checkbox_slices_all') === ''; 179 | rex_delete_cache(); 180 | } 181 | 182 | 183 | // Slices 184 | $content .= '