protected static function _findAllInstancesProcessModel(&$ret, $model) { $model = Kwf_Model_Abstract::getInstance($model); if (isset($ret[$model->getFactoryId()])) { return; } $ret[$model->getFactoryId()] = $model; if ($model instanceof Kwf_Model_Proxy) { self::_findAllInstancesProcessModel($ret, $model->getProxyModel()); } else { if ($model instanceof Kwf_Model_Union) { foreach ($model->getUnionModels() as $subModel) { self::_findAllInstancesProcessModel($ret, $subModel); } } } foreach ($model->getDependentModels() as $m) { self::_findAllInstancesProcessModel($ret, $m); } foreach ($model->getSiblingModels() as $m) { self::_findAllInstancesProcessModel($ret, $m); } foreach ($model->getReferences() as $rule) { $m = $model->getReferencedModel($rule); self::_findAllInstancesProcessModel($ret, $m); } }
private function _getNetworks($currentPage) { $networks = array(); foreach (Kwf_Model_Abstract::getInstance('Kwc_Advanced_SocialBookmarks_AvaliableModel')->getRows() as $n) { $networks[$n->id] = $n->toArray(); } $s = new Kwf_Model_Select(); $s->order('pos'); $ret = array(); foreach ($this->getRow()->getChildRows('Networks', $s) as $net) { if (isset($networks[$net->network_id])) { $icon = '/Kwc/Advanced/SocialBookmarks/Icons/' . $this->_getSetting('iconSet') . '/'; if (file_exists(KWF_PATH . $icon . $net->network_id . '.jpg')) { $icon .= $net->network_id . '.jpg'; } else { if (file_exists(KWF_PATH . $icon . $net->network_id . '.png')) { $icon .= $net->network_id . '.png'; } else { $icon = false; } } if ($icon) { $icon = '/assets/kwf' . $icon; } $url = str_replace('{0}', $currentPage->getAbsoluteUrl(), $networks[$net->network_id]['url']); $ret[] = array('id' => $net->network_id, 'name' => $networks[$net->network_id]['name'], 'url' => $url, 'icon' => $icon); } } return $ret; }
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; }
public function alterBackendOrderForm(Kwc_Shop_AddToCartAbstract_FrontendForm $form) { $component = null; foreach (Kwc_Abstract::getComponentClasses() as $c) { if (is_instance_of($c, 'Kwc_Shop_Products_Directory_Component')) { $detailClasses = Kwc_Abstract::getChildComponentClasses($c, 'detail'); foreach ($detailClasses as $key => $class) { if (Kwc_Abstract::getChildComponentClass($class, 'addToCart') == $this->_class) { $component = $key; } } } } $m = Kwf_Model_Abstract::getInstance('Kwc_Shop_Products'); $s = $m->select(); $s->whereEquals('visible', 1); if ($component) { $s->whereEquals('component', $component); } $s->order('pos'); $data = array(); foreach ($m->getRows($s) as $product) { $data[] = array($product->current_price_id, $product->__toString() . ' (' . $product->current_price . ' €)'); } $form->prepend(new Kwf_Form_Field_Select('shop_product_price_id', trlKwfStatic('Product')))->setValues($data)->setAllowBlank(false); }
public function testProxy() { $proxyModel = Kwf_Model_Abstract::getInstance('Kwf_Model_FnF_ProxyFnFExtendedReference_ProxyModel'); $row = $proxyModel->getRow(1); $foo = $row->getParentRow('Parent')->foo; $this->assertEquals(5, $foo); }
public function getTemplateVars() { $ret = parent::getTemplateVars(); $r = Kwf_Model_Abstract::getInstance('Kwf_Component_Cache_CacheTag_Test_Model')->getRow(1); $ret['test'] = $r->test; return $ret; }
protected function updateReferences(Kwf_Model_Row_Interface $row) { $m1 = Kwf_Model_Abstract::getInstance('Linkdata'); $s = $m1->select()->whereEquals('id', $row->subCompanyId); $prow = $m1->getRow($s); $row->subCompanyName = $prow->value; }
protected function _initFields() { $modelName = Kwc_Abstract::getSetting($this->_getParam('class'), 'projectsModel'); $this->_form->setModel(Kwf_Model_Abstract::getInstance($modelName)); $this->_form->add(new Kwf_Form_Field_TextField('text', trlKwf('Text'))); $this->_form->add(new Kwf_Form_Field_Checkbox('visible', trlKwf('Visible'))); }
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); }
protected function updateReferences(Kwf_Model_Row_Interface $row) { $m2 = Kwf_Model_Abstract::getInstance('Employees'); $s = $m2->select()->whereEquals('id', $row->responsibleId); $prow = $m2->getRow($s); $row->responsibleName = (string) $prow; }
public function __construct($config = array()) { $this->_referenceMap['Image']['refModelClass'] = 'Kwc_ImageResponsive_MediaOutput_Image_UploadsModel'; $m = Kwf_Model_Abstract::getInstance('Kwc_ImageResponsive_MediaOutput_Image_UploadsModel'); $config['proxyModel'] = new Kwf_Model_FnF(array('columns' => array(), 'primaryKey' => 'component_id', 'data' => array(array('component_id' => 'root_imageabstract1', 'kwf_upload_id' => $m->uploadId1, 'dimension' => 'default'), array('component_id' => 'root_imageabstract2', 'kwf_upload_id' => $m->uploadId3, 'dimension' => 'default2')))); parent::__construct($config); }
public function testEvents7() { $model = Kwf_Model_Abstract::getInstance('Kwf_Component_Events_Table_Model'); $row = $model->getRow(3); $row->delete(); $this->assertEquals(0, $this->_events->countCalled); }
protected function execute(InputInterface $input, OutputInterface $output) { if (!file_exists('bootstrap.php')) { throw new \Exception("Run this script in the application root directory"); } \Kwf_Setup::setUp(); if (file_exists('setup/initial/dump.sql')) { unlink('setup/initial/dump.sql'); } if (file_exists('setup/initial/uploads')) { foreach (glob('setup/initial/uploads/*') as $f) { unlink($f); } } if ($input->getOption('include-initial-dump')) { $output->writeln("checking for pending updates..."); $pendingUpdatesCount = \Kwf_Util_Update_Helper::countPendingUpdates(); if ($pendingUpdatesCount) { throw new \Exception("{$pendingUpdatesCount} Updates have not been executed. Run update first."); } $output->writeln("creating database dump..."); $dump = DbDump::dump(); if (!file_exists('setup/initial')) { mkdir('setup/initial', 0777, true); $ignore = ""; if (file_exists('setup/.gitignore')) { $ignore = file_get_contents('setup/.gitignore'); } if (!preg_match('#^initial$#m', $ignore)) { $ignore = rtrim($ignore); if ($ignore) { $ignore .= "\n"; } $ignore .= "initial\n"; } file_put_contents('setup/.gitignore', $ignore); } file_put_contents('setup/initial/dump.sql', $dump); $output->writeln("copying uploads..."); if (!file_exists('setup/initial/uploads')) { mkdir('setup/initial/uploads'); } $model = \Kwf_Model_Abstract::getInstance('Kwf_Uploads_Model'); $select = new \Kwf_Model_Select(); $it = new \Kwf_Model_Iterator_Packages(new \Kwf_Model_Iterator_Rows($model, $select)); foreach ($it as $row) { $fileSource = $row->getFileSource(); copy($fileSource, 'setup/initial/uploads/' . basename($fileSource)); } } $excludes = ExcludeFinder::findExcludes('.'); $excludeArgs = ''; foreach ($excludes as $i) { $excludeArgs .= " -x " . escapeshellarg('./' . $i . '*'); } $cmd = "zip deploy.zip . --quiet -r {$excludeArgs}"; $output->writeln("creating deploy.zip archive..."); $this->_systemCheckRet($cmd, $input, $output); $output->writeln("deploy.zip successfully created."); }
public function testIt() { $m = $this->_model; $r = $m->getRow(1); $this->assertEquals('aaabbbccc', $r->foo); $this->assertEquals('abcd', $r->bar); $this->assertEquals('aha', $r->baz); $r = $m->getRow(2); $this->assertEquals('bam', $r->foo); $this->assertEquals('bum', $r->bar); $this->assertEquals(null, $r->baz); $r = $m->getRow($m->select()->whereEquals('baz', 'aha')); $this->assertNotNull($r); $this->assertEquals(1, $r->id); $r = $m->getRow($m->select()->whereNull('baz')); $this->assertNotNull($r); $this->assertEquals(2, $r->id); $r = $m->getRows($m->select()->order('baz')); $this->assertEquals(2, count($r)); $r = $m->createRow(); $r->foo = 'xxy'; $r->baz = 'xxz'; $r->save(); $tableName = Kwf_Model_Abstract::getInstance('Kwf_Model_DbWithConnection_DbSiblingProxy_DbModel')->getTable()->info(Zend_Db_Table_Abstract::NAME); $m = new Kwf_Model_Db(array('table' => $tableName)); $r = $m->getRow(3); $this->assertEquals('xxy', $r->foo); $this->assertEquals(null, $r->bar); $tableName = Kwf_Model_Abstract::getInstance('Kwf_Model_DbWithConnection_DbSiblingProxy_SiblingModel')->getTable()->info(Zend_Db_Table_Abstract::NAME); $m = new Kwf_Model_Db(array('table' => $tableName)); $r = $m->getRow(3); $this->assertEquals('xxz', $r->baz); }
/** * 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; }
public function testIgnoreDeleted() { $model = Kwf_Model_Abstract::getInstance('Kwf_Model_Union_DeletedFlag_TestModel'); $s = new Kwf_Model_Select(); $s->ignoreDeleted(); $this->assertEquals($model->countRows($s), 3); }
public function testCacheEn() { $c = $this->_root->getComponentById('root-master_test3'); $this->assertEquals('', $c->render()); $c = $this->_root->getComponentById('root-en_test3'); $this->assertEquals('', $c->render()); $model = Kwf_Model_Abstract::getInstance('Kwc_Trl_LinkTag_LinkTag_TestModel'); $r = $model->getRow('root-master_test3'); $r->component = 'extern'; $r->save(); $this->_process(); $c = $this->_root->getComponentById('root-master_test3'); $this->assertEquals('', $c->render()); $c = $this->_root->getComponentById('root-en_test3'); $this->assertEquals('', $c->render()); $model = Kwf_Model_Abstract::getInstance('Kwc_Trl_LinkTag_LinkTag_Extern_TestModel'); $model->createRow(array('component_id' => 'root-master_test3-child', 'target' => 'http://www.test.de/', 'open_type' => 'self'))->save(); $this->_process(); $c = $this->_root->getComponentById('root-master_test3'); $this->assertRegExp('#<a .*?href="http://www.test.de/">#', $c->render()); $c = $this->_root->getComponentById('root-en_test3'); $this->assertEquals('', $c->render()); $model = Kwf_Model_Abstract::getInstance('Kwc_Trl_LinkTag_LinkTag_Extern_Trl_TestModel'); $model->createRow(array('component_id' => 'root-en_test3-child', 'target' => 'http://www.test.de/en', 'own_target' => true))->save(); $this->_process(); $c = $this->_root->getComponentById('root-master_test3'); $this->assertRegExp('#<a .*?href="http://www.test.de/">#', $c->render()); $c = $this->_root->getComponentById('root-en_test3'); $this->assertRegExp('#<a .*?href="http://www.test.de/en">#', $c->render()); }
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'"); }
public function tearDown() { parent::tearDown(); Kwf_Model_Abstract::getInstance('Kwf_Model_Union_Db_Model1')->dropTable(); Kwf_Model_Abstract::getInstance('Kwf_Model_Union_Db_Model2')->dropTable(); Kwf_Model_Abstract::getInstance('Kwf_Model_Union_Db_ModelSibling')->dropTable(); }
public function preProcessInput() { //use custom user model Kwf_Registry::get('config')->user->model = 'Kwc_FavouritesSelenium_UserModel'; //unset existing userModel instance to get new one $reg = Kwf_Registry::getInstance()->set('userModel', Kwf_Model_Abstract::getInstance('Kwc_FavouritesSelenium_UserModel')); }
/** * @return self */ public static function getInstance() { if (isset(self::$_instance)) { return self::$_instance; } return Kwf_Model_Abstract::getInstance('Kwc_FulltextSearch_MetaModel'); }
protected function _init() { parent::_init(); if (is_string($this->_sourceModel)) { $this->_sourceModel = Kwf_Model_Abstract::getInstance($this->_sourceModel); } }
public function testIt() { $m = Kwf_Model_Abstract::getInstance('Kwf_Model_Relations_DependentModelWithArrow_ChildParentModel'); $row = $m->getRow(200); $crow = $row->getChildRows('Child')->current(); $this->assertEquals($crow->id, 100); }
public function setPool($pool) { $model = Kwf_Model_Abstract::getInstance('Kwf_Util_Model_Pool'); $select = $model->select()->whereEquals('pool', $pool)->whereEquals('visible', 1)->order('pos', 'ASC'); $this->setValues($model->getRows($select)); return $this; }
public function getParentRow($rule) { $ref = $this->_model->getReference($rule); if ($ref === Kwf_Model_RowsSubModel_Interface::SUBMODEL_PARENT) { if (!$this instanceof Kwf_Model_RowsSubModel_Row_Interface) { throw new Kwf_Exception("row '" . get_class($this) . "' must implement Kwf_Model_RowsSubModel_Row_Interface"); } return $this->getSubModelParentRow(); } if (!isset($ref['column'])) { throw new Kwf_Exception("column for reference '{$rule}' not set"); } $id = $this->{$ref['column']}; if (!$id) { return null; } if (isset($ref['refModelClass'])) { $refModel = Kwf_Model_Abstract::getInstance($ref['refModelClass']); } else { if (isset($ref['refModel'])) { $refModel = $ref['refModel']; } else { throw new Kwf_Exception("refModel or refModelClass for reference '{$rule}' not set"); } } return $refModel->getRow($id); }
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 _getRecipient() { $rs = $this->_getMailComponent()->getRecipientSources(); $recipientId = $this->_getParam('recipientId'); if (!$recipientId) { $component = Kwf_Component_Data_Root::getInstance()->getComponentById($this->_getParam('componentId'), array('ignoreVisible' => true)); $source = reset($rs); $model = Kwf_Model_Abstract::getInstance($source['model']); $select = $model->select(); if ($model->hasColumn('newsletter_component_id')) { $select->whereEquals('newsletter_component_id', $component->parent->componentId); } if (isset($source['select'])) { $select->merge($source['select']); } $row = $model->getRow($select); if (!$row) { throw new Kwf_Exception_Client(trlKwf('Preview cannot be shown because it needs at least one recipient of this newsletter')); } $recipientId = $row->id; } $select = new Kwf_Model_Select(); $select->whereEquals('id', $recipientId); $subscribeModelKey = $this->_getParam('subscribeModelKey'); if (!$subscribeModelKey) { $subscribeModelKey = current(array_keys($rs)); } $model = $rs[$subscribeModelKey]['model']; $row = Kwf_Model_Abstract::getInstance($model)->getRow($select); return $row; }
public function setUp() { $this->_modelParent = Kwf_Model_Abstract::getInstance('Kwf_Model_DbWithConnection_ParentExprDeletedFlag_ParentModel'); $this->_modelParent->setUp(); $this->_modelChild = Kwf_Model_Abstract::getInstance('Kwf_Model_DbWithConnection_ParentExprDeletedFlag_ChildModel'); $this->_modelChild->setUp(); }
public function testProxyProxySourceEventModel() { Kwf_Model_Abstract::getInstance('Kwf_Model_Events_ProxyReFire_ProxyProxyModel')->import(Kwf_Model_Abstract::FORMAT_ARRAY, array(array('foo' => 'bar'))); $this->assertEquals(1, Kwf_Model_Events_ProxyReFire_EventSubscriber::$onProxyModelUpdatedCalled); $this->assertEquals(1, Kwf_Model_Events_ProxyReFire_EventSubscriber::$onProxyProxyModelUpdatedCalled); $this->assertEquals(1, Kwf_Model_Events_ProxyReFire_EventSubscriber::$onSourceModelUpdatedCalled); }
public function setUp() { parent::setUp('Kwf_Component_Cache_LinkTag_Intern_Root_Component'); $this->_linkModel = Kwf_Model_Abstract::getInstance('Kwf_Component_Cache_LinkTag_Intern_Root_Link_Model'); $this->_pagesModel = Kwf_Model_Abstract::getInstance('Kwf_Component_Cache_LinkTag_Intern_Root_Model'); $this->_tableModel = Kwf_Model_Abstract::getInstance('Kwf_Component_Cache_LinkTag_Intern_Root_TableModel'); }