Source for file mod_templatechooser.php

Documentation is available at mod_templatechooser.php

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

Documentation generated on Mon, 05 May 2008 16:21:24 +0400 by phpDocumentor 1.4.0