本文整理汇总了PHP中Kwf_Component_Data_Root::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Kwf_Component_Data_Root::getInstance方法的具体用法?PHP Kwf_Component_Data_Root::getInstance怎么用?PHP Kwf_Component_Data_Root::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kwf_Component_Data_Root
的用法示例。
在下文中一共展示了Kwf_Component_Data_Root::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: orderConfirmed
public function orderConfirmed(Kwc_Shop_Cart_Order $order)
{
if (!$order->voucher_code) {
return;
}
$c = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($order->checkout_component_id);
foreach ($c->getComponent()->getSumRows($order) as $sumRow) {
if (isset($sumRow['type']) && $sumRow['type'] == 'voucher') {
$s = new Kwf_Model_Select();
$s->whereEquals('code', $order->voucher_code);
$row = Kwf_Model_Abstract::getInstance('Kwc_Shop_Cart_Plugins_Voucher_Vouchers')->getRow($s);
$remainingAmount = $row->amount - $row->used_amount + $sumRow['amount'];
$h = $row->createChildRow('history');
$h->amount = -$sumRow['amount'];
$h->order_id = $order->id;
$h->date = $order->date;
$h->comment = trlKwf('Order') . ' ' . $order->order_number;
$h->save();
//verbrauchten betrag auch noch bei der order speichern
$order->voucher_amount = (double) $h->amount;
$order->voucher_remaining_amount = (double) $remainingAmount;
$order->save();
break;
}
}
}
示例2: getInstance
/**
* 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];
}
示例3: testMaskComponentLink
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))));
}
示例4: getIncludeCode
/**
* 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;
}
示例5: getAllChainedByMasterFromChainedStart
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;
}
示例6: update
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'");
}
示例7: afterDuplicate
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();
}
示例8: load
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;
}
示例9: testNodeConfig
public function testNodeConfig()
{
$user = 'test';
$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']);
}
示例10: getChildData
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;
}
示例11: _getSelect
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;
}
示例12: _beforeInsert
protected function _beforeInsert(Kwf_Model_Row_Interface $row)
{
parent::_beforeInsert($row);
$row->status = 'ordered';
$row->checkout_component_id = $this->_getParam('componentId');
$row->cart_component_class = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($this->_getParam('componentId'))->parent->componentClass;
}
示例13: jsonDuplicateAction
public function jsonDuplicateAction()
{
if (!isset($this->_permissions['duplicate']) || !$this->_permissions['duplicate']) {
throw new Kwf_Exception("Duplicate is not allowed.");
}
$ids = $this->getRequest()->getParam($this->_primaryKey);
$ids = explode(';', $ids);
$this->view->data = array('duplicatedIds' => array());
$parentTarget = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($this->_getParam('componentId'));
foreach ($ids as $id) {
$sourceId = $this->_getParam('componentId') . '_' . $id;
$source = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($sourceId);
// Switch off observer due to performance - it's not necessary here
Kwf_Events_ModelObserver::getInstance()->disable();
$newDetail = Kwf_Util_Component::duplicate($source, $parentTarget);
Kwf_Util_Component::afterDuplicate($source, $newDetail);
Kwf_Events_ModelObserver::getInstance()->enable();
$newDetailRow = $newDetail->row;
$newDetailRow->create_date = date('Y-m-d H:i:s');
$newDetailRow->mails_per_minute = 'normal';
$newDetailRow->start_date = null;
$newDetailRow->resume_date = null;
$newDetailRow->last_sent_date = null;
$newDetailRow->count_sent = null;
$newDetailRow->status = null;
$newDetailRow->save();
$mailRow = $newDetail->getChildComponent('_mail')->getComponent()->getRow();
$mailRow->subject = trlKwf('Copy of') . ' ' . $mailRow->subject;
$mailRow->save();
}
}
示例14: __construct
public function __construct($order)
{
parent::__construct();
$moneyHelper = new Kwf_View_Helper_Money();
$dateHelper = new Kwf_View_Helper_Date();
$data = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($order->checkout_component_id);
$this->SetMargins(20, 15, 20);
$this->setPrintHeader(false);
$this->setPrintFooter(false);
$this->SetAutoPageBreak(true);
$this->AddPage();
$this->SetFont("Arial", "", 9);
if ($order->title) {
$order->title .= " ";
}
$this->MultiCell(0, 0, $order->title . $order->firstname . " " . $order->lastname, 0, 'L');
$this->MultiCell(0, 0, "\n" . $data->trlKwf('Order Number') . ":\n{$order->order_number}\n" . "\n" . $data->trlKwf('Customer Number') . ":\n{$order->customer_number}\n" . "\n" . $data->trlKwf('Invoice Number') . ":\n{$order->invoice_number}\n" . "\n" . $data->trlKwf('Invoice Date') . ":\n" . $dateHelper->date($order->invoice_date), 0, 'L');
foreach ($order->getProductsData() as $item) {
$text = $item->amount . "x " . $item->text;
foreach ($item->additionalOrderData as $d) {
if ($d['class'] != 'amount') {
$text .= ", {$d['name']} {$d['value']}";
}
}
$this->MultiCell(120, 0, $data->trlStaticExecute($text), 0, 'L');
$this->MultiCell(35, 0, $moneyHelper->money($item->price), 0, 'R');
}
foreach ($order->getSumRows() as $addSumRow) {
if (isset($addSumRow['class']) && $addSumRow['class'] == 'totalAmount') {
$this->MultiCell(0, 0, $data->trlStaticExecute($addSumRow['text']) . " " . $moneyHelper->money($addSumRow['amount']), 0, 'L');
}
}
}
示例15: getTemplateVars
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;
}