Skip to content

Commit

Permalink
Update NewsManager.php
Browse files Browse the repository at this point in the history
to use with redaxo_url 2
  • Loading branch information
ansichtsache authored Jul 7, 2022
1 parent f722d8c commit 723254e
Showing 1 changed file with 29 additions and 32 deletions.
61 changes: 29 additions & 32 deletions lib/NewsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Newsmanager Class
*
* @author Georg Kaser
* @author Georg Kaser Upgrade to use with addon redaxo_url 2 by Claus Bammann/Tizian Bauer
*
*/
class NewsManager
Expand All @@ -19,25 +19,28 @@ public function __construct()
$this->category_id_parameter = rex_get('category', 'int');
$this->tpl = new Template(rex_path::addonData('newsmanager') . 'views/');

$urlData = UrlGenerator::getData();

if (($urlData) && ($urlData->urlParamKey == 'newsmanager')) {
$this->news_id_parameter = UrlGenerator::getId();
}
$manager = Url\Url::resolveCurrent();

if (($urlData) && ($urlData->urlParamKey == 'newsmanager_category')) {
$this->category_id_parameter = UrlGenerator::getId();
if($manager) {
if (($manager) && ( $manager->getProfile()->getNamespace() == 'newsmanager')) { // cb
$this->news_id_parameter = $manager->getDatasetId(); // cb
}
if (($manager) && ( $manager->getProfile()->getNamespace()== 'newsmanager_category')) { // cb
$this->category_id_parameter = $manager->getDatasetId(); // cb
}
}


}

public static function create() {

if (rex_addon::get('newsmanager')->getPlugin('comments')->isAvailable()) {
$instance = new NewsManagerWithComments();
} else {
$instance = new self();
}

return $instance;
}

Expand Down Expand Up @@ -94,13 +97,13 @@ private function initializeArticleObject($result, $lang_id)
{

$newsArticle = new NewsManagerArticle();

$newsArticle->setPid($result->getValue('pid'));
$newsArticle->setId($result->getValue('id'));
$newsArticle->setStatus($result->getValue('status'));
$newsArticle->setNewsmanager_category_id($result->getValue('newsmanager_category_id'));
$newsArticle->setTitle($result->getValue('title'));
$newsArticle->setSubtitle($result->getValue('subtitle'));
$newsArticle->setSubtitle($result->getValue('subtitle'));
$newsArticle->setRichtext($result->getValue('richtext'));
$newsArticle->setImages($result->getValue('images'));
$newsArticle->setSeo_title($result->getValue('seo_title'));
Expand Down Expand Up @@ -208,9 +211,9 @@ public function getArticleById($newsArticle_id)

return $newsArticle;
}





/**
* Generates a list view of the articles from a template (article-teaser-list-view.php)
*
Expand Down Expand Up @@ -238,10 +241,10 @@ public function printTeaserListView($singleViewArticleId, $limit = 0)

return '<ul>'.$TeaserlistView_output.'</ul>';
}




/**
* Generates the list view of the articles from a template (article-list-view.php)
*
Expand Down Expand Up @@ -294,23 +297,19 @@ public function printSingleView($newsArticle)
} else {
$image = '<div id="images">' . PHP_EOL;
foreach ($images as $key => $value) {
// $image .= '<div id="image-' . $key . '" class="image">' . PHP_EOL;
$image .= $newsArticle->makeImage($value);
// $image .= '</div>' . PHP_EOL;
}
$image .= '</div>' . PHP_EOL;
}
}
if (strpos($newsArticle->getRichtext(), '<hr>')) {
// $richtext_with_image = str_replace('<hr>', $image, $newsArticle->getRichtext());
$richtext = str_replace('<hr>', $image, $newsArticle->getRichtext());
} else {
// $richtext_with_image = $newsArticle->getRichtext() . $image; // Ausgabe von Text und Bild unabhängig
$richtext = $newsArticle->getRichtext();
$richtext = $newsArticle->getRichtext();
}

$richtext = $newsArticle->getRichtext();

$output .= $this->tpl->render($suggestions, array(
'title' => $newsArticle->getTitle(),
'subtitle' => $newsArticle->getSubtitle(),
Expand Down Expand Up @@ -353,9 +352,7 @@ public function printCategoryMenu()
if ($this->category_id_parameter == $result->getValue('id')) {
$current = 'class="rex-current "';
}

$category_menu .= '<li ' . $current . '><a href="' . rex_getUrl('', '', ['newsmanager_category' => $result->getValue('id')]) . '">' . $result->getValue('name') . '</a></li>' . PHP_EOL;

$category_menu .= '<li ' . $current . '><a href="' . rex_getUrl('', '', ['newsmanager_category' => $result->getValue('id')]) . '" class="btn btn-fill">' . $result->getValue('name') . '</a></li>' . PHP_EOL;
$result->next();
}

Expand Down Expand Up @@ -403,11 +400,11 @@ private function getPager($total, $limit)

return $pagemenu;
}

public static function getRssHeaderLink() {

return '<link rel="alternate" type="application/rss+xml" title="' . rex::getServerName() . ' RSS-Feed" href="' . rex::getServer() . 'rss-feed-' . rex_clang::getCurrent()->getCode() . '.xml" />';

}
/**
* Generates a RSS Feed file for all available online languages
Expand Down Expand Up @@ -453,7 +450,7 @@ private function generateRssFeed($lang)

$head_link = $xml->createElement('link', rex::getServer());
$channel->appendChild($head_link);

$articles = $this->getRSSArticleObjects($lang, 20);

foreach ($articles as $article) {
Expand Down

0 comments on commit 723254e

Please sign in to comment.