[ Index ]
 

Code source de Mantis 1.1.0rc3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/core/ -> collapse_api.php (source)

   1  <?php
   2  # Mantis - a php based bugtracking system
   3  
   4  # Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
   5  # Copyright (C) 2002 - 2007  Mantis Team   - mantisbt-dev@lists.sourceforge.net
   6  
   7  # Mantis is free software: you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation, either version 2 of the License, or
  10  # (at your option) any later version.
  11  #
  12  # Mantis is distributed in the hope that it will be useful,
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  # GNU General Public License for more details.
  16  #
  17  # You should have received a copy of the GNU General Public License
  18  # along with Mantis.  If not, see <http://www.gnu.org/licenses/>.
  19  
  20      # --------------------------------------------------------
  21      # $Id: collapse_api.php,v 1.6.2.1 2007-10-13 22:35:17 giallu Exp $
  22      # --------------------------------------------------------
  23  
  24      $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
  25  
  26      ### Collapse API ###
  27  
  28      #
  29      #    collapse_open( 'xyz' );        # marks the start of the expanded section
  30      #    :
  31      #    ... collapse_icon( 'xyz' );    # this will add the '+' icon
  32      #    :
  33      #    collapse_closed( 'xyz' );    # marks the start of the collapsed section
  34      #    :
  35      #    ... collapse_icon( 'xyz' );    # this will add the '-' icon
  36      #    :
  37      #    collapse_end( 'xyz' );        # marks the end of the whole section
  38      #
  39      # In javascript/common.js, add the g_div_xyz constants.
  40      #
  41  
  42      $g_current_collapse_section = null;
  43      $g_open_collapse_section = false;
  44  
  45      # ---------------
  46      # Use at the top of the section that should be visible when the section is expanded.
  47      # sections can not be nested
  48  	function collapse_open( $p_name ) {
  49          global $g_current_collapse_section, $g_open_collapse_section;
  50  
  51          # make sure no other collapse section is started
  52          if ( $g_current_collapse_section !== null ) {
  53              trigger_error( ERROR_GENERIC, ERROR );
  54          }
  55  
  56          $g_open_collapse_section = true;
  57          $g_current_collapse_section = $p_name;
  58  
  59          $t_div_id = $p_name . '_open';
  60          echo "<div id=\"$t_div_id\">";
  61      }
  62  
  63      # ---------------
  64      # Use to mark the end of the expanded section and the beginning of the closed section
  65      # the closed section will not be sent to the browser if $g_Use_javascript is OFF.
  66      # This is achieved using output buffering.
  67  	function collapse_closed( $p_name ) {
  68          global $g_current_collapse_section, $g_open_collapse_section;
  69  
  70          # Make sure a section is opened, and it is the same section.
  71          if ( $p_name !== $g_current_collapse_section ) {
  72              trigger_error( ERROR_GENERIC, ERROR );
  73          }
  74  
  75          echo '</div>';
  76  
  77          $g_open_collapse_section = false;
  78  
  79          ob_start();
  80  
  81          echo '<div id="', $p_name, '_closed" style="display: none;">';
  82      }
  83  
  84      # ---------------
  85      # This is used within both the open and closed section to identify the location where the
  86      # '+'/'-' icon should be placed.
  87  	function collapse_icon( $p_name ) {
  88          if ( OFF == config_get( 'use_javascript' ) ) {
  89              return;
  90          }
  91  
  92          global $g_open_collapse_section;
  93  
  94          if ( $g_open_collapse_section === true ) {
  95              $t_icon = 'minus.png';
  96              $t_alt  = '-';
  97          } else {
  98              $t_icon = 'plus.png';
  99              $t_alt  = '+';
 100          }
 101  
 102          echo "<a href=\"\" onclick=\"ToggleDiv( '$p_name', g_div_$p_name ); return false;\"
 103              ><img border=\"0\" src=\"images/$t_icon\" alt=\"$t_alt\" /></a>&nbsp;";
 104      }
 105  
 106      # ---------------
 107      # Mark the end of the collapsible section
 108  	function collapse_end( $p_name ) {
 109          global $g_current_collapse_section, $g_open_collapse_section;
 110  
 111  
 112          # Make sure a section is opened, and it is the same section.
 113          if ( $p_name !== $g_current_collapse_section ) {
 114              ob_end_clean();
 115              trigger_error( ERROR_GENERIC, ERROR );
 116          }
 117  
 118          echo '</div>';
 119  
 120          $g_open_collapse_section = false;
 121  
 122          if ( ON == config_get( 'use_javascript' ) ) {
 123              echo '<script type="text/javascript" language="JavaScript"><!--' . "\n";
 124              echo '    SetDiv( "', $p_name, '", g_div_', $p_name, ' );' . "\n";
 125              echo '--></script>';
 126  
 127              ob_end_flush();
 128          } else {
 129              ob_end_clean();
 130          }
 131  
 132          $g_current_collapse_section = null;
 133      }
 134  ?>


Généré le : Thu Nov 29 09:42:17 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics