concrete/src/Page/Collection/Collection.php
public static function createCollection($data)
    {
        $db = Loader::db();
        $dh = Loader::helper('date');
        $cDate = $dh->getOverridableNow();

        $data = array_merge(
            [
                'name' => '',
                'pTemplateID' => 0,
                'handle' => null,
                'uID' => null,
                'cDatePublic' => $cDate,
                'cDescription' => null,
            ],
            $data
            );

        $cDatePublic = ($data['cDatePublic']) ? $data['cDatePublic'] : $cDate;

        if (isset($data['cID'])) {
            $res = $db->query(
                'insert into Collections (cID, cHandle, cDateAdded, cDateModified) values (?, ?, ?, ?)',
                [$data['cID'], $data['handle'], $cDate, $cDate]
                );
            $newCID = $data['cID'];
        } else {
            $res = $db->query(
                'insert into Collections (cHandle, cDateAdded, cDateModified) values (?, ?, ?)',
                [$data['handle'], $cDate, $cDate]
                );
            $newCID = $db->Insert_ID();
        }

        $cvIsApproved = (isset($data['cvIsApproved']) && $data['cvIsApproved'] == 0) ? 0 : 1;
        $cvIsNew = 1;
        if ($cvIsApproved) {
            $cvIsNew = 0;
        }
        if (isset($data['cvIsNew'])) {
            $cvIsNew = $data['cvIsNew'];
        }
        $data['name'] = Loader::helper('text')->sanitize($data['name']);
        $pThemeID = 0;
        if (isset($data['pThemeID']) && $data['pThemeID']) {
            $pThemeID = $data['pThemeID'];
        }

        $pTemplateID = 0;
        if ($data['pTemplateID']) {
            $pTemplateID = $data['pTemplateID'];
        }

        if ($res) {
            // now we add a pending version to the collectionversions table
            $v2 = [
                $newCID,
                1,
                $pTemplateID,
                $data['name'],
                $data['handle'],
                $data['cDescription'],
                $cDatePublic,
                $cDate,
                t(VERSION_INITIAL_COMMENT),
                $data['uID'],
                $cvIsApproved,
                $cvIsNew,
                $pThemeID,
            ];
            $q2 = 'insert into CollectionVersions (cID, cvID, pTemplateID, cvName, cvHandle, cvDescription, cvDatePublic, cvDateCreated, cvComments, cvAuthorUID, cvIsApproved, cvIsNew, pThemeID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
            $r2 = $db->prepare($q2);
            $res2 = $db->execute($r2, $v2);
        }

        $nc = self::getByID($newCID);

        return $nc;
    }
public static function createCollection($data)
    {
        $db = Loader::db();
        $dh = Loader::helper('date');
        $cDate = $dh->getOverridableNow();

        $data = array_merge(
            [
                'name' => '',
                'pTemplateID' => 0,
                'handle' => null,
                'uID' => null,
                'cDatePublic' => $cDate,
                'cDescription' => null,
            ],
            $data
            );

        $cDatePublic = ($data['cDatePublic']) ? $data['cDatePublic'] : $cDate;

        if (isset($data['cID'])) {
            $res = $db->query(
                'insert into Collections (cID, cHandle, cDateAdded, cDateModified) values (?, ?, ?, ?)',
                [$data['cID'], $data['handle'], $cDate, $cDate]
                );
            $newCID = $data['cID'];
        } else {
            $res = $db->query(
                'insert into Collections (cHandle, cDateAdded, cDateModified) values (?, ?, ?)',
                [$data['handle'], $cDate, $cDate]
                );
            $newCID = $db->Insert_ID();
        }

        $cvIsApproved = (isset($data['cvIsApproved']) && $data['cvIsApproved'] == 0) ? 0 : 1;
        $cvIsNew = 1;
        if ($cvIsApproved) {
            $cvIsNew = 0;
        }
        if (isset($data['cvIsNew'])) {
            $cvIsNew = $data['cvIsNew'];
        }
        $data['name'] = Loader::helper('text')->sanitize($data['name']);
        $pThemeID = 0;
        if (isset($data['pThemeID']) && $data['pThemeID']) {
            $pThemeID = $data['pThemeID'];
        }

        $pTemplateID = 0;
        if ($data['pTemplateID']) {
            $pTemplateID = $data['pTemplateID'];
        }

        if ($res) {
            // now we add a pending version to the collectionversions table
            $v2 = [
                $newCID,
                1,
                $pTemplateID,
                $data['name'],
                $data['handle'],
                $data['cDescription'],
                $cDatePublic,
                $cDate,
                t(VERSION_INITIAL_COMMENT),
                $data['uID'],
                $cvIsApproved,
                $cvIsNew,
                $pThemeID,
            ];
            $q2 = 'insert into CollectionVersions (cID, cvID, pTemplateID, cvName, cvHandle, cvDescription, cvDatePublic, cvDateCreated, cvComments, cvAuthorUID, cvIsApproved, cvIsNew, pThemeID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
            $r2 = $db->prepare($q2);
            $res2 = $db->execute($r2, $v2);
        }

        $nc = self::getByID($newCID);

        return $nc;
    }
public static function createCollection ( $ data ) { $ db = Loader :: db ( ) ; $ dh = Loader :: helper ( 'date' ) ; $ cDate = $ dh -> getOverridableNow ( ) ; $ data = array_merge ( [ 'name' => '' , 'pTemplateID' => 0 , 'handle' => null , 'uID' => null , 'cDatePublic' => $ cDate , 'cDescription' => null , ] , $ data ) ; $ cDatePublic = ( $ data [ 'cDatePublic' ] ) ? $ data [ 'cDatePublic' ] : $ cDate ; if ( isset ( $ data [ 'cID' ] ) ) { $ res = $ db -> query ( 'insert into Collections (cID, cHandle, cDateAdded, cDateModified) values (?, ?, ?, ?)' , [ $ data [ 'cID' ] , $ data [ 'handle' ] , $ cDate , $ cDate ] ) ; $ newCID = $ data [ 'cID' ] ; } else { $ res = $ db -> query ( 'insert into Collections (cHandle, cDateAdded, cDateModified) values (?, ?, ?)' , [ $ data [ 'handle' ] , $ cDate , $ cDate ] ) ; $ newCID = $ db -> Insert_ID ( ) ; } $ cvIsApproved = ( isset ( $ data [ 'cvIsApproved' ] ) && $ data [ 'cvIsApproved' ] == 0 ) ? 0 : 1 ; $ cvIsNew = 1 ; if ( $ cvIsApproved ) { $ cvIsNew = 0 ; } if ( isset ( $ data [ 'cvIsNew' ] ) ) { $ cvIsNew = $ data [ 'cvIsNew' ] ; } $ data [ 'name' ] = Loader :: helper ( 'text' ) -> sanitize ( $ data [ 'name' ] ) ; $ pThemeID = 0 ; if ( isset ( $ data [ 'pThemeID' ] ) && $ data [ 'pThemeID' ] ) { $ pThemeID = $ data [ 'pThemeID' ] ; } $ pTemplateID = 0 ; if ( $ data [ 'pTemplateID' ] ) { $ pTemplateID = $ data [ 'pTemplateID' ] ; } if ( $ res ) { // now we add a pending version to the collectionversions table $ v2 = [ $ newCID , 1 , $ pTemplateID , $ data [ 'name' ] , $ data [ 'handle' ] , $ data [ 'cDescription' ] , $ cDatePublic , $ cDate , t ( VERSION_INITIAL_COMMENT ) , $ data [ 'uID' ] , $ cvIsApproved , $ cvIsNew , $ pThemeID , ] ; $ q2 = 'insert into CollectionVersions (cID, cvID, pTemplateID, cvName, cvHandle, cvDescription, cvDatePublic, cvDateCreated, cvComments, cvAuthorUID, cvIsApproved, cvIsNew, pThemeID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' ; $ r2 = $ db -> prepare ( $ q2 ) ; $ res2 = $ db -> execute ( $ r2 , $ v2 ) ; } $ nc = self :: getByID ( $ newCID ) ; return $ nc ; }
Create a new Collection instance.

@param array $data {

@var int|null $cID The ID of the collection to create (if unspecified or NULL: database autoincrement value)
@var string $handle The collection handle (default: NULL)
@var string $name The collection name (default: empty string)
@var string $cDescription The collection description (default: NULL)
@var string $cDatePublic The collection publish date/time in format 'YYYY-MM-DD hh:mm:ss' (default: now)
@var bool $cvIsApproved Is the collection version approved (default: true)
@var bool $cvIsNew Is the collection to be considered "new"? (default: true if $cvIsApproved is false, false if $cvIsApproved is true)
@var int|null $pThemeID The collection theme ID (default: NULL)
@var int|null $pTemplateID The collection template ID (default: NULL)
@var int|null $uID The ID of the collection author (default: NULL)
}

@return \Concrete\Core\Page\Collection\Collection
Create a new Collection instance .