本文整理汇总了PHP中NewsModel::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP NewsModel::findAll方法的具体用法?PHP NewsModel::findAll怎么用?PHP NewsModel::findAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NewsModel
的用法示例。
在下文中一共展示了NewsModel::findAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAll
public function actionAll()
{
$article = new NewsModel();
$view = new View();
$view->items = $article->findAll();
$view->display('news/all.php');
}
示例2: actionAll
public function actionAll()
{
$news = NewsModel::findAll();
$view = new View();
$view->items = $news;
$view->display('news/all.php');
}
示例3: actionAll
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: actionDelNews
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: generateUrl
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: getIncludeItems
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: getRelatedNews
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;
}