Exemple #1
0
 /**
  * Controller default action
  */
 public function action_index()
 {
     $this->page_title = __('Welcome to :site', array(':site' => Kohana::config('site.site_name')));
     // Display news feed
     $newsfeed = new NewsFeed(self::$user);
     $newsfeed->max_items = 25;
     Widget::add('main', View_Module::factory('generic/newsfeed', array('newsfeed' => $newsfeed->as_array())));
     // Shout
     $shouts = Jelly::select('shout')->limit(10)->execute();
     Widget::add('side', View_Module::factory('generic/shout', array('mod_title' => __('Shouts'), 'shouts' => $shouts, 'can_shout' => Permission::has(new Model_Shout(), Model_Shout::PERMISSION_CREATE), 'errors' => array(), 'values' => array())));
 }
Exemple #2
0
 /**
  * Home page
  */
 public function index()
 {
     $this->page_title = __('Welcome to :site', array(':site' => Kohana::config('site.site_name')));
     // Display news feed
     $newsfeed = new NewsFeed($this->user);
     $newsfeed->max_items = 25;
     widget::add('main', View_Mod::factory('generic/newsfeed', array('newsfeed' => $newsfeed->as_array())));
     // Shout
     $shouts = ORM::factory('shout')->find_all(10);
     widget::add('side', View_Mod::factory('generic/shout', array('mod_title' => __('Shouts'), 'shouts' => $shouts, 'can_shout' => ORM::factory('shout')->has_access(Shout_Model::ACCESS_WRITE, $this->user), 'errors' => array(), 'values' => array())));
     // Online
     $guests = Online_User_Model::get_guest_count();
     $online = Online_User_Model::find_online_users();
     $counts = array();
     if ($guests) {
         $counts[] = __2(':guests guest', ':guests guests', $guests, array(':guests' => $guests));
     }
     if (count($online)) {
         $counts[] = __2(':members member', ':members members', count($online), array(':members' => count($online)));
     }
     widget::add('side', View_Mod::factory('generic/users', array('mod_title' => __('Online') . ': ' . implode(', ', $counts), 'viewer' => $this->user, 'users' => $online)));
 }
Exemple #3
0
 public static function getMailForUser($userid = null, $delivery = '', $mc = null, $subjecttype = "app")
 {
     if (is_null($userid)) {
         return null;
     }
     $mailData = array();
     if ($delivery == '' || is_numeric($delivery) == false) {
         $delivery = NewsDeliveryType::D_DAILY_DIGEST | NewsDeliveryType::D_WEEKLY_DIGEST | NewsDeliveryType::D_MONTHLY_DIGEST;
     }
     $news = NewsFeed::getEmailDigest($delivery, $userid, $subjecttype);
     if (count($news) == 0) {
         return null;
     }
     $mailData["news"] = $news;
     $mailData["server"] = "http://" . $_SERVER['APPLICATION_UI_HOSTNAME'] . "/";
     $mailData["delivery"] = $delivery;
     if ($delivery == NewsDeliveryType::D_DAILY_DIGEST) {
         $mailData["digest"] = "daily";
     } else {
         if ($delivery == NewsDeliveryType::D_WEEKLY_DIGEST) {
             $mailData["digest"] = "weekly";
         } else {
             if ($delivery == NewsDeliveryType::D_MONTHLY_DIGEST) {
                 $mailData["digest"] = "monthly";
             }
         }
     }
     $us = new Default_Model_Researchers();
     $us->filter->id->equals($userid);
     if (count($us->items) > 0) {
         $u = $us->items[0];
         $mailData["unsubscribeall"] = $mailData["server"] . "news/unsubscribeall?id=" . $userid . "&pwd=" . md5($u->mailUnsubscribePwd);
         $mailData["unsubscribedigestall"] = $mailData["server"] . "news/unsubscribeall?id=" . $userid . "&delivery=" . $delivery . "&pwd=" . md5($u->mailUnsubscribePwd);
         $mailData["externalurl"] = $mailData["server"] . "news/mail?id=" . $userid . "&delivery=" . $delivery . "&h=" . md5('' . $u->id . ':' . $u->mailUnsubscribePwd . ':' . $delivery);
     } else {
         $mailData["unsubscribeall"] = null;
         $mailData["unsubscribedigestall"] = null;
         $mailData["externalurl"] = null;
     }
     $text = self::getTextMail($mailData);
     $mc->mailAction($mailData);
     $html = $mc->view->render("news/mail.phtml");
     return array("html" => $html, "text" => $text);
 }
<?php

namespace cd;

set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../core/');
require_once 'io_newsfeed.php';
die('XXX: cant really test like this');
$url = 'http://xxx/webtv/apple.php?format=rss';
$feed = new NewsFeed();
$feed->load($url);
$list = $feed->getItems();
d($list);
die;
/*
$list[] = array(
    'pubdate' => 127652734,
    'link' => 'http://example.com/news/1',
    'title' => 'Latest news',
    'desc' => 'A short summary'
);

$list[] = array(
    'pubdate' => 127652224,
    'link' => 'http://example.com/news/2',
    'title' => 'Some older news',
    'desc' => 'A short summary'
);

$list[] = array(
    'pubdate' => 127651734,
    'link' => 'http://example.com/news/3',
Exemple #5
0
<?php

/**
 * Created by PhpStorm.
 * User: Asus
 * Date: 5/30/2015
 * Time: 2:46 AM
 */
require_once "includes/loader.php";
if (!isset($_GET['Id'])) {
    header("Location: index.php");
}
$feed = new NewsFeed(get_input('Id'));
if ($feed->count() != 1) {
    header("Location: index.php");
}
$title = $feed->PostTitle;
require_once "includes/views/header.view.php";
?>

<div class="container">
    <div class="row">
        <div class="col-lg-12">
            <p>
                <span class="text-info"><b>Feed Title:</b></span>
                <span><?php 
echo $feed->PostTitle;
?>
</span>
            </p>
            <p>
Exemple #6
0
 /**
  * Get newsfeed items.
  *
  * @return  array
  */
 protected function _items()
 {
     switch ($this->type) {
         // Friend newsfeed
         case self::TYPE_FRIENDS:
             $newsfeed = new Newsfeed(Visitor::$user, Newsfeed::USERS);
             if (Visitor::$user) {
                 $newsfeed->users = Visitor::$user->find_friends(0, 0);
             }
             break;
             // Single user newsfeed
         // Single user newsfeed
         case self::TYPE_PERSONAL:
             $newsfeed = new NewsFeed($this->user, Newsfeed::PERSONAL);
             break;
             // All users
         // All users
         case self::TYPE_ALL:
         default:
             $newsfeed = new NewsFeed(Visitor::$user, Newsfeed::ALL);
             break;
     }
     $newsfeed->max_items = $this->limit;
     return (array) $newsfeed->as_array();
 }
Exemple #7
0
<?php

/**
 * Created by PhpStorm.
 * User: Asus
 * Date: 5/30/2015
 * Time: 10:35 AM
 */
if (isset($_POST['save_feed'])) {
    require_once "../../includes/loader.php";
    if (isset($_POST['Id'])) {
        $feed = new NewsFeed(get_input("Id"));
    } else {
        $feed = new NewsFeed();
    }
    $validator = new Validator();
    $rules = array("Name" => "required", "PH_NO" => "required|numeric", "PostTitle" => "required", "PostDetail" => "required");
    $validator->run($rules);
    if (!$validator->fails()) {
        $feed->Name = get_input("Name");
        $feed->PH_NO = get_input("PH_NO");
        $feed->PostTitle = get_input("PostTitle");
        $feed->PostDetail = get_input("PostDetail");
        $feed->save();
        $messages = array("success" => 1, "message" => array("status" => "News Feed Sucessfully posted"));
    } else {
        $messages["message"] = $validator->getMessages();
        $messages["success"] = 0;
        Validator::reset();
    }
} else {
Exemple #8
0
 function handler_rss($page, $user = null, $hash = null)
 {
     $feed = new NewsFeed();
     return $feed->run($page, $user, $hash);
 }
Exemple #9
0
 /**
  * Controller default action
  */
 public function action_index()
 {
     $user = $this->_get_user();
     // Set generic page parameters
     $this->_set_page($user);
     // Helper variables
     $owner = self::$user && self::$user->id == $user->id;
     // Comments section
     if (Permission::has($user, Model_User::PERMISSION_COMMENTS, self::$user)) {
         $errors = array();
         $values = array();
         // Handle comment
         if (Permission::has($user, Model_User::PERMISSION_COMMENT, self::$user) && $_POST) {
             $comment = Jelly::factory('user_comment');
             $comment->user = $user;
             $comment->author = self::$user;
             $comment->set(Arr::extract($_POST, Model_User_Comment::$editable_fields));
             try {
                 $comment->save();
                 // Receiver
                 $user->comment_count++;
                 if (!$owner) {
                     $user->new_comment_count++;
                 }
                 $user->save();
                 // Sender
                 self::$user->left_comment_count++;
                 self::$user->save();
                 if (!$this->ajax) {
                     $this->request->redirect(Route::get('user')->uri(array('username' => urlencode($user->username))));
                 }
             } catch (Validate_Exception $e) {
                 $errors = $e->array->errors('validation');
                 $values = $comment;
             }
         }
         // Pagination
         $per_page = 25;
         $pagination = Pagination::factory(array('items_per_page' => $per_page, 'total_items' => max(1, $user->get('comments')->viewer(self::$user)->count())));
         $view = View_Module::factory('generic/comments', array('mod_title' => __('Comments'), 'delete' => Route::get('user_comment')->uri(array('id' => '%d', 'commentaction' => 'delete')) . '?token=' . Security::csrf(), 'private' => Route::get('user_comment')->uri(array('id' => '%d', 'commentaction' => 'private')) . '?token=' . Security::csrf(), 'comments' => $user->get('comments')->viewer(self::$user)->pagination($pagination)->execute(), 'errors' => $errors, 'values' => $values, 'pagination' => $pagination, 'user' => self::$user));
         if ($this->ajax) {
             echo $view;
             return;
         }
         Widget::add('main', $view);
     }
     // Display news feed
     $newsfeed = new NewsFeed($user, true);
     $newsfeed->max_items = 5;
     Widget::add('main', View_Module::factory('generic/newsfeed', array('newsfeed' => $newsfeed->as_array(), 'mini' => true)), Widget::TOP);
     // Slideshow
     if (count($user->images) > 1) {
         $images = array();
         foreach ($user->images as $image) {
             $images[] = $image;
         }
         Widget::add('side', View_Module::factory('generic/image_slideshow', array('images' => array_reverse($images), 'default_id' => $user->default_image->id)));
     }
     // Portrait
     Widget::add('side', $this->_get_mod_image($user), Widget::TOP);
     // Info
     Widget::add('side', View_Module::factory('user/info', array('user' => $user)), Widget::TOP);
 }
/*
Request Handler PHP Script
Author: Vitor Pêgas
Date: 04/09/2015

Description: This script will handle all the requests made to the server, and will use the backend API's
*/
require "functions.php";
require "NewsApi.php";
require "TVApi.php";
require "weatherAPI.php";
if (isset($_REQUEST["ajaxGetNews"])) {
    $request = $_REQUEST["ajaxGetNews"];
    if ($request == "CM") {
        $news = new NewsFeed("http://www.cmjornal.xl.pt/rss.aspx");
        $json = $news->getJSON();
        print $json;
    } else {
        exit;
    }
} else {
    if (isset($_REQUEST["ajaxGetTVGuide"])) {
        $channel = $_REQUEST["ajaxGetTVGuide"];
        $API = new TVApi();
        $API->getChannel(0)->getPrograms($API->getChannel($API->getChannelID($channel))->getSigla() . "&startDate=" . $today . "&endDate=" . $tomorrow);
        print $API->getChannel(0)->getJSON();
    } else {
        if (isset($_REQUEST["ajaxGetWeather"])) {
            $city = $_REQUEST["ajaxGetWeather"];
            $w = new Weather($city);
Exemple #11
0
 function render($format = '')
 {
     if ($format) {
         //echo "pl->render(FORMAT) is deprecated!! use ->setFormat()\n";
         $this->format = $format;
     }
     $page = XmlDocumentHandler::getInstance();
     switch ($this->format) {
         case 'xspf':
             if ($this->headers) {
                 $page->setMimeType('application/xspf+xml');
                 $page->disableDesign();
             }
             return $this->renderXSPF();
         case 'm3u':
             if ($this->headers) {
                 $page->setMimeType('audio/x-mpegurl');
                 $page->disableDesign();
             }
             return $this->renderM3U();
         case 'pls':
             if ($this->headers) {
                 $page->setMimeType('audio/x-scpls');
                 $page->disableDesign();
             }
             return $this->renderPLS();
         case 'sh':
             if ($this->headers) {
                 $page->setMimeType('text/plain; charset=utf-8');
                 $page->disableDesign();
             }
             return $this->renderSh();
         case 'xhtml':
         case 'html':
             return $this->renderXHTML();
         case 'atom':
             $feed = new NewsFeed();
             $feed->sendHeaders($this->headers);
             $feed->addItems($this->getItems());
             $feed->setTitle($this->title);
             return $feed->render('atom');
         case 'rss2':
         case 'rss':
             $feed = new NewsFeed();
             $feed->sendHeaders($this->headers);
             $feed->addItems($this->getItems());
             $feed->setTitle($this->title);
             return $feed->render('rss');
     }
     echo "Playlist->render: unknown format " . $this->format . "\n";
     return false;
 }