[ Index ]
 

Code source de CMS made simple 1.0.5

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

title

Body

[fermer]

/lib/sllists/ -> SLLists.class.php (source)

   1  <?php
   2  /*

   3  * This class implements a PHP wrapper around the scriptaculous javascript libraries created by

   4  * Thomas Fuchs (http://script.aculo.us/).

   5  *

   6  * SLLists was created by Greg Neustaetter in 2005 and may be used for free by anyone for any purpose.  Just keep my name in here please and

   7  * give me credit if you like, but give Thomas all the real credit!

   8  */
   9  class SLLists {
  10  
  11      var $lists;
  12      var $jsPath;
  13      var $debug;
  14      
  15  	function SLLists($jsPath) {
  16          $this->lists = array();
  17          $this->jsPath = $jsPath;
  18          $this->debug = false;
  19      }
  20      
  21  	function addList($list, $input, $tag = 'li', $additionalOptions = '') {
  22          if ($additionalOptions != '') $additionalOptions = ','.$additionalOptions;
  23          $this->lists[] = array("list" => $list, "input" => $input, "tag" => $tag, "additionalOptions" => $additionalOptions);
  24      }
  25      
  26  	function printTopJS() {
  27          ?>
  28          <script src="<?php echo $this->jsPath;?>/prototype.js" type="text/javascript"></script>
  29          <script src="<?php echo $this->jsPath;?>/scriptaculous.js" type="text/javascript"></script>
  30          <?php
  31      }
  32      
  33  	function printJSFunction()
  34      {
  35          $result = '';
  36          foreach($this->lists as $list) {
  37              $result .= 'document.getElementById(\''.$list['input'].'\').value = Sortable.serialize(\''.$list['list'].'\');';
  38          }
  39          return $result;
  40      }
  41      
  42  	function printBottomJs() {
  43          ?>
  44              <?php
  45              foreach($this->lists as $list) {
  46                  ?>
  47                  Sortable.create('<?php echo $list['list'];?>',{tag:'<?php echo $list['tag'];?>'<?php echo $list['additionalOptions'];?>});
  48                  <?php
  49              }
  50              ?>
  51          <?php
  52      }
  53      
  54  	function printHiddenInputs() {
  55          $inputType = ($this->debug) ? 'text' : 'hidden';
  56  
  57          foreach($this->lists as $list) {
  58              if ($this->debug) echo '<br />'.$list['input'].': ';
  59              ?>
  60              <input type="<?php echo $inputType;?>" name="<?php echo $list['input'];?>" id="<?php echo $list['input'];?>" size="60">
  61              <?php
  62          }
  63          if ($this->debug) echo '<br />';
  64      }
  65      
  66  	function printForm($action, $method = 'POST', $submitText = 'Submit', $submitClass = '', $formName = 'sortableListForm', $cancelText = 'Cancel', $listcontent = '') {
  67          ?>
  68          <form action="<?php echo $action;?>" method="<?php echo $method;?>" onsubmit="<?php echo $this->printJSFunction(); ?>xajax_reorder_process(xajax.getFormValues('<?php echo $formName;?>'));return false;" name="<?php echo $formName;?>" id="<?php echo $formName;?>">
  69              <input type="submit" value="<?php echo $submitText ?>" class="<?php echo $submitClass;?>" />
  70              <input type="button" value="<?php echo $cancelText; ?>" class="<?php echo $submitClass;?>" onclick="xajax_content_list_ajax(); return false;" />
  71              <?php echo $listcontent ?>
  72              <?php $this->printHiddenInputs();?>
  73              <input type="hidden" name="sortableListsSubmitted" value="true" />
  74              <?php
  75              if ($this->debug) {
  76                  ?><input type="button" value="View Serialized Lists" class="<?php echo $submitClass;?>" onClick="populateHiddenVars();" /><br /><?php
  77              }
  78              ?>
  79              <input type="submit" value="<?php echo $submitText ?>" class="<?php echo $submitClass;?>" />
  80              <input type="button" value="<?php echo $cancelText; ?>" class="<?php echo $submitClass;?>" onclick="xajax_content_list_ajax(); return false;" />
  81          </form>
  82          <?php
  83      }
  84      
  85  	function getOrderArray($input,$listname,$itemKeyName = 'element',$orderKeyName = 'order') {
  86          parse_str($input,$inputArray);
  87          $inputArray = $inputArray[$listname];
  88          $orderArray = array();
  89          for($i=0;$i<count($inputArray);$i++) {
  90              $orderArray[] = array($itemKeyName => $inputArray[$i], $orderKeyName => $i +1);
  91          }
  92          return $orderArray;
  93      }
  94  
  95  }


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