本文整理汇总了PHP中CComponentUtil::isComponent方法的典型用法代码示例。如果您正苦于以下问题:PHP CComponentUtil::isComponent方法的具体用法?PHP CComponentUtil::isComponent怎么用?PHP CComponentUtil::isComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComponentUtil
的用法示例。
在下文中一共展示了CComponentUtil::isComponent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CopyTemplate
function CopyTemplate($componentName, $templateName, $siteTemplate, $newSiteTemplate, $newName = False, $bRewrite = False)
{
$componentName = Trim($componentName);
if (StrLen($componentName) <= 0)
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("comp_util_err1"), "EMPTY_COMPONENT_NAME");
return false;
}
$path2Comp = CComponentEngine::MakeComponentPath($componentName);
if (StrLen($path2Comp) <= 0)
{
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#NAME#", $componentName, GetMessage("comp_util_err2")), "ERROR_NOT_COMPONENT");
return false;
}
$componentPath = "/bitrix/components".$path2Comp;
if (!CComponentUtil::isComponent($componentPath))
{
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#NAME#", $componentName, GetMessage("comp_util_err2")), "ERROR_NOT_COMPONENT");
return false;
}
if (StrLen($templateName) <= 0)
$templateName = ".default";
$templateNameTmp = preg_replace("#[^A-Za-z0-9_.-]#i", "", $templateName);
if ($templateNameTmp != $templateName)
{
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#NAME#", $templateName, GetMessage("comp_util_err7")), "ERROR_BAD_TEMPLATE_NAME");
return false;
}
if (StrLen($siteTemplate) <= 0)
$siteTemplate = False;
if ($siteTemplate != False)
{
if (!file_exists($_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/templates/".$siteTemplate)
|| !is_dir($_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/templates/".$siteTemplate))
{
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#NAME#", $siteTemplate, GetMessage("comp_util_err8")), "ERROR_NO_SITE_TEMPL");
return false;
}
}
if ($siteTemplate != False)
$path = BX_PERSONAL_ROOT."/templates/".$siteTemplate."/components".$path2Comp."/".$templateName;
else
$path = "/bitrix/components".$path2Comp."/templates/".$templateName;
if (!file_exists($_SERVER["DOCUMENT_ROOT"].$path))
{
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#C_NAME#", $componentName, str_replace("#T_NAME#", $templateName, GetMessage("comp_util_err9"))), "ERROR_NO_TEMPL");
return false;
}
if (StrLen($newSiteTemplate) <= 0)
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("comp_util_err10"), "ERROR_EMPTY_SITE_TEMPL");
return false;
}
if (!file_exists($_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/templates/".$newSiteTemplate)
|| !is_dir($_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/templates/".$newSiteTemplate))
{
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#NAME#", $newSiteTemplate, GetMessage("comp_util_err8")), "ERROR_NO_SITE_TEMPL");
return false;
}
if ($siteTemplate !== False
&& $siteTemplate == $newSiteTemplate
&& ($newName === False || $newName !== False && $templateName == $newName))
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("comp_util_err11"), "ERROR_DUPL1");
return false;
}
if ($newName !== False)
$templateNameNew = $newName;
else
$templateNameNew = $templateName;
$templateNameNewTmp = preg_replace("#[^A-Za-z0-9_.-]#i", "", $templateNameNew);
if ($templateNameNewTmp != $templateNameNew)
{
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#NAME#", $templateNameNew, GetMessage("comp_util_err7")), "ERROR_BAD_TEMPLATE_NAME");
return false;
}
$pathNew = BX_PERSONAL_ROOT."/templates/".$newSiteTemplate."/components".$path2Comp."/".$templateNameNew;
if (file_exists($_SERVER["DOCUMENT_ROOT"].$pathNew))
{
if (!$bRewrite)
{
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#NAME#", $templateNameNew, GetMessage("comp_util_err12")), "ERROR_EXISTS");
return false;
}
//.........这里部分代码省略.........
示例2: CopyTemplate
public static function CopyTemplate($componentName, $templateName, $siteTemplate, $newSiteTemplate, $newName = false, $bRewrite = false)
{
global $APPLICATION;
$componentName = trim($componentName);
if (strlen($componentName) <= 0) {
$APPLICATION->ThrowException(GetMessage("comp_util_err1"), "EMPTY_COMPONENT_NAME");
return false;
}
$path2Comp = CComponentEngine::MakeComponentPath($componentName);
if (strlen($path2Comp) <= 0) {
$APPLICATION->ThrowException(str_replace("#NAME#", $componentName, GetMessage("comp_util_err2")), "ERROR_NOT_COMPONENT");
return false;
}
$componentPath = getLocalPath("components" . $path2Comp);
if (!CComponentUtil::isComponent($componentPath)) {
$APPLICATION->ThrowException(str_replace("#NAME#", $componentName, GetMessage("comp_util_err2")), "ERROR_NOT_COMPONENT");
return false;
}
if (strlen($templateName) <= 0) {
$templateName = ".default";
}
$templateNameTmp = preg_replace("#[^A-Za-z0-9_.-]#i", "", $templateName);
if ($templateNameTmp != $templateName) {
$APPLICATION->ThrowException(str_replace("#NAME#", $templateName, GetMessage("comp_util_err7")), "ERROR_BAD_TEMPLATE_NAME");
return false;
}
if (strlen($siteTemplate) <= 0) {
$siteTemplate = false;
}
if ($siteTemplate != false) {
$siteTemplateDir = getLocalPath("templates/" . $siteTemplate, BX_PERSONAL_ROOT);
if ($siteTemplateDir === false || !is_dir($_SERVER["DOCUMENT_ROOT"] . $siteTemplateDir)) {
$APPLICATION->ThrowException(str_replace("#NAME#", $siteTemplate, GetMessage("comp_util_err8")), "ERROR_NO_SITE_TEMPL");
return false;
}
}
if ($siteTemplate != false) {
$path = getLocalPath("templates/" . $siteTemplate . "/components" . $path2Comp . "/" . $templateName, BX_PERSONAL_ROOT);
} else {
$path = getLocalPath("components" . $path2Comp . "/templates/" . $templateName);
}
if ($path === false || !file_exists($_SERVER["DOCUMENT_ROOT"] . $path)) {
$APPLICATION->ThrowException(str_replace("#C_NAME#", $componentName, str_replace("#T_NAME#", $templateName, GetMessage("comp_util_err9"))), "ERROR_NO_TEMPL");
return false;
}
if (strlen($newSiteTemplate) <= 0) {
$APPLICATION->ThrowException(GetMessage("comp_util_err10"), "ERROR_EMPTY_SITE_TEMPL");
return false;
}
$newSiteTemplateDir = getLocalPath("templates/" . $newSiteTemplate, BX_PERSONAL_ROOT);
if ($newSiteTemplateDir === false || !is_dir($_SERVER["DOCUMENT_ROOT"] . $newSiteTemplateDir)) {
$APPLICATION->ThrowException(str_replace("#NAME#", $newSiteTemplate, GetMessage("comp_util_err8")), "ERROR_NO_SITE_TEMPL");
return false;
}
if ($siteTemplate !== false && $siteTemplate == $newSiteTemplate && ($newName === false || $newName !== false && $templateName == $newName)) {
$APPLICATION->ThrowException(GetMessage("comp_util_err11"), "ERROR_DUPL1");
return false;
}
if ($newName !== false) {
$templateNameNew = $newName;
} else {
$templateNameNew = $templateName;
}
$templateNameNewTmp = preg_replace("#[^A-Za-z0-9_.-]#i", "", $templateNameNew);
if ($templateNameNewTmp != $templateNameNew) {
$APPLICATION->ThrowException(str_replace("#NAME#", $templateNameNew, GetMessage("comp_util_err7")), "ERROR_BAD_TEMPLATE_NAME");
return false;
}
$pathNew = $newSiteTemplateDir . "/components" . $path2Comp . "/" . $templateNameNew;
if (file_exists($_SERVER["DOCUMENT_ROOT"] . $pathNew)) {
if (!$bRewrite) {
$APPLICATION->ThrowException(str_replace("#NAME#", $templateNameNew, GetMessage("comp_util_err12")), "ERROR_EXISTS");
return false;
} else {
DeleteDirFilesEx($pathNew);
}
}
CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . $path, $_SERVER["DOCUMENT_ROOT"] . $pathNew, true, true, false);
return true;
}
示例3: CheckCustomComponents
public static function CheckCustomComponents($arParams)
{
$arResult["STATUS"] = false;
$arComponentFolders = array("/bitrix/components", "/local/components");
$components = array();
foreach ($arComponentFolders as $componentFolder) {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . $componentFolder) && ($handle = opendir($_SERVER['DOCUMENT_ROOT'] . $componentFolder))) {
while (($file = readdir($handle)) !== false) {
if ($file == "bitrix" || $file == ".." || $file == ".") {
continue;
}
$dir = $componentFolder . "/" . $file;
if (is_dir($_SERVER['DOCUMENT_ROOT'] . $dir)) {
if (CComponentUtil::isComponent($dir)) {
$components[] = array("path" => $dir, "name" => $file);
} elseif ($comp_handle = opendir($_SERVER['DOCUMENT_ROOT'] . $dir)) {
while (($subdir = readdir($comp_handle)) !== false) {
if ($subdir == ".." || $subdir == "." || $subdir == ".svn") {
continue;
}
if (CComponentUtil::isComponent($dir . "/" . $subdir)) {
$components[] = array("path" => $dir . "/" . $subdir, "name" => $file . ":" . $subdir);
}
}
closedir($comp_handle);
}
}
}
closedir($handle);
}
}
if ($arParams["ACTION"] == "FIND") {
foreach ($components as $component) {
$arResult["MESSAGE"]["DETAIL"] .= $component["name"] . " \n";
}
if (strlen($arResult["MESSAGE"]["DETAIL"]) == 0) {
$arResult["MESSAGE"]["PREVIEW"] = GetMessage("CL_HAVE_NO_CUSTOM_COMPONENTS");
} else {
$arResult = array("STATUS" => true, "MESSAGE" => array("PREVIEW" => GetMessage("CL_HAVE_CUSTOM_COMPONENTS") . " (" . count($components) . ")", "DETAIL" => $arResult["MESSAGE"]["DETAIL"]));
}
} else {
foreach ($components as $component) {
$desc = $_SERVER['DOCUMENT_ROOT'] . $component["path"] . "/.description.php";
if (!file_exists($desc) || filesize($desc) === 0) {
$arResult["MESSAGE"]["DETAIL"] .= GetMessage("CL_EMPTY_DESCRIPTION") . " " . $component["name"] . " \n";
}
}
if (strlen($arResult["MESSAGE"]["DETAIL"]) == 0) {
$arResult["STATUS"] = true;
$arResult["MESSAGE"]["PREVIEW"] = GetMessage("CL_HAVE_CUSTOM_COMPONENTS_DESC");
} else {
$arResult = array("STATUS" => false, "MESSAGE" => array("PREVIEW" => GetMessage("CL_ERROR_FOUND_SHORT"), "DETAIL" => $arResult["MESSAGE"]["DETAIL"]));
}
}
return $arResult;
}