public static function formatLi(rex_structure_element $OOobject, $current_category_id, rex_context $context, $liAttr = '', $linkAttr = '') { $linkAttr .= ' class="' . ($OOobject->isOnline() ? 'rex-online' : 'rex-offline') . '"'; if (strpos($linkAttr, ' href=') === false) { $linkAttr .= ' href="' . $context->getUrl(['category_id' => $OOobject->getId()]) . '"'; } $label = self::formatLabel($OOobject); $icon = '<i class="rex-icon rex-icon-' . ($OOobject->isStartArticle() ? 'startarticle' : 'article') . '"></i>'; return '<li' . $liAttr . '><a' . $linkAttr . '>' . $icon . ' ' . htmlspecialchars($label) . '</a>'; }
/** * @param string $value * * @return bool */ public static function hasValue($value) { return parent::_hasValue($value, ['cat_']); }
public static function resetClassVars() { self::$classVars = null; }
/** * Konvertiert einen Artikel zum Startartikel der eigenen Kategorie. * * @param int $neu_id Artikel ID des Artikels, der Startartikel werden soll * * @return bool TRUE bei Erfolg, sonst FALSE */ public static function article2startarticle($neu_id) { $GAID = []; // neuen startartikel holen und schauen ob da $neu = rex_sql::factory(); $neu->setQuery('select * from ' . rex::getTablePrefix() . 'article where id=? and startarticle=0 and clang_id=?', [$neu_id, rex_clang::getStartId()]); if ($neu->getRows() != 1) { return false; } $neu_cat_id = $neu->getValue('parent_id'); // in oberster kategorie dann return if ($neu_cat_id == 0) { return false; } // alten startartikel $alt = rex_sql::factory(); $alt->setQuery('select * from ' . rex::getTablePrefix() . 'article where id=? and startarticle=1 and clang_id=?', [$neu_cat_id, rex_clang::getStartId()]); if ($alt->getRows() != 1) { return false; } $alt_id = $alt->getValue('id'); $parent_id = $alt->getValue('parent_id'); // cat felder sammeln. + $params = ['path', 'priority', 'catname', 'startarticle', 'catpriority', 'status']; $db_fields = rex_structure_element::getClassVars(); foreach ($db_fields as $field) { if (substr($field, 0, 4) == 'cat_') { $params[] = $field; } } // LANG SCHLEIFE foreach (rex_clang::getAllIds() as $clang) { // alter startartikel $alt->setQuery('select * from ' . rex::getTablePrefix() . "article where id={$neu_cat_id} and startarticle=1 and clang_id={$clang}"); // neuer startartikel $neu->setQuery('select * from ' . rex::getTablePrefix() . "article where id={$neu_id} and startarticle=0 and clang_id={$clang}"); // alter startartikel updaten $alt2 = rex_sql::factory(); $alt2->setTable(rex::getTablePrefix() . 'article'); $alt2->setWhere(['id' => $alt_id, 'clang_id' => $clang]); $alt2->setValue('parent_id', $neu_id); // neuer startartikel updaten $neu2 = rex_sql::factory(); $neu2->setTable(rex::getTablePrefix() . 'article'); $neu2->setWhere(['id' => $neu_id, 'clang_id' => $clang]); $neu2->setValue('parent_id', $alt->getValue('parent_id')); // austauschen der definierten paramater foreach ($params as $param) { $alt2->setValue($param, $neu->getValue($param)); $neu2->setValue($param, $alt->getValue($param)); } $alt2->update(); $neu2->update(); } // alle artikel suchen nach |art_id| und pfade ersetzen // alles artikel mit parent_id alt_id suchen und ersetzen $articles = rex_sql::factory(); $ia = rex_sql::factory(); $articles->setQuery('select * from ' . rex::getTablePrefix() . "article where path like '%|{$alt_id}|%'"); for ($i = 0; $i < $articles->getRows(); ++$i) { $iid = $articles->getValue('id'); $ipath = str_replace("|{$alt_id}|", "|{$neu_id}|", $articles->getValue('path')); $ia->setTable(rex::getTablePrefix() . 'article'); $ia->setWhere(['id' => $iid]); $ia->setValue('path', $ipath); if ($articles->getValue('parent_id') == $alt_id) { $ia->setValue('parent_id', $neu_id); } $ia->update(); $GAID[$iid] = $iid; $articles->next(); } $GAID[$neu_id] = $neu_id; $GAID[$alt_id] = $alt_id; $GAID[$parent_id] = $parent_id; foreach ($GAID as $gid) { rex_article_cache::delete($gid); } rex_complex_perm::replaceItem('structure', $alt_id, $neu_id); foreach (rex_clang::getAllIds() as $clang) { rex_extension::registerPoint(new rex_extension_point('ART_TO_STARTARTICLE', '', ['id' => $neu_id, 'id_old' => $alt_id, 'clang' => $clang])); } return true; }
/** * Löscht die gecachten List-Dateien eines Artikels. Wenn keine clang angegeben, wird * der Artikel in allen Sprachen gelöscht. * * @param int $id ArtikelId des Artikels * * @return bool True on success, False on errro */ public static function deleteLists($id) { // sanity check if ($id < 0) { return false; } $cachePath = rex_path::addonCache('structure'); foreach (['alist', 'clist'] as $list) { rex_file::delete($cachePath . $id . '.' . $list); rex_structure_element::clearInstanceList([$id, $list]); } return true; }
public static function formatLi(rex_structure_element $OOobject, $current_category_id, rex_context $context, $liAttr = '', $linkAttr = '') { $liAttr .= $OOobject->getId() == $current_category_id ? ' id="rex-linkmap-active"' : ''; $linkAttr .= ' class="' . ($OOobject->isOnline() ? 'rex-online' : 'rex-offline') . '"'; if (strpos($linkAttr, ' href=') === false) { $linkAttr .= ' href="' . $context->getUrl(['category_id' => $OOobject->getId()]) . '"'; } $label = self::formatLabel($OOobject); return '<li' . $liAttr . '><a' . $linkAttr . '>' . htmlspecialchars($label) . '</a>'; }
rex_extension::register('CLANG_ADDED', function (rex_extension_point $ep) { $firstLang = rex_sql::factory(); $firstLang->setQuery('select * from ' . rex::getTablePrefix() . 'article where clang_id=?', [rex_clang::getStartId()]); $fields = $firstLang->getFieldnames(); $newLang = rex_sql::factory(); // $newLang->setDebug(); foreach ($firstLang as $firstLangArt) { $newLang->setTable(rex::getTablePrefix() . 'article'); foreach ($fields as $key => $value) { if ($value == 'pid') { echo ''; } elseif ($value == 'clang_id') { $newLang->setValue('clang_id', $ep->getParam('clang')->getId()); } elseif ($value == 'status') { $newLang->setValue('status', '0'); } else { $newLang->setValue($value, $firstLangArt->getValue($value)); } } $newLang->insert(); } }); rex_extension::register('CLANG_DELETED', function (rex_extension_point $ep) { $del = rex_sql::factory(); $del->setQuery('delete from ' . rex::getTablePrefix() . 'article where clang_id=?', [$ep->getParam('clang')->getId()]); }); rex_extension::register('CACHE_DELETED', function () { rex_structure_element::clearInstancePool(); rex_structure_element::clearInstanceListPool(); rex_structure_element::resetClassVars(); });