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


PHP BlockType::getPackageID方法代码示例

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


在下文中一共展示了BlockType::getPackageID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getBlockTypeAssetsURL

 /** 
  * Gets a full URL to the directory containing all of a block's items, including JavaScript, tools, icons, etc...
  * @param BlockType $bt
  * @return string $url
  */
 public function getBlockTypeAssetsURL($bt, $file = false)
 {
     $ff = '';
     if ($file != false) {
         $ff = '/' . $file;
     }
     if (file_exists(DIR_FILES_BLOCK_TYPES . '/' . $bt->getBlockTypeHandle() . $ff)) {
         $url = BASE_URL . DIR_REL . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff;
     } else {
         if ($bt->getPackageID() > 0) {
             $db = Loader::db();
             $h = $bt->getPackageHandle();
             $dirp = is_dir(DIR_PACKAGES . '/' . $h) ? DIR_PACKAGES . '/' . $h : DIR_PACKAGES_CORE . '/' . $h;
             if (file_exists($dirp . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff)) {
                 $url = is_dir(DIR_PACKAGES . '/' . $h) ? BASE_URL . DIR_REL : ASSETS_URL;
                 $url = $url . '/' . DIRNAME_PACKAGES . '/' . $h . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff;
             }
         } else {
             if (file_exists(DIR_FILES_BLOCK_TYPES_CORE . '/' . $bt->getBlockTypeHandle() . $ff)) {
                 $url = ASSETS_URL . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff;
             }
         }
     }
     return $url;
 }
开发者ID:homer6,项目名称:concrete5-mirror,代码行数:30,代码来源:urls.php

示例2: doInstallBlockType

		/**
		 * installs a block type
		 * @param string $btHandle
		 * @param BlockType $bt
		 * @param string $dir
		 * @param int $btID
		 * @param string $dirDbXml
		 */
		protected function doInstallBlockType($btHandle, $bt, $dir, $btID = 0, $dirDbXml) {
			$db = Loader::db();
			$env = Environment::get();
			$env->clearOverrideCache();
			
			if (file_exists($dir . '/' . $btHandle . '/' . FILENAME_BLOCK_CONTROLLER)) {
				$class = $bt->getBlockTypeClass();
				
				$path = $dirDbXml . '/' . $btHandle;
				if (!class_exists($class)) {
					require_once($dir . '/' . $btHandle . '/' . FILENAME_BLOCK_CONTROLLER);
				}
				
				if (!class_exists($class)) {
					throw new Exception(t("%s not found. Please check that the block controller file contains the correct class name.", $class));
				}
				$bta = new $class;
				
				//Attempt to run the subclass methods (install schema from db.xml, etc.)
				$r = $bta->install($path);

				//Validate
				if ($r === false) {
					return t('Error: Block Type cannot be installed because no db.xml file can be found. Either create a db.xml file for this block type, or remove the $btTable variable from its controller.');
				} else if (!$r->result && $r->message) {
					return $r->message;
				} else if (!$r->result && !$r->message) {
					return t('Error: Block Type cannot be installed due to an unknown database error. Please check that the db.xml file for this block type is formatted correctly.');
				} else if ($message = BlockType::validateInstalledDatabaseTable($bta->getBlockTypeDatabaseTable())) {
					$db->Execute('DROP TABLE IF EXISTS ' . $bta->getBlockTypeDatabaseTable());
					return $message;
				}
				
				$currentLocale = Localization::activeLocale();
				if ($currentLocale != 'en_US') {
					// Prevent the database records being stored in wrong language
					Localization::changeLocale('en_US');
				}

				//Install the block
				$btd = new BlockTypeDB();
				$btd->btHandle = $btHandle;
				$btd->btName = $bta->getBlockTypeName();
				$btd->btDescription = $bta->getBlockTypeDescription();
				$btd->btActiveWhenAdded = $bta->isActiveWhenAdded();
				$btd->btCopyWhenPropagate = $bta->isCopiedWhenPropagated();
				$btd->btIncludeAll = $bta->includeAll();
				$btd->btIsInternal = $bta->isBlockTypeInternal();
				$btd->btInterfaceHeight = $bta->getInterfaceHeight();
				$btd->btInterfaceWidth = $bta->getInterfaceWidth();
				$btd->pkgID = $bt->getPackageID();
				if ($currentLocale != 'en_US') {
					Localization::changeLocale($currentLocale);
				}
				
				if ($btID > 0) {
					$btd->btID = $btID;
					$btDisplayOrder = $db->GetOne('select btDisplayOrder from BlockTypes where btID = ?', array($btID));
					if (!$btDisplayOrder) {
						$btDisplayOrder = 0;
					}
					$btd->btDisplayOrder = $btDisplayOrder;
					$r = $btd->Replace();
				} else {
					if ($bta->isBlockTypeInternal()) {
						$btd->btDisplayOrder = 0;
					} else {
						$btMax = $db->GetOne('select max(btDisplayOrder) from BlockTypes');
						if ($btMax < 1 && $btMax !== '0') {
							$btd->btDisplayOrder = 0;
						} else {
							$btd->btDisplayOrder = $btMax + 1;
						}
					}

					$r = $btd->save();
				}
				
				// now we remove the block type from cache
				$ca = new Cache();
				$ca->delete('blockTypeByID', $btID);
				$ca->delete('blockTypeByHandle', $btHandle);
				$ca->delete('blockTypeList', false);		 	

				if (!$r) {
					return $db->ErrorMsg();
				}
			} else {
				return t("No block found with the handle %s.", $btHandle);
			}
		}
开发者ID:ronlobo,项目名称:concrete5,代码行数:99,代码来源:block_types.php

示例3: doInstallBlockType

 /**
  * installs a block type
  * @param string $btHandle
  * @param BlockType $bt
  * @param string $dir
  * @param int $btID
  */
 protected function doInstallBlockType($btHandle, $bt, $dir, $btID = 0)
 {
     $db = Loader::db();
     if (file_exists($dir . '/' . $btHandle . '/' . FILENAME_BLOCK_CONTROLLER)) {
         $class = $bt->getBlockTypeClassFromHandle();
         $path = $dir . '/' . $btHandle;
         if (!class_exists($class)) {
             require_once $dir . '/' . $btHandle . '/' . FILENAME_BLOCK_CONTROLLER;
         }
         if (!class_exists($class)) {
             throw new Exception(t("%s not found. Please check that the block controller file contains the correct class name.", $class));
         }
         $bta = new $class();
         // first run the subclass methods. If they work then we install the block
         $r = $bta->install($path);
         if (!$r->result) {
             return $r->message;
         }
         $btd = new BlockTypeDB();
         $btd->btHandle = $btHandle;
         $btd->btName = $bta->getBlockTypeName();
         $btd->btDescription = $bta->getBlockTypeDescription();
         $btd->btActiveWhenAdded = $bta->isActiveWhenAdded();
         $btd->btCopyWhenPropagate = $bta->isCopiedWhenPropagated();
         $btd->btIncludeAll = $bta->includeAll();
         $btd->btIsInternal = $bta->isBlockTypeInternal();
         $btd->btInterfaceHeight = $bta->getInterfaceHeight();
         $btd->btInterfaceWidth = $bta->getInterfaceWidth();
         $btd->pkgID = $bt->getPackageID();
         if ($btID > 0) {
             $btd->btID = $btID;
             $r = $btd->Replace();
         } else {
             $r = $btd->save();
         }
         // now we remove the block type from cache
         $ca = new Cache();
         $ca->delete('blockTypeByID', $btID);
         $ca->delete('blockTypeByHandle', $btHandle);
         $ca->delete('blockTypeList', false);
         if (!$r) {
             return $db->ErrorMsg();
         }
     } else {
         return t("No block found with the handle %s.", $btHandle);
     }
 }
开发者ID:nbourguig,项目名称:concrete5,代码行数:54,代码来源:block_types.php


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