コード例 #1
0
ファイル: NewsController.php プロジェクト: TTcuXOgaJI/Test
 public function actionAll()
 {
     $article = new NewsModel();
     $view = new View();
     $view->items = $article->findAll();
     $view->display('news/all.php');
 }
コード例 #2
0
 public function actionAll()
 {
     $news = NewsModel::findAll();
     $view = new View();
     $view->items = $news;
     $view->display('news/all.php');
 }
コード例 #3
0
 public function actionAll()
 {
     $articles = NewsModel::findAll();
     if (!empty($articles)) {
         $view = new View();
         $view->articles = $articles;
         $view->display('news/all.php');
     } else {
         $e_message = 'Page not found: Пустой результат выборки по запросу';
         $e_code = 3;
         throw new E404Exception($e_message, $e_code);
     }
 }
コード例 #4
0
 public function actionDelNews()
 {
     $news = new NewsModel();
     $view = new View();
     if (isset($_GET['id'])) {
         $item = NewsModel::findOneByPk($_GET['id']);
         $view->item = $item;
         $view->deleted = true;
         //$news->delete();
     } else {
         $newsTitles = NewsModel::findAll();
         $view->news = $newsTitles;
     }
     $view->display('admin/delnews.php');
 }
コード例 #5
0
ファイル: GlossarNews.php プロジェクト: kbits/SWGlossar
 public function generateUrl($arrPages)
 {
     $arrPages = array();
     $News = \NewsModel::findAll();
     if (empty($News)) {
         return array();
     }
     $arrNews = array();
     while ($News->next()) {
         if (!empty($News)) {
             $arrNews[$News->pid][] = $this->generateNewsUrl($News);
         }
     }
     $InactiveArchives = \GlossarNewsArchiveModel::findByPidsAndInactiveGlossar(array_keys($arrNews));
     if (!empty($InactiveArchives)) {
         while ($InactiveArchives->next()) {
             unset($arrNews[$InactiveArchives->id]);
         }
     }
     if (empty($arrNews)) {
         return array();
     }
     $NewsReader = \ModuleModel::findByType('newsreader');
     if (empty($NewsReader)) {
         return array();
     }
     $arrReader = array();
     while ($NewsReader->next()) {
         $arrReader[$NewsReader->id] = deserialize($NewsReader->news_archives);
     }
     $Content = \ContentModel::findBy(array("module IN ('" . implode("','", array_keys($arrReader)) . "')"), array());
     if (empty($Content)) {
         return array();
     }
     $arrContent = array();
     while ($Content->next()) {
         $arrContent[$Content->module] = $Content->pid;
     }
     $Article = \ArticleModel::findBy(array("tl_article.id IN ('" . implode("','", $arrContent) . "')"), array());
     if (empty($Article)) {
         return array();
     }
     $finishedIDs = $arrPages = array();
     while ($Article->next()) {
         // $root = $this->getRootPage($Article->pid);
         $domain = \Environment::get('base');
         $strLanguage = 'de';
         $objPages = $Article->getRelated('pid');
         $ReaderId = false;
         foreach ($arrContent as $module => $mid) {
             if ($mid == $Article->id) {
                 $ReaderId = $module;
             }
         }
         foreach ($arrReader[$ReaderId] as $news_id) {
             if (in_array($news_id, $finishedIDs)) {
                 continue;
             }
             if (!empty($arrNews[$news_id])) {
                 foreach ($arrNews[$news_id] as $news_domain) {
                     $news_domain = str_replace('.html', '', $news_domain);
                     $arrPages['de'][] = $domain . static::generateFrontendUrl($objPages->row(), substr($news_domain, strpos($news_domain, '/')), $strLanguage);
                 }
             }
             $finishedIDs[] = $news_id;
         }
     }
     return $arrPages;
 }
コード例 #6
0
 public function getIncludeItems(\DataContainer $dc)
 {
     $arrReturn = array();
     $strTable = '';
     $strDateKey = '';
     $strTitleKeyArchive = '';
     $strTitleKeyItem = '';
     $strPatternArchiveUrl = '%s';
     $strPatternItemUrl = '%s';
     if (!$dc->activeRecord->type) {
         return $arrReturn;
     }
     switch ($dc->activeRecord->type) {
         case 'nl_news':
             $strTable = 'tl_news';
             $strDateKey = 'date';
             $strTitleKeyItem = 'headline';
             $strTitleKeyArchive = 'title';
             $strPatternArchiveUrl = 'contao/main.php?do=news&id=%s&act=edit&popup=1&nb=1&rt=%s';
             $strPatternItemUrl = 'contao/main.php?do=news&id=%s&act=edit&popup=1&nb=1&rt=%s&table=%s';
             $objItems = \NewsModel::findAll(array('order' => $strTable . '.' . $strDateKey));
             break;
         case 'nl_events':
             $strTable = 'tl_calendar_events';
             $strDateKey = 'startDate';
             $strTitleKeyItem = 'title';
             $strTitleKeyArchive = 'title';
             $strPatternArchiveUrl = 'contao/main.php?do=calendar&id=%s&act=edit&popup=1&nb=1&rt=%s';
             $strPatternItemUrl = 'contao/main.php?do=calendar&id=%s&act=edit&popup=1&nb=1&rt=%s&table=%s';
             $objItems = \CalendarEventsModel::findAll(array('order' => $strTable . '.' . $strDateKey));
             break;
         default:
             return $arrReturn;
             break;
     }
     if (!is_null($objItems)) {
         foreach ($objItems as $objItem) {
             $objArchive = $objItem->getRelated('pid');
             $strDoArchive = ampersand(sprintf($strPatternArchiveUrl, $objItem->pid, REQUEST_TOKEN));
             $strDoItem = ampersand(sprintf($strPatternItemUrl, $objItem->id, REQUEST_TOKEN, $strTable));
             $strDateField = \Date::parse(\Config::get('dateFormat') ?: 'd.m.Y', $objItem->{$strDateKey}) . ' - ';
             $time = time();
             //"($t.start='' OR $t.start<$time) AND ($t.stop='' OR $t.stop>$time) AND $t.published=1";
             $blnPublished = (!$objItem->start || $objItem->start < $time) && (!$objItem->stop || $objItem->stop > $time) && $objItem->published;
             $arrReturn[$objItem->id] = sprintf('%s<strong><a%s href="%s" title="%s" onclick="Backend.openModalIframe({\'width\':768,\'title\':\'%s\',\'url\':this.href});return false">%s</a></strong> (<a href="%s" title="%s" onclick="Backend.openModalIframe({\'width\':768,\'title\':\'%s\',\'url\':this.href});return false">%s</a>)', $strDateField, $blnPublished ? '' : ' style="color:#c33"', $strDoItem, sprintf(specialchars($GLOBALS['TL_LANG']['tl_content']['editalias'][1]), $objItem->id), sprintf(specialchars($GLOBALS['TL_LANG']['tl_content']['editalias'][1]), $objItem->id), $objItem->{$strTitleKeyItem}, $strDoArchive, sprintf(specialchars($GLOBALS['TL_LANG']['tl_content']['editalias'][1]), $objArchive->id), sprintf(specialchars($GLOBALS['TL_LANG']['tl_content']['editalias'][1]), $objArchive->id), $objArchive->{$strTitleKeyArchive});
         }
     }
     return $arrReturn;
 }
コード例 #7
0
 public static function getRelatedNews(\DataContainer $dc, array $arrRelation = array())
 {
     $arrOptionGroups = array();
     $arrOptions = array();
     // front end mode with module & relation context
     if (!empty($arrRelation)) {
         $objNews = \NewsModel::findPublishedByPids(deserialize($dc->objModule->news_archives, true), null, 0, 0, array('order' => 'headline'));
     } else {
         $objNews = \NewsModel::findAll();
     }
     if ($objNews === null) {
         return $arrOptions;
     }
     while ($objNews->next()) {
         // return as optgroup if more than 1 $arrPids
         if (($objArchive = $objNews->getRelated('pid')) === null) {
             continue;
         }
         $arrOptionGroups[$objArchive->title][$objNews->id] = $objNews->headline;
         $arrOptions[$objNews->id] = $objNews->headline;
     }
     $arrDca =& $GLOBALS['TL_DCA']['tl_submission'];
     // filter menu does not support optgroups
     if (TL_MODE == 'BE' && $dc->field != 'news') {
         return $arrOptions;
     }
     // remove optgroups if not wanted, or less than 2 optgroups
     if (count($arrOptionGroups) == 1 || $arrDca['fields'][$arrRelation['submissionField']]['eval']['optgroup'] === false) {
         return $arrOptions;
     }
     return $arrOptionGroups;
 }