Phundament-Packages
[ class tree: Phundament-Packages ] [ index: Phundament-Packages ] [ all elements ]

Source for file LMetaTextSelection.php

Documentation is available at LMetaTextSelection.php

  1. <?php
  2.  
  3.  
  4. /**
  5.  * class file.
  6.  *
  7.  * @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
  8.  * @copyright 2005, diemeisterei GmbH. All rights reserved.
  9.  * @author $Author: schmunk $
  10.  * @version $Revision: 321 $  $Date: 2006-08-22 16:36:12 +0000 (Di, 22 Aug 2006) $
  11.  * @package Phundament.Packages
  12.  * @subpackage LMetaText
  13.  */
  14.  
  15. /**
  16.  * Implements IMetaData. (TODO)
  17.  *
  18.  * Displays a selection for media files
  19.  *
  20.  * @package System.Web.UI.WebControls
  21.  * @subpackage MetaData
  22.  */
  23.  
  24.  
  25. class LMetaTextSelection extends TTemplateControl implements IMetaData
  26. {
  27.     private $Core;
  28.  
  29.     /**
  30.      * Prepares the core
  31.      */
  32.     public function onInit($param)
  33.     {
  34.         parent :: onInit($param);
  35.         $this->Corenew LMetaTextCore;
  36.         $this->getData();
  37.     }
  38.  
  39.  
  40.     public function getData()
  41.     {
  42.         $_cd split(":",$this->CustomData);
  43.  
  44.         $c new LMetaTextCriteria;
  45.         $c->setCategory($_cd[1]);
  46.         $items$this->Core->queryRecords($c->build());
  47.  
  48.         // fill grid
  49.         $this->Repeater->DataSource$items;
  50.         $this->Repeater->dataBind();
  51.     }
  52.  
  53.     /**
  54.      * @return array selected items in both lists
  55.      */
  56.     public function getSelection()
  57.     {
  58.         $returnarray ();
  59.  
  60.         // get selection from search
  61.         $items$this->Repeater->getItems();
  62.         foreach ($items AS $item)
  63.         {
  64.             if ($item->Select->getChecked())
  65.             {
  66.                 $r['MetaRecordId']$item->Select->Value;
  67.                 #$r['Description']= $item->Cells[2]->MediaDescription->Text;
  68.                 #$r['Rank']= "z";
  69.                 $return[]$r;
  70.             }
  71.         }
  72.  
  73.         return $return;
  74.     }
  75.  
  76.     /**
  77.      * @param array sets selection from database and current selection
  78.      */
  79.     public function setSelection($arraynull)
  80.     {
  81.         $selection$array;
  82.  
  83.         // parse data for later usage
  84.         $idsnull;
  85.         if (is_array($selection))
  86.             foreach ($selection AS $s)
  87.             {
  88.                 $ids[]$s['MetaRecordId'];
  89.                 if (isset ($s['Description']))
  90.                     $info[$s['MetaRecordId']]array (
  91.                         $s['Description'],
  92.                         $s['Rank']
  93.                     );
  94.             }
  95.         else
  96.         {
  97.             $idsarray ();
  98.         }
  99.         if ($ids == nullreturn;
  100.  
  101.         $this->getData();
  102.  
  103.         // set checkbox & set values in selected grid
  104.         $selected_items$this->Repeater->getItems();
  105.         foreach ($selected_items AS $item)
  106.         {
  107.             if (in_array($item->Select->Value,$ids)) $item->Select->setChecked(true);
  108.         }
  109.  
  110.     }
  111.  
  112. }
  113. ?>

Documentation generated on Sun, 25 Feb 2007 16:11:17 +0100 by phpDocumentor 1.3.1