Ejemplo n.º 1
0
 public function getPartialVars($partial, $nr, $info)
 {
     if (!$partial instanceof Kwf_Component_Partial_Random) {
         throw new Kwf_Exception('Only Kwf_Component_Partial_Random supported');
     }
     $select = new Kwf_Component_Select();
     $select->whereGenerator('child');
     $select->limit(1, $nr);
     return array('child' => $this->getData()->getChildComponent($select));
 }
Ejemplo n.º 2
0
 /**
  * Searches for component datas by it's dbId
  *
  * @param string
  * @param array|Kwf_Component_Select
  * @return Kwf_Component_Data[]
  */
 public function getComponentsByDbId($dbId, $select = array())
 {
     if (is_array($select)) {
         $select = new Kwf_Component_Select($select);
     }
     $cacheId = $dbId . $select->getHash();
     if (!isset($this->_componentsByDbIdCache[$cacheId])) {
         if (is_numeric(substr($dbId, 0, 1)) || substr($dbId, 0, 4) == 'root') {
             $data = $this->getComponentById($dbId, $select);
             if ($data) {
                 return array($data);
             } else {
                 return array();
             }
         }
         if ($select->hasPart(Kwf_Component_Select::LIMIT_COUNT)) {
             $limitCount = $select->getPart(Kwf_Component_Select::LIMIT_COUNT);
         }
         $ret = array();
         foreach (Kwc_Abstract::getComponentClasses() as $class) {
             foreach (Kwc_Abstract::getSetting($class, 'generators') as $key => $generator) {
                 if (isset($generator['dbIdShortcut']) && substr($dbId, 0, strlen($generator['dbIdShortcut'])) == $generator['dbIdShortcut']) {
                     $idParts = $this->_getIdParts(substr($dbId, strlen($generator['dbIdShortcut']) - 1));
                     $generator = Kwf_Component_Generator_Abstract::getInstance($class, $key);
                     if (count($idParts) <= 1) {
                         $generatorSelect = clone $select;
                     } else {
                         $generatorSelect = new Kwf_Component_Select();
                         // Select erst bei letzten Part
                         if ($select->hasPart(Kwf_Component_Select::IGNORE_VISIBLE)) {
                             $generatorSelect->ignoreVisible($select->getPart(Kwf_Component_Select::IGNORE_VISIBLE));
                         }
                         if ($select->hasPart(Kwf_Component_Select::WHERE_SUBROOT)) {
                             $generatorSelect->whereSubroot($select->getPart(Kwf_Component_Select::WHERE_SUBROOT));
                         }
                     }
                     if (isset($limitCount)) {
                         $generatorSelect->limit($limitCount - count($ret));
                     }
                     $generatorSelect->whereId($idParts[0]);
                     $data = $generator->getChildData(null, $generatorSelect);
                     unset($idParts[0]);
                     foreach ($data as $d) {
                         $componentId = $d->componentId . implode('', $idParts);
                         $data = $this->getComponentById($componentId, $select);
                         if ($data) {
                             $ret[] = $data;
                         }
                         if (isset($limitCount) && $limitCount - count($ret) <= 0) {
                             break 3;
                         }
                     }
                 }
             }
         }
         $this->_componentsByDbIdCache[$cacheId] = $ret;
     }
     return $this->_componentsByDbIdCache[$cacheId];
 }
Ejemplo n.º 3
0
 /**
  * Returns a single child pseudo page
  *
  * @see getChildPseudoPages
  * @return Kwf_Component_Data
  */
 public function getChildPseudoPage($select = array())
 {
     if (is_array($select)) {
         $select = new Kwf_Component_Select($select);
     }
     $select->limit(1);
     $ret = $this->getChildPseudoPages($select);
     if (!$ret) {
         return null;
     }
     return current($ret);
 }