issue27, first trial of gallery export for HTML and MoinMoin markup
authorAndreas Unterkircher <unki@netshadow.at>
Tue, 10 Jul 2007 18:48:41 +0000 (18:48 +0000)
committerAndreas Unterkircher <unki@netshadow.at>
Tue, 10 Jul 2007 18:48:41 +0000 (18:48 +0000)
git-svn-id: file:///var/lib/svn/phpfspot/trunk@185 fa6a889d-dae6-447d-9e79-4ba9a3039384

phpfspot.class.php
phpfspot.js
rpc.php
templates/photo_index.tpl

index 3a6a59082a7c04e6943d18fb265fad8497f02fd2..14dff99eb0ed67e4681e97651c4f4b652bbb8505 100644 (file)
@@ -64,6 +64,11 @@ class PHPFSPOT {
                $_SESSION['selected_tags'] = split(',', $_GET['tags']);
             }
             break;
+         case 'export':
+            $this->tmpl->show("export.tpl");
+            return;
+            break;
+
       }
 
       $this->tmpl->assign('content_page', 'welcome.tpl');
@@ -594,7 +599,10 @@ class PHPFSPOT {
          $extern_link.= "&tags=". $current_tags;
       }
 
+      $export_link = "index.php?mode=export";
+
       $this->tmpl->assign('extern_link', $extern_link);
+      $this->tmpl->assign('export_link', $export_link);
       $this->tmpl->assign('count', $count);
       $this->tmpl->assign('width', $this->cfg->thumb_width);
       $this->tmpl->assign('images', $images);
@@ -1129,6 +1137,37 @@ class PHPFSPOT {
 
    } // get_calendar()
 
+   public function getExport($mode)
+   {
+      $pictures = $this->getPhotoSelection();
+
+      if(!isset($_SERVER['HTTPS'])) $protocol = "http";
+      else $protocol = "https";
+
+      $server_name = $_SERVER['SERVER_NAME'];
+
+      foreach($pictures as $picture) {
+
+         $orig_url = $protocol ."://". $server_name . $this->cfg->web_path ."phpfspot_img.php?idx=". $picture ."&width=". $this->cfg->photo_width;
+         $thumb_url = $protocol ."://". $server_name . $this->cfg->web_path ."phpfspot_img.php?idx=". $picture ."&width=". $this->cfg->thumb_width;
+
+         switch($mode) {
+
+            case 'HTML':
+               // <a href="%pictureurl%"><img src="%thumbnailurl%" ></a>
+               print htmlspecialchars("<a href=\"". $orig_url ."\"><img src=\"". $thumb_url ."\" /></a>") ."<br />\n";
+               break;
+               
+            case 'MoinMoin':
+               // [%pictureurl% %thumbnailurl%]
+               print htmlspecialchars("[$orig_url $thumb_url]") ."<br />\n";
+               break;
+         }
+
+      }
+
+   } // getExport()
+
 }
 
 ?>
index 4b6a640eaf2d86bb45e73a4be199d1c8a8c05e73..ce66cf6a35a924ec5f5a5e979575f5c06fb791ac 100644 (file)
@@ -117,7 +117,9 @@ function startTagSearch(searchfor)
 
 function setViewMode(mode)
 {
-   window.alert(mode);
+   var exprt = document.getElementById('output');
+   exprt.innerHTML = "Loading...";
+   exprt.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=get_export&mode=' + mode));
 }
 
 function clearSearch()
diff --git a/rpc.php b/rpc.php
index 9b56c48308967dd85ef41e9256919836e4d6bef6..704c921a63f9d9da033adbde9a25d9e9ab81e069 100644 (file)
--- a/rpc.php
+++ b/rpc.php
@@ -98,6 +98,11 @@ class PHPFSPOT_RPC {
             $fspot->startTagSearch($_GET['for']);
             break;
 
+         case 'get_export':
+
+            $fspot->getExport($_GET['mode']);
+            break;
+
       }
 
    } // process_ajax_request();
index 8aea9bc2555b5455c9251644cfa3c28aad5b7128..774e142d3ddd13f0297c30566c3f3bdc76cccef2 100644 (file)
       {/if}
      </td>
      <td class="index_header" style="text-align: right">
-      <form action="" onsubmit="setViewMode(document.getElementsByName('view')[0].options[document.getElementsByName('view')[0].selectedIndex].value); return false;">
       {if $extern_link }
        <a href="{$extern_link}" title="Use this link to return to the current view"><img src="resources/link.png" /></a>
       {/if} 
-       <select name="view">
-        <option value="photos" selected="selected">Photos</option>
-        <option value="html">HTML source</option>
-        <option value="moinmoin">MoinMoin markup</option>
-       </select>
-       <input type="image" src="resources/doit.png" alt="Switch View" />
-      </form>
+      <a href="{$export_link}" target="_blank">Export</a>
      </td>
     </tr>
    </table>