Ejemplo n.º 1
0
 protected function _formatConfig($parentData, $row)
 {
     $ret = parent::_formatConfig($parentData, $row);
     //im pages generator fangen die ids immer von vorne an
     $id = $this->_getIdFromRow($row);
     if (!is_numeric($id)) {
         throw new Kwf_Exception("Id must be numeric");
     }
     $idParent = $parentData;
     while ($idParent->componentClass != $this->_class) {
         $idParent = $idParent->parent;
     }
     $id = $this->_getIdFromRow($row);
     $ret['componentId'] = $idParent->componentId . $this->getIdSeparator() . $id;
     $ret['dbId'] = $idParent->dbId . $this->getIdSeparator() . $id;
     //parent geradebiegen
     if (!$parentData || $parentData->componentClass == $this->_class && is_numeric($ret['chained']->parent->componentId)) {
         $c = new Kwf_Component_Select();
         $c->ignoreVisible(true);
         $c->whereId('_' . $ret['chained']->parent->componentId);
         $parentData = $parentData->getChildComponent($c);
     }
     $ret['parent'] = $parentData;
     return $ret;
 }
Ejemplo n.º 2
0
 public function setComponentId($componentId)
 {
     $c = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($componentId, array('ignoreVisible' => true));
     $s = new Kwf_Component_Select();
     $s->ignoreVisible();
     $s->whereGenerator('detail');
     foreach ($c->getChildComponents($s) as $c) {
         $this->_data[$c->componentId] = array('id' => $c->chained->row->id, 'component_id' => $componentId, 'original_name' => $c->chained->row->name, 'name' => $c->row->name, 'row' => $c->row, 'visible' => $c->row->visible);
     }
 }
Ejemplo n.º 3
0
 public function setComponentId($componentId)
 {
     $c = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($componentId, array('ignoreVisible' => true));
     $s = new Kwf_Component_Select();
     $s->ignoreVisible();
     $s->whereGenerator('child');
     $i = 0;
     foreach ($c->getChildComponents($s) as $c) {
         $this->_data[$c->componentId] = array('id' => $c->chained->row->id, 'pos' => $i++, 'component_id' => $componentId, 'row' => $c->row, 'name' => $c->targetPage->name);
     }
 }
Ejemplo n.º 4
0
 public function setComponentId($componentId)
 {
     $c = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($componentId, array('ignoreVisible' => true));
     $s = new Kwf_Component_Select();
     $s->ignoreVisible();
     $s->whereGenerator('child');
     foreach ($c->getChildComponents($s) as $c) {
         $row = $c->generator->getTrlRowByData($c);
         $this->_data[$c->componentId] = array('id' => $c->chained->row->id, 'component_id' => $componentId, 'row' => $row, 'pos' => isset($c->chained->row->pos) ? $c->chained->row->pos : null);
         foreach ($this->_translateFields as $tf) {
             $this->_data[$c->componentId][$tf] = $row->{$tf};
         }
     }
 }
Ejemplo n.º 5
0
 public function setComponentId($componentId)
 {
     $c = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($componentId, array('ignoreVisible' => true));
     $s = new Kwf_Component_Select();
     $s->ignoreVisible();
     $s->whereGenerator('paragraphs');
     $chainedModel = Kwc_Abstract::createChildModel($c->componentClass);
     foreach ($c->getChildComponents($s) as $c) {
         $chainedRow = $chainedModel->getRow($c->dbId);
         if (!$chainedRow) {
             $chainedRow = $chainedModel->createRow(array('component_id' => $c->dbId, 'visible' => false));
         }
         $this->_data[$c->componentId] = array('id' => $c->chained->row->id, 'component_id' => $componentId, 'component_class' => $c->componentClass, 'component_name' => Kwf_Trl::getInstance()->trlStaticExecute(Kwc_Abstract::getSetting($c->componentClass, 'componentName')), 'component_icon' => (string) new Kwf_Asset(Kwc_Abstract::getSetting($c->componentClass, 'componentIcon')), 'row' => $chainedRow, 'visible' => $chainedRow->visible, 'pos' => $c->chained->row->pos);
     }
 }
Ejemplo n.º 6
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.º 7
0
 public static function getMediaOutput($id, $type, $className)
 {
     $s = new Kwf_Component_Select();
     $s->ignoreVisible(true);
     $component = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($id, $s);
     $row = $component->getComponent()->getRow();
     if ($type == 'webm') {
         $uploadRow = $row->getParentRow('FileWebm');
         $mimeType = 'video/webm';
     } else {
         if ($type == 'mp4') {
             $uploadRow = $row->getParentRow('FileMp4');
             $mimeType = 'video/mp4';
         } else {
             if ($type == 'ogg') {
                 $uploadRow = $row->getParentRow('FileOgg');
                 $mimeType = 'video/ogg';
             }
         }
     }
     if (!$uploadRow) {
         return null;
     }
     return array('file' => $uploadRow->getFileSource(), 'mimeType' => $mimeType);
 }