Up pages menu position

@param string $menuName
@param number $position
@param number $positionLimit
324965
public function upMenuPagesPosition($menuName, $position, $positionLimit = NULL)
    {
        if (is_null($positionLimit))
        {
            $query = $this->getEntityManager()->createQuery('UPDATE FulgurioLightCMSBundle:PageMenu m SET m.position=m.position-1 WHERE m.position>=:position AND m.label=:menuName');
        }
        else
        {
            $query = $this->getEntityManager()->createQuery('UPDATE FulgurioLightCMSBundle:PageMenu m SET m.position=m.position-1 WHERE m.position>=:position AND m.position<=:positionLimit AND m.label=:menuName');
            $query->setParameter('positionLimit', $positionLimit);
        }
        $query->setParameter('menuName', $menuName);
        $query->setParameter('position', $position);
        $query->getResult();
    }
167086
private function buildMenuItem($menuName, $subMenuName, $url, $order = 50, $tooltip = false, $icon = false, $onclick = false)
    {
        if (!isset($this->menu[$menuName])) {
            $this->menu[$menuName] = array(
                '_hasSubmenu' => false,
                '_order' => $order
            );
        }

        if (empty($subMenuName)) {
            $this->menu[$menuName]['_url']   = $url;
            $this->menu[$menuName]['_order'] = $order;
            $this->menu[$menuName]['_name']  = $menuName;
            $this->menu[$menuName]['_tooltip'] = $tooltip;
            if (!empty($this->menuIcons[$menuName])) {
                $this->menu[$menuName]['_icon'] = $this->menuIcons[$menuName];
            } else {
                $this->menu[$menuName]['_icon'] = '';
            }
        }
        if (!empty($subMenuName)) {
            $this->menu[$menuName][$subMenuName]['_url'] = $url;
            $this->menu[$menuName][$subMenuName]['_order'] = $order;
            $this->menu[$menuName][$subMenuName]['_name'] = $subMenuName;
            $this->menu[$menuName][$subMenuName]['_tooltip'] = $tooltip;
            $this->menu[$menuName][$subMenuName]['_icon'] = $icon;
            $this->menu[$menuName][$subMenuName]['_onclick'] = $onclick;
            $this->menu[$menuName]['_hasSubmenu'] = true;

            if (!array_key_exists('_tooltip', $this->menu[$menuName])) {
                $this->menu[$menuName]['_tooltip'] = $tooltip;
            }
        }
    }
1041553
public function setPosition(WebDriverPoint $position)
    {
        $params = [
            'x' => $position->getX(),
            'y' => $position->getY(),
            ':windowHandle' => 'current',
        ];
        $this->executor->execute(DriverCommand::SET_WINDOW_POSITION, $params);

        return $this;
    }
558846
private function addLocationsToMenu(ItemInterface $menu, array $searchHits)
    {
        foreach ($searchHits as $searchHit) {
            /** @var Location $location */
            $location = $searchHit->valueObject;
            $menuItem = isset($menu[$location->parentLocationId]) ? $menu[$location->parentLocationId] : $menu;
            $menuItem->addChild(
                $location->id,
                array(
                    'label' => $this->translationHelper->getTranslatedContentNameByContentInfo($location->contentInfo),
                    'uri' => $this->router->generate($location),
                    'attributes' => array('id' => 'nav-location-' . $location->id),
                )
            );
            $menuItem->setChildrenAttribute('class', 'nav');
        }
    }
1163033
public function moveNode( $sourceNode, $position, $relatedNode )
    {
        if ( ! $this->getUserPermissionsModel()
                    ->isAllowed( 'menu', 'edit' ) )
        {
            return array(
                'sourceNode'    => $sourceNode,
                'position'      => $position,
                'relatedNode'   => $relatedNode,
                'success'       => false,
            );
        }

        $success = $this->getMapper()
                        ->moveNode( $sourceNode,
                                    strtolower( $position ),
                                    $relatedNode );

        return array(
            'sourceNode'    => $sourceNode,
            'position'      => $position,
            'relatedNode'   => $relatedNode,
            'success'       => (bool) $success,
        );
    }
1370948
protected function handleUnmatchedState($content, $position, TokenList $tokenList) {
        if (empty($content)) {
            return;
        }

        $contentTokenList = $this->parseContent($content);

        $startRule = $this->set->getStartRule();

        for ($i = 0; $i < count($contentTokenList); $i++) {
            if ($contentTokenList->getTokenAt($i)->getName() === $this->name) {
                $token = $contentTokenList->getTokenAt($i);
                $contentTokenList->removeTokenAt($i);
                $contentTokenList->insertTokenAt($startRule->getName(), $token->getPosition(), $i)
                    ->set('content', $token->get('content', ''));
            }
        }

        $tokenList->merge($contentTokenList);

    }
712705
public function addDevelopmentItem($menuName, $url, $order = 50, $tooltip = false)
    {
        if (Development::isEnabled()) {
            $this->addItem('CoreAdminHome_MenuDevelopment', $menuName, $url, $order, $tooltip);
        }
    }
817713
protected void updateExpiredOverlayPosition(Element positioningParent) {

        if (m_expiredOverlay != null) {
            Style expiredStyle = m_expiredOverlay.getStyle();
            expiredStyle.setHeight(m_position.getHeight() + 4, Unit.PX);
            expiredStyle.setWidth(m_position.getWidth() + 4, Unit.PX);
            expiredStyle.setTop(m_position.getTop() - positioningParent.getAbsoluteTop() - 2, Unit.PX);
            expiredStyle.setLeft(m_position.getLeft() - positioningParent.getAbsoluteLeft() - 2, Unit.PX);
        }
    }
1258575
public function addMenuItem(MenuItem $menuItem, $position = -1) {
        if (!is_int($position)) {
            throw new InvalidArgumentException('position should be of type int.');
        }

        if ($position < 0) {
            $position = count($this->menuItems);
        }

        $menuItem->setOrder($position);

        Utils::array_insert($this->menuItems, $menuItem, $position);

        return $this;
    }
899366
public function paginate($pageLimit = 25)
    {
        $page = Paginator::resolveCurrentPage() ?: 1;
       
        return new Paginator($this->items, $this->hits, $this->totalHits(), $pageLimit, $page, ['path' => Paginator::resolveCurrentPath()]);
    }
405282
private void updatePositions(int position) {

        for (int i = position; i < m_subEntries.size(); i++) {
            m_subEntries.get(i).setPosition(i);
        }
    }
322050
private function updatePageMenuPosition(Page $page)
    {
        $pageMenuRepository = $this->doctrine->getRepository('FulgurioLightCMSBundle:PageMenu');
        $em = $this->doctrine->getManager();
        $data = $this->request->get('page');
        if (isset($data['availableMenu']))
        {
            if (!is_null($page->getId()))
            {
                $menus = $page->getMenu();
                $alreadyInMenu = array();
                foreach ($menus as $menu)
                {
                    if (!in_array($menu->getLabel(), $data['availableMenu']))
                    {
                        $pageMenuRepository->upMenuPagesPosition($menu->getLabel(), $menu->getPosition() + 1);
                        $em->remove($menu);
                    }
                    else
                    {
                        $alreadyInMenu[] = $menu->getLabel();
                    }
                }
            }
            foreach ($data['availableMenu'] as $menuLabel)
            {
                // If it s a new page, or if it a page which we had a new menu
                if (!isset($alreadyInMenu) || !in_array($menuLabel, $alreadyInMenu))
                {
                    $menu = new PageMenu();
                    $menu->setPosition($pageMenuRepository->getNextMenuPosition($menuLabel));
                    $menu->setLabel($menuLabel);
                    $menu->setPage($page);
                    $em->persist($menu);
                }
            }
        }
        else if (!is_null($page->getId()))
        {
            $menus = $page->getMenu();
            foreach ($menus as $menu)
            {
                $pageMenuRepository->upMenuPagesPosition($menu->getLabel(), $menu->getPosition() + 1);
                $em->remove($menu);
            }
        }
    }
389291
function (position) {
                /** @type {?} */
                var positionChangeData = new PositionChangeData(position, this.limitRoles);
                /** @type {?} */
                var limitException = this.limitsService.exceedsLimit(positionChangeData);
                if (limitException.exceeds) {
                    // if exceeds limits, reposition
                    this.resetPosition = limitException.resetCoordinates;
                }
                else {
                    this.limitsService.positionChange(positionChangeData);
                    this._currentPosition = position;
                }
            }
1230023
public void setRewindPosition(@NonNull String frameName, int position) {
        frames.get(frameName).setRewindPosition(position);
    }
1115100
function MovePages($target_page, $start_page, $end_page = -1)
	{
		// move a page/pages EARLIER in the document
		if ($end_page < 1) {
			$end_page = $start_page;
		}
		$n_toc = $end_page - $start_page + 1;

		// Set/Update PageNumSubstitutions changes before moving anything
		if (count($this->PageNumSubstitutions)) {
			$tp_present = false;
			$sp_present = false;
			$ep_present = false;
			foreach ($this->PageNumSubstitutions as $k => $v) {
				if ($this->PageNumSubstitutions[$k]['from'] == $target_page) {
					$tp_present = true;
					if ($this->PageNumSubstitutions[$k]['suppress'] != 'on' && $this->PageNumSubstitutions[$k]['suppress'] != 1) {
						$this->PageNumSubstitutions[$k]['suppress'] = 'off';
					}
				}
				if ($this->PageNumSubstitutions[$k]['from'] == $start_page) {
					$sp_present = true;
					if ($this->PageNumSubstitutions[$k]['suppress'] != 'on' && $this->PageNumSubstitutions[$k]['suppress'] != 1) {
						$this->PageNumSubstitutions[$k]['suppress'] = 'off';
					}
				}
				if ($this->PageNumSubstitutions[$k]['from'] == ($end_page + 1)) {
					$ep_present = true;
					if ($this->PageNumSubstitutions[$k]['suppress'] != 'on' && $this->PageNumSubstitutions[$k]['suppress'] != 1) {
						$this->PageNumSubstitutions[$k]['suppress'] = 'off';
					}
				}
			}

			if (!$tp_present) {
				list($tp_type, $tp_suppress, $tp_reset) = $this->docPageSettings($target_page);
			}
			if (!$sp_present) {
				list($sp_type, $sp_suppress, $sp_reset) = $this->docPageSettings($start_page);
			}
			if (!$ep_present) {
				list($ep_type, $ep_suppress, $ep_reset) = $this->docPageSettings($start_page - 1);
			}
		}

		$last = [];
		// store pages
		for ($i = $start_page; $i <= $end_page; $i++) {
			$last[] = $this->pages[$i];
		}
		// move pages
		for ($i = $start_page - 1; $i >= ($target_page); $i--) {
			$this->pages[$i + $n_toc] = $this->pages[$i];
		}
		// Put toc pages at insert point
		for ($i = 0; $i < $n_toc; $i++) {
			$this->pages[$target_page + $i] = $last[$i];
		}

		/* -- BOOKMARKS -- */
		// Update Bookmarks
		foreach ($this->BMoutlines as $i => $o) {
			if ($o['p'] >= $target_page) {
				$this->BMoutlines[$i]['p'] += $n_toc;
			}
		}
		/* -- END BOOKMARKS -- */

		// Update Page Links
		if (count($this->PageLinks)) {
			$newarr = [];
			foreach ($this->PageLinks as $i => $o) {
				foreach ($this->PageLinks[$i] as $key => $pl) {
					if (strpos($pl[4], '@') === 0) {
						$p = substr($pl[4], 1);
						if ($p >= $start_page && $p <= $end_page) {
							$this->PageLinks[$i][$key][4] = '@' . ($p + ($target_page - $start_page));
						} elseif ($p >= $target_page && $p < $start_page) {
							$this->PageLinks[$i][$key][4] = '@' . ($p + $n_toc);
						}
					}
				}
				if ($i >= $start_page && $i <= $end_page) {
					$newarr[($i + ($target_page - $start_page))] = $this->PageLinks[$i];
				} elseif ($i >= $target_page && $i < $start_page) {
					$newarr[($i + $n_toc)] = $this->PageLinks[$i];
				} else {
					$newarr[$i] = $this->PageLinks[$i];
				}
			}
			$this->PageLinks = $newarr;
		}

		// OrientationChanges
		if (count($this->OrientationChanges)) {
			$newarr = [];
			foreach ($this->OrientationChanges as $p => $v) {
				if ($p >= $start_page && $p <= $end_page) {
					$newarr[($p + ($target_page - $start_page))] = $this->OrientationChanges[$p];
				} elseif ($p >= $target_page && $p < $start_page) {
					$newarr[$p + $n_toc] = $this->OrientationChanges[$p];
				} else {
					$newarr[$p] = $this->OrientationChanges[$p];
				}
			}
			ksort($newarr);
			$this->OrientationChanges = $newarr;
		}

		// Page Dimensions
		if (count($this->pageDim)) {
			$newarr = [];
			foreach ($this->pageDim as $p => $v) {
				if ($p >= $start_page && $p <= $end_page) {
					$newarr[($p + ($target_page - $start_page))] = $this->pageDim[$p];
				} elseif ($p >= $target_page && $p < $start_page) {
					$newarr[$p + $n_toc] = $this->pageDim[$p];
				} else {
					$newarr[$p] = $this->pageDim[$p];
				}
			}
			ksort($newarr);
			$this->pageDim = $newarr;
		}

		// HTML Headers & Footers
		if (count($this->saveHTMLHeader)) {
			$newarr = [];
			foreach ($this->saveHTMLHeader as $p => $v) {
				if ($p >= $start_page && $p <= $end_page) {
					$newarr[($p + ($target_page - $start_page))] = $this->saveHTMLHeader[$p];
				} elseif ($p >= $target_page && $p < $start_page) {
					$newarr[$p + $n_toc] = $this->saveHTMLHeader[$p];
				} else {
					$newarr[$p] = $this->saveHTMLHeader[$p];
				}
			}
			ksort($newarr);
			$this->saveHTMLHeader = $newarr;
		}
		if (count($this->saveHTMLFooter)) {
			$newarr = [];
			foreach ($this->saveHTMLFooter as $p => $v) {
				if ($p >= $start_page && $p <= $end_page) {
					$newarr[($p + ($target_page - $start_page))] = $this->saveHTMLFooter[$p];
				} elseif ($p >= $target_page && $p < $start_page) {
					$newarr[$p + $n_toc] = $this->saveHTMLFooter[$p];
				} else {
					$newarr[$p] = $this->saveHTMLFooter[$p];
				}
			}
			ksort($newarr);
			$this->saveHTMLFooter = $newarr;
		}

		// Update Internal Links
		if (count($this->internallink)) {
			foreach ($this->internallink as $key => $o) {
				if ($o['PAGE'] >= $start_page && $o['PAGE'] <= $end_page) {
					$this->internallink[$key]['PAGE'] += ($target_page - $start_page);
				} elseif ($o['PAGE'] >= $target_page && $o['PAGE'] < $start_page) {
					$this->internallink[$key]['PAGE'] += $n_toc;
				}
			}
		}

		// Update Links
		if (count($this->links)) {
			foreach ($this->links as $key => $o) {
				if ($o[0] >= $start_page && $o[0] <= $end_page) {
					$this->links[$key][0] += ($target_page - $start_page);
				}
				if ($o[0] >= $target_page && $o[0] < $start_page) {
					$this->links[$key][0] += $n_toc;
				}
			}
		}

		// Update Form fields
		if (count($this->form->forms)) {
			foreach ($this->form->forms as $key => $f) {
				if ($f['page'] >= $start_page && $f['page'] <= $end_page) {
					$this->form->forms[$key]['page'] += ($target_page - $start_page);
				}
				if ($f['page'] >= $target_page && $f['page'] < $start_page) {
					$this->form->forms[$key]['page'] += $n_toc;
				}
			}
		}

		/* -- ANNOTATIONS -- */
		// Update Annotations
		if (count($this->PageAnnots)) {
			$newarr = [];
			foreach ($this->PageAnnots as $p => $anno) {
				if ($p >= $start_page && $p <= $end_page) {
					$np = $p + ($target_page - $start_page);
					foreach ($anno as $o) {
						$newarr[$np][] = $o;
					}
				} elseif ($p >= $target_page && $p < $start_page) {
					$np = $p + $n_toc;
					foreach ($anno as $o) {
						$newarr[$np][] = $o;
					}
				} else {
					$newarr[$p] = $this->PageAnnots[$p];
				}
			}
			$this->PageAnnots = $newarr;
			unset($newarr);
		}
		/* -- END ANNOTATIONS -- */

		// Update TOC pages
		if (count($this->tableOfContents->_toc)) {
			foreach ($this->tableOfContents->_toc as $key => $t) {
				if ($t['p'] >= $start_page && $t['p'] <= $end_page) {
					$this->tableOfContents->_toc[$key]['p'] += ($target_page - $start_page);
				}
				if ($t['p'] >= $target_page && $t['p'] < $start_page) {
					$this->tableOfContents->_toc[$key]['p'] += $n_toc;
				}
			}
		}

		// Update PageNumSubstitutions
		if (count($this->PageNumSubstitutions)) {
			$newarr = [];
			foreach ($this->PageNumSubstitutions as $k => $v) {
				if ($this->PageNumSubstitutions[$k]['from'] >= $start_page && $this->PageNumSubstitutions[$k]['from'] <= $end_page) {
					$this->PageNumSubstitutions[$k]['from'] += ($target_page - $start_page);
					$newarr[$this->PageNumSubstitutions[$k]['from']] = $this->PageNumSubstitutions[$k];
				} elseif ($this->PageNumSubstitutions[$k]['from'] >= $target_page && $this->PageNumSubstitutions[$k]['from'] < $start_page) {
					$this->PageNumSubstitutions[$k]['from'] += $n_toc;
					$newarr[$this->PageNumSubstitutions[$k]['from']] = $this->PageNumSubstitutions[$k];
				} else {
					$newarr[$this->PageNumSubstitutions[$k]['from']] = $this->PageNumSubstitutions[$k];
				}
			}

			if (!$sp_present) {
				$newarr[$target_page] = ['from' => $target_page, 'suppress' => $sp_suppress, 'reset' => $sp_reset, 'type' => $sp_type];
			}
			if (!$tp_present) {
				$newarr[($target_page + $n_toc)] = ['from' => ($target_page + $n_toc), 'suppress' => $tp_suppress, 'reset' => $tp_reset, 'type' => $tp_type];
			}
			if (!$ep_present && $end_page > count($this->pages)) {
				$newarr[($end_page + 1)] = ['from' => ($end_page + 1), 'suppress' => $ep_suppress, 'reset' => $ep_reset, 'type' => $ep_type];
			}
			ksort($newarr);
			$this->PageNumSubstitutions = [];
			foreach ($newarr as $v) {
				$this->PageNumSubstitutions[] = $v;
			}
		}
	}
754306
public function addPlatformItem($menuName, $url, $order = 50, $tooltip = false)
    {
        $this->addItem('CorePluginsAdmin_MenuPlatform', $menuName, $url, $order, $tooltip);
    }
804498
private function addPagination(Search $search, $pageSize, $page, $limit)
    {
        $offset = 0;
        if ($pageSize) {
            $pageSize = intval($pageSize);
            $offset = ($page - 1) * $pageSize;
        }

        if (null === $limit) {
            $limit = $this->defaultLimit;
        }

        if (null === $pageSize || $offset + $pageSize > $limit) {
            $pageSize = $limit - $offset;

            if ($pageSize < 0) {
                $pageSize = 0;
            }
        }

        $search->setFrom($offset);
        $search->setSize($pageSize);
    }