/** * Cron calls */ public function cron() { /* this will run once a week */ if (JRequest::getVar('maintenance')) { // Diffbot weekly maintenance if (StreamLinks::unjump()) { exit('Maintenance complete'); } exit('Failed to perform maintenance'); } /* weekly cron task */ if (JRequest::getVar('weekly')) { // only allow script to run from the server if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') { StreamFactory::load('libraries.activity'); $activity = new StreamActivity(); $activity->scan(); } else { throw new Exception('Unaccessible'); } } // Since the cron job already exist here, use the same jobs to perform link refetching StreamLinks::refetch(); StreamFactory::load('libraries.cron'); $cron = new StreamCron(); $cron->run(); exit; }
public function updateCalendar() { $month = JRequest::getVar('month'); $year = JRequest::getVar('year'); StreamFactory::load('helpers' . DS . 'calendar'); $html = StreamCalendarHelper::generate_calendar($year, $month); $data = array(); $data['html'] = $html; $data['script'] = '$(\'div.popover\').hide();$(\'td.running\').popmodal({html:true, live:true, placement: \'below\'});'; echo json_encode($data); exit; }
/** * Initialize the video */ private function _init() { StreamFactory::load('libraries.slideshare'); jimport('joomla.http.http'); $feedURL = 'http://www.slideshare.net/api/oembed/2?url=' . $this->source . '&format=json'; $options = new JRegistry(); $transport = new JHttpTransportCurl($options); $http = new JHttp($options, $transport); $response = $http->get($feedURL); $this->response = $response->body; return true; }
function display($tpl = null) { $doc = JFactory::getDocument(); $doc->setTitle(JText::_("COM_STREAM_LABEL_ALL_EVENTS")); $html = ''; $this->addPathway(JText::_('NAVIGATOR_LABEL_EVENTS'), JRoute::_('index.php?option=com_stream&view=groups')); $this->_attachScripts(); $tmpl = new StreamTemplate(); $html .= $tmpl->fetch('event.page'); $my = JXFactory::getUser(); if (!$my->getParam(ALERT_CALENDAR_INTRO)) { $html .= ' <div class="alert alert-success" data-alert_id="' . ALERT_CALENDAR_INTRO . '"> <a data-dismiss="alert" class="close">×</a> ' . JText::_('COM_STREAM_HELPER_EVENT') . '</div>'; } JXModule::addBuffer('right', $this->getUpcomingHotEvent()); // Show calendar $now = new JDate(); StreamFactory::load('helpers' . DS . 'calendar'); $html .= '<div id="stream-calendar">' . StreamCalendarHelper::generate_calendar($now->format('Y'), $now->format('m')) . '</div>'; echo $html; //echo $this->getStreamDataHTML(); }
/** * */ public function load($keys = null, $reset = true) { if (!is_array($keys)) { // Load by primary key. $keys = array($this->_tbl_key => $keys); } else { // Return false for videos link StreamFactory::load('libraries.video'); $videoLib = new StreamVideo(); $videos = $videoLib->getURL($keys['link']); if (in_array($keys['link'], $videos)) { return false; } // Return false for slidehshare links StreamFactory::load('libraries.slideshare'); $ssLib = new StreamSlideshare(); $slideShares = $ssLib->getURL($keys['link']); if (in_array($keys['link'], $slideShares)) { return false; } } $result = parent::load($keys, $reset); $this->_params = new JParameter($this->params); if (!$result && isset($keys['link'])) { $this->link = $keys['link']; } if (empty($this->params)) { $this->params = StreamLinks::grab($this->link); if ($this->params) { $date = new JDate(); $this->timestamp = $date->format('Y-m-d h:i:s'); $this->store(true); } } return $result; }
/** * If there are videos, store it */ private function _filterVideoURL(&$stream) { StreamFactory::load('libraries.video'); $rawData = json_decode($stream->raw); $videoLib = new StreamVideo(); $videos = $videoLib->getURL($stream->message); $rawData->video = array(); //print_r($videos); exit; if ($videos) { // Youtube link found foreach ($videos as $youtubeLink) { $video = JTable::getInstance('Video', 'StreamTable'); $video->load(array('source' => $youtubeLink)); $video->store(); $rawData->video[] = $video->id; } } $stream->raw = json_encode($rawData); }
/** * Return video object */ public static function getVideo($type) { StreamFactory::load('libraries.videos.' . $type); $classname = 'StreamVideo' . ucfirst($type); return new $classname(); }