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

Source for file LInterlinkCore.php

Documentation is available at LInterlinkCore.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: 382 $  $Date: 2006-11-16 11:41:32 +0100 (Thu, 16 Nov 2006) $
  11.  * @package Phundament.Packages
  12.  * @subpackage LInterlink
  13.  */
  14.  
  15. Prado :: setPathOfAlias("LInterlink"dirname(__FILE__));
  16. Prado :: using("LInterlink.db.propel.*");
  17. Prado :: using("LInterlink.db.propel.l_interlink.*");
  18.  
  19.  
  20. /**
  21.  * @package System.Collections
  22.  */
  23. {
  24.     private $_rank null;
  25.     private $_custom_data null;
  26.  
  27.     public function __construct($rank null$custom_data null)
  28.     {
  29.         $this->_rank $rank;
  30.         $this->_custom_data $custom_data;    
  31.     }
  32.     
  33.     public function getRank()
  34.     {
  35.         return $this->_rank;
  36.     }
  37.  
  38.     public function getCustomData()
  39.     {
  40.         return $this->_custom_data;
  41.     }
  42. }
  43.  
  44. /**
  45.  * @package System.Collections
  46.  */
  47. class LRelation extends TMap 
  48. {
  49.     private $_key;
  50.     private $_category;
  51.     private $_source_id;
  52.     
  53.     public function __construct($key$category$source_id$records)
  54.     {
  55.         $this->_key $key;
  56.         $this->_category $category;
  57.         $this->_source_id $source_id;
  58.         
  59.         foreach($records as $rec)
  60.         {
  61.             $entry new LRelationEntry($rec->getRank()$rec->getCustomData());
  62.             $this->add($rec->getDestinationId()$entry);
  63.         }
  64.     }
  65.     
  66.     public function save()
  67.     {
  68.         $conn Prado::getApplication()->getModule("database")->getConnection("l_interlink""propel");
  69.         $cnew Criteria();
  70.         $c->add(LInterlinkPeer :: KEY$this->_key);
  71.         $c->add(LInterlinkPeer :: CATEGORY$this->_category);
  72.         $c->add(LInterlinkPeer :: SOURCE_ID$this->_source_id);
  73.         LInterlinkPeer :: doDelete($c$conn);
  74.         foreach($this as $dest_id => $entry)
  75.         {
  76.             $r new LInterlink;
  77.             $r->setKey($this->_key);        
  78.             $r->setCategory($this->_category);        
  79.             $r->setSourceId($this->_source_id);
  80.             $r->setDestinationId($dest_id);
  81.             $r->setRank($entry->getRank());
  82.             $cust $entry->getCustomData();
  83.             if ($cust !== null)
  84.                 $r->setCustomData($cust);
  85.             $r->save();
  86.         }
  87.     }
  88. }
  89.  
  90.  
  91. /**
  92.  * @package System.Util
  93.  * @subpackage Cores
  94.  */
  95.  
  96. class LInterlinkCore extends TModule
  97. {
  98.     protected $_links = array();
  99.  
  100.     public function init($config)
  101.     {
  102.         Prado::trace("Initializing interlink module ...""Lithron.LInterlink");
  103.         $links $config->getElementsByTagName("link");
  104.          foreach($links as $link)
  105.          {
  106.             $link_akku array();             
  107.              $categories $link->    getElementsByTagName("category");
  108.              foreach($categories as $category)
  109.              {
  110.                  $cat_akku array();
  111.                  $statements $category->    getElements();
  112.                  foreach($statements as $statement)
  113.                  {
  114.                     switch($statement->getTagName())
  115.                     {
  116.                         case "selection":
  117.                             $cat_akku["selection"$statement->getAttribute("class");
  118.                     }                     
  119.                  }
  120.                  $link_akku[$category->getAttribute("id")$cat_akku;    
  121.              }
  122.              $this->_links[$link->getAttribute("key")$link_akku;
  123.          }
  124.     }
  125.  
  126.     public function getCategories($link)
  127.     {
  128.         if (isset($this->_links[$link]))
  129.             return $this->_links[$link];
  130.         else
  131.             return array();
  132.     }
  133.     
  134.     public function getSelectionControlClassName($link$category)
  135.     {
  136.         if (isset($this->_links[$link]&& 
  137.             isset($this->_links[$link][$category]&&
  138.             isset($this->_links[$link][$category]["selection"]))
  139.             return $this->_links[$link][$category]["selection"];
  140.         else
  141.             return null;
  142.     }
  143.  
  144.      public function loadRelation($key$category$source_id)
  145.      {
  146.         $conn $this->Application->getModule("database")->getConnection("l_interlink""propel");
  147.         $cnew Criteria();
  148.         $c->add(LInterlinkPeer :: KEY$key);
  149.         $c->add(LInterlinkPeer :: CATEGORY$category);
  150.         $c->add(LInterlinkPeer :: SOURCE_ID$source_id);
  151.         $c->addAscendingOrderByColumn(LInterlinkPeer :: RANK);
  152.         $records LInterlinkPeer :: doSelect($c$conn);
  153.         return new LRelation($key$category$source_id$records);
  154.      }
  155.      
  156. }
  157.  
  158. ?>

Documentation generated on Sun, 25 Feb 2007 16:10:46 +0100 by phpDocumentor 1.3.1