Exemple #1
0
 /**
  * Function saves component epilog environment
  *
  * @param array[string]mixed $arEpilogInfo
  * @return void
  *
  */
 public final function setTemplateEpilog($arEpilogInfo)
 {
     $this->__component_epilog = $arEpilogInfo;
     //Check if parent component exists and plug epilog it to it's "collection"
     if ($this->__parent) {
         $this->__parent->addChildEpilog($this->__component_epilog);
     }
 }
Exemple #2
0
	public function executeComponent()
	{
		$this->IBLOCK_ID = $this->arParams["IBLOCK_ID"];
		$this->SECTION_ID = $this->arParams["SECTION_ID"];
		$this->FILTER_NAME = $this->arParams["FILTER_NAME"];

		if(CModule::IncludeModule("catalog"))
		{
			$arCatalog = CCatalogSKU::GetInfoByProductIBlock($this->IBLOCK_ID);
			if (!empty($arCatalog) && is_array($arCatalog))
			{
				$this->SKU_IBLOCK_ID = $arCatalog["IBLOCK_ID"];
				$this->SKU_PROPERTY_ID = $arCatalog["SKU_PROPERTY_ID"];
			}
		}

		/*DEMO CODE for "pure" class.php component
		$this->arResult["FFF"] = "ggg";
		$this->includeComponentTemplate();
		return $this->ELEMENT_ID;
		*/

		return parent::executeComponent();
	}
Exemple #3
0
 public function GetIcons()
 {
     /** @global CMain $APPLICATION */
     global $USER, $APPLICATION;
     $arIcons = array();
     $arPanelParams = array();
     $arComponentDescription = CComponentUtil::GetComponentDescr($this->componentName);
     $bComponentAccess = $USER->CanDoOperation('edit_php') || $this->bSrcFound && $USER->CanDoFileOperation('fm_lpa', array(SITE_ID, $this->sSrcFile));
     if ($bComponentAccess && !$this->parentComponent && $this->bSrcFound) {
         $url = $APPLICATION->GetPopupLink(array('URL' => "/freetrix/admin/component_props.php?" . "component_name=" . urlencode(CUtil::addslashes($this->componentName)) . "&component_template=" . urlencode(CUtil::addslashes($this->componentTemplate)) . "&template_id=" . urlencode(CUtil::addslashes(SITE_TEMPLATE_ID)) . "&lang=" . urlencode(CUtil::addslashes(LANGUAGE_ID)) . "&src_path=" . urlencode(CUtil::addslashes($this->sSrcFile)) . "&src_line=" . $this->iSrcLine . "&src_page=" . urlencode(CUtil::addslashes($APPLICATION->GetCurPage())) . "&src_site=" . urlencode(CUtil::addslashes(SITE_ID)), "PARAMS" => array("min_width" => 450)));
         $arIcons[] = array('URL' => 'javascript:' . $url, 'TYPE' => 'components2_props', 'ICON' => "bx-context-toolbar-settings-icon", 'TITLE' => GetMessage("main_incl_file_comp_param"), 'DEFAULT' => true);
         $aMenuItem = array("TEXT" => $arComponentDescription["NAME"], "TITLE" => GetMessage("main_comp_button_menu_title") . ' ' . $this->componentName, "ICON" => "parameters-2", "ACTION" => $url);
         $APPLICATION->AddPanelButtonMenu("components", $aMenuItem);
     }
     if ($bComponentAccess) {
         $template = $this->component->GetTemplate();
         if (is_null($template)) {
             if ($this->component->InitComponentTemplate()) {
                 $template = $this->component->GetTemplate();
             }
         }
         if (!is_null($template)) {
             $urlCopy = '';
             if ($this->bSrcFound && $template->IsInTheme() == false) {
                 //copy template dialog
                 $urlCopy = "/freetrix/admin/template_copy.php?" . "lang=" . urlencode(CUtil::addslashes(LANGUAGE_ID)) . "&component_name=" . urlencode(CUtil::addslashes($this->componentName)) . "&component_template=" . urlencode(CUtil::addslashes($this->componentTemplate)) . "&template_id=" . urlencode(CUtil::addslashes(SITE_TEMPLATE_ID)) . "&template_site_template=" . urlencode(CUtil::addslashes($template->GetSiteTemplate())) . "&src_path=" . urlencode(CUtil::addslashes($this->sSrcFile)) . "&src_line=" . $this->iSrcLine . "&src_site=" . urlencode(CUtil::addslashes(SITE_ID)) . "&edit_file=" . urlencode($template->GetPageName()) . "&back_path=" . urlencode($_SERVER["REQUEST_URI"]);
                 $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => $urlCopy, "PARAMS" => array("min_width" => 450))), 'ICON' => "copy-2", 'TITLE' => GetMessage("main_comp_copy_templ"), 'IN_MENU' => true);
             }
             if ($USER->CanDoOperation('edit_php') && strlen($template->GetSiteTemplate()) > 0) {
                 //edit template copied to site template
                 $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => "/freetrix/admin/public_file_edit_src.php?site=" . SITE_ID . "&" . 'path=' . urlencode($template->GetFile()) . "&back_url=" . urlencode($_SERVER["REQUEST_URI"]) . "&lang=" . LANGUAGE_ID, 'PARAMS' => array('width' => 770, 'height' => 470, 'resize' => true, "dialog_type" => 'EDITOR'))), 'ICON' => 'edit-2', 'TITLE' => GetMessage("main_comp_edit_templ"), 'IN_MENU' => true);
                 if (strlen($template->GetFolder()) > 0) {
                     if (file_exists($_SERVER["DOCUMENT_ROOT"] . $template->GetFolder() . "/style.css")) {
                         //edit template CSS copied to site template
                         $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => "/freetrix/admin/public_file_edit_src.php?site=" . SITE_ID . "&" . 'path=' . urlencode($template->GetFolder() . "/style.css") . "&back_url=" . urlencode($_SERVER["REQUEST_URI"]) . "&lang=" . LANGUAGE_ID, 'PARAMS' => array('width' => 770, 'height' => 470, 'resize' => true, "dialog_type" => 'EDITOR'))), 'ICON' => 'edit-css', 'TITLE' => GetMessage("main_comp_edit_css"), 'IN_MENU' => true);
                     }
                     $bWasSep = false;
                     if (file_exists($_SERVER["DOCUMENT_ROOT"] . $template->GetFolder() . "/result_modifier.php")) {
                         $bWasSep = true;
                         $arIcons[] = array('SEPARATOR' => true);
                         $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => "/freetrix/admin/public_file_edit_src.php?site=" . SITE_ID . "&" . 'path=' . urlencode($template->GetFolder() . "/result_modifier.php") . "&back_url=" . urlencode($_SERVER["REQUEST_URI"]) . "&lang=" . LANGUAGE_ID, 'PARAMS' => array('width' => 770, 'height' => 470, 'resize' => true, "dialog_type" => 'EDITOR'))), 'TITLE' => GetMessage("main_comp_edit_res_mod"), 'IN_MENU' => true);
                     }
                     if (file_exists($_SERVER["DOCUMENT_ROOT"] . $template->GetFolder() . "/component_epilog.php")) {
                         if (!$bWasSep) {
                             $arIcons[] = array('SEPARATOR' => true);
                         }
                         $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => "/freetrix/admin/public_file_edit_src.php?site=" . SITE_ID . "&" . 'path=' . urlencode($template->GetFolder() . "/component_epilog.php") . "&back_url=" . urlencode($_SERVER["REQUEST_URI"]) . "&lang=" . LANGUAGE_ID, 'PARAMS' => array('width' => 770, 'height' => 470, 'resize' => true, "dialog_type" => 'EDITOR'))), 'TITLE' => GetMessage("main_comp_edit_epilog"), 'IN_MENU' => true);
                     }
                 }
             } elseif ($urlCopy != '') {
                 //copy template for future editing
                 $urlCopy .= '&system_template=Y';
                 $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => $urlCopy, "PARAMS" => array("min_width" => 450))), 'ICON' => "edit-2", 'TITLE' => GetMessage("main_comp_edit_templ"), 'ALT' => GetMessage("main_comp_copy_title"), 'IN_MENU' => true);
             }
         }
     }
     $aAddIcons = array();
     $arPanelParams['COMPONENT'] = $this->componentName;
     if ($arComponentDescription && is_array($arComponentDescription)) {
         $arPanelParams['COMPONENT_DESCRIPTION'] = $arComponentDescription;
         //component bar tooltip
         $arPanelParams['TOOLTIP'] = array('TITLE' => $arComponentDescription["NAME"], 'TEXT' => '(' . GetMessage('main_incl_comp_component') . ' ' . $this->componentName . ')' . (isset($arComponentDescription["DESCRIPTION"]) && $arComponentDescription["DESCRIPTION"] != "" ? '<br />' . $arComponentDescription["DESCRIPTION"] : ''));
         //clear cache
         if (array_key_exists("CACHE_PATH", $arComponentDescription) && $USER->CanDoOperation('cache_control')) {
             if (strlen($arComponentDescription["CACHE_PATH"]) > 0) {
                 $arIcons[] = array("URL" => "javascript:jsComponentUtils.ClearCache('component_name=" . urlencode(CUtil::addslashes($this->componentName)) . "&site_id=" . SITE_ID . "&" . freetrix_sessid_get() . "');", "ICON" => "del-cache", "TITLE" => GetMessage("MAIN_FX_COMPONENT_CACHE_CLEAR"), 'IN_MENU' => true);
                 $APPLICATION->aCachedComponents[] = $this->componentName;
             }
         }
         //additional buttons from component description
         if (array_key_exists("AREA_BUTTONS", $arComponentDescription)) {
             $componentRelativePath = CComponentEngine::MakeComponentPath($this->componentName);
             $localPath = getLocalPath("components" . $componentRelativePath);
             foreach ($arComponentDescription["AREA_BUTTONS"] as $value) {
                 if (array_key_exists("SRC", $value)) {
                     $value["SRC"] = $localPath . $value["SRC"];
                 }
                 $aAddIcons[] = $value;
             }
         }
     }
     if (!empty($arIcons) && !empty($aAddIcons)) {
         $arIcons[] = array("SEPARATOR" => true);
     }
     $arIcons = array_merge($arIcons, $aAddIcons);
     $aAddIcons = $this->component->GetIncludeAreaIcons();
     if (!empty($arIcons) && !empty($aAddIcons)) {
         $arIcons[] = array("SEPARATOR" => true);
     }
     $arIcons = array_merge($arIcons, $aAddIcons);
     // enable/disable menu item
     if ($bComponentAccess && !$this->parentComponent && $this->bSrcFound) {
         if (!empty($arIcons)) {
             $arIcons[] = array("SEPARATOR" => true);
         }
         $arIcons[] = array("URL" => "javascript:jsComponentUtils.EnableComponent('component_name=" . urlencode(CUtil::addslashes($this->componentName)) . "&lang=" . urlencode(CUtil::addslashes(LANGUAGE_ID)) . "&src_path=" . urlencode(CUtil::addslashes($this->sSrcFile)) . "&src_line=" . $this->iSrcLine . "&src_site=" . urlencode(CUtil::addslashes(SITE_ID)) . '&active=' . ($this->bComponentEnabled ? 'N' : 'Y') . '&' . freetrix_sessid_get() . "');", "TITLE" => $this->bComponentEnabled ? GetMessage("main_comp_disable") : GetMessage("main_comp_enable"), "ALT" => $this->bComponentEnabled ? GetMessage("main_comp_disable_title") : GetMessage("main_comp_enable_title"), 'IN_MENU' => true);
     }
     if ($this->bSrcFound) {
         $arPanelParams['COMPONENT_ID'] = md5($arPanelParams['COMPONENT'] . '|' . $this->sSrcFile . ':' . $this->iSrcLine);
     }
     return array("icons" => $arIcons, "parameters" => $arPanelParams);
 }
<?
require($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/include/prolog_admin_before.php");
require($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/include/prolog_admin_js.php");
/** @global CUser $USER */
global $USER;
/** @global CCacheManager $CACHE_MANAGER */
global $CACHE_MANAGER;

if(!$USER->CanDoOperation('cache_control') || !check_freetrix_sessid())
	die(GetMessage("ACCESS_DENIED"));

if($_GET["site_id"] == '')
	die("Empty site_id.");

$sites = CSite::GetByID($_GET["site_id"]);
if(!($site = $sites->Fetch()))
	die("Incorrect site_id.");

$aComponents = explode(",", $_GET["component_name"]);
foreach($aComponents as $component_name)
{
	CFreetrixComponent::clearComponentCache($component_name, $site["ID"]);
}
require($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/include/epilog_admin_js.php");
?>
 /**
  * Function returns next pseudo random value.
  *
  * @param int $length
  * @return string
  *
  * @see \Freetrix\Main\Type\RandomSequence::randString
  */
 public function randString($length = 6)
 {
     return $this->__component->randString($length);
 }
Exemple #6
0
 /**
  * @param CFreetrixComponent $parent
  * @return bool
  */
 function _checkParent($parent)
 {
     if ('Y' == $parent->arParams['AJAX_MODE']) {
         return true;
     } elseif ($parentComponent = $parent->GetParent()) {
         return $this->_checkParent($parentComponent);
     }
     return false;
 }
Exemple #7
0
	function __bx_share_get_handlers($template = false, $siteTemplate = false)
	{
		if (trim($template) == ".default")
			$template = "";
	
		$arBookmarkHandlerDropdown = array();
		$arBookmarkHandlerDropdownDefault = array();
	
		$shareComponent = new CFreetrixComponent;
		$shareComponent->InitComponent("freetrix:main.share", $template);
		$shareComponent->InitComponentTemplate("", $siteTemplate);

		if (strlen($shareComponent->__template->__folder) > 0)
		{
			$path2Handlers = $_SERVER["DOCUMENT_ROOT"]."/".$shareComponent->__template->__folder."/handlers/";
			CheckDirPath($path2Handlers);

			$arHandlers = array();
			if ($handle = opendir($path2Handlers))
			{
				while (($file = readdir($handle)) !== false)
				{
					if ($file == "." || $file == "..")
						continue;
					if (is_file($path2Handlers.$file) && strtoupper(substr($file, strlen($file)-4))==".PHP")
					{
						$name = $title = $icon_url_template = "";
						$sort = 0;
						include($path2Handlers.$file);
						
						if (strlen($name) > 0)
						{
							$arHandlers[$name] = array(
								"TITLE" => $title,
								"ICON" => $icon_url_template,
								"SORT" => intval($sort)	
							);
						}
					}
				}
			}

			foreach($arHandlers as $name=>$arSystem)
				if (strlen($arSystem["TITLE"]) > 0)
					$arBookmarkHandlerDropdown[$name] = $arSystem["TITLE"];

			$arBookmarkHandlerDropdownTmp = $arBookmarkHandlerDropdown;
			if (LANGUAGE_ID != 'ru')
			{
				if (array_key_exists("vk", $arBookmarkHandlerDropdownTmp))
					unset($arBookmarkHandlerDropdownTmp["vk"]);
				if (array_key_exists("mailru", $arBookmarkHandlerDropdownTmp))
					unset($arBookmarkHandlerDropdownTmp["mailru"]);
			}
			$arBookmarkHandlerDropdownDefault = array_keys($arBookmarkHandlerDropdownTmp);
		}

		return array(
			"HANDLERS" => $arBookmarkHandlerDropdown,
			"HANDLERS_DEFAULT" => $arBookmarkHandlerDropdownDefault
		);
	}
Exemple #8
0
					(!empty($arComponent["DATA"]["FUNCTION_PARAMS"])? ",\n\t"."array(\n\t".PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"])."\n\t)" : "").
					"\n);";

				$filesrc_for_save = substr($filesrc, 0, $arComponent["START"]).$code.substr($filesrc, $arComponent["END"]);

				if(!$APPLICATION->SaveFileContent($abs_path, $filesrc_for_save))
					$strWarning .= GetMessage("comp_prop_err_save")."<br>";
			}

			if($strWarning == "")
			{
				$strJSText = 'window.location = window.location.href;';

				if ($_POST["EDIT_TEMPLATE"] == "Y")
				{
					$component = new CFreetrixComponent();
					if ($component->InitComponent($arComponent["DATA"]["COMPONENT_NAME"], $_POST["TEMPLATE_NAME"]))
					{
						if ($component->InitComponentTemplate($_REQUEST["edit_file"], $_POST["SITE_TEMPLATE"]))
						{
							$template = & $component->GetTemplate();
							if (!is_null($template))
							{
								$strJSText = $APPLICATION->GetPopupLink(
									array(
										'URL' => '/freetrix/admin/public_file_edit_src.php?lang='.LANGUAGE_ID.'&site='.SITE_ID.'&back_url='.urlencode($_REQUEST["back_path"]).'&path='.urlencode($template->GetFile()),
										"PARAMS" => Array("width" => 770, "height" => 570,"resize" => true,"dialog_type" => 'EDITOR'),
									)
								);
							}
						}
Exemple #9
0
 function RemoveFileAccessPermission($path, $arGroups = false)
 {
     global $CACHE_MANAGER;
     CMain::InitPathVars($site, $path);
     $DOC_ROOT = CSite::GetSiteDocRoot($site);
     $path = rtrim($path, "/");
     if ($path == '') {
         $path = "/";
     }
     if (($p = bxstrrpos($path, "/")) !== false) {
         $path_file = substr($path, $p + 1);
         $path_dir = substr($path, 0, $p);
     } else {
         return false;
     }
     $PERM = array();
     $io = CBXVirtualIo::GetInstance();
     if (!$io->FileExists($DOC_ROOT . $path_dir . "/.access.php")) {
         return true;
     }
     include $io->GetPhysicalName($DOC_ROOT . $path_dir . "/.access.php");
     $str = "<?\n";
     foreach ($PERM as $file => $arPerm) {
         if ($file != $path_file || $arGroups !== false) {
             foreach ($arPerm as $group => $perm) {
                 $bExists = false;
                 if ($arGroups !== false) {
                     //compatibility with group id
                     if (in_array($group, $arGroups)) {
                         $bExists = true;
                     } elseif (preg_match('/^G[0-9]+$/', $group) && in_array(substr($group, 1), $arGroups)) {
                         $bExists = true;
                     } elseif (preg_match('/^[0-9]+$/', $group) && in_array('G' . $group, $arGroups)) {
                         $bExists = true;
                     }
                 }
                 if ($file != $path_file || $arGroups !== false && !$bExists) {
                     $str .= "\$PERM[\"" . EscapePHPString($file) . "\"][\"" . EscapePHPString($group) . "\"]=\"" . EscapePHPString($perm) . "\";\n";
                 }
             }
         }
     }
     $str .= "?" . ">";
     $this->SaveFileContent($DOC_ROOT . $path_dir . "/.access.php", $str);
     $CACHE_MANAGER->CleanDir("menu");
     CFreetrixComponent::clearComponentCache("freetrix:menu");
     unset($this->FILE_PERMISSION_CACHE[$site . "|" . $path_dir . "/.access.php"]);
     foreach (GetModuleEvents("main", "OnChangePermissions", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array(array($site, $path), array()));
     }
     return true;
 }