本文整理汇总了PHP中SS_HTTPRequest::latestparam方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_HTTPRequest::latestparam方法的具体用法?PHP SS_HTTPRequest::latestparam怎么用?PHP SS_HTTPRequest::latestparam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS_HTTPRequest
的用法示例。
在下文中一共展示了SS_HTTPRequest::latestparam方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tree
/**
* Get the whole tree of a part of the tree via an AJAX request with empty / none item prepended.
*
* @param SS_HTTPRequest $request
* @return string
* for version 2.4 and later
*/
public function tree(SS_HTTPRequest $request)
{
if ($ID = (int) $request->latestparam('ID')) {
return parent::tree($request);
} else {
return $this->preTree() . parent::tree($request) . OptionalTreeDropdownField::$postTree;
}
}
示例2: tree
/**
* Get the whole tree of a part of the tree via an AJAX request.
*
* @param SS_HTTPRequest $request
* @return string
*/
public function tree(SS_HTTPRequest $request)
{
// Array sourceObject is an explicit list of values - construct a "flat tree"
if (is_array($this->sourceObject)) {
$output = "<ul class=\"tree\">\n";
foreach ($this->sourceObject as $k => $v) {
$output .= '<li id="selector-' . $this->name . '-' . $k . '"><a>' . $v . '</a>';
}
$output .= "</ul>";
return $output;
}
// Regular source specification
$isSubTree = false;
$this->search = $request->requestVar('search');
$ID = is_numeric($request->latestparam('ID')) ? (int) $request->latestparam('ID') : (int) $request->requestVar('ID');
if ($ID && !$request->requestVar('forceFullTree')) {
$obj = DataObject::get_by_id($this->sourceObject, $ID);
$isSubTree = true;
if (!$obj) {
throw new Exception("TreeDropdownField->tree(): the object #{$ID} of type {$this->sourceObject} could not be found");
}
} else {
if ($this->baseID) {
$obj = DataObject::get_by_id($this->sourceObject, $this->baseID);
}
if (!$this->baseID || !$obj) {
$obj = singleton($this->sourceObject);
}
}
// pre-process the tree - search needs to operate globally, not locally as marking filter does
if ($this->search != "") {
$this->populateIDs();
}
if ($this->filterCallback || $this->search != "") {
$obj->setMarkingFilterFunction(array($this, "filterMarking"));
}
$obj->markPartialTree($nodeCountThreshold = 30, $context = null, $this->childrenMethod, $this->numChildrenMethod);
// allow to pass values to be selected within the ajax request
if (isset($_REQUEST['forceValue']) || $this->value) {
$forceValue = isset($_REQUEST['forceValue']) ? $_REQUEST['forceValue'] : $this->value;
if (($values = preg_split('/,\\s*/', $forceValue)) && count($values)) {
foreach ($values as $value) {
if (!$value || $value == 'unchanged') {
continue;
}
$obj->markToExpose($this->objectForKey($value));
}
}
}
$self = $this;
$titleFn = function (&$child) use(&$self) {
$keyField = $self->keyField;
$labelField = $self->labelField;
return sprintf('<li id="selector-%s-%s" data-id="%s" class="class-%s %s %s"><a rel="%d">%s</a>', Convert::raw2xml($self->getName()), Convert::raw2xml($child->{$keyField}), Convert::raw2xml($child->{$keyField}), Convert::raw2xml($child->class), Convert::raw2xml($child->markingClasses($self->numChildrenMethod)), $self->nodeIsDisabled($child) ? 'disabled' : '', (int) $child->ID, $child->obj($labelField)->forTemplate());
};
// Limit the amount of nodes shown for performance reasons.
// Skip the check if we're filtering the tree, since its not clear how many children will
// match the filter criteria until they're queried (and matched up with previously marked nodes).
$nodeThresholdLeaf = Config::inst()->get('Hierarchy', 'node_threshold_leaf');
if ($nodeThresholdLeaf && !$this->filterCallback && !$this->search) {
$className = $this->sourceObject;
$nodeCountCallback = function ($parent, $numChildren) use($className, $nodeThresholdLeaf) {
if ($className == 'SiteTree' && $parent->ID && $numChildren > $nodeThresholdLeaf) {
return sprintf('<ul><li><span class="item">%s</span></li></ul>', _t('LeftAndMain.TooManyPages', 'Too many pages'));
}
};
} else {
$nodeCountCallback = null;
}
if ($isSubTree) {
$html = $obj->getChildrenAsUL("", $titleFn, null, true, $this->childrenMethod, $this->numChildrenMethod, true, null, $nodeCountCallback);
return substr(trim($html), 4, -5);
} else {
$html = $obj->getChildrenAsUL('class="tree"', $titleFn, null, true, $this->childrenMethod, $this->numChildrenMethod, true, null, $nodeCountCallback);
return $html;
}
}