/** * CLASS Function: * Return a list of articles for a certain category */ function getArticlesOfCategory($a_category_id, $ignore_offlines = false, $clang = false) { global $REX; if ($clang === false) { $clang = $REX['CUR_CLANG']; } if (!isset($REX['RE_ID'][$a_category_id])) { $articlelist = $REX['INCLUDE_PATH'] . "/generated/articles/" . $a_category_id . "." . $clang . ".alist"; if (file_exists($articlelist)) { include $articlelist; } } $artlist = array(); if (isset($REX['RE_ID'][$a_category_id])) { foreach ($REX['RE_ID'][$a_category_id] as $var) { $article = OOArticle::getArticleById($var, $clang); if ($ignore_offlines) { if ($article->isOnline()) { $artlist[] = $article; } } else { $artlist[] = $article; } } } return $artlist; }
/** * GET SITEMAP ARTICLES FROM DB * * @return (array) sitemap articles */ private function get_db_articles() { global $REX, $SEO42_URLS; if ($REX['ADDON']['seo42']['settings']['rewriter']) { // use seo42 pathlist array_multisort($SEO42_URLS); foreach ($SEO42_URLS as $url) { $article = OOArticle::getArticleById($url['id'], $url['clang']); if (OOArticle::isValid($article)) { $hasPermission = true; // community addon if (class_exists('rex_com_auth') && !rex_com_auth::checkPerm($article)) { $hasPermission = false; } // add sitemap block if (($article->isOnline() || $article->getId() == $REX['START_ARTICLE_ID'] && $article->getClang() == $REX['START_CLANG_ID']) && !isset($url['status']) && $hasPermission) { $db_articles[$url['id']][$url['clang']] = array('loc' => rex_getUrl($url['id'], $url['clang']), 'lastmod' => date('c', $article->getValue('updatedate')), 'changefreq' => self::calc_article_changefreq($article->getValue('updatedate'), ''), 'priority' => self::calc_article_priority($url['id'], $url['clang'], $article->getValue('path'), ''), 'noindex' => $article->getValue('seo_noindex')); } } } } else { // at the moment: no sitemap urls if rewriter is turned off } // EXTENSIONPOINT SEO42_SITEMAP_ARRAY_CREATED $db_articles = rex_register_extension_point('SEO42_SITEMAP_ARRAY_CREATED', $db_articles); // EXTENSIONPOINT SEO42_SITEMAP_ARRAY_FINAL (READ ONLY) rex_register_extension_point('SEO42_SITEMAP_ARRAY_FINAL', $db_articles); $this->db_articles = $db_articles; }
function getBreadcrumb($startPageLabel, $includeCurrent = FALSE, $category_id = 0) { if (!$this->_setActivePath()) { return FALSE; } global $REX; $path = $this->path; $i = 1; $lis = ''; if ($startPageLabel) { $lis .= '<li class="rex-lvl' . $i . '"><a href="' . rex_getUrl($REX['START_ARTICLE_ID']) . '">' . htmlspecialchars($startPageLabel) . '</a></li>'; $i++; // StartArticle nicht doppelt anzeigen if (isset($path[0]) && $path[0] == $REX['START_ARTICLE_ID']) { unset($path[0]); } } foreach ($path as $pathItem) { if ($cat = OOCategory::getCategoryById($pathItem) && $this->_check($cat, $i)) { $lis .= '<li class="rex-lvl' . $i . '"><a href="' . $cat->getUrl() . '">' . htmlspecialchars($cat->getName()) . '</a></li>'; $i++; } } if ($includeCurrent) { if ($art = OOArticle::getArticleById($this->current_article_id) && $this->_check($art, $i)) { if (!$art->isStartpage()) { $lis .= '<li class="rex-lvl' . $i . '">' . htmlspecialchars($art->getName()) . '</li>'; } else { $cat = OOCategory::getCategoryById($this->current_article_id); $lis .= '<li class="rex-lvl' . $i . '">' . htmlspecialchars($cat->getName()) . '</li>'; } } } return '<ul class="rex-breadcrumb">' . $lis . '</ul>'; }
function rex_getUrl($id, $clang = "", $params = "") { /* * Object Helper Function: * Returns a url for linking to this article * This url respects the setting for mod_rewrite * support! * * If you pass an associative array for $params, * then these parameters will be attached to the URL. * e.g.: * $param = array("order" => "123", "name" => "horst"); * $article->getUrl($param); * will return: * index.php?article_id=1&order=123&name=horst * or if mod_rewrite support is activated: * /1-The_Article_Name?order=123&name=horst */ global $REX; // ----- definiere sprache if ($clang == "") { $clang = $REX[CUR_CLANG]; } // ----- get article Name $id = $id + 0; if ($id == 0) { $name = "NoName"; } else { $ooa = OOArticle::getArticleById($id); if ($ooa) { $name = strtolower($ooa->getName()); } $name = preg_replace("/[^a-zA-Z]/", "", $name); } // ----- get params $param_string = ""; if (is_array($params)) { $first = true; foreach ($params as $key => $value) { // Nur Wenn MOD_REWRITE aktiv ist, das erste "&" entfernen. if ($first && $REX['MOD_REWRITE']) { $first = false; } else { $param_string .= '&'; } $param_string .= $key . '=' . $value; } } else { if ($params != "") { $param_string = str_replace('&', '&', $params); } } if ($REX['MOD_REWRITE'] && $param_string != "") { $param_string = "?" . $param_string; } // ----- create url $url = $REX['MOD_REWRITE'] ? "{$id}-{$clang}-{$name}.html" : "index.php?article_id={$id}&clang={$clang}"; return $REX['WWW_PATH'] . "{$url}" . "{$param_string}"; }
function getCategoryById($category_id = false, $clang = false) { global $REX; if ($clang === false) { $clang = $REX['CUR_CLANG']; } return OOArticle::getArticleById($category_id, $clang, true); }
/** * Erweitert das Meta-Formular um die neuen Meta-Felder */ function rex_a62_metainfo_form($params) { $OOArt = OOArticle::getArticleById($params['id'], $params['clang']); $params['activeItem'] = $params['article']; // Hier die category_id setzen, damit beim klick auf den REX_LINK_BUTTON der Medienpool in der aktuellen Kategorie startet $params['activeItem']->setValue('category_id', $OOArt->getCategoryId()); return $params['subject'] . _rex_a62_metainfo_form('art_', $params, '_rex_a62_metainfo_art_handleSave'); }
function rex_a128_historyHandler($params) { global $page, $subpage, $REX_USER, $REX; $mypage = $params['mypage']; require $REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/classes/class.rex_historyManager.inc.php'; require $REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/classes/class.rex_history.inc.php'; require $REX['INCLUDE_PATH'] . '/addons/' . $mypage . '/classes/class.rex_historyItem.inc.php'; $function = rex_request('function', 'string'); $mode = rex_request('mode', 'string'); // Alle Histories registrierens $articleHistory =& rexHistoryManager::getHistory('articles'); $templateHistory =& rexHistoryManager::getHistory('templates'); $moduleHistory =& rexHistoryManager::getHistory('modules'); $actionHistory =& rexHistoryManager::getHistory('actions'); $sql = new rex_sql(); $sql->debugsql = true; if ($page == 'module' && $function == 'edit' && ($module_id = rex_get('modul_id', 'int')) != 0) { $result = $sql->getArray('SELECT name FROM ' . $REX['TABLE_PREFIX'] . 'modultyp WHERE id=' . $module_id); if (isset($result[0])) { $link = 'index.php?page=' . $page . '&function=' . $function . '&modul_id=' . $module_id; $title = $result[0]['name']; if ($REX_USER->hasPerm('advancedMode[]')) { $title .= ' [' . $module_id . ']'; } $moduleHistory->addItem(new rexHistoryItem($title, $link)); } } elseif ($page == 'module' && $subpage == 'actions' && $function == 'edit' && ($action_id = rex_get('action_id', 'int')) != 0) { $result = $sql->getArray('SELECT name FROM ' . $REX['TABLE_PREFIX'] . 'action WHERE id=' . $action_id); if (isset($result[0])) { $link = 'index.php?page=' . $page . '&subpage=' . $subpage . '&function=' . $function . '&modul_id=' . $action_id; $title = $result[0]['name']; if ($REX_USER->hasPerm('advancedMode[]')) { $title .= ' [' . $action_id . ']'; } $actionHistory->addItem(new rexHistoryItem($title, $link)); } } elseif ($page == 'template' && $function == 'edit' && ($template_id = rex_get('template_id', 'int')) != 0) { $result = $sql->getArray('SELECT name FROM ' . $REX['TABLE_PREFIX'] . 'template WHERE id=' . $template_id); if (isset($result[0])) { $link = 'index.php?page=' . $page . '&function=' . $function . '&template_id=' . $template_id; $title = $result[0]['name']; if ($REX_USER->hasPerm('advancedMode[]')) { $title .= ' [' . $template_id . ']'; } $templateHistory->addItem(new rexHistoryItem($title, $link)); } } elseif ($page == 'content' && $mode == 'edit' && ($article_id = rex_get('article_id', 'int')) != 0) { $art = OOArticle::getArticleById($article_id); if (OOArticle::isValid($art)) { $link = 'index.php?page=' . $page . '&mode=' . $mode . '&article_id=' . $article_id; $title = $art->getName(); if ($REX_USER->hasPerm('advancedMode[]')) { $title .= ' [' . $article_id . ']'; } $articleHistory->addItem(new rexHistoryItem($title, $link)); } } }
function getArticleName() { $article_id = $this->getValue(); $article_name = ''; if ($article_id != '' && $article_id != 0) { $ooa = OOArticle::getArticleById($article_id); if ($ooa !== null) { $article_name = $ooa->getName(); } } return $article_name; }
/** * Wert für die Ausgabe */ function matchArticleVar($content) { global $article_id, $clang; $var = 'REX_ARTICLE_VAR'; $matches = $this->getArticleVarInputParams($content, $var); $article = OOArticle::getArticleById($article_id, $clang); foreach ($matches as $match) { list($param_str) = $match; $content = str_replace($var . '[' . $param_str . ']', $article->getValue($param_str), $content); } return $content; }
public static function control() { global $REX; $myself = 'url_control'; $addon = $REX['ADDON'][$myself]['addon']; $rewriter = $REX['ADDON'][$myself]['rewriter']; // http://www.domain.de/kategorie/artikel.html $url_full = parent::getFullRequestedUrl(); $parse = parse_url($url_full); $url_path = $parse['path']; $sql = rex_sql::factory(); //$sql->debugsql = true; $sql->setQuery('SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'url_control_manager WHERE status = "1" AND ( url = "' . mysql_real_escape_string($url_full) . '" OR url = "' . mysql_real_escape_string($url_path) . '" ) '); if ($sql->getRows() == 1) { $method = $sql->getValue('method'); $params = unserialize($sql->getValue('method_parameters')); switch ($method) { case 'article': $article_id = (int) $params['article']['article_id']; $clang = (int) $params['article']['clang']; if ($params['article']['action'] == 'view') { return array('article_id' => $article_id, 'clang' => $clang); } elseif ($params['article']['action'] == 'redirect') { $a = OOArticle::getArticleById((int) $params['article']['article_id'], (int) $params['article']['clang']); if ($a instanceof OOArticle) { if (isset($rewriter[$addon]['get_url'])) { $func = $rewriter[$addon]['get_url']; $url = call_user_func($func, $article_id, $clang); } else { $url = $a->getUrl(); } } //$url = rex_getUrl((int) $params['article']['article_id'], (int) $params['article']['clang']); self::redirect($a->getUrl(), $params['http_type']['code']); } break; case 'target_url': $url = $params['target_url']['url']; self::redirect($url, $params['http_type']['code']); break; } } return false; }
/** * Object Helper Function: * Returns a url for linking to this article * This url respects the setting for mod_rewrite * support! * * If you pass an associative array for $params, * then these parameters will be attached to the URL. * * * USAGE: * $param = array("order" => "123", "name" => "horst"); * $url = $article->getUrl($param); * * - OR - * * $url = $article->getUrl("order=123&name=horst"); * * RETURNS: * index.php?article_id=1&order=123&name=horst * or if mod_rewrite support is activated: * /1-The_Article_Name?order=123&name=horst */ function rex_getUrl($id = '', $clang = '', $params = '') { global $REX, $article_id; $id = (int) $id; $clang = (int) $clang; // ----- get id if (strlen($id) == 0 || $id == 0) { $id = $article_id; } // ----- get clang // Wenn eine rexExtension vorhanden ist, immer die clang mitgeben! // Die rexExtension muss selbst entscheiden was sie damit macht if (strlen($clang) == 0 && (count($REX['CLANG']) > 1 || rex_extension_is_registered('URL_REWRITE'))) { $clang = $REX['CUR_CLANG']; } // ----- get params $param_string = ''; if (is_array($params)) { foreach ($params as $key => $value) { $param_string .= '&' . $key . '=' . $value; } } elseif ($params != '') { $param_string = str_replace('&', '&', $params); } // ----- get article name $id = (int) $id; if ($id != 0) { $ooa = OOArticle::getArticleById($id, $clang); if ($ooa) { $name = rex_parseArticleName($ooa->getName()); } } if (!isset($name) or $name == '') { $name = 'NoName'; } // ----- EXTENSION POINT $url = rex_register_extension_point('URL_REWRITE', '', array('id' => $id, 'name' => $name, 'clang' => $clang, 'params' => $param_string)); if ($url == '') { // ----- get rewrite function if ($REX['MOD_REWRITE'] === true || $REX['MOD_REWRITE'] == 'true') { $rewrite_fn = 'rexrewrite_apache_rewrite'; } else { $rewrite_fn = 'rexrewrite_no_rewrite'; } $url = call_user_func($rewrite_fn, $id, $name, $clang, $param_string); } return $url; }
function enterObject(&$email_elements, &$sql_elements, &$warning, &$form_output, $send = 0) { global $REX; if (!isset($REX["xform_classes_be_link"])) { $REX["xform_classes_be_link"] = 0; } $REX["xform_classes_be_link"]++; $i = $REX["xform_classes_be_link"]; if ($this->value == "" && !$send) { if (isset($this->elements[3])) { $this->value = $this->elements[3]; } } $wc = ""; if (isset($warning[$this->getId()])) { $wc = $warning[$this->getId()]; } $linkname = ""; if ($this->getValue() != "" && ($a = OOArticle::getArticleById($this->getValue()))) { $linkname = $a->getName(); } $form_output[] = ' <div class="xform-element formbe_mediapool formlabel-' . $this->getName() . '"> <label class="text ' . $wc . '" for="el_' . $this->getId() . '" >' . $this->elements[2] . '</label> <div class="rex-widget"> <div class="rex-widget-link"> <p class="rex-widget-field"> <input type="hidden" name="FORM[' . $this->params["form_name"] . '][el_' . $this->id . ']" id="LINK_' . $i . '" value="' . $this->getValue() . '" /> <input type="text" size="30" name="LINK_' . $i . '_NAME" value="' . htmlspecialchars($linkname) . '" id="LINK_' . $i . '_NAME" readonly="readonly" /> </p> <p class="rex-widget-icons rex-widget-1col"> <span class="rex-widget-column rex-widget-column-first"> <a href="#" class="rex-icon-file-open" onclick="openLinkMap(\'LINK_' . $i . '\', \'&clang=0&category_id=1\');return false;" title="Link auswŠhlen" tabindex="21"></a> <a href="#" class="rex-icon-file-delete" onclick="deleteREXLink(' . $i . ');return false;" title="AusgewŠhlten Link lšschen" tabindex="22"></a> </span> </p> </div> </div> <div class="rex-clearer"></div> </div> '; $email_elements[$this->elements[1]] = stripslashes($this->value); if (!isset($this->elements[4]) || $this->elements[4] != "no_db") { $sql_elements[$this->elements[1]] = $this->value; } }
function enterObject() { static $counter = 0; $counter++; if ($this->getValue() == '' && !$this->params['send']) { $this->setValue($this->getElement(3)); } $linkName = ''; if ($this->getValue() != '' && ($a = OOArticle::getArticleById($this->getValue()))) { $linkName = $a->getName(); } $this->params['form_output'][$this->getId()] = $this->parse('value.be_link.tpl.php', compact('counter', 'linkName')); $this->params['value_pool']['email'][$this->getName()] = stripslashes($this->getValue()); if ($this->getElement(4) != 'no_db') { $this->params['value_pool']['sql'][$this->getName()] = $this->getValue(); } }
function setArticleId($article_id) { // bc if ($this->viasql) { return parent::setArticleId($article_id); } global $REX; $article_id = (int) $article_id; $this->article_id = $article_id; $OOArticle = OOArticle::getArticleById($article_id, $this->clang); if (OOArticle::isValid($OOArticle)) { $this->category_id = $OOArticle->getCategoryId(); $this->template_id = $OOArticle->getTemplateId(); return TRUE; } $this->article_id = 0; $this->template_id = 0; $this->category_id = 0; return FALSE; }
/** * Gibt eine Url zu einem Artikel zurück * * @param [$_id] ArtikelId des Artikels * @param [$_clang] SprachId des Artikels * @param [$_params] Array von Parametern * @param [$_divider] Trennzeichen für Parameter * (z.B. & für HTML, & für Javascript) */ function rex_getUrl($_id = '', $_clang = '', $_params = '', $_divider = '&') { global $REX, $article_id; $id = (int) $_id; $clang = (int) $_clang; // ----- get id if ($id == 0) { $id = $article_id; } // ----- get clang // Wenn eine rexExtension vorhanden ist, immer die clang mitgeben! // Die rexExtension muss selbst entscheiden was sie damit macht if ($_clang === '' && (count($REX['CLANG']) > 1 || rex_extension_is_registered('URL_REWRITE'))) { $clang = $REX['CUR_CLANG']; } // ----- get params $param_string = rex_param_string($_params, $_divider); if ($id != 0) { $ooa = OOArticle::getArticleById($id, $clang); if ($ooa) { $name = rex_parse_article_name($ooa->getName()); } } if (!isset($name) or $name == '') { $name = 'NoName'; } // ----- EXTENSION POINT $url = rex_register_extension_point('URL_REWRITE', '', array('id' => $id, 'name' => $name, 'clang' => $clang, 'params' => $param_string, 'divider' => $_divider)); if ($url == '') { // ----- get rewrite function if ($REX['MOD_REWRITE'] === true || $REX['MOD_REWRITE'] == 'true') { $rewrite_fn = 'rex_apache_rewrite'; } else { $rewrite_fn = 'rex_no_rewrite'; } $url = call_user_func($rewrite_fn, $id, $name, $clang, $param_string, $_divider); } return $url; }
function url_generate_column_article($params) { global $I18N; $list = $params['list']; $return = ''; $a = OOArticle::getArticleById($list->getValue("article_id"), $list->getValue("clang")); if ($a instanceof OOArticle) { $return = $a->getName(); $return .= ' ['; $return .= '<a href="index.php?article_id=' . $list->getValue('article_id') . '&clang=' . $list->getValue('clang') . '">Backend</a>'; $return .= ' | '; $return .= '<a href="' . rex_getUrl($list->getValue('article_id'), $list->getValue('clang')) . '">Frontend</a>'; $return .= ']'; $tree = $a->getParentTree(); $levels = array(); foreach ($tree as $object) { $levels[] = $object->getName(); } $return .= '<div class="url-control-path"><small><b>Pfad: </b>' . implode(' : ', $levels) . '</small></div>'; } return $return; }
public function getBreadcrumbNavigation() { global $REX; $listType = 'ul'; if ($this->breadcrumbOlList) { $listType = 'ol'; } if ($this->breadcrumbCssClass !== '') { $cssClass = ' class="' . $this->breadcrumbCssClass . '"'; } else { $cssClass = ''; } $html = '<' . $listType . $cssClass . '>'; $path = explode('|', $REX['ART'][$REX['ARTICLE_ID']]['path'][$REX['CUR_CLANG']] . $REX['ARTICLE_ID']); if ($REX['ARTICLE_ID'] !== $REX['START_ARTICLE_ID']) { $path = array_merge(array($REX['START_ARTICLE_ID']), $path); } foreach ($path as $id) { if ($id) { if ($this->breadcrumbStartArticleName === false && intval($id) === $REX['START_ARTICLE_ID']) { continue; } $article = OOArticle::getArticleById($id); $articleName = $article->getName(); if ($article->isOnline()) { if ($this->breadcrumbStartArticleName !== '' && intval($id) === $REX['START_ARTICLE_ID']) { $articleName = $this->breadcrumbStartArticleName; } $html .= '<li>'; if (intval($id) === $REX['ARTICLE_ID']) { $html .= $articleName; } else { $html .= '<a href="' . $article->getUrl() . '">' . $articleName . '</a>'; } $html .= '</li>'; } } } return $html .= '</' . $listType . '>'; }
/** * rex_rewriter_generate_pathnames * generiert die Pathlist, abhŠngig von Aktion * @author markus.staab[at]redaxo[dot]de Markus Staab * @package redaxo4.2 */ function rex_rewriter_generate_pathnames($params) { global $REX, $REXPATH; if (file_exists(FULLNAMES_PATHLIST)) { require_once FULLNAMES_PATHLIST; } if (!isset($REXPATH)) { $REXPATH = array(); } if (!isset($params['extension_point'])) { $params['extension_point'] = ''; } $where = ''; switch ($params['extension_point']) { // ------- sprachabhängig, einen artikel aktualisieren case 'CAT_DELETED': case 'ART_DELETED': unset($REXPATH[$params['id']]); break; case 'CAT_ADDED': case 'CAT_UPDATED': case 'ART_ADDED': case 'ART_UPDATED': $where = '(id=' . $params['id'] . ' AND clang=' . $params['clang'] . ') OR (path LIKE "%|' . $params['id'] . '|%" AND clang=' . $params['clang'] . ')'; break; // ------- alles aktualisieren // ------- alles aktualisieren case 'ALL_GENERATED': default: $where = '1=1'; break; } if ($where != '') { $db = new rex_sql(); // $db->debugsql=true; $db->setQuery('SELECT id,clang,path,startpage FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE ' . $where . ' and revision=0'); while ($db->hasNext()) { $clang = $db->getValue('clang'); $pathname = ''; if (count($REX['CLANG']) > 1) { $pathname = $REX['CLANG'][$clang] . '/'; } // pfad über kategorien bauen $path = trim($db->getValue('path'), '|'); if ($path != '') { $path = explode('|', $path); foreach ($path as $p) { $ooc = OOCategory::getCategoryById($p, $clang); $name = $ooc->getName(); unset($ooc); // speicher freigeben $pathname = rex_rewriter_appendToPath($pathname, $name); } } $ooa = OOArticle::getArticleById($db->getValue('id'), $clang); if ($ooa->isStartArticle()) { $ooc = $ooa->getCategory(); $catname = $ooc->getName(); unset($ooc); // speicher freigeben $pathname = rex_rewriter_appendToPath($pathname, $catname); } // eigentlicher artikel anhängen $name = $ooa->getName(); unset($ooa); // speicher freigeben $pathname = rex_rewriter_appendToPath($pathname, $name); $pathname = substr($pathname, 0, strlen($pathname) - 1) . '.html'; $REXPATH[$db->getValue('id')][$db->getValue('clang')] = $pathname; $db->next(); } } rex_put_file_contents(FULLNAMES_PATHLIST, "<?php\n\$REXPATH = " . var_export($REXPATH, true) . ";\n"); }
function getArticle() { return OOArticle::getArticleById($this->getArticleId()); }
/** * Indexes a certain article. * * @param int $_id * @param mixed $_clang * * @return int */ function indexArticle($_id, $_clang = false) { global $REX; if ($_clang === false) { $langs = $this->languages; } else { $langs = array(intval($_clang) => $this->languages[intval($_clang)]); } $return = array(); $keywords = array(); foreach ($langs as $langID => $v) { if (in_array($_id, $this->excludeIDs)) { $return[$v] = A587_ART_EXCLUDED; continue; } $REX['CUR_CLANG'] = $langID; $delete = new rex_sql(); $where = sprintf("ftable = '%s' AND fid = %d AND clang = %d", $delete->escape($this->tablePrefix . 'article'), $_id, $langID); // delete from cache $select = new rex_sql(); $select->setTable($this->tablePrefix . '587_searchindex'); $select->setWhere($where); $select->select('id'); $indexIds = array(); foreach ($select->getArray() as $result) { $indexIds[] = $result['id']; } $this->deleteCache($indexIds); // delete old $delete->setTable($this->tablePrefix . '587_searchindex'); $delete->setWhere($where); $delete->delete(); // index article $article = OOArticle::getArticleById(intval($_id), $langID); if (is_object($article) and ($article->isOnline() or $this->indexOffline)) { $this->beginFrontendMode(); if (ini_get('allow_url_fopen') and $this->indexViaHTTP) { $articleText = @file_get_contents('http://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['PHP_SELF'], 0, strpos($_SERVER['PHP_SELF'], '/redaxo/') + 1) . rex_geturl($_id, $langID, '', '&')); } elseif ($_id != 0 and $this->dontIndexRedirects) { $rex_article = new rex_article(intval($_id), $langID); $article_content_file = $this->generatedPath . '/articles/' . $_id . '.' . $langID . '.content'; if (!file_exists($article_content_file)) { include_once $this->includePath . "/functions/function_rex_generate.inc.php"; $generated = rex_generateArticleContent($_id, $langID); if ($generated !== true) { $return[$v] = A587_ART_IDNOTFOUND; continue; } } if (file_exists($article_content_file) and preg_match($this->encodeRegex('~(header\\s*\\(\\s*["\']\\s*Location\\s*:)|(rex_redirect\\s*\\()~is'), rex_get_file_contents($article_content_file))) { $return[$v] = A587_ART_REDIRECT; continue; } if ($this->indexWithTemplate) { $articleText = $rex_article->getArticleTemplate(); } else { $articleText = $rex_article->getArticle(); } if ($this->ep_outputfilter) { $tmp = array('artid' => $REX['ARTICLE_ID'], 'clang' => $REX['CUR_CLANG']); $REX['ARTICLE_ID'] = $_id; $REX['CUR_CLANG'] = $langID; $articleText = rex_register_extension_point('OUTPUT_FILTER', $articleText, array('environment' => 'frontend', 'sendcharset' => false)); $REX['ARTICLE_ID'] = $tmp['artid']; $REX['CUR_CLANG'] = $tmp['clang']; } } $insert = new rex_sql(); $articleData = array(); $articleData['texttype'] = 'article'; $articleData['ftable'] = $this->tablePrefix . 'article'; $articleData['fcolumn'] = NULL; $articleData['clang'] = $article->getClang(); $articleData['fid'] = intval($_id); $articleData['catid'] = $article->getCategoryId(); $articleData['unchangedtext'] = $insert->escape($articleText); $articleData['plaintext'] = $insert->escape($plaintext = $this->getPlaintext($articleText)); if (array_key_exists($REX['TABLE_PREFIX'] . 'article', $this->includeColumns)) { $additionalValues = array(); $select->flush(); $select->setTable($REX['TABLE_PREFIX'] . 'article'); $select->setWhere('id = ' . $_id . ' AND clang = ' . $langID); $select->select('`' . implode('`,`', $this->includeColumns[$REX['TABLE_PREFIX'] . 'article']) . '`'); foreach ($this->includeColumns[$REX['TABLE_PREFIX'] . 'article'] as $col) { $additionalValues[$col] = $select->getValue($col); } $articleData['values'] = $insert->escape(serialize($additionalValues)); } foreach (preg_split($this->encodeRegex('~[[:punct:][:space:]]+~ism'), $plaintext) as $keyword) { if ($this->significantCharacterCount <= mb_strlen($keyword, 'UTF-8')) { $keywords[] = array('search' => $keyword, 'clang' => $langID); } } $articleData['teaser'] = $insert->escape($this->getTeaserText($plaintext)); $insert->setTable($this->tablePrefix . '587_searchindex'); $insert->setValues($articleData); $insert->insert(); $this->endFrontendMode(); $return[$langID] = A587_ART_GENERATED; } } $this->storeKeywords($keywords, false); return $return; }
function _setActivePath() { global $REX; $article_id = $REX["ARTICLE_ID"]; if ($OOArt = OOArticle::getArticleById($article_id)) { $path = trim($OOArt->getValue("path"), '|'); $this->path = array(); if ($path != "") { $this->path = explode("|", $path); } $this->current_article_id = $article_id; $this->current_category_id = $OOArt->getCategoryId(); return TRUE; } return FALSE; }
function getCategoryById($category_id, $clang = false) { return OOArticle::getArticleById($category_id, $clang, true); }
public static function extension_sitemap_seo42($sitemap) { global $REX; $myself = 'url_control'; $addon = $REX['ADDON'][$myself]['addon']; $rewriter = $REX['ADDON'][$myself]['rewriter']; $query = ' SELECT `article_id`, `clang`, `table`, `table_parameters` FROM ' . $REX['TABLE_PREFIX'] . 'url_control_generate '; $sql = rex_sql::factory(); $sql->setQuery($query); $paths = array(); if ($sql->getRows() >= 1) { $results = $sql->getArray(); foreach ($results as $result) { $article_id = $result['article_id']; $clang = $result['clang']; $a = OOArticle::getArticleById($article_id, $clang); if ($a instanceof OOArticle) { if (isset($rewriter[$addon]['get_url'])) { $func = $rewriter[$addon]['get_url']; $path = call_user_func($func, $article_id, $clang); } else { $path = $a->getUrl(); } $table = $result['table']; $table_params = unserialize($result['table_parameters']); if (isset($table_params[$table][$table . '_sitemap_settings'])) { $sitemapSetting = $table_params[$table][$table . '_sitemap_settings']; } else { $sitemapSetting = 'Artikel ohne dynamische Seiten'; } switch ($sitemapSetting) { case 'Artikel ohne dynamische Seiten': break; case 'Artikel mit dynamische Seiten': $sitemapNode = $sitemap['subject'][$a->getId()][0]; $tableUrls = url_generate::getUrlsByTable($table); foreach ($tableUrls as $tableUrl) { $sitemapNode['loc'] = $tableUrl; $sitemap['subject'][][] = $sitemapNode; } break; case 'Nur dynamische Seiten': $sitemapNode = $sitemap['subject'][$a->getId()][0]; unset($sitemap['subject'][$a->getId()]); $tableUrls = url_generate::getUrlsByTable($table); foreach ($tableUrls as $tableUrl) { $sitemapNode['loc'] = $tableUrl; $sitemap['subject'][][] = $sitemapNode; } break; } } } } return $sitemap['subject']; }
/** * Execute the search for the given SearchCommand * * @param SearchCommand $search * @return SearchResult */ public function fire(SearchCommand $search) { global $REX; $search_result = new SearchResult(); $searchResults = array(); $command_parts = $search->getCommandParts(); // Artikelnamen in der Struktur durchsuchen // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $fields = array('a.name'); $where = $search->getSqlWhere($fields); if (count($command_parts) == 1 && (int) $command_parts[0] >= 1) { $where = 'a.id = "' . (int) $command_parts[0] . '"'; } $sql_query = ' SELECT a.id, a.clang, CONCAT(a.id, "|", a.clang) as bulldog FROM ' . Watson::getTable('article') . ' AS a WHERE ' . $where . ' GROUP BY bulldog '; $results = $this->getDatabaseResults($sql_query); if (count($results)) { foreach ($results as $result) { $searchResults[$result['bulldog']] = $result; } } // Slices der Artikel durchsuchen // Werden Slices gefunden, dann die Strukturartikel überschreiben // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $fields = array('s.value' => range('1', '20'), 's.file' => range('1', '10'), 's.filelist' => range('1', '10')); $searchFields = array(); foreach ($fields as $field => $numbers) { foreach ($numbers as $number) { $searchFields[] = $field . $number; } } $fields = $searchFields; $sql_query = ' SELECT s.article_id AS id, s.clang, s.ctype, CONCAT(s.article_id, "|", s.clang) as bulldog FROM ' . Watson::getTable('article_slice') . ' AS s LEFT JOIN ' . Watson::getTable('article') . ' AS a ON (s.article_id = a.id AND s.clang = a.clang) WHERE ' . $search->getSqlWhere($fields) . ' GROUP BY bulldog'; $results = $this->getDatabaseResults($sql_query); if (count($results)) { foreach ($results as $result) { $searchResults[$result['bulldog']] = $result; } } // Ergebnisse auf Rechte prüfen und bereitstellen // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (count($searchResults)) { foreach ($searchResults as $result) { $clang = $result['clang']; $article = \OOArticle::getArticleById($result['id'], $clang); $category_id = $article->getCategoryId(); // Rechte prüfen if (in_array($clang, $REX['USER']->getClangPerm()) && $REX['USER']->hasCategoryPerm($category_id)) { $path = array(); $tree = $article->getParentTree(); foreach ($tree as $o) { $path[] = $o->getName(); } if (!$article->isStartArticle()) { $path[] = $article->getName(); } $path = '/' . implode('/', $path); $url = Watson::getUrl(array('page' => 'structure', 'category_id' => $article->getCategoryId(), 'clang' => $clang)); if (isset($result['ctype'])) { $url = Watson::getUrl(array('page' => 'content', 'article_id' => $article->getId(), 'mode' => 'edit', 'clang' => $clang, 'ctype' => $result['ctype'])); } $suffix = array(); if ($REX['USER']->hasPerm('advancedMode[]')) { $suffix[] = $article->getId(); } if (count($REX['CLANG']) > 1) { $suffix[] = $REX['CLANG'][$clang]; } $suffix = implode(', ', $suffix); $suffix = $suffix != '' ? '(' . $suffix . ')' : ''; $entry = new SearchResultEntry(); $entry->setValue($article->getName(), $suffix); $entry->setDescription($path); $entry->setIcon('icon_article.png'); $entry->setUrl($url); $entry->setQuickLookUrl('../index.php?article_id=' . $article->getId() . '&clang=' . $clang); $search_result->addEntry($entry); } } } return $search_result; }
function getArticlesOfCategory($a_category_id, $ignore_offlines = false, $clang = false) { global $REX; if ($clang === false) { $clang = $GLOBALS[REX][CUR_CLANG]; } $articlelist = $REX[HTDOCS_PATH] . "redaxo/include/generated/articles/" . $a_category_id . "." . $clang . ".alist"; if (file_exists($articlelist)) { include $articlelist; if (is_array($REX[RE_ID][$a_category_id])) { foreach ($REX[RE_ID][$a_category_id] as $var) { $article = OOArticle::getArticleById($var, $clang); if ($ignore_offlines) { if ($article->isOnline()) { $artlist[] = $article; } } else { $artlist[] = $article; } } return $artlist; } else { return null; } } else { return null; } }
/** * Erzeugt die Domains * */ public static function generatePathFile($params) { global $REX; $myself = 'url_control'; $addon = $REX['ADDON'][$myself]['addon']; $rewriter = $REX['ADDON'][$myself]['rewriter']; $query = ' SELECT `article_id`, `clang`, `table`, `table_parameters` FROM ' . $REX['TABLE_PREFIX'] . 'url_control_generate '; $sql = rex_sql::factory(); $sql->setQuery($query); $paths = array(); if ($sql->getRows() >= 1) { $results = $sql->getArray(); foreach ($results as $result) { $article_id = $result['article_id']; $clang = $result['clang']; $a = OOArticle::getArticleById($article_id, $clang); if ($a instanceof OOArticle) { if (isset($rewriter[$addon]['get_url'])) { $func = $rewriter[$addon]['get_url']; $path = call_user_func($func, $article_id, $clang); } else { $path = $a->getUrl(); } $path = parent::getCleanPath($path); $table = $result['table']; $table_params = unserialize($result['table_parameters']); $name = $table_params[$table][$table . '_name']; $name_2 = $table_params[$table][$table . '_name_2']; $id = $table_params[$table][$table . '_id']; $restriction_field = $table_params[$table][$table . '_restriction_field']; $restriction_operator = $table_params[$table][$table . '_restriction_operator']; $restriction_value = $table_params[$table][$table . '_restriction_value']; $qyery_where = ''; if ($restriction_field != '' && $restriction_value != '' && in_array($restriction_operator, self::getRestrictionOperators())) { switch ($restriction_operator) { case 'IN (...)': case 'NOT IN (...)': $restriction_operator = str_replace(' (...)', '', $restriction_operator); $values = explode(',', $restriction_value); foreach ($values as $key => $value) { if (!(int) $value > 0) { unset($values[$key]); } } $restriction_value = ' (' . implode(',', $values) . ') '; break; case 'BETWEEN': case 'NOT BETWEEN': $values = explode(',', $restriction_value); if (count($values) == 2) { $restriction_value = $values[0] . ' AND ' . $values[1]; } break; default: $restriction_value = '"' . mysql_real_escape_string($restriction_value) . '"'; break; } $qyery_where = ' WHERE ' . $restriction_field . ' ' . $restriction_operator . ' ' . $restriction_value . ''; } $query_select = $name_2 != '' ? ', ' . $name_2 . ' AS name_2' : ''; $query = ' SELECT ' . $name . ' AS name, ' . $id . ' AS id ' . $query_select . ' FROM ' . $table . ' ' . $qyery_where . ' '; $s = rex_sql::factory(); $s->setQuery($query); if ($s->getRows() >= 1) { $urls = $s->getArray(); $save_names = array(); foreach ($urls as $url) { if (isset($url['name_2']) && $url['name_2'] != '') { $url['name'] = $url['name'] . ' ' . $url['name_2']; } if (isset($save_names[$url['name']])) { $url['name'] = $url['name'] . '-' . $url['id']; } $paths[$table][$article_id][$clang][$url['id']] = $path . strtolower(rex_parse_article_name($url['name'])) . '.html'; $save_names[$url['name']] = ''; } } } } } rex_put_file_contents(self::$path_file, json_encode($paths)); }
if ($article->getRows() == 1) { // ----- ctype holen $template_attributes = $article->getValue('template_attributes'); // Für Artikel ohne Template if ($template_attributes === null) { $template_attributes = ''; } $REX['CTYPE'] = rex_getAttributes('ctype', $template_attributes, array()); // ctypes - aus dem template $ctype = rex_request('ctype', 'rex-ctype-id', 1); if (!array_key_exists($ctype, $REX['CTYPE'])) { $ctype = 1; } // default = 1 // ----- Artikel wurde gefunden - Kategorie holen $OOArt = OOArticle::getArticleById($article_id, $clang); $category_id = $OOArt->getCategoryId(); // ----- category pfad und rechte require $REX['INCLUDE_PATH'] . '/functions/function_rex_category.inc.php'; // $KATout kommt aus dem include // $KATPERM if ($REX['PAGE'] == 'content' && $article_id > 0) { $KATout .= "\n" . '<p>'; if ($article->getValue('startpage') == 1) { $KATout .= $I18N->msg('start_article') . ' : '; } else { $KATout .= $I18N->msg('article') . ' : '; } $catname = str_replace(' ', ' ', htmlspecialchars($article->getValue('name'))); $KATout .= '<a href="index.php?page=content&article_id=' . $article_id . '&mode=edit&clang=' . $clang . '"' . rex_tabindex() . '>' . $catname . '</a>'; // $KATout .= " [$article_id]";
/** * Erweitert das Meta-Formular um die neuen Meta-Felder * * @param string $prefix Feldprefix * @param string $params EP Params * @param callback $saveCallback Callback, dass die Daten speichert */ function _rex_a62_metainfo_form($prefix, $params, $saveCallback) { // Beim ADD gibts noch kein activeItem $activeItem = null; if (isset($params['activeItem'])) { $activeItem = $params['activeItem']; } $restrictionsCondition = ''; if ($prefix == 'art_') { if ($params['id'] != '') { $s = ''; $OOArt = OOArticle::getArticleById($params['id'], $params['clang']); // Alle Metafelder des Pfades sind erlaubt foreach (explode('|', $OOArt->getPath()) as $pathElement) { if ($pathElement != '') { $s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"'; } } $restrictionsCondition = 'AND (`p`.`restrictions` = ""' . $s . ')'; } } elseif ($prefix == 'cat_') { $s = ''; if ($params['id'] != '') { $OOCat = OOCategory::getCategoryById($params['id'], $params['clang']); // Alle Metafelder des Pfades sind erlaubt foreach (explode('|', $OOCat->getPath()) as $pathElement) { if ($pathElement != '') { $s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"'; } } // Auch die Kategorie selbst kann Metafelder haben $s .= ' OR `p`.`restrictions` LIKE "%|' . $params['id'] . '|%"'; } $restrictionsCondition = 'AND (`p`.`restrictions` = ""' . $s . ')'; } elseif ($prefix == 'med_') { $catId = rex_session('media[rex_file_category]', 'int'); if ($activeItem) { $catId = $activeItem->getValue('category_id'); } if ($catId !== '') { $s = ''; if ($catId != 0) { $OOCat = OOMediaCategory::getCategoryById($catId); // Alle Metafelder des Pfades sind erlaubt foreach (explode('|', $OOCat->getPath()) as $pathElement) { if ($pathElement != '') { $s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"'; } } } // Auch die Kategorie selbst kann Metafelder haben $s .= ' OR `p`.`restrictions` LIKE "%|' . $catId . '|%"'; $restrictionsCondition = 'AND (`p`.`restrictions` = ""' . $s . ')'; } } $sqlFields = _rex_a62_metainfo_sqlfields($prefix, $restrictionsCondition); $params = rex_call_func($saveCallback, array($params, $sqlFields), false); return rex_a62_metaFields($sqlFields, $activeItem, 'rex_a62_metainfo_form_item', $params); }
} else { $warning = $action->getErrro(); } } // ---------------------------- FUNKTIONEN FÜR MODULE if ($function == 'delete') { $del = rex_sql::factory(); $del->setQuery("SELECT " . $REX['TABLE_PREFIX'] . "article_slice.article_id, " . $REX['TABLE_PREFIX'] . "article_slice.clang, " . $REX['TABLE_PREFIX'] . "article_slice.ctype, " . $REX['TABLE_PREFIX'] . "module.name FROM " . $REX['TABLE_PREFIX'] . "article_slice\r\n LEFT JOIN " . $REX['TABLE_PREFIX'] . "module ON " . $REX['TABLE_PREFIX'] . "article_slice.modultyp_id=" . $REX['TABLE_PREFIX'] . "module.id\r\n WHERE " . $REX['TABLE_PREFIX'] . "article_slice.modultyp_id='{$modul_id}' GROUP BY " . $REX['TABLE_PREFIX'] . "article_slice.article_id"); if ($del->getRows() > 0) { $module_in_use_message = ''; $modulname = htmlspecialchars($del->getValue($REX['TABLE_PREFIX'] . "module.name")); for ($i = 0; $i < $del->getRows(); $i++) { $aid = $del->getValue($REX['TABLE_PREFIX'] . "article_slice.article_id"); $clang_id = $del->getValue($REX['TABLE_PREFIX'] . "article_slice.clang"); $ctype = $del->getValue($REX['TABLE_PREFIX'] . "article_slice.ctype"); $OOArt = OOArticle::getArticleById($aid, $clang_id); $label = $OOArt->getName() . ' [' . $aid . ']'; if (count($REX['CLANG']) > 1) { $label = '(' . rex_translate($REX['CLANG'][$clang_id]) . ') ' . $label; } $module_in_use_message .= '<li><a href="index.php?page=content&article_id=' . $aid . '&clang=' . $clang_id . '&ctype=' . $ctype . '">' . htmlspecialchars($label) . '</a></li>'; $del->next(); } if ($module_in_use_message != '') { $warning_block = '<ul>' . $module_in_use_message . '</ul>'; } $warning = $I18N->msg("module_cannot_be_deleted", $modulname); } else { $del->setQuery("DELETE FROM " . $REX['TABLE_PREFIX'] . "module WHERE id='{$modul_id}'"); $del->setQuery("DELETE FROM " . $REX['TABLE_PREFIX'] . "module_action WHERE module_id='{$modul_id}'"); $info = $I18N->msg("module_deleted");
} else { // echo "nichts"; $rex_com_auth_info = 0; // 0 - nichts / 1 - logout / 2 - failed login / 3 - logged in unset($REX['COM_USER']); } $rex_com_auth_jump = rex_request('rex_com_auth_jump', 'string'); if (isset($jump_aid) && ($article = OOArticle::getArticleById($jump_aid)) || $rex_com_auth_use_jump_url && $rex_com_auth_jump != "") { ob_end_clean(); $url_params['rex_com_auth_info'] = $rex_com_auth_info; if ($rex_com_auth_use_jump_url && $rex_com_auth_jump != "") { header('Location: http://' . $REX["SERVER"] . '/' . rex_com_auth_urldecode($rex_com_auth_jump)); } else { if ($rex_com_auth_jump != "") { $url_params[$REX['ADDON']['community']['plugin_auth']['request']['jump']] = $rex_com_auth_jump; } header('Location:' . rex_getUrl($jump_aid, '', $url_params, '&')); } exit; } // ---------- page_permissions if ($article = OOArticle::getArticleById($REX["ARTICLE_ID"])) { if (!rex_com_checkperm($article)) { ob_end_clean(); header('Location:' . rex_getUrl($REX['ADDON']['community']['plugin_auth']['article_withoutperm'], '', $url_params, '&')); exit; } } else { // Wenn Article nicht vorhanden - nichts machen -> wird dann von der index.php geregelt sodass eine fehlerseite auftaucht // $jump_aid = $REX['ADDON']['community']['plugin_auth']['article_withoutperm']; }