diff options
| author | 2017-12-17 20:28:04 +0100 | |
|---|---|---|
| committer | 2017-12-17 20:28:04 +0100 | |
| commit | 60f56539c3f30fd3f7ba4f2a3570f7029ac93e5f (patch) | |
| tree | 1e78bfac7042dceb63898e2215db8fb0c1d7745d /app/Controllers | |
| parent | ceda55c75b158fc1cf4813fe0f258527754b9289 (diff) | |
| parent | 0b1516af91792f86868689392f72ad4b6e32cdcf (diff) | |
Merge pull request #1720 from FreshRSS/dev
FreshRSS 1.9.0
Diffstat (limited to 'app/Controllers')
| -rwxr-xr-x | app/Controllers/configureController.php | 6 | ||||
| -rwxr-xr-x | app/Controllers/entryController.php | 4 | ||||
| -rw-r--r-- | app/Controllers/extensionController.php | 37 | ||||
| -rwxr-xr-x | app/Controllers/feedController.php | 27 | ||||
| -rw-r--r-- | app/Controllers/updateController.php | 4 | ||||
| -rw-r--r-- | app/Controllers/userController.php | 4 |
6 files changed, 68 insertions, 14 deletions
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 155221d19..9d2ee450c 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -225,10 +225,12 @@ class FreshRSS_configure_Controller extends Minz_ActionController { $entryDAO = FreshRSS_Factory::createEntryDao(); $this->view->nb_total = $entryDAO->count(); - $this->view->size_user = $entryDAO->size(); + + $databaseDAO = FreshRSS_Factory::createDatabaseDAO(); + $this->view->size_user = $databaseDAO->size(); if (FreshRSS_Auth::hasAccess('admin')) { - $this->view->size_total = $entryDAO->size(true); + $this->view->size_total = $databaseDAO->size(true); } } diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php index c40588105..bd8b65b2b 100755 --- a/app/Controllers/entryController.php +++ b/app/Controllers/entryController.php @@ -147,8 +147,8 @@ class FreshRSS_entry_Controller extends Minz_ActionController { @set_time_limit(300); - $entryDAO = FreshRSS_Factory::createEntryDao(); - $entryDAO->optimizeTable(); + $databaseDAO = FreshRSS_Factory::createDatabaseDAO(); + $databaseDAO->optimize(); $feedDAO = FreshRSS_Factory::createFeedDao(); $feedDAO->updateCachedValues(); diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.php index b6d2d3fe4..bb846e921 100644 --- a/app/Controllers/extensionController.php +++ b/app/Controllers/extensionController.php @@ -25,10 +25,47 @@ class FreshRSS_extension_Controller extends Minz_ActionController { 'user' => array(), ); + $this->view->extensions_installed = array(); + $extensions = Minz_ExtensionManager::listExtensions(); foreach ($extensions as $ext) { $this->view->extension_list[$ext->getType()][] = $ext; + $this->view->extensions_installed[$ext->getEntrypoint()] = $ext->getVersion(); + } + + $availableExtensions = $this->getAvailableExtensionList(); + $this->view->available_extensions = $availableExtensions; + } + + /** + * fetch extension list from GitHub + */ + protected function getAvailableExtensionList() { + $extensionListUrl = 'https://raw.githubusercontent.com/FreshRSS/Extensions/master/extensions.json'; + $json = file_get_contents($extensionListUrl); + + // we ran into problems, simply ignore them + if ($json === false) { + Minz_Log::error('Could not fetch available extension from GitHub'); + return array(); + } + + // fetch the list as an array + $list = json_decode($json, true); + if (empty($list)) { + Minz_Log::warning('Failed to convert extension file list'); + return array(); } + + // we could use that for comparing and caching later + $version = $list['version']; + + // By now, all the needed data is kept in the main extension file. + // In the future we could fetch detail information from the extensions metadata.json, but I tend to stick with + // the current implementation for now, unless it becomes too much effort maintain the extension list manually + $extensions = $list['extensions']; + + return $extensions; } /** diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 45cba9e98..fff20f798 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -26,6 +26,18 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } } + /** + * @param $url + * @param string $title + * @param int $cat_id + * @param string $new_cat_name + * @param string $http_auth + * @return FreshRSS_Feed|the + * @throws FreshRSS_AlreadySubscribed_Exception + * @throws FreshRSS_FeedNotAdded_Exception + * @throws FreshRSS_Feed_Exception + * @throws Minz_FileNotExistException + */ public static function addFeed($url, $title = '', $cat_id = 0, $new_cat_name = '', $http_auth = '') { FreshRSS_UserDAO::touch(); @set_time_limit(300); @@ -33,12 +45,13 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $catDAO = new FreshRSS_CategoryDAO(); $cat = null; + if ($new_cat_name != '') { + $new_cat_id = $catDAO->addCategory(array('name' => $new_cat_name)); + $cat_id = $new_cat_id > 0 ? $new_cat_id : $cat_id; + } if ($cat_id > 0) { $cat = $catDAO->searchById($cat_id); } - if ($cat == null && $new_cat_name != '') { - $cat = $catDAO->addCategory(array('name' => $new_cat_name)); - } if ($cat == null) { $catDAO->checkDefault(); } @@ -54,7 +67,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { throw new FreshRSS_AlreadySubscribed_Exception($url, $feed->name()); } - // Call the extension hook + /** @var FreshRSS_Feed $feed */ $feed = Minz_ExtensionManager::callHook('feed_before_insert', $feed); if ($feed === null) { throw new FreshRSS_FeedNotAdded_Exception($url, $feed->name()); @@ -136,7 +149,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { // User want to create a new category, new_category parameter // must exist $new_cat = Minz_Request::param('new_category'); - $new_cat_name = isset($new_cat['name']) ? $new_cat['name'] : ''; + $new_cat_name = isset($new_cat['name']) ? trim($new_cat['name']) : ''; } // HTTP information are useful if feed is protected behind a @@ -263,7 +276,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { if ((!$simplePiePush) && (!$feed_id) && $pubSubHubbubEnabled && ($feed->lastUpdate() > $pshbMinAge)) { //$text = 'Skip pull of feed using PubSubHubbub: ' . $url; //Minz_Log::debug($text); - //file_put_contents(USERS_PATH . '/_/log_pshb.txt', date('c') . "\t" . $text . "\n", FILE_APPEND); + //Minz_Log::debug($text, PSHB_LOG); continue; //When PubSubHubbub is used, do not pull refresh so often } @@ -371,7 +384,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { if ($pubSubHubbubEnabled && !$simplePiePush) { //We use push, but have discovered an article by pull! $text = 'An article was discovered by pull although we use PubSubHubbub!: Feed ' . $url . ' GUID ' . $entry->guid(); - file_put_contents(USERS_PATH . '/_/log_pshb.txt', date('c') . "\t" . $text . "\n", FILE_APPEND); + Minz_Log::warning($text, PSHB_LOG); Minz_Log::warning($text); $pubSubHubbubEnabled = false; $feed->pubSubHubbubError(true); diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php index 7a8a3d6c0..c67b358bb 100644 --- a/app/Controllers/updateController.php +++ b/app/Controllers/updateController.php @@ -102,7 +102,7 @@ class FreshRSS_update_Controller extends Minz_ActionController { $version = 'git'; } else { $this->view->message = array( - 'status' => 'bad', + 'status' => 'latest', 'title' => _t('gen.short.damn'), 'body' => _t('feedback.update.none') ); @@ -138,7 +138,7 @@ class FreshRSS_update_Controller extends Minz_ActionController { $status = $res_array[0]; if (strpos($status, 'UPDATE') !== 0) { $this->view->message = array( - 'status' => 'bad', + 'status' => 'latest', 'title' => _t('gen.short.damn'), 'body' => _t('feedback.update.none') ); diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php index a58501186..2a1d43d9e 100644 --- a/app/Controllers/userController.php +++ b/app/Controllers/userController.php @@ -120,7 +120,9 @@ class FreshRSS_user_Controller extends Minz_ActionController { // Get information about the current user. $entryDAO = FreshRSS_Factory::createEntryDao($this->view->current_user); $this->view->nb_articles = $entryDAO->count(); - $this->view->size_user = $entryDAO->size(); + + $databaseDAO = FreshRSS_Factory::createDatabaseDAO(); + $this->view->size_user = $databaseDAO->size(); } public static function createUser($new_user_name, $passwordPlain, $apiPasswordPlain, $userConfig = array(), $insertDefaultFeeds = true) { |
