Esempio n. 1
0
 protected final function _process()
 {
     $filename = $this->_root->filename;
     Kwf_Events_ModelObserver::getInstance()->process();
     Kwf_Component_Data_Root::reset();
     $this->_root = Kwf_Component_Data_Root::getInstance();
     $this->_root->setFilename($filename);
 }
Esempio n. 2
0
 protected function _getSelect()
 {
     $ret = parent::_getSelect();
     $component = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($this->_getParam('componentId'), array('ignoreVisible' => true));
     $ret->whereEquals('component_id', $component->chained->dbId);
     return $ret;
 }
Esempio n. 3
0
 /**
  * Gibt den Komponenten-Baum aus (für CLI)
  **/
 public static function output()
 {
     $componentClass = Kwf_Component_Data_Root::getComponentClass();
     $model = new self();
     $maxComponentLength = self::_maxComponentLength($componentClass, $model);
     self::_output(null, $model, $maxComponentLength);
 }
 public static function getMediaOutput($id, $type, $className)
 {
     $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible' => true));
     $cls = $c->chained->componentClass;
     $cls = strpos($cls, '.') ? substr($cls, 0, strpos($cls, '.')) : $cls;
     return call_user_func(array($cls, 'getMediaOutput'), $c->chained->componentId, $type, $c->chained->componentClass);
 }
Esempio n. 5
0
 public function __construct()
 {
     $providers = array();
     if (Kwf_Component_Data_Root::getComponentClass()) {
         $providers[] = new Kwf_Assets_Components_Provider(Kwf_Component_Data_Root::getComponentClass());
     } else {
         $providers[] = new Kwf_Assets_Provider_NoComponents();
     }
     if (file_exists('dependencies.ini')) {
         $providers[] = new Kwf_Assets_Provider_Ini('dependencies.ini');
     }
     $providers = array_merge($providers, self::getVendorProviders());
     $providers[] = new Kwf_Assets_Provider_IniNoFiles();
     $providers[] = new Kwf_Assets_Provider_Dynamic();
     $providers[] = new Kwf_Assets_TinyMce_Provider();
     $providers[] = new Kwf_Assets_Provider_JsClassKwf();
     $providers[] = new Kwf_Assets_Provider_JsClass('./ext', 'web/ext', 'App');
     $providers[] = new Kwf_Assets_Provider_CssByJs(array('web/ext', 'kwf/commonjs'));
     $providers[] = new Kwf_Assets_Provider_ExtTrl();
     $providers[] = new Kwf_Assets_Provider_ErrorHandler();
     $providers[] = new Kwf_Assets_Provider_AtRequires();
     $providers[] = new Kwf_Assets_Provider_ViewsUser();
     $providers[] = new Kwf_Assets_Modernizr_Provider();
     $providers[] = new Kwf_Assets_CommonJs_Provider();
     $providers[] = new Kwf_Assets_Provider_KwfCommonJs();
     $providers[] = new Kwf_Assets_CommonJs_JQueryPluginProvider();
     $providers[] = new Kwf_Assets_ResponsiveEl_Provider();
     parent::__construct($providers);
 }
 public static function getAllChainedByMasterFromChainedStart($componentClass, $master, $chainedType, $parentDataSelect = array())
 {
     if (Kwc_Abstract::getFlag($componentClass, 'chainedType') != $chainedType) {
         return array();
     }
     $ret = array();
     foreach (Kwf_Component_Data_Root::getInstance()->getComponentsByClass($componentClass, $parentDataSelect) as $chainedStart) {
         //if additional subroots are above trl subroot (eg. domains)
         if ($sr = $chainedStart->parent->getSubroot()) {
             $masterSr = $master;
             while (Kwc_Abstract::getFlag($masterSr->componentClass, 'chainedType') != $chainedType) {
                 $masterSr = $masterSr->parent;
                 if (!$masterSr) {
                     continue 2;
                 }
             }
             if ($masterSr->parent && $sr != $masterSr->parent->getSubroot()) {
                 continue;
             }
         }
         $i = Kwc_Chained_Abstract_Component::getChainedByMasterAndType($master, $chainedStart, $chainedType, $parentDataSelect);
         if ($i) {
             $ret[] = $i;
         }
     }
     return $ret;
 }
 /**
  * Puts a JavaScript Variable used in Kwf_js/Statistics.js
  *
  * @return string
  */
 public function getIncludeCode()
 {
     $value = Kwf_Statistics::getDefaultOptValue($this->getData());
     $optInShowBox = $this->getData()->getBaseProperty('statistics.optInShowBox');
     $html = '';
     if ($value == 'out' || $value == 'in' && $optInShowBox) {
         $components = Kwf_Component_Data_Root::getInstance()->getComponentsByClass('Kwc_Statistics_Opt_Component', array('subroot' => $this->getData()));
         $url = isset($components[0]) ? $components[0]->url : null;
         $html = $this->_getOptBoxInnerHtml($url);
         if (!$html) {
             $exception = new Kwf_Exception('To disable optbox please change config.');
             $exception->logOrThrow();
         }
         $html = '<div class="' . self::getRootElementClass($this) . '"><div class="inner">' . $html . '<div></div>';
         $html = str_replace("'", "\\'", $html);
     }
     $ret = '<script type="text/javascript">';
     //TODO commonjs
     /*
     $ret .= "if (typeof Kwf == 'undefined') Kwf = {};";
     $ret .= "if (typeof Kwf.Statistics == 'undefined') Kwf.Statistics = {};";
     $ret .= "Kwf.Statistics.defaultOptValue = '$value';";
     $ret .= "Kwf.Statistics.optBoxHtml = '$html';";
     */
     $ret .= $this->_getJavascriptIncludeCode();
     $ret .= '</script>';
     return $ret;
 }
Esempio n. 8
0
 public function afterDuplicate($rootSource, $rootTarget)
 {
     parent::afterDuplicate($rootSource, $rootTarget);
     foreach ($this->_duplicated as $d) {
         //modify duplicated links so they point to duplicated page
         //only IF link points to page below $rootSource
         $source = Kwf_Component_Data_Root::getInstance()->getComponentById($d['source'], array('ignoreVisible' => true));
         $sourceLinkedData = $source->getLinkedData();
         if (!$sourceLinkedData) {
             continue;
         }
         $linkTargetIsBelowRootSource = false;
         $data = $sourceLinkedData;
         do {
             if ($data->componentId == $rootSource->componentId) {
                 $linkTargetIsBelowRootSource = true;
                 break;
             }
         } while ($data = $data->parent);
         unset($data);
         if ($linkTargetIsBelowRootSource) {
             $target = Kwf_Component_Data_Root::getInstance()->getComponentById($d['target'], array('ignoreVisible' => true));
             $targetRow = $target->getComponent()->getRow();
             $this->_modifyOwnRowAfterDuplicate($targetRow, $sourceLinkedData);
             $targetRow->save();
         }
     }
     $this->_duplicated = array();
 }
Esempio n. 9
0
 public static function getLanguages()
 {
     $config = Zend_Registry::get('config');
     $langs = array();
     if ($config->webCodeLanguage) {
         $langs[] = $config->webCodeLanguage;
     }
     $possibleUserLanguages = array();
     if ($config->languages) {
         foreach ($config->languages as $lang => $name) {
             $possibleUserLanguages[] = $lang;
         }
     }
     $userModel = Kwf_Registry::get('userModel');
     if (isset($userModel->getAuthedUser()->language) && $userModel->getAuthedUser()->language && in_array($userModel->getAuthedUser()->language, $possibleUserLanguages)) {
         $langs[] = $userModel->getAuthedUser()->language;
     }
     if (Kwf_Component_Data_Root::getComponentClass()) {
         $lngClasses = array();
         foreach (Kwc_Abstract::getComponentClasses() as $c) {
             if (Kwc_Abstract::hasSetting($c, 'baseProperties') && in_array('language', Kwc_Abstract::getSetting($c, 'baseProperties'))) {
                 $lngClasses[] = $c;
             }
         }
         $lngs = Kwf_Component_Data_Root::getInstance()->getComponentsBySameClass($lngClasses, array('ignoreVisible' => true));
         foreach ($lngs as $c) {
             if (Kwf_Registry::get('acl')->getComponentAcl()->isAllowed($userModel->getAuthedUser(), $c)) {
                 $langs[] = $c->getLanguage();
             }
         }
     }
     return array_unique($langs);
 }
 public function setUp()
 {
     Kwf_Component_Data_Root::setComponentClass(false);
     if (!`which rrdtool`) {
         $this->markTestSkipped();
     }
 }
Esempio n. 11
0
 protected function _initFields()
 {
     parent::_initFields();
     $userEditForm = $this->fields->add(new $this->_userDataFormName('user'));
     $userEditForm->setIdTemplate('{0}');
     $root = Kwf_Component_Data_Root::getInstance();
     if ($root) {
         $userDirectory = $root->getComponentByClass('Kwc_User_Directory_Component');
     }
     if ($root && isset($userDirectory) && $userDirectory) {
         $detailClass = Kwc_Abstract::getChildComponentClass($userDirectory->componentClass, 'detail');
         $userEditForm->addUserForms($detailClass, array('general'));
         $userEditForm->fields['firstname']->setAllowBlank(true);
         $userEditForm->fields['lastname']->setAllowBlank(true);
     } else {
         $this->fields->add(new Kwc_User_Detail_General_Form('general', null))->setIdTemplate('{0}');
     }
     $config = Zend_Registry::get('config');
     $authedUser = Kwf_Registry::get('userModel')->getAuthedUser();
     if (isset($authedUser->language) && $config->languages) {
         $data = array();
         foreach ($config->languages as $key => $value) {
             $data[$key] = $value;
         }
         $this->fields->add(new Kwf_Form_Field_Select('language', trlKwf('Language')))->setValues($data);
     }
 }
Esempio n. 12
0
 /**
  *
  * @param string
  * @param string
  * @param string
  * @param string
  * @param int Kann gesetzt werden wenn wir in diesem web auf das bild nicht direkten zugriff haben
  *            sondern nur für ein anderes web die url generieren
  */
 public static function getUrl($class, $id, $type, $filename, $time = null)
 {
     if ($filename instanceof Kwf_Uploads_Row) {
         $filename = $filename->filename . '.' . $filename->extension;
     }
     if ($filename == '.') {
         $filename = '';
     }
     //Replace Slashes and Backslashes with an underscore
     //Otherwise we would get a wrong url
     //e.g. $filename = foo/bar.png -> /media/FooModel/1/default/ab123/1234/foo/bar.png
     $filename = str_replace('/', '_', $filename);
     $filename = str_replace('\\', '_', $filename);
     $checksumType = $type;
     if (substr($type, 0, strlen(Kwf_Media::DONT_HASH_TYPE_PREFIX)) == Kwf_Media::DONT_HASH_TYPE_PREFIX) {
         $checksumType = Kwf_Media::DONT_HASH_TYPE_PREFIX;
     }
     $class = rawurlencode($class);
     $checksum = self::getChecksum($class, $id, $checksumType, rawurlencode($filename));
     $prefix = Kwf_Setup::getBaseUrl();
     if ($r = Kwf_Component_Data_Root::getInstance()) {
         if ($r->filename) {
             $prefix .= '/' . $r->filename;
         }
     }
     if (is_null($time)) {
         $cacheId = 'mtime-' . self::createCacheId($class, $id, $type);
         $time = Kwf_Media_MemoryCache::getInstance()->load($cacheId);
         if (!$time) {
             $time = time();
             Kwf_Media_MemoryCache::getInstance()->save($time, $cacheId);
         }
     }
     return $prefix . '/media/' . $class . '/' . $id . '/' . $type . '/' . $checksum . '/' . $time . '/' . rawurlencode($filename);
 }
Esempio n. 13
0
 public function testNodeConfig()
 {
     $user = '******';
     $c = Kwf_Component_Data_Root::getInstance();
     $cfg = Kwf_Controller_Action_Component_PagesController::getComponentNodeConfig($c, $user, $this->_acl);
     $this->assertFalse($cfg['actions']['add']);
     $this->assertFalse($cfg['allowDrop']);
     $this->assertFalse($cfg['actions']['delete']);
     $this->assertFalse($cfg['actions']['makeHome']);
     $this->assertFalse($cfg['allowDrag']);
     $c = Kwf_Component_Data_Root::getInstance()->getComponentById('root-main');
     $cfg = Kwf_Controller_Action_Component_PagesController::getComponentNodeConfig($c, $user, $this->_acl);
     $this->assertFalse($cfg['actions']['delete']);
     $this->assertFalse($cfg['actions']['makeHome']);
     $this->assertTrue($cfg['actions']['add']);
     $this->assertTrue($cfg['allowDrop']);
     $this->assertFalse($cfg['allowDrag']);
     $c = Kwf_Component_Data_Root::getInstance()->getComponentById('1');
     $cfg = Kwf_Controller_Action_Component_PagesController::getComponentNodeConfig($c, $user, $this->_acl);
     $this->assertTrue($cfg['actions']['delete']);
     $this->assertTrue($cfg['actions']['makeHome']);
     $this->assertTrue($cfg['actions']['add']);
     $this->assertTrue($cfg['allowDrop']);
     $this->assertTrue($cfg['allowDrag']);
     $c = Kwf_Component_Data_Root::getInstance()->getComponentById('3');
     $cfg = Kwf_Controller_Action_Component_PagesController::getComponentNodeConfig($c, $user, $this->_acl);
     $this->assertTrue($cfg['actions']['delete']);
     $this->assertTrue($cfg['actions']['makeHome']);
     $this->assertTrue($cfg['actions']['add']);
     $this->assertTrue($cfg['allowDrop']);
     $this->assertTrue($cfg['allowDrag']);
 }
 public function load($row, $postData = array())
 {
     $ret = parent::load($row, $postData);
     $component = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($row->component_id, array('ignoreVisible' => true, 'limit' => 1));
     if ($component) {
         //component can be non-existent if it's in a not selected card
         if (is_instance_of($component->componentClass, 'Kwc_Abstract_Image_Component')) {
             $contentWidth = null;
             $usesContentWidth = false;
             foreach (Kwc_Abstract::getSetting($component->componentClass, 'dimensions') as $dim) {
                 if (isset($dim['width'])) {
                     if ($dim['width'] == Kwc_Abstract_Image_Component::CONTENT_WIDTH) {
                         $usesContentWidth = true;
                     } else {
                         if ($dim['width'] > $contentWidth) {
                             $contentWidth = $dim['width'];
                         }
                     }
                 }
             }
             if ($usesContentWidth) {
                 $contentWidth = $component->getComponent()->getMaxContentWidth();
             }
         } else {
             $contentWidth = $component->getComponent()->getContentWidth();
         }
         $ret[$this->getFieldName()]['contentWidth'] = $contentWidth;
     }
     return $ret;
 }
Esempio n. 15
0
 private function _getAllLanguages()
 {
     $config = Zend_Registry::get('config');
     $langs = array();
     if ($config->webCodeLanguage) {
         $langs[] = $config->webCodeLanguage;
     }
     if ($config->languages) {
         foreach ($config->languages as $lang => $name) {
             $langs[] = $lang;
         }
     }
     if (Kwf_Component_Data_Root::getComponentClass()) {
         foreach (Kwc_Abstract::getComponentClasses() as $c) {
             if (Kwc_Abstract::getFlag($c, 'hasAvailableLanguages')) {
                 foreach (call_user_func(array($c, 'getAvailableLanguages'), $c) as $i) {
                     if (!in_array($i, $langs)) {
                         $langs[] = $i;
                     }
                 }
             }
         }
     }
     $langs = array_unique($langs);
     return $langs;
 }
 public function findModels()
 {
     $ret = array();
     foreach (Kwc_Abstract::getComponentClasses() as $componentClass) {
         $cls = strpos($componentClass, '.') ? substr($componentClass, 0, strpos($componentClass, '.')) : $componentClass;
         $m = call_user_func(array($cls, 'createOwnModel'), $componentClass);
         if ($m) {
             self::_findAllInstancesProcessModel($ret, $m);
         }
         $m = call_user_func(array($cls, 'createChildModel'), $componentClass);
         if ($m) {
             self::_findAllInstancesProcessModel($ret, $m);
         }
         foreach (Kwc_Abstract::getSetting($componentClass, 'generators') as $g) {
             if (isset($g['model'])) {
                 self::_findAllInstancesProcessModel($ret, $g['model']);
             }
         }
     }
     if ($root = Kwf_Component_Data_Root::getInstance()) {
         foreach ($root->getPlugins('Kwf_Component_PluginRoot_Interface_Models') as $plugin) {
             foreach ($plugin->getModels() as $model) {
                 self::_findAllInstancesProcessModel($ret, $model);
             }
         }
     }
     return $ret;
 }
Esempio n. 17
0
 protected function _initFields()
 {
     parent::_initFields();
     $showDirectoryClass = Kwc_Abstract::getSetting($this->getClass(), 'showDirectoryClass');
     $hideDirectoryClasses = Kwc_Abstract::getSetting($this->getClass(), 'hideDirectoryClasses');
     $cards = $this->add(new Kwf_Form_Container_Cards('source_component_id', trlKwf('Directory')));
     $defaultCard = null;
     $categories = Kwf_Component_Data_Root::getInstance()->getComponentsByClass('Kwc_Directories_Category_Directory_Component');
     foreach ($categories as $category) {
         $itemDirectory = $category->parent;
         if (is_instance_of($itemDirectory->componentClass, $showDirectoryClass)) {
             foreach ($hideDirectoryClasses as $c) {
                 if (is_instance_of($itemDirectory->componentClass, $c)) {
                     continue 2;
                 }
             }
             $categoriesModel = $category->getComponent()->getChildModel();
             $select = $categoriesModel->select()->whereEquals('component_id', $category->componentId);
             $values = array();
             foreach ($categoriesModel->getRows($select) as $row) {
                 $values[$row->id] = $row->name;
             }
             $card = $cards->add();
             $card->setTitle($category->parent->getTitle());
             $card->setName($category->componentId);
             if (!$defaultCard) {
                 $defaultCard = $category->componentId;
             }
             $model = Kwf_Model_Abstract::getInstance('Kwc_Directories_Category_ShowCategories_Model');
             $card->add(new Kwf_Form_Field_MultiCheckboxLegacy($model, trlKwf('Categories')))->setValues($values)->setReferences(array('columns' => array('component_id'), 'refColumns' => array('id')))->setColumnName('category_id');
         }
     }
     $cards->setDefaultValue($defaultCard);
 }
 protected function _getSelect()
 {
     //$ret = parent::_getSelect(); what do we lose by not using that?
     if ($this->_getParam('filterComponentId')) {
         $filter = Kwf_Component_Data_Root::getInstance()->getComponentById($this->_getParam('filterComponentId'));
         if (!is_instance_of($filter->componentClass, 'Kwc_Directories_List_Component')) {
             $filter = $filter->getChildComponent('-list');
             //TODO don't hardcode that here
         }
         $viewData = $filter->getChildComponent('-view');
         //TODO don't hardcode that here
     } else {
         $viewData = $this->_component;
     }
     $view = $viewData->getComponent();
     if ($view->hasSearchForm()) {
         $sf = $view->getSearchForm();
         $params = $this->getRequest()->getParams();
         $params[$sf->componentId . '-post'] = true;
         //post
         $params[$sf->componentId] = true;
         //submit
         $sf->getComponent()->processInput($params);
         //TODO don't do processInput here in _getSelect()
     }
     $ret = $view->getSelect();
     return $ret;
 }
 /**
  * returns a list of all visible favourite componentIds
  */
 public static function getFavouriteComponentIds($favouritesModel)
 {
     $ret = array();
     $userId = Kwf_Registry::get('userModel')->getAuthedUserId();
     if ($userId) {
         $cacheIdUser = '******' . $userId;
         $ret = Kwf_Cache_Simple::fetch($cacheIdUser, $success);
         if (!$success) {
             // get all favourites related to user
             $select = new Kwf_Model_Select();
             $select->whereEquals('user_id', $userId);
             $favouritesModel = Kwf_Model_Abstract::getInstance($favouritesModel);
             $favourites = $favouritesModel->getRows($select);
             $componentIds = array();
             foreach ($favourites as $favourite) {
                 $component = Kwf_Component_Data_Root::getInstance()->getComponentById($favourite->component_id);
                 // check if component is visible and existent
                 if ($component) {
                     // if component is visible create list of users related to component
                     $componentIds[] = $component->componentId;
                 }
             }
             // cache relation of visible components to user
             Kwf_Cache_Simple::add($cacheIdUser, $componentIds);
             $ret = $componentIds;
         }
     }
     return $ret;
 }
Esempio n. 20
0
 public function onOwnRowEvent(Kwf_Events_Event_Row_Abstract $event)
 {
     $components = Kwf_Component_Data_Root::getInstance()->getComponentsByDbId($event->row->component_id, array('ignoreVisible' => true));
     foreach ($components as $component) {
         $this->fireEvent(new Kwf_Component_Event_Component_ContentChanged($this->_class, $component));
     }
 }
 public static function getMediaOutput($id, $type, $className)
 {
     if ($type == 'list') {
         $component = Kwf_Component_Data_Root::getInstance()->getComponentById($id);
         if ($component) {
             $galleryComponent = $component->parent;
             $components = $galleryComponent->getChildComponents(array('generator' => 'child'));
             $paths = array();
             foreach ($components as $component) {
                 $data = $component->getComponent()->getImageData();
                 if ($data['file']) {
                     $paths[$data['file']] = $data['filename'];
                 }
             }
         }
         if (!$paths) {
             throw new Kwf_Exception_NotFound();
         }
         Kwf_Util_TempCleaner::clean();
         $tmpname = "temp/" . uniqid() . ".zip";
         $zip = new ZipArchive();
         if ($zip->open($tmpname, ZIPARCHIVE::CREATE) !== TRUE) {
             throw new Kwf_Exception('Could not open file for writing: ' . $filename);
         }
         foreach ($paths as $path => $filename) {
             $zip->addFile($path, $filename);
         }
         $zip->close();
         $file = array('file' => $tmpname, 'mimeType' => 'application/zip', 'downloadFilename' => $galleryComponent->getPage()->name . '.zip');
         Kwf_Media_Output::output($file);
         exit;
     }
 }
Esempio n. 22
0
 public function testFeed()
 {
     Kwf_Component_Cache::setInstance(Kwf_Component_Cache::CACHE_BACKEND_FNF);
     $feed = Kwf_Component_Data_Root::getInstance()->getChildComponent('_feed');
     $xml = $feed->getComponent()->getXml();
     $rows = Kwf_Component_Cache::getInstance()->getModel()->getRows();
     $row = $rows->current();
     $feedRow = Kwf_Model_Abstract::getInstance('Kwc_Basic_Feed_Model')->getRows()->current();
     // XML prüfen
     $this->assertEquals('<?xml', substr($xml, 0, 5));
     $this->assertTrue(strpos($xml, '<rss') !== false);
     $this->assertTrue(strpos($xml, 'testtitle') !== false);
     $this->assertTrue(strpos($xml, 'testdescription') !== false);
     $this->assertTrue(strpos($xml, 'testlink') !== false);
     // Cache-Eintrag prüfen
     $this->assertEquals($xml, $feed->getComponent()->getXml());
     $this->assertEquals(1, count($rows));
     $this->assertEquals($xml, $row->content);
     // Cache-Eintrag ändern um festzustellen, ob eh Cache verwendet wird
     $feedRow->description = 'foo';
     $feedRow->save();
     $this->assertEquals($row->content, $feed->getComponent()->getXml());
     // Cache löschen
     $this->_process();
     $xml = $feed->getComponent()->getXml();
     $this->assertEquals('<?xml', substr($xml, 0, 5));
     $this->assertTrue(strpos($xml, '<rss') !== false);
 }
Esempio n. 23
0
 protected function _getLanguages()
 {
     $languages = Kwf_Component_Data_Root::getInstance()->getComponentsByClass('Kwc_Root_LanguageRoot_Language_Component', array('subroot' => $this->getData()));
     $languages = array_merge($languages, Kwf_Component_Data_Root::getInstance()->getComponentsByClass('Kwc_Root_TrlRoot_Master_Component', array('subroot' => $this->getData())));
     $languages = array_merge($languages, Kwf_Component_Data_Root::getInstance()->getComponentsByClass('Kwc_Root_TrlRoot_Chained_Component', array('subroot' => $this->getData())));
     return $languages;
 }
Esempio n. 24
0
 public function getTemplateVars()
 {
     $ret = parent::getTemplateVars();
     $feeds = Kwf_Component_Data_Root::getInstance()->getComponentsByClass('Kwc_Abstract_Feed_Component', array('subroot' => $this->getData()));
     $ret['feeds'] = $feeds;
     return $ret;
 }
Esempio n. 25
0
 /**
  * Returns Zend_Search_Lucene instance for given subroot
  *
  * every subroot has it's own instance
  *
  * @param Kwf_Component_Data for this index
  * @return Zend_Search_Lucene_Interface
  */
 public static function getInstance(Kwf_Component_Data $subroot)
 {
     while ($subroot) {
         if (Kwc_Abstract::getFlag($subroot->componentClass, 'subroot')) {
             break;
         }
         $subroot = $subroot->parent;
     }
     if (!$subroot) {
         $subroot = Kwf_Component_Data_Root::getInstance();
     }
     static $instance = array();
     if (!isset($instance[$subroot->componentId])) {
         $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive();
         $analyzer->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_ShortWords(2));
         //$stopWords = explode(' ', 'der dir das einer eine ein und oder doch ist sind an in vor nicht wir ihr sie es ich');
         //$analyzer->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_StopWords($stopWords));
         Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
         Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
         Zend_Search_Lucene_Storage_Directory_Filesystem::setDefaultFilePermissions(0666);
         $path = 'cache/fulltext';
         $path .= '/' . $subroot->componentId;
         try {
             $instance[$subroot->componentId] = Zend_Search_Lucene::open($path);
         } catch (Zend_Search_Lucene_Exception $e) {
             $instance[$subroot->componentId] = Zend_Search_Lucene::create($path);
         }
     }
     return $instance[$subroot->componentId];
 }
 public function postUpdate()
 {
     if ($this->_afterUpdateRequired) {
         $c = Kwf_Component_Data_Root::getInstance()->getComponentByClass('Kwc_NewsletterCategory_Component', array('limit' => 1));
         Kwf_Registry::get('db')->query("UPDATE `kwc_newsletter_categories` SET newsletter_component_id='{$c->dbId}'");
     }
 }
Esempio n. 27
0
 public function testMaskComponentLink()
 {
     $this->_init('Kwf_Component_PluginRoot_MaskComponentLink_Component');
     $this->assertEquals('f1f2f3', $this->_renderRoot());
     $plugin = new Kwf_Component_PluginRoot_MaskComponentLink_Plugin();
     Kwf_Component_Data_Root::getInstance()->registerPlugin($plugin);
     $this->assertEquals('f1f3', $this->_renderRoot());
     $output = $this->_root->render(false, true);
     $parts = $plugin->getMaskedContentParts($output);
     $this->assertEquals(2, count($parts));
     $this->assertEquals($plugin::MASK_TYPE_HIDE, $parts[0]['maskType']);
     $this->assertEquals($plugin::MASK_TYPE_SHOW, $parts[1]['maskType']);
     $parts = $plugin->getMaskedContentParts($output, $plugin::MASK_TYPE_HIDE);
     $this->assertEquals(1, count($parts));
     $this->assertEquals(array('foo' => 'a'), $parts[0]['params']);
     $parts = $plugin->getMaskedContentParts($output, $plugin::MASK_TYPE_HIDE, array('foo' => 'b'));
     $this->assertEquals(0, count($parts));
     $parts = $plugin->getMaskedContentParts($output, $plugin::MASK_TYPE_SHOW, array('foo' => 'b'));
     $this->assertEquals(1, count($parts));
     $this->assertEquals('f1f2f3', $this->_strip($plugin->removeMasksFromComponentLinks($output)));
     $this->assertEquals('f1f2f3', $this->_strip($plugin->removeMasksFromComponentLinks($output, array('foo' => 'a'))));
     $this->assertEquals('f1f3', $this->_strip($plugin->removeMasksFromComponentLinks($output, '')));
     $this->assertEquals('f1', $this->_strip($plugin->removeMaskedComponentLinks($output)));
     $this->assertEquals('f1f2', $this->_strip($plugin->removeMaskedComponentLinks($plugin->removeMasksFromComponentLinks($output))));
 }
 public function update()
 {
     $entries = Kwf_Registry::get('db')->query('SELECT COUNT(*) FROM kwc_events_to_categories')->fetchColumn();
     if (!$entries) {
         return;
     }
     Kwf_Registry::get('db')->query('ALTER TABLE `kwc_events_to_categories` CHANGE `category_id` `category_id` INT( 11 ) NOT NULL DEFAULT \'0\'');
     Kwf_Registry::get('db')->query('UPDATE kwc_events_to_categories SET category_id=-category_id');
     $m = Kwf_Model_Abstract::getInstance('Kwf_Util_Model_Pool');
     $s = $m->select()->whereEquals('pool', 'Newskategorien');
     $pool = $m->getRows($s);
     $cats = Kwf_Component_Data_Root::getInstance()->getComponentsByClass('Kwc_Events_Category_Directory_Component');
     foreach ($cats as $cat) {
         foreach ($pool as $r) {
             $newRow = Kwf_Model_Abstract::getInstance('Kwc_Directories_Category_Directory_CategoriesModel')->createRow();
             $newRow->component_id = $cat->dbId;
             $newRow->pos = $r->pos;
             $newRow->name = $r->value;
             $newRow->visible = $r->visible;
             $newRow->save();
             $sql = "UPDATE kwc_events_to_categories SET category_id={$newRow->id} WHERE category_id=-{$r->id}\n                            AND event_id IN (SELECT id FROM kwc_events WHERE component_id='" . $cat->parent->dbId . "')";
             Kwf_Registry::get('db')->query($sql);
         }
     }
     Kwf_Registry::get('db')->query("DELETE FROM kwf_pools WHERE pool='Eventcategories'");
 }
Esempio n. 29
0
 public function processIpn(Kwc_Shop_Cart_Checkout_Payment_Wirecard_LogRow $row, $param)
 {
     if ($row->paymentState == 'SUCCESS' || $row->paymentState == 'PENDING') {
         $order = Kwf_Model_Abstract::getInstance(Kwc_Abstract::getSetting($this->getData()->parent->parent->componentClass, 'childModel'))->getReferencedModel('Order')->getRow($param['orderId']);
         if (!$order) {
             throw new Kwf_Exception("Order not found!");
         }
         $order->payment_component_id = $this->getData()->componentId;
         $order->checkout_component_id = $this->getData()->parent->componentId;
         $order->cart_component_class = $this->getData()->parent->parent->componentClass;
         if ($row->paymentState == 'SUCCESS') {
             $order->status = 'payed';
             $order->payed = date('Y-m-d H:i:s');
         }
         if (!$order->confirm_mail_sent) {
             foreach ($this->getData()->parent->parent->getComponent()->getShopCartPlugins() as $p) {
                 $p->orderConfirmed($order);
             }
             foreach ($order->getChildRows('Products') as $p) {
                 $addComponent = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($p->add_component_id);
                 $addComponent->getComponent()->orderConfirmed($p);
             }
             $this->sendConfirmMail($order);
             $order->date = date('Y-m-d H:i:s');
             $order->confirm_mail_sent = date('Y-m-d H:i:s');
         }
         $order->save();
         return true;
     } else {
         throw new Kwf_Exception('Error by processing ipn');
     }
     return false;
 }
Esempio n. 30
0
 public function getChildData($parentData, $select = array())
 {
     Kwf_Benchmark::count('GenStatic::getChildData');
     if (is_array($select)) {
         $select = new Kwf_Component_Select($select);
     }
     $pData = $parentData;
     $ret = array();
     if ($p = $select->getPart(Kwf_Component_Select::WHERE_ID)) {
         if (!$this->_idMatches($p)) {
             return $ret;
         }
     }
     if (!$parentData) {
         if ($p = $select->getPart(Kwf_Component_Select::WHERE_CHILD_OF)) {
             throw new Kwf_Exception("this must not happen");
             $p = $p->getPageOrRoot();
             $parentData = $p->getRecursiveChildComponents(array('componentClass' => $this->_class));
         } else {
             $parentSelect = new Kwf_Component_Select();
             $parentSelect->copyParts(array(Kwf_Component_Select::WHERE_SUBROOT, Kwf_Component_Select::IGNORE_VISIBLE, Kwf_Component_Select::WHERE_CHILD_OF), $select);
             $parentData = Kwf_Component_Data_Root::getInstance()->getComponentsBySameClass($this->_class, $parentSelect);
         }
     }
     $parentDatas = is_array($parentData) ? $parentData : array($parentData);
     foreach ($this->_fetchKeys($pData, $select) as $key) {
         foreach ($parentDatas as $parentData) {
             $data = $this->_createData($parentData, $key, $select);
             if ($data) {
                 $ret[] = $data;
             }
         }
     }
     return $ret;
 }