]> git.mjollnir.org Git - s9y.git/commitdiff
Increase spartacus output
authorgarvinhicking <garvinhicking>
Fri, 27 May 2005 09:18:20 +0000 (09:18 +0000)
committergarvinhicking <garvinhicking>
Fri, 27 May 2005 09:18:20 +0000 (09:18 +0000)
docs/NEWS
plugins/serendipity_event_spartacus/serendipity_event_spartacus.php

index 59ca5d4c2216e019dd7e3619cb7d01ee04766aad..09b9f17adcb789a71067757309f4afd3cc4a5f47 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,9 @@
 Version 0.9 ()
 ------------------------------------------------------------------------
 
+    * Increased level of output message from the Spartacus plugin
+      (garvinhicking)
+
     * Patched XML-RPC functions, thanks to Tim Putnam. This should enable
       XML-RPC services to properly fetch existing articles and edit them.
 
index 9b2597a06d81d0cdd62ae25fb3b8acd3e4d86aec..ca58fefbb15036b609ba216162c8dc2c72d221ad 100644 (file)
@@ -21,7 +21,11 @@ switch ($serendipity['lang']) {
         @define('PLUGIN_EVENT_SPARTACUS_FETCH', 'Hier klicken um ein neues %s aus dem Netz zu installieren.');
         @define('PLUGIN_EVENT_SPARTACUS_FETCHERROR', 'Die URL %s konnte nicht geöffnet werden. Möglicherweise existieren Server- oder Netzwerkprobleme.');
         @define('PLUGIN_EVENT_SPARTACUS_FETCHING', 'Versuche URL %s zu öffnen...');
+        @define('PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_URL', '%s bytes von obiger URL geladen. Speichere Inhalt als %s...');
+        @define('PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_CACHE', '%s bytes von bereits bestehender Datei geladen. Speichere Inhalt als %s...');
+        @define('PLUGIN_EVENT_SPARTACUS_FETCHED_DONE', 'Data successfully fetched.');
         break;
+
     case 'en':
     default:
         @define('PLUGIN_EVENT_SPARTACUS_NAME', 'Spartacus');
@@ -29,6 +33,9 @@ switch ($serendipity['lang']) {
         @define('PLUGIN_EVENT_SPARTACUS_FETCH', 'Click here to fetch a new %s from the Serendipity Online Repository');
         @define('PLUGIN_EVENT_SPARTACUS_FETCHERROR', 'The URL %s could not be opened. Maybe the Serendipity or SourceForge.net Server is down - we are sorry, you need to try again later.');
         @define('PLUGIN_EVENT_SPARTACUS_FETCHING', 'Trying to open URL %s...');
+        @define('PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_URL', 'Fetched %s bytes from the URL above. Saving file as %s...');
+        @define('PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_CACHE', 'Fetched %s bytes from already existing file on your server. Saving file as %s...');
+        @define('PLUGIN_EVENT_SPARTACUS_FETCHED_DONE', 'Data successfully fetched.');
         break;
 }
 
@@ -44,7 +51,7 @@ class serendipity_event_spartacus extends serendipity_event
         $propbag->add('description',   PLUGIN_EVENT_SPARTACUS_DESC);
         $propbag->add('stackable',     false);
         $propbag->add('author',        'Garvin Hicking');
-        $propbag->add('version',       '1.01');
+        $propbag->add('version',       '1.1');
         $propbag->add('requirements',  array(
             'serendipity' => '0.8',
             'smarty'      => '2.6.7',
@@ -120,23 +127,30 @@ class serendipity_event_spartacus extends serendipity_event
     }
 
     function &fetchfile($url, $target, $cacheTimeout = 0) {
-        printf(PLUGIN_EVENT_SPARTACUS_FETCHING, '<a href="' . $url . '">' . serendipity_truncateString($url, 68) . '</a>');
+        printf(PLUGIN_EVENT_SPARTACUS_FETCHING, '<a href="' . $url . '">' . basename($url) . '</a>');
         echo '<br />';
 
         if (file_exists($target) && filesize($target) > 0 && filemtime($target) >= (time()-$cacheTimeout)) {
             $data = file_get_contents($target);
+            printf(PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_CACHE, strlen($data), $target);
+            echo '<br />';
         } else {
             require_once S9Y_INCLUDE_PATH . 'bundled-libs/HTTP/Request.php';
             $req = &new HTTP_Request($url);
 
             if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
                 printf(PLUGIN_EVENT_SPARTACUS_FETCHERROR, $url);
+                echo '<br />';
                 if (file_exists($target) && filesize($target) > 0) {
                     $data = file_get_contents($target);
+                    printf(PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_CACHE, strlen($data), $target);
+                    echo '<br />';
                 }
             } else {
                 // Fetch file
                 $data = $req->getResponseBody();
+                printf(PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_URL, strlen($data), $target);
+                echo '<br />';
                 $tdir = dirname($target);
                 if (!is_dir($tdir) && !$this->rmkdir($tdir)) {
                     printf(FILE_WRITE_ERROR, $tdir);
@@ -148,11 +162,14 @@ class serendipity_event_spartacus extends serendipity_event
 
                 if (!$fp) {
                     printf(FILE_WRITE_ERROR, $target);
+                    echo '<br />';
                     return false;
                 }
 
                 fwrite($fp, $data);
                 fclose($fp);
+                echo PLUGIN_EVENT_SPARTACUS_FETCHED_DONE;                
+                echo '<br />';
             }
         }
 
@@ -277,6 +294,7 @@ class serendipity_event_spartacus extends serendipity_event
         $pdir = $serendipity['serendipityPath'] . '/plugins/';
         if (!is_writable($pdir)) {
             printf(DIRECTORY_WRITE_ERROR, $pdir);
+            echo '<br />';
             return false;
         }