/** * Gibt die URL der Terminkategorie zurück. * @global mixed[] $REX Redaxo Variable * @var boolean $path_only Gibt an, ob die URL mit Domain oder ohne erstellt * werden soll. * @return String URL für das Objekt */ function getURL($path_only = FALSE) { if ($this->url == "") { global $REX; $pathname = ''; if (OOAddon::isActivated('seo42')) { // Mit SEO42 require_once dirname(__FILE__) . "/../../seo42/classes/class.seo42_rewrite.inc.php"; // Dann Redaxo Artikelfolge if ($REX['ADDON']['d2u_kurse']['settings']['kurse_artikel'] > 0 && $REX['ADDON']['d2u_kurse']['settings']['kurse_artikel'] != $REX['START_ARTICLE_ID']) { $kategorie = OOCategory::getCategoryById($REX['ADDON']['d2u_kurse']['settings']['kurse_artikel'], $REX['CUR_CLANG']); $hauptkategorien = $kategorie->getPathAsArray(); for ($i = 0; $i < count($hauptkategorien); $i++) { $hauptkategorie = OOCategory::getCategoryById($hauptkategorien[$i], $REX['CUR_CLANG']); if ($hauptkategorie instanceof OOCategory) { $pathname = seo42_appendToPath($pathname, $hauptkategorie->getName(), $hauptkategorie->getId(), $REX['CUR_CLANG']); } } if ($kategorie->getName() != "") { $pathname = seo42_appendToPath($pathname, $kategorie->getName(), $kategorie->getId(), $REX['CUR_CLANG']); } else { // Wenn angegebener Artikel keine Kategorie ist, sondern nur Artikelname hat $pathname = seo42_appendToPath($pathname, $kategorie->getValue("name"), $kategorie->getId(), $REX['CUR_CLANG']); } } // Art der Startkachel $pathname = seo42_appendToPath($pathname, $REX['ADDON']['d2u_kurse']['settings']['termin_titel'], $REX['ADDON']['d2u_kurse']['settings']['kurse_artikel'], $REX['CUR_CLANG']); // Die Elternkategorie if ($this->eltern_terminkategorie !== FALSE) { $pathname = seo42_appendToPath($pathname, $this->eltern_terminkategorie->name, $REX['ADDON']['d2u_kurse']['settings']['kurse_artikel'], $REX['CUR_CLANG']); } // Die Terminkategorie $pathname = seo42_appendToPath($pathname, $this->name, $REX['ADDON']['d2u_kurse']['settings']['kurse_artikel'], $REX['CUR_CLANG']); $pathname = substr($pathname, 0, -1) . $REX['ADDON']['seo42']['settings']['url_ending']; } else { // Ohne SEO42 $parameterArray = array(); $parameterArray['terminkategorie_id'] = $this->terminkategorie_id; $pathname = rex_getUrl($REX['ADDON']['d2u_kurse']['settings']['kurse_artikel'], $REX['CUR_CLANG'], $parameterArray, "&"); } $this->url = $pathname; } if ($path_only) { return $this->url; } else { return $REX['SERVER'] . $this->url; } }
/** * seo42_generate_pathlist() * * generiert die Pathlist, abhängig von Aktion * @author markus.staab[at]redaxo[dot]de Markus Staab * @package redaxo4.2 */ function seo42_generate_pathlist($params) { global $REX, $SEO42_IDS, $SEO42_URLS; // temporary community install workaround if (!isset($REX['ADDON']['seo42'])) { return; } // include pathlist file if (file_exists(SEO42_PATHLIST)) { require_once SEO42_PATHLIST; } // EXTENSION POINT "SEO42_PATHLIST_BEFORE_REBUILD" $subject = array('SEO42_IDS' => $SEO42_IDS, 'SEO42_URLS' => $SEO42_URLS); rex_register_extension_point('SEO42_PATHLIST_BEFORE_REBUILD', $subject); $SEO42_IDS = array(); $SEO42_URLS = array(); $REX['SEO42_URL_CLONE'] = array(); $db = new rex_sql(); // REVISION FIX $db->setQuery('UPDATE ' . $REX['TABLE_PREFIX'] . 'article SET revision = 0 WHERE revision IS NULL;'); $db->setQuery('UPDATE ' . $REX['TABLE_PREFIX'] . 'article_slice SET revision = 0 WHERE revision IS NULL;'); if ($REX['ADDON']['seo42']['settings']['ignore_root_cats']) { $sqlQuery = 'SELECT `id`, `clang`, `path`, `startpage`,`seo_custom_url` FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE re_id != 0 OR (re_id = 0 AND catname LIKE "") AND revision=0 OR revision IS NULL ORDER BY id'; } else { $sqlQuery = 'SELECT `id`, `clang`, `path`, `startpage`,`seo_custom_url` FROM ' . $REX['TABLE_PREFIX'] . 'article WHERE revision=0 OR revision IS NULL ORDER BY id'; } $db->setQuery($sqlQuery); // redirects start articles withou slash: /xx to /xx/ if (count($REX['CLANG']) > 1) { foreach ($REX['CLANG'] as $clangId => $clangName) { if ($REX['ADDON']['seo42']['settings']['url_ending'] == '') { $langSlug = seo42::getLangUrlSlug($clangId) . '/'; } else { $langSlug = seo42::getLangUrlSlug($clangId); } if ($REX['ADDON']['seo42']['settings']['homelang'] != $clangId) { $SEO42_URLS[$langSlug] = array('id' => $REX['START_ARTICLE_ID'], 'clang' => $clangId, 'status' => 301); } } } while ($db->hasNext()) { $pathname = ''; $id = $db->getValue('id'); $clang = $db->getValue('clang'); $path = $db->getValue('path'); // LANG SLUG if (count($REX['CLANG']) > 1 && $clang != $REX['ADDON']['seo42']['settings']['hide_langslug']) { $pathname = ''; $pathname = seo42_appendToPath($pathname, seo42::getLangUrlSlug($clang), $id, $clang); } // pfad über kategorien bauen $path = trim($path, '|'); if ($path != '') { $path = explode('|', $path); foreach ($path as $p) { $ooc = OOCategory::getCategoryById($p, seo42_utils::getInheritedClang($clang)); // PREVENT FATALS IN RARE CONDITIONS WHERE DB/CACHE ARE OUT OF SYNC if (!is_a($ooc, 'OOCategory')) { continue; } // 42 if ($REX['ADDON']['seo42']['settings']['ignore_root_cats'] && $ooc->getParentId() == 0) { continue; } $name = $ooc->getName(); unset($ooc); $pathname = seo42_appendToPath($pathname, $name, $id, $clang); } } $ooa = OOArticle::getArticleById($id, seo42_utils::getInheritedClang($clang)); // PREVENT FATALS IN RARE CONDITIONS WHERE DB/CACHE ARE OUT OF SYNC if (!is_a($ooa, 'OOArticle')) { $db->next(); continue; } if ($ooa->isStartArticle()) { $ooc = $ooa->getCategory(); $catname = $ooc->getName(); unset($ooc); $pathname = seo42_appendToPath($pathname, $catname, $id, $clang); } // url_schema: seo42 if (!$ooa->isStartArticle()) { // eigentlicher artikel anhängen $name = $ooa->getName(); unset($ooa); $pathname = seo42_appendToPath($pathname, $name, $id, $clang); } // ALLGEMEINE URL ENDUNG $pathname = substr($pathname, 0, strlen($pathname) - 1) . $REX['ADDON']['seo42']['settings']['url_ending']; // STARTSEITEN URL FORMAT if ($db->getValue('id') == $REX['START_ARTICLE_ID'] && $db->getValue('clang') == $REX['ADDON']['seo42']['settings']['homelang'] && ($REX['ADDON']['seo42']['settings']['homeurl'] == 1 || $REX['ADDON']['seo42']['settings']['homeurl'] == 2)) { $pathname = ''; } elseif ($REX['ADDON']['seo42']['settings']['homeurl'] == 2 && $db->getValue('id') == $REX['START_ARTICLE_ID'] && count($REX['CLANG']) > 1) { if ($REX['ADDON']['seo42']['settings']['url_ending'] == '') { $langSlug = seo42::getLangUrlSlug($clang); } else { $langSlug = seo42::getLangUrlSlug($clang) . '/'; } $pathname = $langSlug; } // UNSET OLD URL FROM $SEO42_URLS if (isset($SEO42_IDS[$id][$clang]['url']) && isset($SEO42_URLS[$SEO42_IDS[$id][$clang]['url']])) { unset($SEO42_URLS[$SEO42_IDS[$id][$clang]['url']]); } $SEO42_IDS[$id][$clang] = array('url' => $pathname); $SEO42_URLS[$pathname] = array('id' => (int) $id, 'clang' => (int) $clang); // get data from default lang if clone option is enabled for all other langs $jsonData = json_decode($db->getValue('seo_custom_url'), true); $articleId = $db->getValue('id'); $clangId = $db->getValue('clang'); if (isset($jsonData['url_clone']) && $jsonData['url_clone'] == true && $clangId == $REX['START_CLANG_ID']) { $REX['SEO42_URL_CLONE'][$articleId] = $jsonData; } $db->next(); } // URL MANIPULATION BY SEO42 // ----------------------------------------------------------------------------------------------------------- $interReplaceIds = array(); $db->reset(); for ($i = 0; $i < $db->getRows(); $i++) { $urlField = $db->getValue('seo_custom_url'); $articleId = $db->getValue('id'); $clangId = $db->getValue('clang'); if ($urlField != '' || isset($REX['SEO42_URL_CLONE'][$articleId])) { $urlData = seo42_utils::getUrlTypeData($urlField); $jsonData = json_decode($urlData, true); if (isset($REX['SEO42_URL_CLONE'][$articleId]) && !isset($jsonData['url_type'])) { $jsonData = $REX['SEO42_URL_CLONE'][$articleId]; } switch ($jsonData['url_type']) { case SEO42_URL_TYPE_DEFAULT: // do nothing break; case SEO42_URL_TYPE_USERDEF_INTERN: $customUrl = $jsonData['custom_url']; if ($SEO42_IDS[$articleId][$clangId]['url'] != $customUrl) { // only if custom url ist different then auto url $SEO42_URLS[$customUrl] = $SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]; unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]); } $SEO42_IDS[$articleId][$clangId] = array('url' => $customUrl); break; case SEO42_URL_TYPE_USERDEF_EXTERN: $customUrl = $jsonData['custom_url']; unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]); $SEO42_IDS[$articleId][$clangId] = array('url' => $customUrl); break; case SEO42_URL_TYPE_MEDIAPOOL: $customUrl = $REX['MEDIA_DIR'] . '/' . $jsonData['file']; unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]); $SEO42_IDS[$articleId][$clangId] = array('url' => $customUrl); break; case SEO42_URL_TYPE_INTERN_REPLACE: $customArticleId = $jsonData['article_id']; $interReplaceIds[$clangId][$articleId] = array('id' => $customArticleId, 'clang' => $clangId); unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]); if (isset($SEO42_IDS[$customArticleId][$clangId]['url'])) { $SEO42_IDS[$articleId][$clangId] = array('url' => $SEO42_IDS[$customArticleId][$clangId]['url']); } else { $SEO42_IDS[$articleId][$clangId] = array('url' => ''); } break; case SEO42_URL_TYPE_INTERN_REPLACE_CLANG: $customArticleId = $jsonData['article_id']; $customClangId = $jsonData['clang_id']; $interReplaceIds[$clangId][$articleId] = array('id' => $customArticleId, 'clang' => $customClangId); unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]); if (isset($SEO42_IDS[$customArticleId][$customClangId]['url'])) { $SEO42_IDS[$articleId][$clangId] = array('url' => $SEO42_IDS[$customArticleId][$customClangId]['url']); } else { $SEO42_IDS[$articleId][$clangId] = array('url' => ''); } break; case SEO42_URL_TYPE_REMOVE_ROOT_CAT: $curUrl = $SEO42_IDS[$articleId][$clangId]['url']; $newUrl = seo42_utils::removeRootCatFromUrl($curUrl, $clangId); if ($newUrl != '') { // same as SEO42_URL_TYPE_USERDEF_INTERN $SEO42_URLS[$newUrl] = $SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]; unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]); $SEO42_IDS[$articleId][$clangId] = array('url' => $newUrl); } break; case SEO42_URL_TYPE_CALL_FUNC: if ($jsonData['no_url']) { unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]); } break; case SEO42_URL_TYPE_LANGSWITCH: unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]); break; case SEO42_URL_TYPE_NONE: unset($SEO42_URLS[$SEO42_IDS[$articleId][$clangId]['url']]); $SEO42_IDS[$articleId][$clangId] = array('url' => ''); break; } unset($jsonData); } $db->next(); } // workaround for #177 foreach ($interReplaceIds as $clangId => $value) { foreach ($value as $interReplaceId => $targetArticle) { if (isset($SEO42_IDS[$targetArticle['id']][$targetArticle['clang']]['url'])) { $SEO42_IDS[$interReplaceId][$clangId] = array('url' => $SEO42_IDS[$targetArticle['id']][$targetArticle['clang']]['url']); } } } // ----------------------------------------------------------------------------------------------------------- // EXTENSION POINT "SEO42_PATHLIST_CREATED" $subject = array('SEO42_IDS' => $SEO42_IDS, 'SEO42_URLS' => $SEO42_URLS); $subject = rex_register_extension_point('SEO42_PATHLIST_CREATED', $subject); // EXTENSION POINT "SEO42_PATHLIST_FINAL" - READ ONLY rex_register_extension_point('SEO42_PATHLIST_FINAL', $subject); // ASSEMBLE, COMPRESS & WRITE PATHLIST TO FILE $pathlist_content = '$SEO42_IDS = ' . var_export($subject['SEO42_IDS'], true) . ';' . PHP_EOL . '$SEO42_URLS = ' . var_export($subject['SEO42_URLS'], true) . ';'; $pathlist_content = seo42_compressPathlist($pathlist_content); rex_put_file_contents(SEO42_PATHLIST, '<?php' . PHP_EOL . $pathlist_content); // PURGE *.CONTENT CACHEFILES TO UPDATE INTERNAL LINKS CREATED BY replceLinks() in rex_article_base seo42_purgeCacheFiles(); }
function d2u_stellenmarkt_extended_sitemap($_params) { global $REX; // Hier werden Pfade zwischengespeichert um Performance zu gewinnen $artikel_pathnames = array(); $query_kategorie = "SELECT lang.stellen_id, clang_id, artikel_id, interne_nummer, interne_bezeichnung, datum " . "FROM " . $REX['TABLE_PREFIX'] . "d2u_stellenmarkt_stellen_lang AS lang " . "LEFT JOIN " . $REX['TABLE_PREFIX'] . "d2u_stellenmarkt_stellen AS kategorie " . "ON lang.stellen_id = kategorie.stellen_id " . "WHERE status = 'online' " . "ORDER BY lang.stellen_id, clang_id"; $sql_kategorie = new rex_sql(); $sql_kategorie->setQuery($query_kategorie); $rows_kategorie = $sql_kategorie->getRows(); // Hier werden Pfade der Kategorien gespeichert for ($i = 0; $i < $rows_kategorie; $i++, $sql_kategorie->next()) { $artikel_id = $sql_kategorie->getValue("artikel_id"); $clang_id = $sql_kategorie->getValue("clang_id"); $stellen_id = $sql_kategorie->getValue("stellen_id"); $stellen_interne_bezeichnung = $sql_kategorie->getValue("interne_bezeichnung"); $stellen_interne_nummer = $sql_kategorie->getValue("interne_nummer"); $date_array = explode("-", $sql_kategorie->getValue("datum")); $change_date = mktime(0, 0, 0, $date_array[1], $date_array[2], $date_array[0]); $pathname = ''; // Pfadnamen fuer Artikel if ($artikel_id > 0) { // Pfad wurde schon generiert if (array_key_exists($artikel_id, $artikel_pathnames) && array_key_exists($clang_id, $artikel_pathnames[$artikel_id])) { $pathname = $artikel_pathnames[$artikel_id][$clang_id]; } else { // Sprachkuerzel if (count($REX['CLANG']) > 1 && $clang_id != $REX['ADDON']['seo42']['settings']['hide_langslug']) { $pathname = seo42_appendToPath($pathname, $REX['ADDON']['seo42']['settings']['lang'][$clang_id]['code'], $REX['START_ARTICLE_ID'], $clang_id); } // Redaxo Artikel $artikel_kategorie = OOCategory::getCategoryById($artikel_id, $clang_id); if ($artikel_kategorie->isOnline() == false) { // Nur in Index aufnehmen, wenn online continue; } $artikel_hauptkategorien = $artikel_kategorie->getPathAsArray(); for ($j = 0; $j < count($artikel_hauptkategorien); $j++) { $artikel_hauptkategorie = OOCategory::getCategoryById($artikel_hauptkategorien[$j], $clang_id); if ($artikel_hauptkategorie instanceof OOCategory) { $pathname = seo42_appendToPath($pathname, $artikel_hauptkategorie->getName(), $artikel_hauptkategorie->getId(), $clang_id); } } $pathname = seo42_appendToPath($pathname, $artikel_kategorie->getName(), $artikel_kategorie->getId(), $clang_id); if (!is_array($artikel_pathnames[$artikel_id])) { $artikel_pathnames[$artikel_id] = array(); } $artikel_pathnames[$artikel_id][$clang_id] = $pathname; } } // Pfad fuer Kategorie $pathname = seo42_appendToPath($pathname, $stellen_interne_bezeichnung . "-" . $stellen_interne_nummer, $artikel_id, $clang_id); // Nur wenn fuer Kategorien ebenfalls URLs vorgesehen sind $add_array = array(); $add_array[$clang_id] = array('loc' => substr($pathname, 0, -1) . $REX['ADDON']['seo42']['settings']['url_ending'], 'lastmod' => date('c', $change_date), 'changefreq' => 'monthly', 'priority' => 0.6); $_params['subject'][] = $add_array; } return $_params['subject']; /* Allgemeiner Hinweis: In der config.inc.php muessen folgende Zeilen hinzugefuegt werden: -----%<----- require_once dirname(__FILE__) ."/extensions/seo42.inc.php"; rex_register_extension('SEO42_SITEMAP_ARRAY_CREATED', 'd2u_stellenmarkt_extended_sitemap'); -----%<----- */ }
/** * Gibt die URL dieses Stellenangebots zurück. * @param int clang_id SprachID aus Redaxo * @return string URL für dieses Stellenangebot. */ public function getURL($clang_id = -1) { if ($clang_id == -1) { $clang_id = $this->clang_id; } if ($this->url != "") { return $this->url; } else { global $REX; $url = $REX['SERVER']; $pathname = ''; if ($REX['MOD_REWRITE'] == true && OOAddon::isActivated('seo42')) { // Mit SEO42 require_once dirname(__FILE__) . "/../../seo42/classes/class.seo42_rewrite.inc.php"; if (count($REX['CLANG']) > 1 && $clang_id != $REX['ADDON']['seo42']['settings']['hide_langslug']) { // Sprachkuerzel $pathname = seo42_appendToPath($pathname, $REX['ADDON']['seo42']['settings']['lang'][$clang_id]['code'], $REX['START_ARTICLE_ID'], $clang_id); } // Dann Redaxo Artikelfolge if ($this->artikel_id > 0 && $clang_id > -1) { $kategorie = OOCategory::getCategoryById($this->artikel_id, $clang_id); $hauptkategorien = $kategorie->getPathAsArray(); for ($i = 0; $i < count($hauptkategorien); $i++) { $hauptkategorie = OOCategory::getCategoryById($hauptkategorien[$i], $clang_id); if ($hauptkategorie instanceof OOCategory) { $pathname = seo42_appendToPath($pathname, $hauptkategorie->getName(), $hauptkategorie->getId(), $clang_id); } } $pathname = seo42_appendToPath($pathname, $kategorie->getName(), $kategorie->getId(), $clang_id); } // Jetzt die Stelle $pathname = seo42_appendToPath($pathname, $this->interne_bezeichnung . "-" . $this->interne_nummer, $this->artikel_id, $clang_id); $pathname = substr($pathname, 0, -1) . $REX['ADDON']['seo42']['settings']['url_ending']; } else { // Ohne SEO42 $parameterArray = array(); $parameterArray['stellen_id'] = $this->stellen_id; $pathname = rex_getUrl($this->artikel_id, $clang_id, $parameterArray, "&"); } $url .= $pathname; return $url; } }