Exemplo n.º 1
0
 /**
  * Get the latest news for the specified news category beetween the specified dates.
  *
  * @param int $category Category.
  *
  * @return News[] Returns a news array.
  */
 function getLatestMarshalingEvent($category)
 {
     $sql = "SELECT publish_date, content, title FROM pa_npro_news\n\t\t\t\tWHERE status ='Published'\n\t\t\t\tAND cat_id = {$category}\n\t\t\t\tORDER BY publish_date DESC\n\t\t\t\tLIMIT 1";
     $result = $this->connection->query($sql);
     $newsItems = array();
     while ($row = mysqli_fetch_array($result)) {
         $news = new News();
         $news->setPublishDate($row['publish_date']);
         $news->setContent($row['content']);
         $news->setTitle($row['title']);
         array_push($newsItems, $news);
     }
     return $newsItems;
 }
Exemplo n.º 2
0
        Message::register(new Message(Message::DANGER, i18n(array("en" => "image is required.", "zh" => "请填写image"))));
        $error_flag = true;
    }
    // validation for $date
    $date = isset($_POST["date"]) ? strip_tags($_POST["date"]) : null;
    if (empty($date)) {
        Message::register(new Message(Message::DANGER, i18n(array("en" => "date is required.", "zh" => "请填写date"))));
        $error_flag = true;
    }
    /// proceed submission
    // proceed for $title
    $object->setTitle($title);
    // proceed for $summary
    $object->setSummary($summary);
    // proceed for $content
    $object->setContent($content);
    // proceed for $thumbnail
    $object->setThumbnail($thumbnail);
    // proceed for $image
    $object->setImage($image);
    // proceed for $date
    $object->setDate($date / 1000);
    if ($error_flag == false) {
        if ($object->save()) {
            Message::register(new Message(Message::SUCCESS, i18n(array("en" => "Record saved", "zh" => "记录保存成功"))));
            HTML::forwardBackToReferer();
        } else {
            Message::register(new Message(Message::DANGER, i18n(array("en" => "Record failed to save", "zh" => "记录保存失败"))));
        }
    }
}
Exemplo n.º 3
0
    $news->setSummary('Century 21 Student Service has a free consultation for oversea students');
    $news->setContent('<p>Century 21 Student Service has a free consultation for oversea students ...</p>');
    $news->setThumbnail('files/fixture/news/thumbnail/consultation-education-flagship_572.jpg');
    $news->setImage('files/fixture/news/image/consultation-education-flagship_390.jpg');
    $news->setDate(1439215200);
    $news->save();
    $news = new News();
    $news->setTitle('News Year bonus program for $300 dollars');
    $news->setSummary('We are giving away $300 dollars free credit for students applying for Australian colleges');
    $news->setContent('<p>We are giving away $300 dollars free credit for students applying for Australian colleges...</p>');
    $news->setThumbnail('files/fixture/news/thumbnail/bonus_568.jpg');
    $news->setImage('files/fixture/news/image/bonus_915.jpg');
    $news->setDate(1439733600);
    $news->save();
    $news = new News();
    $news->setTitle('UNSW orientation program is on now!');
    $news->setSummary('From 3rd Sept to 5th Sept, Century 21 Student service will hold a special orientation session');
    $news->setContent('<p>From 3rd Sept to 5th Sept, Century 21 Student service will hold a special orientation session for future students who are planning to study in UNSW.</p>');
    $news->setThumbnail('files/fixture/news/thumbnail/unsw_via_stargate_778.jpg');
    $news->setImage('files/fixture/news/image/unsw_via_stargate_722.jpg');
    $news->setDate(1440079200);
    $news->save();
    $news = new News();
    $news->setTitle('Introduction to CT21 VIP program');
    $news->setSummary('Century 21 Student Service has a new VIP program just announced this Friday.');
    $news->setContent('<p>Century 21 Student Service has a new VIP program just announced this Friday.</p>');
    $news->setThumbnail('files/fixture/news/thumbnail/maxresdefault_797.jpg');
    $news->setImage('files/fixture/news/image/maxresdefault_310.jpg');
    $news->setDate(1440079200);
    $news->save();
}