[ PHPXref.com ] [ Generated: Sun Jul 20 18:31:57 2008 ] [ Mambo 4.6 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/modules/ -> mod_templatechooser.php (source)

   1  <?php
   2  /**
   3  * @package Mambo Open Source
   4  * @copyright (C) 2005 - 2006 Mambo Foundation Inc.
   5  * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
   6  *
   7  * Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure
   8  * that Mambo remained free Open Source software owned and managed by the community.
   9  * Mambo is Free Software
  10  */
  11  
  12  /** ensure this file is being included by a parent file */
  13  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  14  
  15  global $cur_template;
  16  
  17  // titlelength can be set in module params
  18  $titlelength = $params->get( 'title_length', 20 );
  19  $preview_height = $params->get( 'preview_height', 90 );
  20  $preview_width = $params->get( 'preview_width', 140 );
  21  $show_preview = $params->get( 'show_preview', 0 );
  22  
  23  // Read files from template directory
  24  $template_path = "$mosConfig_absolute_path/templates";
  25  $templatefolder = @dir( $template_path );
  26  $darray = array();
  27  if ($templatefolder) {
  28      while ($templatefile = $templatefolder->read()) {
  29          if ($templatefile != "." && $templatefile != ".." && $templatefile != "CVS" && is_dir( "$template_path/$templatefile" )  ) {
  30              if(strlen($templatefile) > $titlelength) {
  31                  $templatename = substr( $templatefile, 0, $titlelength-3 );
  32                  $templatename .= "...";
  33              } else {
  34                  $templatename = $templatefile;
  35              }
  36              $darray[] = mosHTML::makeOption( $templatefile, $templatename );
  37          }
  38      }
  39      $templatefolder->close();
  40  }
  41  
  42  sort( $darray );
  43  
  44  // Show the preview image
  45  // Set up JavaScript for instant preview
  46  $onchange = "";
  47  if ($show_preview) {
  48      $onchange = "showimage()";
  49  ?>
  50  <img src="<?php echo "templates/$cur_template/template_thumbnail.png";?>" name="preview" border="1" width="<?php echo $preview_width;?>" height="<?php echo $preview_height;?>" alt="<?php echo $cur_template; ?>" />
  51  <script language='JavaScript1.2' type='text/javascript'>
  52  <!--
  53      function showimage() {
  54          //if (!document.images) return;
  55          document.images.preview.src = 'templates/' + getSelectedValue( 'templateform', 'mos_change_template' ) + '/template_thumbnail.png';
  56      }
  57  	function getSelectedValue( frmName, srcListName ) {
  58          var form = eval( 'document.' + frmName );
  59          var srcList = eval( 'form.' + srcListName );
  60  
  61          i = srcList.selectedIndex;
  62          if (i != null && i > -1) {
  63              return srcList.options[i].value;
  64          } else {
  65              return null;
  66          }
  67      }
  68  -->
  69  </script>
  70  <?php
  71  }
  72  ?>
  73  <form action="<?php echo $_SERVER['REQUEST_URI'];?>" name='templateform' method="post">
  74  <?php
  75  echo mosHTML::selectList( $darray, 'mos_change_template', "class=\"button\" onchange=\"$onchange\"",'value', 'text', $cur_template );
  76  ?>
  77  <input class="button" type="submit" value="<?php echo T_('Select');?>" />
  78  </form>


[ Powered by PHPXref - Served by Debian GNU/Linux ]