本文整理汇总了PHP中ArrayList::unshift方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayList::unshift方法的具体用法?PHP ArrayList::unshift怎么用?PHP ArrayList::unshift使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayList
的用法示例。
在下文中一共展示了ArrayList::unshift方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canBeDiscounted
/**
* normally returns TRUE, but returns FALSE when it, or its parent is in the list.
* todo: add products in other product categories
* @param SiteTree $page
* @return Boolean
*/
function canBeDiscounted(SiteTree $page)
{
if ($this->owner->PageIDs) {
$allowedPageIDs = explode(',', $this->owner->PageIDs);
$checkPages = new ArrayList(array($page));
$alreadyCheckedPageIDs = array();
while ($checkPages->Count()) {
$page = $checkPages->First();
if (array_search($page->ID, $allowedPageIDs) !== false) {
return true;
}
$alreadyCheckedPageIDs[] = $page->ID;
$checkPages->remove($page);
// Parents list update
if ($page->hasMethod('AllParentGroups')) {
$parents = new ArrayList($page->AllParentGroups()->toArray());
} else {
$parents = new ArrayList();
}
$parent = $page->Parent();
if ($parent && $parent->exists()) {
$parents->unshift($parent);
}
foreach ($parents as $parent) {
if (array_search($parent->ID, $alreadyCheckedPageIDs) === false) {
$checkPages->push($parent);
}
}
$checkPages->removeDuplicates();
}
return false;
}
return true;
}
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce-discount-coupon,代码行数:40,代码来源:DiscountCouponSiteTreeDOD.php
示例2: AllImages
/**
* Combines the main image and the secondary images
* @return ArrayList
*/
function AllImages()
{
$list = new ArrayList($this->owner->AdditionalImages()->sort('SortOrder')->toArray());
$main = $this->owner->Image();
if ($main && $main->exists()) {
$list->unshift($main);
}
return $list;
}
示例3: getBreadcrumbs
/**
* @return ArrayList
*/
function getBreadcrumbs()
{
$out = new ArrayList();
$cur = $this;
while ($cur && $cur->exists()) {
$out->unshift($cur);
$cur = $cur->ParentSearchID > 0 ? $cur->ParentSearch() : null;
}
return $out;
}
示例4: Navigation
/**
* Returns top level navigation of projects.
*
* @param int $limit
*
* @return ArrayList
*/
public function Navigation($limit = 5)
{
$navigation = new ArrayList();
$currentProject = $this->getCurrentProject();
$projects = $this->getStarredProjects();
if ($projects->count() < 1) {
$projects = $this->DNProjectList();
} else {
$limit = -1;
}
if ($projects->count() > 0) {
$activeProject = false;
if ($limit > 0) {
$limitedProjects = $projects->limit($limit);
} else {
$limitedProjects = $projects;
}
foreach ($limitedProjects as $project) {
$isActive = $currentProject && $currentProject->ID == $project->ID;
if ($isActive) {
$activeProject = true;
}
$navigation->push(array('Project' => $project, 'IsActive' => $currentProject && $currentProject->ID == $project->ID));
}
// Ensure the current project is in the list
if (!$activeProject && $currentProject) {
$navigation->unshift(array('Project' => $currentProject, 'IsActive' => true));
if ($limit > 0 && $navigation->count() > $limit) {
$navigation->pop();
}
}
}
return $navigation;
}
示例5: Navigation
/**
* Returns top level navigation of projects.
*
* @param int $limit
*
* @return ArrayList
*/
public function Navigation($limit = 5)
{
$navigation = new ArrayList();
$currentProject = $this->getCurrentProject();
$currentEnvironment = $this->getCurrentEnvironment();
$actionType = $this->getCurrentActionType();
$projects = $this->getStarredProjects();
if ($projects->count() < 1) {
$projects = $this->DNProjectList();
} else {
$limit = -1;
}
if ($projects->count() > 0) {
$activeProject = false;
if ($limit > 0) {
$limitedProjects = $projects->limit($limit);
} else {
$limitedProjects = $projects;
}
foreach ($limitedProjects as $project) {
$isActive = $currentProject && $currentProject->ID == $project->ID;
if ($isActive) {
$activeProject = true;
}
$isCurrentEnvironment = false;
if ($project && $currentEnvironment) {
$isCurrentEnvironment = (bool) $project->DNEnvironmentList()->find('ID', $currentEnvironment->ID);
}
$navigation->push(['Project' => $project, 'IsCurrentEnvironment' => $isCurrentEnvironment, 'IsActive' => $currentProject && $currentProject->ID == $project->ID, 'IsOverview' => $actionType == self::PROJECT_OVERVIEW && !$isCurrentEnvironment && $currentProject->ID == $project->ID]);
}
// Ensure the current project is in the list
if (!$activeProject && $currentProject) {
$navigation->unshift(['Project' => $currentProject, 'IsActive' => true, 'IsCurrentEnvironment' => $currentEnvironment, 'IsOverview' => $actionType == self::PROJECT_OVERVIEW && !$currentEnvironment]);
if ($limit > 0 && $navigation->count() > $limit) {
$navigation->pop();
}
}
}
return $navigation;
}
示例6: unshift
/**
* Push a single field onto the beginning of this FieldList instance.
*
* @param FormField $item The FormField to add
*/
public function unshift($item)
{
$this->onBeforeInsert($item);
$item->setContainerFieldList($this);
return parent::unshift($item);
}
示例7: BreadcrumbParts
/**
* manipulates the parts the pages breadcrumbs if a product detail view is
* requested.
*
* @param int $maxDepth maximum depth level of shown pages in breadcrumbs
* @param bool $unlinked true, if the breadcrumbs should be displayed without links
* @param string $stopAtPageType name of pagetype to stop at
* @param bool $showHidden true, if hidden pages should be displayed in breadcrumbs
*
* @return ArrayList
*
* @author Sebastian Diel <sdiel@pixeltricks.de>, Patrick Schneider <pschneider@pixeltricks.de>
* @since 09.10.2012
*/
public function BreadcrumbParts($maxDepth = 20, $unlinked = false, $stopAtPageType = false, $showHidden = false)
{
$parts = new ArrayList();
$page = $this;
while ($page && (!$maxDepth || $parts->count() < $maxDepth) && (!$stopAtPageType || $page->ClassName != $stopAtPageType)) {
if ($showHidden || $page->ShowInMenus || $page->ID == $this->ID) {
if ($page->hasMethod('OriginalLink')) {
$link = $page->OriginalLink();
} else {
$link = $page->Link();
}
if ($page->ID == $this->ID) {
$isActive = true;
} else {
$isActive = false;
}
$parts->unshift(new ArrayData(array('MenuTitle' => $page->MenuTitle, 'Title' => $page->Title, 'Link' => $link, 'Parent' => $page->Parent, 'IsActive' => $isActive)));
}
$page = $page->Parent;
}
return $parts;
}