summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ajax/importopml.php77
-rw-r--r--ajax/selectfromcloud.php2
-rw-r--r--ajax/uploadopml.php42
-rw-r--r--appinfo/database.xml10
-rw-r--r--appinfo/version2
-rw-r--r--controllers/controller.php151
-rw-r--r--controllers/news.controller.php24
-rw-r--r--index.php16
-rw-r--r--js/items.js2
-rw-r--r--js/main.js2
-rw-r--r--js/settings.js94
-rw-r--r--l10n/ar.php3
-rw-r--r--l10n/bg_BG.php2
-rw-r--r--l10n/ca.php21
-rw-r--r--l10n/cs_CZ.php22
-rw-r--r--l10n/da.php13
-rw-r--r--l10n/de.php23
-rw-r--r--l10n/de_DE.php30
-rw-r--r--l10n/el.php21
-rw-r--r--l10n/eo.php22
-rw-r--r--l10n/es.php39
-rw-r--r--l10n/es_AR.php22
-rw-r--r--l10n/et_EE.php20
-rw-r--r--l10n/eu.php20
-rw-r--r--l10n/fa.php3
-rw-r--r--l10n/fi_FI.php17
-rw-r--r--l10n/fr.php21
-rw-r--r--l10n/gl.php122
-rw-r--r--l10n/he.php2
-rw-r--r--l10n/hr.php2
-rw-r--r--l10n/hu_HU.php3
-rw-r--r--l10n/ia.php2
-rw-r--r--l10n/id.php5
-rw-r--r--l10n/it.php22
-rw-r--r--l10n/ja_JP.php21
-rw-r--r--l10n/ka_GE.php2
-rw-r--r--l10n/ko.php93
-rw-r--r--l10n/ku_IQ.php12
-rw-r--r--l10n/lb.php2
-rw-r--r--l10n/lt_LT.php4
-rw-r--r--l10n/mk.php3
-rw-r--r--l10n/ms_MY.php3
-rw-r--r--l10n/nb_NO.php13
-rw-r--r--l10n/nl.php21
-rw-r--r--l10n/nn_NO.php2
-rw-r--r--l10n/oc.php2
-rw-r--r--l10n/pl.php25
-rw-r--r--l10n/pt_BR.php21
-rw-r--r--l10n/pt_PT.php42
-rw-r--r--l10n/ro.php10
-rw-r--r--l10n/ru.php21
-rw-r--r--l10n/ru_RU.php22
-rw-r--r--l10n/si_LK.php21
-rw-r--r--l10n/sk_SK.php21
-rw-r--r--l10n/sl.php21
-rw-r--r--l10n/sr.php5
-rw-r--r--l10n/sv.php21
-rw-r--r--l10n/ta_LK.php85
-rw-r--r--l10n/th_TH.php20
-rw-r--r--l10n/tr.php4
-rw-r--r--l10n/uk.php102
-rw-r--r--l10n/vi.php80
-rw-r--r--l10n/zh_CN.GB2312.php15
-rw-r--r--l10n/zh_CN.php21
-rw-r--r--l10n/zh_TW.php74
-rw-r--r--lib/item.php32
-rw-r--r--lib/itemmapper.php26
-rw-r--r--lib/search.php2
-rw-r--r--lib/serve.php96
-rw-r--r--lib/utils.php35
l---------news1
-rw-r--r--opmlexporter.php3
-rw-r--r--subscribe.php2
-rw-r--r--templates/main.php2
-rw-r--r--templates/part.items.php26
-rw-r--r--templates/part.shared.php12
-rw-r--r--templates/settings.php5
-rw-r--r--tests/index.php2
78 files changed, 1135 insertions, 797 deletions
diff --git a/ajax/importopml.php b/ajax/importopml.php
index adf14e86e..3733f5413 100644
--- a/ajax/importopml.php
+++ b/ajax/importopml.php
@@ -10,27 +10,49 @@
*
*/
+
+
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('news');
OCP\JSON::callCheck();
-session_write_close();
+global $l;
$l = OC_L10N::get('news');
function bailOut($msg) {
- OCP\JSON::error(array('data' => array('message' => $msg)));
+ global $eventSource;
+ $eventSource->send('error', $msg);
+ $eventSource->close();
OCP\Util::writeLog('news','ajax/importopml.php: '.$msg, OCP\Util::ERROR);
exit();
}
-if(!isset($_POST['path'])) {
- bailOut($l->t('No file path was submitted.'));
-}
+global $eventSource;
+$eventSource=new OC_EventSource();
require_once 'news/opmlparser.php';
-$raw = file_get_contents($_POST['path']);
+$source = isset( $_REQUEST['source'] ) ? $_REQUEST['source'] : '';
+$path = isset( $_REQUEST['path'] ) ? $_REQUEST['path'] : '';
+
+if($path == '') {
+ bailOut($l->t('Empty filename'));
+ exit();
+}
+
+if($source == 'cloud') {
+ $raw = file_get_contents($path);
+} elseif ($source == 'local') {
+ $storage = \OCP\Files::getStorage('news');
+ $raw = $storage->file_get_contents($path);
+} else {
+ bailOut($l->t('No source argument passed'));
+}
+
+if ($raw == false) {
+ bailOut($l->t('Error while reading file'));
+}
try {
$parsed = OPMLParser::parse($raw);
@@ -44,21 +66,34 @@ if ($parsed == null) {
$data = $parsed->getData();
-function importFeed($feedurl, $folderid) {
+function importFeed($feedurl, $folderid, $feedtitle) {
+
+ global $eventSource;
+ global $l;
+
$feedmapper = new OCA\News\FeedMapper();
$feedid = $feedmapper->findIdFromUrl($feedurl);
- $l = OC_L10N::get('news');
-
if ($feedid === null) {
$feed = OCA\News\Utils::slimFetch($feedurl);
-
+
if ($feed !== null) {
+ $feed->setTitle($feedtitle); //we want the title of the feed to be the one from the opml file
$feedid = $feedmapper->save($feed, $folderid);
+
+ $itemmapper = new OCA\News\ItemMapper(OCP\USER::getUser());
+ $unreadItemsCount = $itemmapper->countAllStatus($feedid, OCA\News\StatusFlag::UNREAD);
+
+ $tmpl_listfeed = new OCP\Template("news", "part.listfeed");
+ $tmpl_listfeed->assign('feed', $feed);
+ $tmpl_listfeed->assign('unreadItemsCount', $unreadItemsCount);
+ $listfeed = $tmpl_listfeed->fetchPage();
+
+ $eventSource->send('progress', array('data' => array('type'=>'feed', 'folderid'=>$folderid, 'listfeed'=>$listfeed)));
}
} else {
- OCP\Util::writeLog('news','ajax/importopml.php: Error adding feed: '. $feedurl, OCP\Util::ERROR);
- return false;
+ OCP\Util::writeLog('news','ajax/importopml.php: This feed is already here: '. $feedurl, OCP\Util::WARN);
+ return true;
}
if($feed === null || !$feedid) {
@@ -70,6 +105,10 @@ function importFeed($feedurl, $folderid) {
}
function importFolder($name, $parentid) {
+
+ global $eventSource;
+ global $l;
+
$foldermapper = new OCA\News\FolderMapper();
if($parentid != 0) {
@@ -80,8 +119,12 @@ function importFolder($name, $parentid) {
$folderid = $foldermapper->save($folder);
- $l = OC_L10N::get('news');
-
+ $tmpl = new OCP\Template("news" , "part.listfolder");
+ $tmpl->assign("folder", $folder);
+ $listfolder = $tmpl->fetchPage();
+
+ $eventSource->send('progress', array('data' => array('type'=>'folder', 'listfolder'=>$listfolder)));
+
if(!$folderid) {
OCP\Util::writeLog('news','ajax/importopml.php: Error adding folder' . $name, OCP\Util::ERROR);
return null;
@@ -95,7 +138,8 @@ function importList($data, $parentid) {
foreach($data as $collection) {
if ($collection instanceOf OCA\News\Feed) {
$feedurl = $collection->getUrl();
- if (importFeed($feedurl, $parentid)) {
+ $feedtitle = $collection->getTitle();
+ if (importFeed($feedurl, $parentid, $feedtitle)) {
$countsuccess++;
}
}
@@ -115,5 +159,6 @@ function importList($data, $parentid) {
$countsuccess = importList($data, 0);
-OCP\JSON::success(array('data' => array('title'=>$parsed->getTitle(), 'count'=>$parsed->getCount(),
+$eventSource->send('success', array('data' => array('title'=>$parsed->getTitle(), 'count'=>$parsed->getCount(),
'countsuccess'=>$countsuccess)));
+$eventSource->close();
diff --git a/ajax/selectfromcloud.php b/ajax/selectfromcloud.php
index 37d8053cb..eae8f0a81 100644
--- a/ajax/selectfromcloud.php
+++ b/ajax/selectfromcloud.php
@@ -41,5 +41,5 @@ if(!file_exists($localpath)) {
if (file_put_contents($tmpfname, file_get_contents($localpath))) {
OCP\JSON::success(array('data' => array('tmp'=>$tmpfname, 'path'=>$localpath)));
} else {
- bailOut(bailOut('Couldn\'t save temporary image: '.$tmpfname));
+ bailOut($l->t('Couldn\'t save temporary image: ').$tmpfname);
}
diff --git a/ajax/uploadopml.php b/ajax/uploadopml.php
new file mode 100644
index 000000000..d982e0324
--- /dev/null
+++ b/ajax/uploadopml.php
@@ -0,0 +1,42 @@
+<?php
+/**
+* ownCloud - News app
+*
+* @author Alessandro Cosentino
+* Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
+*
+* This file is licensed under the Affero General Public License version 3 or later.
+* See the COPYING-README file
+*
+*/
+
+// Check if we are a user
+OCP\JSON::checkLoggedIn();
+OCP\JSON::checkAppEnabled('news');
+OCP\JSON::callCheck();
+
+$l = OC_L10N::get('news');
+
+function bailOut($msg) {
+ OCP\JSON::error(array('data' => array('message' => $msg)));
+ OCP\Util::writeLog('news','ajax/uploadopml.php: '.$msg, OCP\Util::ERROR);
+ exit();
+}
+
+if (isset($_POST['path'])) {
+ OCP\JSON::success(array('data' => array('source'=> 'cloud', 'path' => $_POST['path'])));
+
+}
+elseif (isset($_FILES['file'])) {
+ $storage = \OCP\Files::getStorage('news');
+ $filename = 'opmlfile.xml';
+ if ($storage->fromTmpFile($_FILES['file']['tmp_name'], $filename)) {
+ OCP\JSON::success(array('data' => array('source'=> 'local', 'path' => $filename)));
+ } else {
+ bailOut('Could not create the temporary file');
+ }
+
+}
+else {
+ bailOut('No file loaded');
+}
diff --git a/appinfo/database.xml b/appinfo/database.xml
index c5b06bcac..fbc5a4d6f 100644
--- a/appinfo/database.xml
+++ b/appinfo/database.xml
@@ -179,6 +179,16 @@
<notnull>false</notnull>
</field>
<field>
+ <name>enclosure_mime</name>
+ <type>clob</type>
+ <notnull>false</notnull>
+ </field>
+ <field>
+ <name>enclosure_link</name>
+ <type>clob</type>
+ <notnull>false</notnull>
+ </field>
+ <field>
<name>feed_id</name>
<type>integer</type>
<notnull>true</notnull>
diff --git a/appinfo/version b/appinfo/version
index f1d68e6b5..a9212c01c 100644
--- a/appinfo/version
+++ b/appinfo/version
@@ -1,2 +1,2 @@
-7.5
+7.6
diff --git a/controllers/controller.php b/controllers/controller.php
index 43487f0ad..032cb45ee 100644
--- a/controllers/controller.php
+++ b/controllers/controller.php
@@ -10,15 +10,16 @@
*
*/
-
namespace OCA\News;
class Controller {
+ protected $userId;
protected $trans;
- private $safeParams;
+
public function __construct(){
+ $this->userId = \OCP\USER::getUser();
$this->trans = \OC_L10N::get('news');
$this->safeParams = array();
}
@@ -64,154 +65,36 @@ class Controller {
/**
- * Renders a renderer and sets the csrf check and logged in check to true
- * @param Renderer $renderer: the render which should be used to render the page
- */
- protected function render(Renderer $renderer){
- $renderer->render();
- }
-
-
- /**
* Binds variables to the template and prints it
- * @param $templateName the name of the template
+ * The following values are always assigned: userId, trans
* @param $arguments an array with arguments in $templateVar => $content
+ * @param $template the name of the template
* @param $safeParams template parameters which should not be escaped
* @param $fullPage if true, it will render a full page, otherwise only a part
* defaults to true
*/
- protected function renderTemplate($templateName, $arguments=array(),
- $safeParams=array(), $fullPage=true){
- $renderer = new TemplateRenderer($templateName, $fullPage);
- $renderer->bind($arguments);
- $renderer->bindSafe($safeParams);
- $this->render($renderer);
- }
-
- /**
- * Binds variables to a JSON array and prints it
- * @param $arguments an array with arguments in $key => $value
- * @param $error: Empty by default. If set, a log message written and the
- * $error will be sent to the client
- */
- protected function renderJSON($arguments=array(), $error=""){
- $renderer = new JSONRenderer($error);
- $renderer->bind($arguments);
- $this->render($renderer);
- }
-
-
-}
-
+ protected function render($template, $arguments=array(), $safeParams=array(),
+ $fullPage=true){
-/**
- * Renderers
- */
-interface Renderer {
- public function render();
- public function bind($params);
-}
-
-
-/**
- * Used to render a normal template
- */
-class TemplateRenderer implements Renderer {
-
- private $safeParams = array();
- private $template;
-
- /**
- * @param string $name: the template which we want to render
- * @param $fullPage: if the page should be included into the standard page
- */
- public function __construct($name, $fullPage=true){
if($fullPage){
- $this->template = new \OCP\Template('news', $name, 'user');
+ $template = new \OCP\Template('news', $template, 'user');
} else {
- $this->template = new \OCP\Template('news', $name);
+ $template = new \OCP\Template('news', $template);
}
- }
-
-
- /**
- * @brief binds parameters to the renderer which shouldnt be escaped
- * @param array $params: an array of the form $doNotEscape => true
- */
- public function bindSafe($params){
- $this->safeParams = $params;
- }
-
- /**
- * Bind parameters to the template
- * @param array $params: an array of the form $key => value which will be used
- * for access in templates
- */
- public function bind($params){
- foreach($params as $key => $value){
- if(array_key_exists($key, $this->safeParams)) {
- $this->template->assign($key, $value, false);
+ foreach($arguments as $key => $value){
+ if(array_key_exists($key, $safeParams)) {
+ $template->assign($key, $value, false);
} else {
- $this->template->assign($key, $value);
+ $template->assign($key, $value);
}
- }
- }
+ }
- /**
- * Print the page
- */
- public function render(){
- $this->template->printPage();
+ $template->assign('userId', $this->userId);
+ $template->assign('trans', $this->trans);
+ $template->printPage();
}
}
-
-
-
-/**
- * Use this to render JSON calls
- */
-class JSONRenderer implements Renderer {
-
- private $params;
-
- /**
- * @param string $error: if empty a success is sent, otherwise an error message
- * will be logged
- */
- public function __construct($error){
- $this->error = $error;
- }
-
-
- /**
- * Bind parameters to the template
- * @param array $params: an array which will be converted to JSON
- */
- public function bind($params){
- $this->params = $params;
- }
-
-
- /**
- * Print the json array
- */
- public function render(){
- if($this->error === ""){
- OCP\JSON::success($this->params);
- } else {
- OCP\JSON::error(array(
- 'data' => array('message' => $l->t('An error occured: ') . $error)
- )
- );
- OCP\Util::writeLog('news',$_SERVER['REQUEST_URI'] . 'Error: '. $error, OCP\Util::ERROR);
- exit();
- }
-
- }
-
-
-} \ No newline at end of file
diff --git a/controllers/news.controller.php b/controllers/news.controller.php
index bf31d08f2..daa84d13f 100644
--- a/controllers/news.controller.php
+++ b/controllers/news.controller.php
@@ -12,39 +12,35 @@
namespace OCA\News;
-require_once \OC_App::getAppPath('news') . '/controllers/controller.php';
-
-
class NewsController extends Controller {
/**
* Decides wether to show the feedpage or the firstrun page
*/
- public function index($request){
+ public function index(){
$feedMapper = new FeedMapper($this->userId);
if($feedMapper->feedCount() > 0){
- $this->feedPage($request);
+ $this->feedPage();
} else {
- $this->firstRun($request);
+ $this->firstRun();