本文整理汇总了PHP中DataObjectCollection::getModel方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObjectCollection::getModel方法的具体用法?PHP DataObjectCollection::getModel怎么用?PHP DataObjectCollection::getModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataObjectCollection
的用法示例。
在下文中一共展示了DataObjectCollection::getModel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index(DataObjectCollection $collection, $sh = '', &$c_query = null)
{
$display_fields = array();
$model = $collection->getModel();
// If selection of display fields is disabled, don't set them up
if (!$this->search->disable_field_selection) {
foreach ($model->getFields() as $fieldname => $field) {
if ($fieldname != 'id' && $fieldname != 'usercompanyid' && substr($fieldname, -3) != '_id' && !isset($model->belongsToField[$fieldname])) {
$display_fields[$fieldname] = $field->tag;
}
}
$selected_fields = array();
if (isset($this->_data['Search']['display_fields'])) {
foreach ($this->_data['Search']['display_fields'] as $fieldname => $field) {
$selected_fields[$fieldname] = prettify($field);
}
} else {
foreach ($collection->getFields() as $fieldname => $field) {
if (substr($fieldname, -3) != '_id') {
$selected_fields[$fieldname] = $field->tag;
}
}
}
$this->view->set('selected_fields', $selected_fields);
$display_fields = array_diff($display_fields, $selected_fields);
$this->view->set('display_fields', $display_fields);
}
if (!isset($this->_data['ajax_print'])) {
parent::index($collection, $sh, $c_query);
return;
}
showtime('start-controller-index');
$collection->setParams();
if (!$sh instanceof SearchHandler) {
$sh = $this->setSearchHandler($collection);
}
showtime('sh-extracted');
// Need to set the orderby of the collection in the searchhandler?
// But if this is set in the collection, seems to take it
// so why not here?
showtime('pre-load');
// TODO: Printing needs looking at; the model is too complicated and
// therefore maintenance is difficult. Needs breaking down into more
// logical discrete units.
// BEWARE: the following may not work for all cases
// needs extensive testing; this is implemented for selectorController output
if ($this->_data['session_key'] == 'undefined') {
$sh->setLimit(0);
$collection->load($sh);
$this->PrintCollection($collection);
}
// echo 'controller::index setting printing session data<br>';
// in this instance we can only pass the data through the session
// but it's only the collection name and search id :-)
$_SESSION['printing'][$this->_data['session_key']]['collection'] = get_class($collection);
$_SESSION['printing'][$this->_data['session_key']]['search_id'] = $this->_data['search_id'];
exit;
showtime('end-controller-index');
}
示例2: __construct
public function __construct(DataObjectCollection $collection, $use_session = TRUE, $use_system_company = TRUE, $search_id = '')
{
$tablename = $collection->getViewName();
$this->tablename = $tablename;
$this->use_session = $use_session;
$this->search_id = $search_id;
$this->constraints = new ConstraintChain();
$this->use_system_company = $use_system_company;
$this->setOrderby($collection->orderby, $collection->direction);
if (strpos($tablename, ' ')) {
$this->tablename = substr($tablename, strrpos($tablename, ' ') + 1);
}
$cache_id = array('searches', EGS_USERNAME, $this->tablename . '_' . $this->search_id);
$cache = Cache::Instance();
$cached_search = $cache->get($cache_id, 1800);
if ($this->use_session && $cached_search !== FALSE) {
foreach ($cached_search as $key => $val) {
if ($key == 'constraints' || $key == 'fields') {
$this->{$key} = unserialize($val);
} else {
$this->{$key} = $val;
}
}
debug('SearchHandler::__construct ' . $tablename . ' ' . print_r($this, TRUE));
// echo 'SearchHandler::__construct<pre>'.print_r($this, true).'</pre>';
} elseif ($this->use_system_company) {
//if usercompanyid is a field, then it's always a constraint
// TODO: Need to revisit this;
// gets added in DataObject(?)/DataObjectCollection(?)
// if the search is access controlled
$model = $collection->getModel();
if ($model->isField('usercompanyid')) {
$this->constraints = new ConstraintChain();
$this->addConstraint(new Constraint('usercompanyid', '=', EGS_COMPANY_ID));
}
}
$this->collection = $collection;
}