[ Index ]
 

Code source de CMS made simple 1.0.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/plugins/ -> function.image.php (source)

   1  <?php
   2  #CMS - CMS Made Simple
   3  #(c)2004 by Ted Kulp (wishy@users.sf.net)
   4  #This project's homepage is: http://cmsmadesimple.sf.net
   5  #
   6  #This program is free software; you can redistribute it and/or modify
   7  #it under the terms of the GNU General Public License as published by
   8  #the Free Software Foundation; either version 2 of the License, or
   9  #(at your option) any later version.
  10  #
  11  #This program is distributed in the hope that it will be useful,
  12  #but WITHOUT ANY WARRANTY; without even the implied warranty of
  13  #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14  #GNU General Public License for more details.
  15  #You should have received a copy of the GNU General Public License
  16  #along with this program; if not, write to the Free Software
  17  #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18  
  19  function smarty_cms_function_image($params, &$smarty)
  20  {
  21      global $gCms;
  22  
  23      $text = '';
  24      $imgstart = '<img src=';
  25      $imgend = '/>';
  26      if( !empty($params['src'] ) )
  27      {
  28          $text = $imgstart .= '"'.$gCms->config['image_uploads_url'].'/'.$params['src'].'"';
  29          $size = @getimagesize($gCms->config['image_uploads_path'].'/'.$params['src']);
  30          
  31                  if( !empty($params['width'] ) ) {
  32                      $text .= ' width="'.$params['width'].'"';
  33                  } elseif ($size[0] > 0) {
  34                      $text .= ' width="'.$size[0].'"';
  35                  }
  36                  
  37                  if( !empty($params['height'] ) ) {
  38                      $text .= ' height="'.$params['height'].'"';
  39                  } elseif ($size[1] > 0) {
  40                      $text .= ' height="'.$size[1].'"';
  41                  }
  42                  if( !empty($params['alt'] ) )
  43                  {
  44                      $alt = $params['alt'];
  45                  } else {
  46                      $alt = '['.$params['src'].']';
  47                  }
  48                  $text .= ' alt="'.$alt.'"';
  49                  if( !empty($params['title'] ) )
  50                  {
  51                      $text .= ' title="'.$params['title'].'"';
  52                  } else {
  53                      $text .= ' title="'.$alt.'"';
  54                  }
  55                  if( !empty($params['class'] ) )
  56                  {
  57                      $text .= ' class="'.$params['class'].'"';
  58                  }
  59                  
  60                  if( !empty($params['addtext'] ) )
  61                  {
  62                          $text .= ' ' . $params['addtext'];
  63                  }
  64          $text .= $imgend;
  65      } else {
  66          $text = '<!-- empty results from image plugin -->';
  67      }
  68      return $text;    
  69  }
  70  
  71  
  72  function smarty_cms_help_function_image()
  73  {
  74    ?>
  75    <h3>What does this do?</h3>
  76    <p>Creates an image tag to an image stored within your images directory</p>
  77    <h3>How do I use it?</h3>
  78    <p>Just insert the tag into your template/page like: <code>{image src="something.jpg"}</code></p>
  79    <h3>What parameters does it take?</h3>
  80    <ul>
  81       <li><em>(required)</em>  <tt>src</tt> - Image filename within your images directory.</li>
  82       <li><em>(optional)</em>  <tt>width</tt> - Width of the image within the page. Defaults to true size.</li>
  83       <li><em>(optional)</em>  <tt>height</tt> - Height of the image within the page. Defaults to true size.</li>
  84       <li><em>(optional)</em>  <tt>alt</tt> - Alt text for the image -- needed for xhtml compliance. Defaults to filename.</li>
  85       <li><em>(optional)</em>  <tt>class</tt> - CSS class for the image.</li>
  86       <li><em>(optional)</em>  <tt>title</tt> - Mouse over text for the image. Defaults to Alt text.</li>
  87       <li><em>(optional)</em>  <tt>addtext</tt> - Additional text to put into the tag</li>
  88    </ul>
  89    <?php
  90  }
  91  
  92  
  93  function smarty_cms_about_function_image() 
  94  {
  95  ?>
  96    <p>Author:  Robert Campbell &lt;calguy1000@hotmail.com&gt;,</p>
  97    <p>Version 1.2</p>
  98    <p>Change History<br/>
  99       1.2 - Added default width, height and alt <small>(contributed by Walter Wlodarski)</small><br />
 100       1.1 - Added alt param and removed the </img><br />
 101       1.0 - Initial release<br/>
 102    </p>
 103  <?php
 104  }
 105  
 106  ?>


Généré le : Tue Apr 3 18:50:37 2007 par Balluche grâce à PHPXref 0.7