public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName(array('Content', 'URLSegment'));
     $fields->addFieldsToTab('Root.Main', array(TextField::create('ShareLink', 'Link'), DropdownField::create('LinkTarget', 'Target')->setSource(array('_self' => 'Self', '_blank' => 'Open in a new window'))), 'Summary');
     return $fields;
 }
 public function RemoveNewsPostsFromSiteTree(DataList $list)
 {
     $pageTypes = NewsPost::GetNewsTypes();
     $updatedList = $list;
     foreach ($pageTypes as $strClassName) {
         $updatedList = $updatedList->exclude('ClassName', $strClassName);
     }
     return $updatedList;
 }
示例#3
0
 public function defaultAction()
 {
     $post = NewsPost::createById(@$_GET['id']);
     $tpl = 'news-view-post.tpl';
     $vars = ['post' => $post];
     if (isset($this->options['content_only']) && $this->options['content_only']) {
         View::renderTpl($tpl, $vars);
         return;
     }
     View::main($this->mainTpl, $tpl, $vars);
 }
示例#4
0
 public function defaultAction()
 {
     $posts = NewsPost::find([], '-date', [0, 10]);
     $tpl = 'news-recent.tpl';
     $vars = ['posts' => $posts];
     if (isset($this->options['content_only']) && $this->options['content_only']) {
         View::renderTpl($tpl, $vars);
         return;
     }
     View::main($this->mainTpl, $tpl, $vars);
 }
示例#5
0
文件: news.php 项目: bencochran/yeti
 public function actionNewest($window = 1)
 {
     $active_user = User::require_active_user();
     $this->setLayoutVar('active_user', $active_user);
     $this->setVar('active_user', $active_user);
     if (empty($window)) {
         $window = 1;
     }
     $posts = NewsPost::get_posts(1, $window);
     $this->setVar('posts', $posts['posts']);
     $this->setVar('count', $posts['count']);
 }
    public function BlogArchives()
    {
        if ($newsIndex = $this->NewsIndex()) {
            $alRet = new ArrayList();
            $strPattern = SiteConfig::current_site_config()->ArchivePattern ?: '%Y, %M';
            $iLimit = SiteConfig::current_site_config()->NumberOfArchives ?: PHP_INT_MAX;
            $strTable = Versioned::current_stage() == 'Stage' ? 'NewsPost' : 'NewsPost_Live';
            $results = DB::query('SELECT DATE_FORMAT(`DateTime`, \'' . $strPattern . '\') AS Date
				FROM ' . $strTable . '
				WHERE `DateTime` IS NOT NULL
				GROUP BY Date
				ORDER BY `DateTime` DESC
				LIMIT ' . $iLimit);
            while ($row = $results->nextRecord()) {
                $alRet->push(new ArrayData(array('Link' => $newsIndex->Link('archive/' . urlencode($row['Date'])), 'Archive' => $row['Date'], 'List' => NewsPost::get()->where('DATE_FORMAT(`DateTime`, \'' . $strPattern . '\') = \'' . $row['Date'] . '\''))));
            }
            return $alRet;
        }
    }
示例#7
0
 /**
  * @role update
  */
 public function edit()
 {
     $form = $this->buildForm();
     $form->loadData(NewsPost::getInstanceById($this->request->get('id'), NewsPost::LOAD_DATA)->toArray());
     return new ActionResponse('form', $form);
 }
    if (!$newsPost->save()) {
        $logger->LogError("Error saving news category.");
        foreach ($newsPost->errors as $error) {
            $logger->LogError($error);
            $errors[] = $error;
        }
    } else {
        $message = "Values were updated successfully!";
        $newsPost = NewsPost::fetchFromDb($newsPost->id);
    }
} else {
    if (isset($_REQUEST['id']) && is_numeric($_REQUEST['id'])) {
        $logger->LogInfo("Page was called for edit of id: " . $_REQUEST['id']);
        $id = intval($_REQUEST['id']);
        $logger->LogDebug("Numeric id is: {$id}");
        $newsPost = NewsPost::fetchFromDb($id);
        if ($newsPost == null) {
            $logger->LogError("Invalid request. No news category with id: {$id} exists.");
            $errors[] = "Invalid request. No news category with id: {$id} exists.";
        }
    }
}
$defaultLanguage = Language::fetchDefaultLangauge();
include "header.php";
?>

<script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
</td>
<tr>
  <td valign="top">
  <?php 
示例#9
0
            <div class="page">
                <div class="page_inside clear">
                    <div class="subpage clear">
                        <!-- ****** SIDEBAR ****** -->
                        <div id="sidebar">                          
                            <div class="sidebox">
                                <div class="box_top">
                                </div>
                                <h1><?php 
echo TEMPLATE_2_NEWS;
?>
.</h1>
                                <div class="rule">
                                </div>
                                <?php 
$lastNewsPosts = NewsPost::fetchFromDbNewestX(2);
foreach ($lastNewsPosts as $newsPost) {
    ?>
                                	<div class="sideinner sidepost">
	                                    <h2>
	                                        <a href="news.php?id=<?php 
    echo $newsPost->id;
    ?>
"><?php 
    echo $newsPost->title->getText($language_selected);
    ?>
</a></h2>
	                                    <div class="post_thumb">
	                                    	<a href="<?php 
    echo "news.php?id=" . $newsPost->id;
    ?>
示例#10
0
                                    <div style="padding-top: <?php 
echo $errorMessage != "" || $successMessage != "" ? "20px" : "50px";
?>
; font-size: 8pt;"><?php 
echo HOME_BOX_BOTTOM_LEFT_FOOTER;
?>
</div>
                                    <div class="box_down">
                                    </div>
                                </div>
                                <div class="box box_3-2 white">
                                    <div class="box_top">
                                    </div>
                                    <?php 
$logger->LogInfo("Fetching newest news post to display ...");
$newestNewsPost = NewsPost::fetchFromDbNewest();
if ($newestNewsPost != null) {
    ?>
                                        
		                                    <div class="home_post clear">
		                                        <div class="post_thumb">  
		                                        	<a href="<?php 
    echo "news.php?id=" . $newestNewsPost->id;
    ?>
">                                      
		                                            	<img src="images/<?php 
    echo $newestNewsPost->imageSmall;
    ?>
" alt="<?php 
    echo $newestNewsPost->title->getText($language_selected);
    ?>
 public function NextNewsItem()
 {
     return NewsPost::get()->filter(array('DateTime:GreaterThanOrEqual' => $this->DateTime))->exclude('ID', $this->ID)->sort('DateTime')->first();
 }
 public function runSearch()
 {
     global $systemConfiguration;
     global $logger;
     $newsPosts = array();
     $sql = "SELECT * FROM bsi_news_posts ";
     $where = "";
     if ($this->id > 0) {
         $where .= "id = " . $this->id;
     } else {
         if ($this->categoryId > 0) {
             $where .= "category_id = " . $this->categoryId;
         } else {
             if ($this->monthNumber > 0 && $this->yearNumber > 0) {
                 $where .= "CAST(DATE_FORMAT(date_posted, '%Y') as UNSIGNED) = " . $this->yearNumber . " AND CAST(DATE_FORMAT(date_posted,'%m') as UNSIGNED) = " . $this->monthNumber;
             } else {
                 if (strlen(trim($this->keywords)) > 0) {
                     $keywords = str_ireplace(" ", "%", $this->keywords);
                     $where .= NewsSearchCriteria::$titleField . " LIKE '%" . mysql_escape_string($keywords) . "%' OR " . NewsSearchCriteria::$contentsField . " LIKE '%" . mysql_escape_string($keywords) . "%'";
                 }
             }
         }
     }
     if ($where != "") {
         $where = " WHERE " . $where;
         $sql .= $where;
     }
     $sql .= " ORDER BY date_posted DESC ";
     $postsPerPage = $systemConfiguration->getNewsItemsPerPage();
     $count = NewsPost::count($where);
     $this->totalPages = max(ceil($count / $postsPerPage), 1);
     if ($this->page < 1) {
         $this->page = 1;
     } else {
         if ($this->page > $this->totalPages) {
             $this->page = $this->totalPages;
         }
     }
     $sql .= "  LIMIT " . ($this->page - 1) * $postsPerPage . "," . $postsPerPage;
     $query = mysql_query($sql);
     if (!$query) {
         $logger->LogError("Error returning news posts for page {$page}.");
         $logger->LogError("Error: " . mysql_errno() . ". Error message: " . mysql_error());
         $logger->LogError("SQL: {$sql}");
         die("Error: " . mysql_errno() . ". Error message: " . mysql_error());
     }
     while ($row = mysql_fetch_assoc($query)) {
         $newsPost = NewsPost::fetchFromParameters($row, true);
         $newsPosts[] = $newsPost;
     }
     return $newsPosts;
 }
 /**
  * RSS feed
  */
 public function rss()
 {
     $list = NewsPost::get()->filter('ParentID', $this->ID);
     $list = $list->Sort('DateTime DESC');
     $this->extend('updateRSSItems', $list);
     $feed = new RSSFeed($list, $this->AbsoluteLink(), $this->Title);
     return $feed->outputToBrowser();
 }
示例#14
0
$lastPage = 1;
if (isset($_GET['page']) && is_numeric($_GET['page'])) {
    $page = intval($_GET['page']);
}
// Validate page number
if ($page < 1) {
    $page = 1;
} else {
    $count = NewsPost::count();
    $lastPage = max(ceil($count / $postsPerPage), 1);
    if ($page > $lastPage) {
        $page = $lastPage;
    }
}
$logger->LogDebug("Fetching news posts for page {$page} ...");
$newsPosts = NewsPost::fetchFromDbPage($page, true);
//if ($newsPosts == null)
//{
//	$logger->LogError("There were errors fetching news posts.");
//	foreach (NewsPost::$staticErrors as $error)
//	{
//		$logger->LogError($error);
//		$errors[] = $error;
//	}
//}
$logger->LogDebug("Fetching default language ...");
$defaultLanguage = Language::fetchDefaultLangauge();
if ($defaultLanguage == null) {
    $logger->LogError("There were errors fetching default language.");
    foreach (Language::$staticErrors as $error) {
        $logger->LogError($error);
示例#15
0
<?php

// TODO: Uncomment
include "access.php";
include_once "../includes/SystemConfiguration.class.php";
global $systemConfiguration;
global $logger;
// If we have id, then we are trying to delete
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $id = $_GET['id'];
    NewsPost::delete($id);
}
header("Location: news_posts_list.php");
示例#16
0
 public static function delete($id)
 {
     global $logger;
     NewsPost::$staticErrors = array();
     if (is_numeric($id)) {
         // Run DELETE
         $sql = "DELETE FROM bsi_news_posts WHERE id = " . $id;
         if (!mysql_query($sql)) {
             $logger->LogError("Error: " . mysql_errno() . ". Error message: " . mysql_error());
             $logger->LogError("SQL: {$sql}");
             die('Error: ' . mysql_error());
         }
         return true;
     } else {
         NewsPost::$staticErrors[] = "Id is not numeric";
         return false;
     }
 }