public function isEqual(Kwf_Model_Interface $other) { if ($other instanceof Kwf_Component_Model && $this->getTable()->getTableName() == $other->getTable()->getTableName()) { return true; } return false; }
public function isEqual(Kwf_Model_Interface $other) { if ($other instanceof Kwf_Component_Model && $this->getTable()->info(Zend_Db_Table_Abstract::NAME) == $other->getTable()->info(Zend_Db_Table_Abstract::NAME)) { return true; } return false; }
protected function _initProxyModel() { $this->_proxyModel->addProxyContainerModel($this); if (!$this->_proxyModel->getFactoryConfig()) { $this->_proxyModel->setFactoryConfig(array('type' => 'Proxied', 'proxy' => $this)); } }
public function rewind() { $data = $this->_model->export(Kwf_Model_Interface::FORMAT_ARRAY, $this->_select, $this->_options); if ($this->_debugOutput) { echo "loaded " . count($data) . " rows"; echo " memory: " . round(memory_get_usage() / 1024 / 1024, 1) . "MB\n"; } $this->_arrayIterator = new ArrayIterator($data); }
/** * @internal helper function */ public function getQueryExpr(Kwf_Model_Interface $model) { $valuesOrs = array(); foreach ($this->_searchValues as $column => $value) { if (empty($value)) { continue; } $searchWords = preg_split('/[\\s-+,;*]/', $value); foreach ($searchWords as $searchWord) { $searchWord = trim($searchWord); if (empty($searchWord)) { continue; } if ($column == 'query') { $searchFields = $this->_searchFields; if (in_array('*', $searchFields)) { $searchFields = array_merge($searchFields, $model->getColumns()); foreach ($searchFields as $sfk => $sfv) { if ($sfv == '*') { unset($searchFields[$sfk]); } if (substr($sfv, 0, 1) == '!') { unset($searchFields[$sfk]); unset($searchFields[array_search(substr($sfv, 1), $searchFields)]); } } } $ors = array(); foreach ($searchFields as $field) { $ors[] = new Kwf_Model_Select_Expr_Like($field, '%' . $searchWord . '%'); } $valuesOrs[] = new Kwf_Model_Select_Expr_Or($ors); } else { $valuesOrs[] = new Kwf_Model_Select_Expr_Like($column, '%' . $searchWord . '%'); } } } if ($valuesOrs) { return new Kwf_Model_Select_Expr_Or($valuesOrs); } else { return null; } }
public function isEqual(Kwf_Model_Interface $other) { if ($other instanceof Kwf_Model_Xml && $this->getFilepath() == $other->getFilepath()) { return true; } else { return false; } }
protected static final function _optimalImportExportFormat(Kwf_Model_Interface $model1, Kwf_Model_Interface $model2) { $formats = array_values(array_intersect($model1->getSupportedImportExportFormats(), $model2->getSupportedImportExportFormats())); if (!$formats || !$formats[0]) { throw new Kwf_Exception("Model '" . get_class($model1) . "' cannot copy data " . "from model '" . get_class($model2) . "'. Import / Export Formats are not compatible."); } return $formats[0]; }
public function clearRows() { parent::clearRows(); $this->_sourceModel->clearRows(); }
private function _getExportData($onlyShowIn, $calcEstimatedMemUsageType, $memoryLimitMb = 0) { if (!isset($this->_model)) { $rowSet = $this->_fetchData(null, null, null); $countRows = count($rowSet); } else { $sel = $this->_getSelect(); if (is_null($sel)) { return array(); } //TODO: dieser code sollte in _getOrder liegen $order = $this->_defaultOrder; if ($this->getRequest()->getParam('sort')) { $order['field'] = $this->getRequest()->getParam('sort'); } if ($this->_getParam("direction") && $this->_getParam('direction') != 'undefined') { $order['direction'] = $this->_getParam('direction'); } $order = $this->_getOrder($order); if ($order) { $sel->order($order); } $countRows = $this->_model->countRows($sel); $rowSet = $this->_model->getRows($sel); } if ($rowSet && $countRows) { $this->_progressBar = new Zend_ProgressBar(new Kwf_Util_ProgressBar_Adapter_Cache($this->_getParam('progressNum')), 0, $countRows * 1.05 * 3); // Index 0 reserved for column headers $exportData = array(0 => array()); $estimatedMemoryUsage = memory_get_usage(); $memForRows = array(); $rowLenghtes = array(); $columns = $columnsHeader = array(); foreach ($rowSet as $row) { $rowBeginMemUsage = memory_get_usage(); if (is_array($row)) { // wenn _fetchData() überschrieben wurde $row = (object) $row; } if (!$this->_hasPermissions($row, 'load')) { throw new Kwf_Exception("You don't have the permissions to load this row"); } $columns = $columnsHeader = array(); foreach ($this->_columns as $column) { if (!($column->getShowIn() & $onlyShowIn)) { continue; } $currentColumnHeader = $column->getHeader(); if (!is_null($currentColumnHeader)) { $columnsHeader[] = (string) $currentColumnHeader; $colVal = $column->load($row, Kwf_Grid_Column::ROLE_EXPORT, array()); $setTypeTo = 'string'; if ($column->getType()) { if ($column->getType() == 'boolean' || $column->getType() == 'bool') { $setTypeTo = 'bool'; } if ($column->getType() == 'integer' || $column->getType() == 'int') { $setTypeTo = 'int'; } if ($column->getType() == 'double' || $column->getType() == 'float') { $setTypeTo = 'float'; } if ($column->getType() == 'null') { $setTypeTo = 'null'; } } if ($setTypeTo == 'bool') { if ($colVal) { $colVal = trlKwf('Yes'); } else { $colVal = trlKwf('No'); } } else { settype($colVal, $setTypeTo); } $columns[] = $colVal; } } $exportData[] = $columns; // zum berechnen des geschätzten speicherverbrauchs if ($memoryLimitMb) { if (count($rowLenghtes) == 40) { // text length $estimatedMemoryUsage += array_sum($rowLenghtes) / count($rowLenghtes) * $countRows; // daten sammeln in dieser schleife hier $estimatedMemoryUsage += array_sum($memForRows) / count($memForRows) * $countRows; // xls export if ($calcEstimatedMemUsageType == 'xls') { $estimatedMemoryUsage += 1400 * $countRows * count($columns); } /** * TODO: Calculating for csv */ if ($estimatedMemoryUsage / 1024 / 1024 > $memoryLimitMb) { throw new Kwf_Exception_Client(trlKwf("Too many rows to export. Try exporting two times with fewer rows.")); } } if (count($rowLenghtes) < 41) { $memForRows[] = memory_get_usage() - $rowBeginMemUsage; $rowLenghtes[] = strlen(implode('', $columns)); } } $this->_progressBar->next(2, trlKwf('Collecting data')); } $exportData[0] = $columnsHeader; return $exportData; } else { $this->_progressBar = new Zend_ProgressBar(new Kwf_Util_ProgressBar_Adapter_Cache($this->_getParam('progressNum')), 0, 4); } return array(); }
public function isEqual(Kwf_Model_Interface $other) { if ($other instanceof Kwf_Model_Service && $other->getClient() == $this->getClient()) { return true; } return false; }
public function count() { return $this->_model->countRows($this->_select); }