Make an alias to a page.

@param Collection $c

@return int $newCID
423319
public function addCollectionAlias($c)
    {
        $db = Database::connection();
        // the passed collection is the parent collection
        $cParentID = $c->getCollectionID();

        $u = new User();
        $uID = $u->getUserID();

        $handle = $this->getCollectionHandle();
        $cDisplayOrder = $c->getNextSubPageDisplayOrder();

        $_cParentID = $c->getCollectionID();
        $q = 'select PagePaths.cPath from PagePaths where cID = ?';
        $v = array($_cParentID);
        if ($_cParentID > 1) {
            $q .=  ' and ppIsCanonical = ?';
            $v[] = 1;
        }
        $cPath = $db->fetchColumn($q, $v);

        $data = array(
            'handle' => $this->getCollectionHandle(),
            'name' => $this->getCollectionName(),
        );
        $cobj = parent::addCollection($data);
        $newCID = $cobj->getCollectionID();

        $v = array($newCID, $cParentID, $uID, $this->getCollectionID(), $cDisplayOrder);
        $q = "insert into Pages (cID, cParentID, uID, cPointerID, cDisplayOrder) values (?, ?, ?, ?, ?)";
        $r = $db->prepare($q);

        $r->execute($v);

        PageStatistics::incrementParents($newCID);

        $q2 = 'insert into PagePaths (cID, cPath, ppIsCanonical, ppGeneratedFromURLSlugs) values (?, ?, ?, ?)';
        $v2 = array($newCID, $cPath.'/'.$handle, 1, 1);
        $db->executeQuery($q2, $v2);

        return $newCID;
    }
279410
final protected function ci() {return dfc($this, function() {return
		/** @var C $c */ /** @var string $id */ /** @var array(string => mixed) $ci */
		!($c = $this->c()) || !($id = $this->ciId()) || !($ci = df_ci_get($this->m(), $c))
			? [] : dfa($ci, $id)
	;});}
499447
private function newPageFromResult( $array ) {
		if ( array_key_exists( 'pageid', $array ) ) {
			$pageid = $array['pageid'];
			$revisions = $this->getRevisionsFromResult( $array );
		} else {
			$pageid = 0;
			$revisions = new Revisions();
		}

		return new Page(
			new PageIdentifier(
				new Title(
					$array['title'],
					$array['ns']
				),
				$pageid
			),
			$revisions
		);
	}
994772
public function reject(callable $c)
    {
        return new FilterIterator($this->unwrap(), function ($key, $value, $items) use ($c) {
            return !$c($key, $value, $items);
        });
    }
1041235
public function movePageDisplayOrderToSibling(Page $c, $position = 'before')
    {
        $myCID = $this->getCollectionPointerOriginalID() ?: $this->getCollectionID();
        $relatedCID = $c->getCollectionPointerOriginalID() ?: $c->getCollectionID();
        $pageIDs = [];
        $db = Database::connection();
        $r = $db->executeQuery('select cID from Pages where cParentID = ? and cID <> ? order by cDisplayOrder asc', [$this->getCollectionParentID(), $myCID]);
        while (($cID = $r->fetchColumn()) !== false) {
            if ($cID == $relatedCID && $position == 'before') {
                $pageIDs[] = $myCID;
            }
            $pageIDs[] = $cID;
            if ($cID == $relatedCID && $position == 'after') {
                $pageIDs[] = $myCID;
            }
        }
        $displayOrder = 0;
        foreach ($pageIDs as $cID) {
            $co = self::getByID($cID);
            $co->updateDisplayOrder($displayOrder);
            ++$displayOrder;
        }
    }
1051255
protected function isOmitted($c) {
		foreach($this->omissions as $o) {
			if($c == $o || is_subclass_of($c, $o)) {
				return true;
			}
		}

		return false;
	}
1265673
private function loadReferenceManyCollectionOwningSide(PersistentCollectionInterface $collection)
    {
        $mapping = $collection->getMapping();

        /** @var Identifier[] $identifiers */
        $identifiers = array_map(
            function ($referenceData) use ($mapping) {
                return $this->ap->loadReference($mapping, $referenceData);
            },
            $collection->getRawData()
        );

        //reverse + limit must be applied here rather than on the query,
        //since we are potentially performing multiple queries
        if ($mapping->reverse) {
            $identifiers = array_reverse($identifiers);
        }
        if ($mapping->limit !== null) {
            $identifiers = array_slice($identifiers, 0, $mapping->limit);
        }

        //build document proxies and group by class
        $groupedIds = [];
        foreach ($identifiers as $key => $identifier) {
            //create a reference to the class+id and add it to the collection
            $reference = $identifier->getDocument($this->dm);

            if ($mapping->type === Type::MAP) {
                $collection->set($key, $reference);
            } else {
                $collection->add($reference);
            }

            //only query for the referenced object if it is not already initialized
            if ($reference instanceof Proxy && !$reference->__isInitialized__) {
                $className                = $identifier->class->name;
                $groupedIds[$className][] = $identifier;
            }
        }

        //load documents
        foreach ($groupedIds as $className => $batch) {
            $class   = $this->dm->getClassMetadata($className);
            $filters = array_merge(
                [(array)$mapping->criteria],
                $this->dm->getFilterCollection()->getFilterCriteria($class)
            );

            $qb = $this->dm->createQueryBuilder($className);

            if (!empty($filters)) {
                //filters require a full table scan
                //TODO: needs documentation

                //add identifiers to the query as OR conditions
                /** @var Identifier $identifier */
                foreach ($batch as $identifier) {
                    $expr = $qb->expr();
                    $identifier->addToQueryCondition($expr);
                    $qb->addOr($expr);
                }

                //add any other filter criteria
                foreach ($filters as $filter) {
                    $qb->addCriteria($filter);
                }

                $query = $qb->getQuery();
            } else {
                //load using batchgetitem
                foreach ($batch as $identifier) {
                    $qb->get()->setIdentifier($identifier)->batch();
                }

                $query = $qb->getBatch();
            }

            foreach ($query->getMarshalledResult() as $documentData) {
                $identifier = $class->createIdentifier($documentData);
                $document   = $this->uow->getByIdentifier($identifier);

                if ($document instanceof Proxy && !$document->__isInitialized()) {
                    $data = $this->hydratorFactory->hydrate($document, $documentData);
                    $this->uow->setOriginalDocumentData($document, $data);
                    $document->__isInitialized__ = true;
                }
            }
        }
    }
804798
public function setAliasesId(Collection $pages)
    {
        $pages->each(function (PageInterface $page) {
            $page->setAliasId();

            if ($page->getPages()->count()) {
                $this->setAliasesId($page->getPages());
            }
        });
    }
186407
public function createAlias($reference, $alias = null)
    {
        //if reference is array look for array(alias=>reference);
        if (is_array($reference)) {
            foreach ($reference as $key => $class) {
                $this->createAlias($class, $key);
            }

            return true;
        }

        //store in this->alias as an associative array of class to an array of aliases;
        foreach ((!is_array($alias) ? [$alias] : $alias) as $key) {
            $this->aliases[$key] = $reference;
        }
    }
42268
public function createAlias(string $tableName): string
    {
        $alias                          = $tableName . (++$this->aliasIdCounter);
        $this->knownAliases[$tableName] = $alias;

        return $alias;
    }
536589
final function cards($c) {return array_map(function($data) {return
		Card::create($this, $data)
	;}, $this->cardsData($c));}
7698
public static function getCollectionParentIDFromChildID($cID)
    {
        $db = Database::connection();
        $q = 'select cParentID from Pages where cID = ?';
        $cParentID = $db->fetchColumn($q, [$cID]);

        return $cParentID;
    }
562305
protected function generateUniqueAlias(File $phpcsFile, string $shortName, string $fullName): ?string
    {
        $alias = $shortName;
        $count = 0;
        $pieces = explode('\\', $fullName);
        if ($this->isSameVendor($phpcsFile, $fullName)) {
            $pieces = array_reverse($pieces);
            array_shift($pieces);
        }

        // To avoid collisions with PHP core classes we try to add this prefix for all root namespaced classes
        if (count($pieces) < 1) {
            array_unshift($pieces, 'Php');
        }

        while (isset($this->allStatements[$alias]) || $this->className && $alias === $this->className) {
            $alias = $shortName;

            if (count($pieces) - 1 < $count) {
                return null;
            }

            $prefix = '';
            for ($i = 0; $i <= $count; ++$i) {
                $prefix .= $pieces[$i];
            }

            $alias = $prefix . $alias;

            $count++;
        }

        return $alias;
    }
574416
public static function create(callable $cb)
    {
        if (!ServerUtil::coroutineIsEnabled()) {
            return false;
        }

        $tid = self::tid();

        return SwCoroutine::create(function () use ($cb, $tid) {
            $id = SwCoroutine::getuid();

            self::$idMap[$id] = $tid;

            PhpHelper::call($cb);
        });
    }
590267
private function _prepareColumn($c)
    {
        $c->getName()->willReturn('foo');
        $c->getType()->willReturn('string');
        $c->getLimit()->willReturn(256);
        $c->getPrecision()->willReturn(null);
        $c->getScale()->willReturn(null);
        $c->getValues()->willReturn([]);
        $c->isSigned()->willReturn(false);
        $c->isNull()->willReturn(false);
        $c->isIdentity()->willReturn(false);
        $c->getDefault()->willReturn(null);
        $c->getComment()->willReturn(null);
        $c->getUpdate()->willReturn(null);
        $c->getCollation()->willReturn(null);
        $c->getCharset()->willReturn(null);
    }
812512
private String toSQLClause(InCriteria c)
    {
        StringBuffer buf = new StringBuffer();
        Collection values = (Collection) c.getValue();
        int size = values.size();

        buf.append(c.getAttribute());
        buf.append(c.getClause());
        buf.append("(");
        for (int i = 0; i < size - 1; i++)
        {
            buf.append("?,");
        }
        buf.append("?)");
        return buf.toString();
    }
872204
function createImageAliasKey( $alias )
    {
        $keyData = array( $alias['name'],
                          $alias['reference'],
                          $alias['mime_type'] );
        if ( $alias['reference'] )
        {
            $referenceAlias = $this->alias( $alias['reference'] );
            if ( $referenceAlias )
                $keyData[] = $referenceAlias['alias_key'];
        }
        foreach ( $alias['filters'] as $filter )
        {
            $filterData = $filter['name'];
            if ( is_array( $filter['data'] ) )
                $filterData .= '=' . implode( ',', $filter['data'] );
            $keyData[] = $filterData;
        }

        $key = eZSys::ezcrc32( implode( "\n", $keyData ) );

        return $key;
    }