);
}
- protected function getPageContent(Url $url)
- {
- // Saving and clearing context
- $REAL = array();
- foreach( $GLOBALS as $key => $value ) {
- if( $key != 'GLOBALS' && $key != '_SESSION' && $key != 'HTTP_SESSION_VARS' ) {
- $GLOBALS[$key] = array();
- $REAL[$key] = $value;
- }
- }
- // Saving and clearing session
- $REAL_SESSION = array();
- foreach( $_SESSION as $key => $value ) {
- $REAL_SESSION[$key] = $value;
- unset($_SESSION[$key]);
- }
-
- // Running code in different context
- $scope = function() {
- extract( func_get_arg(1) );
- $_GET = $_REQUEST = array(
- "url" => $url->getUrl(),
- "max" => 5,
- "links" => "preserve",
- "exc" => "",
- "format" => "json",
- "submit" => "Create Feed"
- );
- ob_start();
- require func_get_arg(0);
- $json = ob_get_flush();
- return $json;
- };
- $json = $scope( "inc/3rdparty/makefulltextfeed.php", array("url" => $url) );
-
- // Clearing and restoring context
- foreach( $GLOBALS as $key => $value ) {
- if( $key != "GLOBALS" && $key != "_SESSION" ) {
- unset($GLOBALS[$key]);
- }
- }
- foreach( $REAL as $key => $value ) {
- $GLOBALS[$key] = $value;
- }
- // Clearing and restoring session
- foreach( $_SESSION as $key => $value ) {
- unset($_SESSION[$key]);
- }
- foreach( $REAL_SESSION as $key => $value ) {
- $_SESSION[$key] = $value;
- }
- return json_decode($json, true);
- }
-
/**
* Call action (mark as fav, archive, delete, etc.)
*/
switch ($action)
{
case 'add':
- $content = $this->getPageContent($url);
- $title = ($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled');
- $body = $content['rss']['channel']['item']['description'];
-
- // clean content from prevent xss attack
- $config = HTMLPurifier_Config::createDefault();
- $purifier = new HTMLPurifier($config);
- $title = $purifier->purify($title);
- $body = $purifier->purify($body);
+ if (!$import) {
+ $content = Tools::getPageContent($url);
+ $title = ($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled');
+ $body = $content['rss']['channel']['item']['description'];
+
+ // clean content from prevent xss attack
+ $config = HTMLPurifier_Config::createDefault();
+ $purifier = new HTMLPurifier($config);
+ $title = $purifier->purify($title);
+ $body = $purifier->purify($body);
+ }
+ else {
+ $title = '';
+ $body = '';
+ }
//search for possible duplicate if not in import mode
if (!$import) {
switch ($view)
{
case 'config':
- $dev = trim($this->getPocheVersion('dev'));
- $prod = trim($this->getPocheVersion('prod'));
+ $dev_infos = $this->getPocheVersion('dev');
+ $dev = trim($dev_infos[0]);
+ $check_time_dev = date('d-M-Y H:i', $dev_infos[1]);
+ $prod_infos = $this->getPocheVersion('prod');
+ $prod = trim($prod_infos[0]);
+ $check_time_prod = date('d-M-Y H:i', $prod_infos[1]);
$compare_dev = version_compare(POCHE, $dev);
$compare_prod = version_compare(POCHE, $prod);
$themes = $this->getInstalledThemes();
'languages' => $languages,
'dev' => $dev,
'prod' => $prod,
+ 'check_time_dev' => $check_time_dev,
+ 'check_time_prod' => $check_time_prod,
'compare_dev' => $compare_dev,
'compare_prod' => $compare_prod,
'token' => $token,
# the second <ol> is for read links
$read = 1;
}
- $this->messages->add('s', _('import from instapaper completed'));
+ $this->messages->add('s', _('import from instapaper completed. You have to execute the cron to fetch content.'));
Tools::logm('import from instapaper completed');
Tools::redirect();
}
# the second <ul> is for read links
$read = 1;
}
- $this->messages->add('s', _('import from pocket completed'));
+ $this->messages->add('s', _('import from pocket completed. You have to execute the cron to fetch content.'));
Tools::logm('import from pocket completed');
Tools::redirect();
}
}
}
}
- $this->messages->add('s', _('import from Readability completed. ' . $count . ' new links.'));
+ $this->messages->add('s', _('import from Readability completed. You have to execute the cron to fetch content.'));
Tools::logm('import from Readability completed');
Tools::redirect();
}
}
}
- $this->messages->add('s', _('import from Poche completed. ' . $count . ' new links.'));
+ $this->messages->add('s', _('import from Poche completed. You have to execute the cron to fetch content.'));
Tools::logm('import from Poche completed');
Tools::redirect();
}
Tools::redirect();
}
- $targetDefinition = 'IMPORT_' . strtoupper($from) . '_FILE';
- $targetFile = constant($targetDefinition);
-
- if (! defined($targetDefinition)) {
- $this->messages->add('e', _('Incomplete inc/poche/define.inc.php file, please define "' . $targetDefinition . '".'));
- Tools::redirect();
- }
+ $targetFile = CACHE . '/' . constant(strtoupper($from) . '_FILE');
if (! file_exists($targetFile)) {
$this->messages->add('e', _('Could not find required "' . $targetFile . '" import file.'));
$this->$providers[$from]($targetFile);
}
+ public function uploadFile() {
+ if(isset($_FILES['file']))
+ {
+ $dir = CACHE . '/';
+ $file = basename($_FILES['file']['name']);
+ if(move_uploaded_file($_FILES['file']['tmp_name'], $dir . $file)) {
+ $this->messages->add('s', _('File uploaded. You can now execute import.'));
+ }
+ else {
+ $this->messages->add('e', _('Error while importing file. Do you have access to upload it?'));
+ }
+ }
+
+ Tools::redirect('?view=config');
+ }
+
/**
* export poche entries in json
* @return json all poche entries
private function getPocheVersion($which = 'prod')
{
$cache_file = CACHE . '/' . $which;
+ $check_time = time();
# checks if the cached version file exists
if (file_exists($cache_file) && (filemtime($cache_file) > (time() - 86400 ))) {
$version = file_get_contents($cache_file);
+ $check_time = filemtime($cache_file);
} else {
$version = file_get_contents('http://static.wallabag.org/versions/' . $which);
file_put_contents($cache_file, $version, LOCK_EX);
}
- return $version;
+ return array($version, $check_time);
}
public function generateToken()
$feed = new FeedWriter(RSS2);
$feed->setTitle('wallabag — ' . $type . ' feed');
$feed->setLink(Tools::getPocheUrl());
- $feed->setChannelElement('updated', date(DATE_RSS , time()));
- $feed->setChannelElement('author', 'wallabag');
+ $feed->setChannelElement('pubDate', date(DATE_RSS , time()));
+ $feed->setChannelElement('generator', 'wallabag');
+ $feed->setDescription('wallabag ' . $type . ' elements');
if ($type == 'tag') {
$entries = $this->store->retrieveEntriesByTag($tag_id, $user_id);
<h2>{% trans "Saving articles" %}</h2>
<p>{% trans "There are several ways to save an article:" %} (<a href="http://doc.wallabag.org/" title="{% trans "read the documentation" %}">?</a>)</p>
<ul>
- <li>Firefox: <a href="https://addons.mozilla.org/firefox/addon/poche/" title="download the firefox extension">{% trans "download the extension" %}</a></li>
+ <li>Firefox: <a href="https://addons.mozilla.org/firefox/addon/wallabag/" title="download the firefox extension">{% trans "download the extension" %}</a></li>
<li>Chrome: <a href="http://doc.wallabag.org/doku.php?id=users:chrome_extension" title="download the chrome extension">{% trans "download the extension" %}</a></li>
- <li>Android: <a href="https://f-droid.org/repository/browse/?fdid=fr.gaulupeau.apps.Poche" title="download the application">{% trans "via F-Droid" %}</a> {% trans " or " %} <a href="https://play.google.com/store/apps/details?id=fr.gaulupeau.apps.InThePoche" title="download the application">{% trans "via Google Play" %}</a></li>
+ <li>Android: <a href="https://f-droid.org/app/fr.gaulupeau.apps.InThePoche" title="download the application">{% trans "via F-Droid" %}</a> {% trans " or " %} <a href="https://play.google.com/store/apps/details?id=fr.gaulupeau.apps.InThePoche" title="download the application">{% trans "via Google Play" %}</a></li>
+ <li>iOS: <a href="https://itunes.apple.com/app/wallabag/id828331015?mt=8" title="download the iOS application">{% trans "download the application" %}</a></li>
<li>Windows Phone: <a href="https://www.windowsphone.com/en-us/store/app/poche/334de2f0-51b5-4826-8549-a3d805a37e83" title="download the window phone application">{% trans "download the application" %}</a></li>
<li>
<form method="get" action="index.php">
<h2>{% trans "Upgrading wallabag" %}</h2>
<ul>
<li>{% trans "Installed version" %} : <strong>{{ constant('POCHE') }}</strong></li>
- <li>{% trans "Latest stable version" %} : {{ prod }}. {% if compare_prod == -1 %}<strong><a href="http://wallabag.org/">{% trans "A more recent stable version is available." %}</a></strong>{% else %}{% trans "You are up to date." %}{% endif %}</li>
- {% if constant('DEBUG_POCHE') == 1 %}<li>{% trans "Latest dev version" %} : {{ dev }}. {% if compare_dev == -1 %}<strong><a href="http://wallabag.org/">{% trans "A more recent development version is available." %}</a></strong>{% else %}{% trans "You are up to date." %}{% endif %}</li>{% endif %}
+ <li>{% trans "Latest stable version" %} : {{ prod }}. {% if compare_prod == -1 %}<strong><a href="http://wallabag.org/">{% trans "A more recent stable version is available." %}</a></strong>{% else %}{% trans "You are up to date." %}{% endif %} ({% trans "Last check:" %} {{ check_time_prod }})</li>
+ {% if constant('DEBUG_POCHE') == 1 %}<li>{% trans "Latest dev version" %} : {{ dev }}. {% if compare_dev == -1 %}<strong><a href="http://wallabag.org/">{% trans "A more recent development version is available." %}</a></strong>{% else %}{% trans "You are up to date." %}{% endif %} ({% trans "Last check:" %} {{ check_time_dev }}){% endif %}</li>
</ul>
+ <p>{% trans "You can clear cache to check the latest release." %}</p>
<h2>{% trans "Feeds" %}</h2>
{% if token == '' %}
{% endif %}
<h2>{% trans "Import" %}</h2>
- <p>{% trans "Please execute the import script locally as it can take a very long time." %}</p>
- <p>{% trans "More info in the official documentation:" %} <a href="http://doc.wallabag.org/doku.php?id=users:migrate">wallabag.org</a></p>
+ <p>1. {% trans "Select a file on your computer and upload it." %}</p>
+ <form method="post" action="?uploadfile" name="uploadfile" enctype="multipart/form-data">
+ <fieldset class="w500p">
+ <div class="row">
+ <label class="col w150p" for="file">{% trans "File:" %}</label>
+ <input class="col" type="file" id="file" name="file" tabindex="4">
+ </div>
+ <div class="row mts txtcenter">
+ <button class="bouton" type="submit" tabindex="4">{% trans "Upload" %}</button>
+ </div>
+ </fieldset>
+ <input type="hidden" name="MAX_FILE_SIZE" value="1048576">
+ <input type="hidden" name="returnurl" value="{{ referer }}">
+ </form>
+ <p>2. {% trans "Then, click on the right link below." %}</p>
<ul>
- <li><a href="./?import&from=pocket">{% trans "Import from Pocket" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('POCKET_FILE')) }}</li>
- <li><a href="./?import&from=readability">{% trans "Import from Readability" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('READABILITY_FILE')) }}</li>
- <li><a href="./?import&from=instapaper">{% trans "Import from Instapaper" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('INSTAPAPER_FILE')) }}</li>
- <li><a href="./?import&from=poche">{% trans "Import from wallabag" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('POCHE_FILE')) }}</li>
+ <li><a href="./?import&from=pocket">{% trans "Import from Pocket" %}</a> {{ '(after uploaded %s file)'|trans|format(constant('POCKET_FILE')) }}</li>
+ <li><a href="./?import&from=readability">{% trans "Import from Readability" %}</a> {{ '(after uploaded %s file)'|trans|format(constant('READABILITY_FILE')) }}</li>
+ <li><a href="./?import&from=instapaper">{% trans "Import from Instapaper" %}</a> {{ '(after uploaded %s file)'|trans|format(constant('INSTAPAPER_FILE')) }}</li>
+ <li><a href="./?import&from=poche">{% trans "Import from wallabag" %}</a> {{ '(after uploaded %s file)'|trans|format(constant('POCHE_FILE')) }}</li>
</ul>
+ {% if token == '' %}
+ <p>{% trans "3. Your feed token is currently empty and must first be generated to fetch content. Click <a href='?feed&action=generate'>here to generate it</a>." %}</p>
+ {% else %}
+ <p>3. {% trans "You can fetch content for imported items." %} <a href="cron.php?limit=10&user-id={{ user_id }}&token={{token}}" target="_blank">Click here</a> to fetch content for 10 articles.</p>
+ <p>{% trans "You can also create a cron task:" %}</p>
+ <pre><code>0 */4 * * * cd /path/to/wallabag && php cron.php --limit=10 --user-id={{user_id}} --token={{token}} >/dev/null 2>&1</code></pre>
+ {% endif %}
+
<h2>{% trans "Export your wallabag data" %}</h2>
{% if constant('STORAGE') == 'sqlite' %}
<p><a href="?download" target="_blank">{% trans "Click here" %}</a> {% trans "to download your database." %}</p>{% endif %}