/** * getPreview * * @param object &$feed Params * * @return object */ public function getPreview(&$feed) { if (isset($feed->params)) { $feed->xtform = EForm::paramsToRegistry($feed); } $import_limit = $feed->xtform->get('import_limit'); $feed->xtform->set('import_limit', 3); $check_existing = $feed->xtform->get('check_existing'); $feed->xtform->set('check_existing', 0); $loadResult = null; try { $start_time = time(); $feedImporterHelper = new FeedImporterHelper(); $feedProcessorHelper = new FeedProcessorHelper(); $feedGeneratorHelper = new FeedGeneratorHelper(); $loadResult = $feedImporterHelper->import($feed); $contents = $feedProcessorHelper->process($feed, $loadResult); $feedGeneratorHelper->execute($contents, $feed->xtform, true); $loadResult->processed_time = time() - $start_time; $loadResult->preview = $contents; } catch (Exception $e) { ELog::showMessage($e->getMessage(), JLog::ERROR); } $feed->xtform->set('import_limit', $import_limit); $feed->xtform->set('check_existing', $check_existing); return $loadResult; }
/** * import * * @param object &$feed Params * * @return void */ public function import(&$feed) { if (isset($feed->params)) { $feed->xtform = EForm::paramsToRegistry($feed); } $import_frequency = $feed->xtform->get('import_frequency', self::ALWAYS_EXPRESSION); if ($import_frequency != self::ALWAYS_EXPRESSION) { $automators = F0FModel::getTmpInstance('Automators', 'AutoTweetModel'); $key = 'feed-' . $feed->id; $lastexec = $automators->lastRun($key); if ($lastexec->toUnix() < JFactory::getDate()->toUnix()) { $lastexec = 'now'; } $next = TextUtil::nextScheduledDate($import_frequency, $lastexec); $logger = AutotweetLogger::getInstance(); $logger->log(JLog::INFO, "Feed import: lastRunCheck {$lastexec} ({$key}, 0, {$next})"); if (!$automators->lastRunCheck($key, 0, $next)) { $logger->log(JLog::INFO, "Feed import: lastRunCheck skipped!"); return; } } $result = new StdClass(); $result->added_items = 0; $simplePie = $this->_createSimplePie($feed); if ($simplePie->get_type() & SIMPLEPIE_TYPE_NONE) { throw new Exception(JText::sprintf('COM_AUTOTWEET_FEED_UNABLE_TO_PROCESS', $feed->xtform->get('title') . ' (' . $feed->xtform->get('feed') . ')')); } elseif ($simplePie->error) { throw new Exception("SimplePie error (ID={$feed->id}): " . $simplePie->error . ' for ' . $feed->xtform->get('title') . ' (' . $feed->xtform->get('feed') . ')'); } $title = $simplePie->get_title(); $c = (int) $feed->xtform->get('import_limit'); $items = $simplePie->get_items(0, $c); $result->title = $title; $result->items = $items; $simplePie->__destruct(); unset($items, $simplePie); // End SimplePie processing return $result; }
/** * getXingValidation. * * @return void */ public function getXingValidation() { @ob_end_clean(); header('Content-type: text/plain'); // No JInputJSON in J2.5 $raw = file_get_contents('php://input'); $data = json_decode($raw, true); $safeHtmlFilter = JFilterInput::getInstance(); $token = $data['token']; $token = $safeHtmlFilter->clean($token, 'ALNUM'); $this->input->set($token, 1); // CSRF prevention if ($this->csrfProtection) { $this->_csrfProtection(); } $channel_id = $data['channel_id']; $channel_id = $safeHtmlFilter->clean($channel_id, 'ALNUM'); $channel = F0FTable::getAnInstance('Channel', 'AutoTweetTable'); $result = $channel->load($channel_id); $channel->xtform = EForm::paramsToRegistry($channel); $status = false; $error_message = 'Unknown'; $user = null; $userId = null; $url = null; $icon = null; try { $xingChannelHelper = new XingChannelHelper($channel); $isAuth = $xingChannelHelper->isAuth(); if ($isAuth && isset($isAuth->users) && count($isAuth->users) == 1) { $users = $isAuth->users; $user = $users[0]; $status = true; $error_message = 'Ok'; $url = $xingChannelHelper->getSocialUrl($user); $userId = $user->id; $icon = F0FModel::getTmpInstance('Channeltypes', 'AutoTweetModel')->getIcon(AutoTweetModelChanneltypes::TYPE_XING_CHANNEL); } else { $error_message = 'Xing Login Failed!'; } } catch (Exception $e) { $error_message = $e->getMessage(); } $message = json_encode(array('status' => $status, 'error_message' => $error_message, 'user' => $userId, 'icon' => $icon, 'url' => $url)); echo EJSON_START . $message . EJSON_END; flush(); JFactory::getApplication()->close(); }
/** * This method runs after an item has been gotten from the database in a read * operation. You can modify it before it's returned to the MVC triad for * further processing. * * @param JTable &$record Param * * @return bool */ protected function onAfterGetItem(&$record) { jimport('extly.form.eform'); $record->xtform = EForm::paramsToRegistry($record); return parent::onAfterGetItem($record); }
/** * This method runs after an item has been gotten from the database in a read * operation. You can modify it before it's returned to the MVC triad for * further processing. * * @param JTable &$record Param * * @return bool */ protected function onAfterGetItem(&$record) { $record->xtform = EForm::paramsToRegistry($record); return parent::onAfterGetItem($record); }
/** * _getContentData * * @param array &$request Param * * @return data */ public function _getContentData(&$request) { $this->logger->log(JLog::INFO, '_getContentData', $request); // Get source plugin for message // Gets the plugin that has triggered the message $pluginsModel = F0FModel::getTmpInstance('Plugins', 'AutoTweetModel'); $plugin = $pluginsModel->createPlugin($request->plugin); if (empty($plugin)) { $this->logger->log(JLog::WARNING, 'publishRequest: unknown plugin. Source: ' . $request->plugin); $post = $request; } else { $plugin->setMessage($request->description); $request->xtform = EForm::paramsToRegistry($request); $plugin->setHashtags($request->xtform->get('hashtags', '')); // Get data from plugin if (method_exists($plugin, 'getExtendedData')) { if (!isset($request->native_object) && isset($request->params)) { $request->native_object = $request->params; } $data = $plugin->getExtendedData($request->ref_id, $request->typeinfo, $request->native_object); } else { $data = $plugin->getData($request->ref_id, $request->typeinfo); } } // Check if post is valid to avoid spam; if not remove post from queue if (empty($data) || !array_key_exists('is_valid', $data) || !$data['is_valid']) { $this->logger->log(JLog::ERROR, 'publishRequest: message not valid (spam or technical problem - old plugin?), queue id = ' . $request->id); RequestHelp::saveError($request->id, 'COM_AUTOTWEET_ERROR_PUBLISHREQUEST'); return null; } $data['autopublish'] = $plugin->isAutopublish(); $data['show_url'] = $plugin->getShowUrlMode(); return $data; }
/** * setExtensionParam. * * @param string $folder Params * @param string $element Params * @param string $key Params * @param string $value Params * * @return string. */ public static function setExtensionParam($folder, $element, $key, $value) { $extensionsModel = F0FModel::getTmpInstance('Extensions', 'ExtlyModel'); $extensionsModel->set('folder', $folder); $extensionsModel->set('element', $element); $extensionsModel->set('limit', 1); $extensions = $extensionsModel->getItemList(); if (count($extensions) == 1) { $extension = $extensions[0]; if (isset($extension->{$key})) { $extension->{$key} = $value; return $extensionsModel->save($extension); } $extension->xtform = EForm::paramsToRegistry($extension); $extension->xtform->set($key, $value); return $extensionsModel->save($extension); } return false; }
<td colspan="20"><?php EHtml::renderPagination($this); ?> </td> </tr> </tfoot> <tbody> <?php if ($count = count($this->items)) { ?> <?php $i = 0; $m = 1; foreach ($this->items as $item) { $m = 1 - $m; $item->xtform = EForm::paramsToRegistry($item); $checkedout = $item->checked_out != 0; ?> <tr class="row<?php echo $m; ?> "> <?php if ($hasAjaxOrderingSupport !== false) { ?> <td class="order nowrap center hidden-phone"><?php if ($this->perms->editstate) { $disableClassName = ''; $disabledLabel = ''; if (!$hasAjaxOrderingSupport['saveOrder']) { $disabledLabel = JText::_('JORDERINGDISABLED');
/** * loadRequest. * * @param int $req_id Param. * * @return void * * @deprecated */ protected function loadRequest($req_id) { $articles = F0FModel::getTmpInstance('Requests', 'AutoTweetModel'); $articles->set('ref_id', $req_id); $article = $articles->getFirstItem(); $article->xtform = EForm::paramsToRegistry($article); return $article; }
/** * publishCronjobPosts * * @param int $limit Param * * @return boolean */ public static function publishCronjobPosts($limit) { $postsModel = F0FModel::getTmpInstance('Posts', 'AutoTweetModel'); $postsModel->set('pubstate', AutotweetPostHelper::POST_CRONJOB); $postsModel->set('filter_order', 'postdate'); $postsModel->set('filter_order_Dir', 'ASC'); $postsModel->set('limit', $limit); $posts = $postsModel->getItemList(); $sharingHelper = SharingHelper::getInstance(); $logger = AutotweetLogger::getInstance(); $logger->log(JLog::INFO, 'publishCronjobPosts Posts: ' . count($posts)); foreach ($posts as $post) { $logger->log(JLog::INFO, 'Sending Post ID: ' . $post->id . ' Channel: ' . $post->channel_id . ' Plugin: ' . $post->plugin); $post->xtform = EForm::paramsToRegistry($post); $sharingHelper->publishPost($post); } }