本文整理汇总了PHP中selector::flush方法的典型用法代码示例。如果您正苦于以下问题:PHP selector::flush方法的具体用法?PHP selector::flush怎么用?PHP selector::flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selector
的用法示例。
在下文中一共展示了selector::flush方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: guide_items_all
public function guide_items_all() {
$this->setDataType("list");
$this->setActionType("modify");
if($this->ifNotXmlMode()) return $this->doData();
$per_page = $this->per_page;
$guide_id = (int) getRequest('param0');
$sel = new selector('objects');
$sel->types('object-type')->id($guide_id);
$maxItemsCount = (int) mainConfiguration::getInstance()->get("kernel", "max-guided-items");
if ($maxItemsCount && $maxItemsCount <= 15 && $maxItemsCount > 0) {
$maxItemsCount = 16;
} elseif ($maxItemsCount <= 0) {
$maxItemsCount = 50;
}
if ($textSearch = getRequest('search')) {
foreach($textSearch as $searchString)
$sel->where('name')->like('%' . $searchString . '%');
}
if (!permissionsCollection::getInstance()->isSv()) {
$sel->where('guid')->notequals('users-users-15');
}
if(!is_null(getRequest('limit'))) {
$sel->limit((15 * (int) getRequest('p')), 15);
}
$sel->option('return')->value('count');
$total = $sel->length;
if(!is_null(getRequest('allow-empty')) && $total > $maxItemsCount) {
$data = Array(
'empty' => Array(
'attribute:total' => $total,
'attribute:result' => 'Too much items'
)
);
$this->setDataRange(0, 0);
$this->setData($data, $total);
return $this->doData();
} else {
$sel->flush();
$sel->option('return')->value('id');
$guide_items = array();
$tmp = array();
$objects = umiObjectsCollection::getInstance();
foreach($sel->result as $itemArray) {
$itemId = $itemArray['id'];
$item = $objects->getObject($itemId);
if ($item instanceof umiObject) {
$tmp[$itemId] = $item->getName();
$guide_items[$itemId] = $item;
}
}
if(!intval(regedit::getInstance()->getVal("//settings/ignore_guides_sort"))) {
natsort($tmp);
$guide_items = array_keys($tmp);
unset($tmp);
}
$this->setDataRangeByPerPage($maxItemsCount, 0);
$data = $this->prepareData($guide_items, "objects");
$this->setData($data, $total);
return $this->doData();
}
}
示例2: renderEditFieldRelation
/**
* TODO PHPDoc
* Enter description here ...
* @param unknown_type $field
* @param unknown_type $is_multiple
* @param unknown_type $object
* @param unknown_type $template
*/
public function renderEditFieldRelation($field, $is_multiple, $object, $template)
{
if (!$field instanceof umiField) {
return;
}
$controller = cmsController::getInstance();
$objects = umiObjectsCollection::getInstance();
$guide_items = array();
$fieldName = $field->getName();
if ($guide_id = $field->getGuideId()) {
if ($controller->getCurrentMode() != "admin") {
$guide_items = $objects->getGuidedItems($guide_id);
} else {
try {
$sel = new selector('objects');
$sel->option('return')->value('count');
$sel->types('object-type')->id($guide_id);
$total = $sel->length;
} catch (selectorException $e) {
$total = 16;
}
if ($total <= 15) {
$sel->flush();
$sel->option('return')->value('id', 'name');
foreach ($sel->result as $item) {
$guide_items[$item['id']] = $item['name'];
}
} else {
if ($object instanceof iUmiObject) {
$val = $object->getValue($fieldName);
} else {
$val = false;
}
if ($val && !is_array($val)) {
$val = array($val);
}
if (is_array($val)) {
foreach ($val as $item_id) {
$item = $objects->getObject($item_id);
if ($item instanceof iUmiObject) {
$guide_items[$item_id] = $item->getName();
}
}
unset($item_id, $item, $val);
}
}
}
}
if (sizeof($guide_items) == 0) {
if ($object instanceof iUmiObject) {
$val = $object->getValue($fieldName);
if ($val && !is_array($val)) {
$val = array($val);
}
if (sizeof($val)) {
foreach ($val as $itemId) {
if ($item = selector::get('object')->id($itemId)) {
$guide_items[$itemId] = $item->name;
}
}
}
}
}
list($template_block, $template_block_line, $template_block_line_a, $template_mul_block, $template_mul_block_line, $template_mul_block_line_a) = def_module::loadTemplates("data/reflection/{$template}", "reflection_field_relation", "reflection_field_relation_option", "reflection_field_relation_option_a", "reflection_field_multiple_relation", "reflection_field_multiple_relation_option", "reflection_field_multiple_relation_option_a");
$block_arr = array();
$value = $object ? $object->getValue($fieldName) : array();
if ($fieldName == 'publish_status' && $controller->getCurrentMode() != "admin") {
return "";
}
$block_arr['attribute:name'] = $fieldName;
$block_arr['attribute:title'] = $field->getTitle();
$block_arr['attribute:tip'] = $field->getTip();
$block_arr['attribute:field_id'] = $field->getId();
if ($is_multiple) {
$block_arr['attribute:multiple'] = "multiple";
}
if ($guide_id) {
$block_arr['attribute:type-id'] = $guide_id;
$guide = umiObjectTypesCollection::getInstance()->getType($guide_id);
if ($guide instanceof umiObjectType) {
if ($guide->getIsPublic()) {
$block_arr['attribute:public-guide'] = true;
}
}
}
$options = $is_multiple ? array() : "";
foreach ($guide_items as $item_id => $item_name) {
$item_object = $objects->getObject($item_id);
if (!is_object($item_object)) {
continue;
}
if ($is_multiple) {
//.........这里部分代码省略.........