| [ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare SiteMgr - Web Content Management * 4 * http://www.egroupware.org * 5 * ------------------------------------------------- * 6 * This was originaly a phpNuke block, the amazon_id has been changed * 7 * Copyright (C) 2004 RalfBecker@outdoor-training.de * 8 * -------------------------------------------- * 9 * This program is free software; you can redistribute it and/or modify it * 10 * under the terms of the GNU General Public License as published by the * 11 * Free Software Foundation; either version 2 of the License, or (at your * 12 * option) any later version. * 13 \**************************************************************************/ 14 15 /* $Id: class.module_amazon.inc.php 15190 2004-05-08 14:21:37Z ralfbecker $ */ 16 17 class module_amazon extends Module 18 { 19 function module_amazon() 20 { 21 $this->arguments = array( 22 'amazon_id' => array( 23 'type' => 'textfield', 24 'label' => lang('Own Amazon partner-id or empty to donate to the eGroupWare project') 25 ), 26 'amazon_server' => array( 27 'type' => 'textfield', 28 'label' => lang('Amazon server (without www), eg. amazon.com') 29 ), 30 'search' => array( 31 'type' => 'checkbox', 32 'label' => lang('Show searchbox') 33 ), 34 'asins' => array( 35 'type' => 'textarea', 36 'params' => array('rows' => 10,'cols' => 20), 37 'label' => lang("ASIN[=title] pairs (title is optional)") 38 ), 39 ); 40 //$this->post = array('asin' => array('type' => 'textfield')); 41 //$this->session = array('asin'); 42 $this->properties = array(); 43 $this->title = lang('Amazon'); 44 $this->description = lang('Use this module for displaying book ads for the amazon web site'); 45 } 46 47 function get_content(&$arguments,$properties) 48 { 49 $asins = explode("\n",$arguments['asins']); 50 if (!count($asins) || empty($asins[0])) 51 { 52 $asins = array('1565926102=Programming PHP'); 53 } 54 //echo "<p>module_amazon('$arguments[asins]') = ".print_r($asins,True)."</p>"; 55 56 mt_srand((double)microtime()*1000000); 57 $asin = count($asins) > 1 ? $asins[mt_rand(0, count($asins)-1)] : $asins[0]; 58 list($asin,$title) = explode('=',$asin); 59 60 $amazon_id = $arguments['amazon_id'] ? $arguments['amazon_id'] : "egroupware-21"; 61 $server = $arguments['amazon_server'] ? $arguments['amazon_server'] : 'amazon.com'; 62 $buy_at = ($title ? ': ' : '') . lang('Buy at %1',$server); 63 $base_url = ($_SERVER['HTTPS'] ? 'https://ssl-' : 'http://')."images.amazon.com/images/P"; 64 $content = "<div align=\"center\"><a href=\"http://www.$server/exec/obidos/ASIN/$asin/$amazon_id\" target=\"_blank\">" . 65 "<img src=\"$base_url/$asin.03.MZZZZZZZ.jpg\" border=\"0\" title=\"$title$buy_at\"><br>$title</a>\n"; 66 67 if ($arguments['search']) 68 { 69 $content .= "<p><form method=\"get\" action=\"http://www.$server/exec/obidos/external-search?tag=$amazon_id\" target=\"_blank\">". 70 '<INPUT type="text" name="keyword" size="10" value=""><input type="submit" value="'.lang('Search').'"></form>'; 71 } 72 else 73 { 74 $content .= '<br>'; 75 } 76 $content .= '</div>'; 77 return $content; 78 } 79 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |