Plugin Directory

Changeset 326446


Ignore:
Timestamp:
12/27/2010 07:51:44 PM (15 years ago)
Author:
Mantit
Message:

New feature: Server Chace

Location:
flickrstream/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • flickrstream/trunk/flickrstream.php

    r322861 r326446  
    11<?php
    2 
    32/*
    43Plugin Name: flickrStream
    54Plugin URI: http://timomontalto.com/flickrstream/
    65Description: Shows pictures from a flickr user photostream
    7 Version: 0.2
     6Version: 0.5
    87License: GPL
    98Author: Timo Montalto
     
    1110*/
    1211function get_flickrStream() {
     12
     13if (false === ( $ausgabe = get_transient('bilder_cache') ) ) {
     14
     15// Parameter fuer API call werden zusammengestellt
    1316$params_old = array(
    1417    'api_key'   => '4ef2fe2affcdd6e13218f5ddd0e2500d',
     
    1922);
    2023
     24// Options aus der Datenbank ziehen
    2125$shitname = get_option('flickrStream_flickrid');
    2226$zahl = get_option('flickrStream_display_numitems');
     27$imagesize = get_option('flickrStream_display_imagesize');
     28$cachetime = get_option('flickrStream_display_cachetime');
    2329
    24 $params2 = array();
     30// Parameter im Array mit den Daten der Optionspage updaten
     31$params = array();
    2532foreach($params_old as $key => $value) {
    2633   if($key == 'user_id') {
    27         $params2[''.$key.''] = $shitname;
    28    }else{
    29          $params2[''.$key.''] = $value;
    30      }
    31  }
    32 
    33 
    34 $params = array();
    35 foreach($params2 as $key => $value) {
    36    if($key == 'per_page') {
    37         $params[''.$key.''] = $zahl;
     34        $params[''.$key.''] = $shitname;
     35   }elseif ($key == 'per_page') {
     36        $params[''.$key.''] = $zahl;   
    3837   }else{
    3938         $params[''.$key.''] = $value;
     
    4140 }
    4241
     42
    4343$encoded_params = array();
    4444
    4545foreach ($params as $k => $v){
    46 
    4746    $encoded_params[] = urlencode($k).'='.urlencode($v);
    4847}
    4948
    50 
     49// API Call und daten in $rsp speichern
    5150$url = "http://api.flickr.com/services/rest/?".implode('&', $encoded_params);
    52 
    5351$rsp = file_get_contents($url);
    54 
    5552$rsp_obj = unserialize($rsp);
    5653
    57 $imagesize = get_option('flickrStream_display_imagesize');
    58 
     54// Bildergr?§e abrufen
    5955        if ($imagesize == "square") {
    6056                $imgurl = "_s.jpg";
    6157            } elseif ($imagesize == "thumbnail") {
    6258             $imgurl = "_t.jpg";
     59            } elseif ($imagesize == "small") {
     60             $imgurl = "_m.jpg";
    6361            } elseif ($imagesize == "medium") {
    64              $imgurl = "_m.jpg";
     62             $imgurl = "_z.jpg";
     63            } elseif ($imagesize == "large") {
     64             $imgurl = "_b.jpg";
    6565            }
    66 
     66// Wenn der Aufruf funktioniert hat...
    6767if ($rsp_obj['stat'] == 'ok'){ 
    6868
    6969  for($count = 0; $count < $zahl; $count++)
    7070  {
    71    echo "<div class='flickrsingle container" . $count . "'><img class='flickrimage flickrpic" . $count . "' src='http://farm" . $rsp_obj['photos']['photo'][$count]['farm'] . ".static.flickr.com/" . $photo_server1 = $rsp_obj['photos']['photo'][$count]['server'] . "/" . $photo_id1 = $rsp_obj['photos']['photo'][$count]['id'] . "_" . $photo_secret1 = $rsp_obj['photos']['photo'][$count]['secret'] . $imgurl . "' />";
    72     echo "<span class='flickrtext subline" . $count . "'>" . $photo_title1 = $rsp_obj['photos']['photo'][$count]['title'] . "</span></div>";
     71   $ausgabe .= "<div class='flickrsingle container" . $count . "'><a href='http://farm" . $rsp_obj['photos']['photo'][$count]['farm'] . ".static.flickr.com/" . $photo_server1 = $rsp_obj['photos']['photo'][$count]['server'] . "/" . $photo_id1 = $rsp_obj['photos']['photo'][$count]['id'] . "_" . $photo_secret1 = $rsp_obj['photos']['photo'][$count]['secret'] . "_z.jpg'><img class='flickrimage flickrpic" . $count . "' src='http://farm" . $rsp_obj['photos']['photo'][$count]['farm'] . ".static.flickr.com/" . $photo_server1 = $rsp_obj['photos']['photo'][$count]['server'] . "/" . $photo_id1 = $rsp_obj['photos']['photo'][$count]['id'] . "_" . $photo_secret1 = $rsp_obj['photos']['photo'][$count]['secret'] . $imgurl . "' title='" . $photo_title1 = $rsp_obj['photos']['photo'][$count]['title'] . "' /></a> <span class='flickrtext subline" . $count . "'>" . $photo_title1 = $rsp_obj['photos']['photo'][$count]['title'] . "</span></div>";
    7372  }
    7473
    7574}else{
    76 
     75// ...sonst erscheint Hinweis, das der Aufruf fehlschlug
    7776    echo "Aufruf fehlgeschlagen!";
    7877}
     78    $cachetime = "60*60*" . $cachetime;
     79     set_transient('bilder_cache', $ausgabe, $cachetime);
     80}
     81
     82echo get_transient('bilder_cache');
     83
    7984
    8085}
    81    
     86
    8287function flickrStream_subpanel() {
    8388     if (isset($_POST['save_flickrStream_settings'])) {
     89     
     90     // Daten werden aus Input Feldern gelesen
    8491       $option_flickrid = $_POST['flickr_id'];
    8592       $option_display_numitems = $_POST['display_numitems'];
    8693       $option_display_imagesize = $_POST['display_imagesize'];
    87 
     94       $option_display_cachetime = $_POST['display_cachetime'];
     95     // Daten werden in die Options Tabelle geschrieben
    8896       update_option('flickrStream_flickrid', $option_flickrid);
    8997       update_option('flickrStream_display_numitems', $option_display_numitems);
    9098       update_option('flickrStream_display_imagesize', $option_display_imagesize);
    91      
     99       update_option('flickrStream_display_cachetime', $option_display_cachetime);
     100     // Cache reseted
     101        delete_transient('bilder_cache');
    92102       ?> <div class="updated"><p>flickrStream Einstellungen gespeichert</p></div> <?php
    93103     }
    94 
    95104    ?>
    96 
    97105    <div class="wrap">
    98106        <h2>flickrStream Einstellungen</h2>
    99        
    100107        <form method="post">
    101108        <table class="form-table">
     
    108115          <th scope="row">Bilder anzeigen</th>
    109116          <td>
    110  
    111117            Wieviele?
    112118            <select name="display_numitems" id="display_numitems">
     
    138144              <option <?php if(get_option('flickrStream_display_imagesize') == 'small') { echo 'selected'; } ?> value="small">small</option>
    139145              <option <?php if(get_option('flickrStream_display_imagesize') == 'medium') { echo 'selected'; } ?> value="medium">medium</option>
     146              <option <?php if(get_option('flickrStream_display_imagesize') == 'large') { echo 'selected'; } ?> value="large">large</option>
    140147            </select>
    141          
     148            Cache-Zeit
     149            <select name="display_cachetime" id="display_cachetime">
     150              <option <?php if(get_option('flickrStream_display_cachetime') == '1') { echo 'selected'; } ?> value="1">1</option>
     151              <option <?php if(get_option('flickrStream_display_cachetime') == '3') { echo 'selected'; } ?> value="3">3</option>
     152              <option <?php if(get_option('flickrStream_display_cachetime') == '6') { echo 'selected'; } ?> value="6">6</option>
     153              <option <?php if(get_option('flickrStream_display_cachetime') == '8') { echo 'selected'; } ?> value="8">8</option>
     154              <option <?php if(get_option('flickrStream_display_cachetime') == '10') { echo 'selected'; } ?> value="10">10</option>
     155              <option <?php if(get_option('flickrStream_display_cachetime') == '12') { echo 'selected'; } ?> value="12">12</option>
     156              <option <?php if(get_option('flickrStream_display_cachetime') == '18') { echo 'selected'; } ?> value="18">18</option>
     157              <option <?php if(get_option('flickrStream_display_cachetime') == '24') { echo 'selected'; } ?> value="24">24</option>
     158              </select>
     159              Stunden
    142160           </td>
    143          </tr>
    144            
     161         </tr>
    145162                  </table>     
    146 <p>Die Ausgabe erfolgt durch die Platzierung von <strong>get_flickrStream();</strong> im Template</p>
     163<p>Die Ausgabe erfolgt durch die Platzierung von <strong>&lt;?php if ( function_exists('get_flickrStream') ) { get_flickrStream() } ?&gt;</strong> im Template</p>
    147164                <div class="submit">
    148165           <input type="submit" name="save_flickrStream_settings" value="<?php _e('Speichern', 'save_flickrStream_settings') ?>" />
     
    150167        </form>
    151168    </div>
    152 
    153169<?php }
    154 
    155 
    156170function flickrStream_admin_menu() {
    157171   if (function_exists('add_options_page')) {
  • flickrstream/trunk/readme.txt

    r322861 r326446  
    55Requires at least: 3.0
    66Tested up to: 3.0.3
    7 Stable tag: 0.2
     7Stable tag: 0.5
    88
    99Einfaches Wordpress Plugin, dass den Photostream eines flickr Users ausliest und die Bilder mit Titel ausgibt.
     
    2525== Changelog ==
    2626
     27= 0.5 =
     28* Performance upgrade
     29* Chache added
     30* size fix
     31
    2732= 0.2 =
    2833* Rechtschreibfehler behoben
Note: See TracChangeset for help on using the changeset viewer.