当前位置: 首页>>代码示例>>PHP>>正文


PHP CollectionType::getPackageID方法代码示例

本文整理汇总了PHP中CollectionType::getPackageID方法的典型用法代码示例。如果您正苦于以下问题:PHP CollectionType::getPackageID方法的具体用法?PHP CollectionType::getPackageID怎么用?PHP CollectionType::getPackageID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CollectionType的用法示例。


在下文中一共展示了CollectionType::getPackageID方法的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;
 }
开发者ID:Mihail9575,项目名称:concrete5,代码行数:87,代码来源:page.php


注:本文中的CollectionType::getPackageID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。