本文整理汇总了PHP中CollectionType::getCollectionTypeHandle方法的典型用法代码示例。如果您正苦于以下问题:PHP CollectionType::getCollectionTypeHandle方法的具体用法?PHP CollectionType::getCollectionTypeHandle怎么用?PHP CollectionType::getCollectionTypeHandle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CollectionType
的用法示例。
在下文中一共展示了CollectionType::getCollectionTypeHandle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* Adds a new page of a certain type, using a passed associate array to setup value. $data may contain any or all of the following:
* "uID": User ID of the page's owner
* "pkgID": Package ID the page belongs to
* "cName": The name of the page
* "cHandle": The handle of the page as used in the path
* "cDatePublic": The date assigned to the page
* @param collectiontype $ct
* @param array $data
* @return page
**/
public function add(CollectionType $ct, $data)
{
$db = Loader::db();
$txt = Loader::helper('text');
// the passed collection is the parent collection
$cParentID = $this->getCollectionID();
$u = new User();
if (isset($data['uID'])) {
$uID = $data['uID'];
} else {
$uID = $u->getUserID();
$data['uID'] = $uID;
}
if (isset($data['pkgID'])) {
$pkgID = $data['pkgID'];
} else {
if ($ct->getPackageID() > 0) {
$pkgID = $ct->getPackageID();
} else {
$pkgID = 0;
}
}
if (isset($data['cName'])) {
$data['name'] = $data['cName'];
}
if (!$data['cHandle']) {
// make the handle out of the title
$handle = $txt->urlify($data['name']);
} else {
$handle = $txt->urlify($data['cHandle']);
}
$handle = str_replace('-', PAGE_PATH_SEPARATOR, $handle);
$data['handle'] = $handle;
$dh = Loader::helper('date');
$cDate = $dh->getSystemDateTime();
$cDatePublic = $data['cDatePublic'] ? $data['cDatePublic'] : null;
$data['ctID'] = $ct->getCollectionTypeID();
if ($ct->getCollectionTypeHandle() == STACKS_PAGE_TYPE) {
$data['cvIsNew'] = 0;
}
$cobj = parent::add($data);
$cID = $cobj->getCollectionID();
$ctID = $ct->getCollectionTypeID();
$masterCID = $ct->getMasterCollectionID();
$masterCollection = Page::getByID($masterCID);
//$this->rescanChildrenDisplayOrder();
$cDisplayOrder = $this->getNextSubPageDisplayOrder();
$cInheritPermissionsFromCID = $this->overrideTemplatePermissions() ? $this->getPermissionsCollectionID() : $masterCID;
$cInheritPermissionsFrom = $this->overrideTemplatePermissions() ? "PARENT" : "TEMPLATE";
// inherit cache settings from collection type
$cCacheFullPageContent = $masterCollection->getCollectionFullPageCaching();
$cCacheFullPageContentOverrideLifetime = $masterCollection->getCollectionFullPageCachingLifetime();
$cCacheFullPageContentLifetimeCustom = $masterCollection->getCollectionFullPageCachingLifetimeCustomValue();
$v = array($cID, $cParentID, $uID, $cInheritPermissionsFrom, $this->overrideTemplatePermissions(), $cInheritPermissionsFromCID, $cDisplayOrder, $pkgID, $cCacheFullPageContent, $cCacheFullPageContentOverrideLifetime, $cCacheFullPageContentLifetimeCustom);
$q = "insert into Pages (cID, cParentID, uID, cInheritPermissionsFrom, cOverrideTemplatePermissions, cInheritPermissionsFromCID, cDisplayOrder, pkgID, cCacheFullPageContent, cCacheFullPageContentOverrideLifetime, cCacheFullPageContentLifetimeCustom) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$r = $db->prepare($q);
$res = $db->execute($r, $v);
$newCID = $cID;
if ($res) {
// Collection added with no problem -- update cChildren on parrent
Loader::model('page_statistics');
PageStatistics::incrementParents($newCID);
if ($r) {
// now that we know the insert operation was a success, we need to see if the collection type we're adding has a master collection associated with it
if ($masterCID) {
$this->_associateMasterCollectionBlocks($newCID, $masterCID);
$this->_associateMasterCollectionAttributes($newCID, $masterCID);
}
}
$pc = Page::getByID($newCID, 'RECENT');
// run any internal event we have for page addition
Events::fire('on_page_add', $pc);
$pc->rescanCollectionPath();
}
return $pc;
}