function handleComp2Tree()
{
    $allowed_components = trim(COption::GetOptionString('fileman', "~allowed_components", ''));
    // Name filter exists
    if (strlen($allowed_components) > 0) {
        $arAC = explode("\n", $allowed_components);
        $arAC = array_unique($arAC);
        $arAllowedComponents = array();
        foreach ($arAC as $f) {
            $f = preg_replace("/\\s/is", "", $f);
            $f = preg_replace("/\\./is", "\\.", $f);
            $f = preg_replace("/\\*/is", ".*", $f);
            $arAllowedComponents[] = '/^' . $f . '$/';
        }
        $components_namespace = 'bitrix';
        $mask = substr(md5($allowed_components), 2, 6);
    } else {
        $arAllowedComponents = false;
        $components_namespace = false;
        $mask = 0;
    }
    // *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
    global $CACHE_MANAGER;
    $cache = array();
    $arTree = false;
    $lang = isset($_REQUEST['lang']) ? $_REQUEST['lang'] : LANGUAGE_ID;
    $cache_name = 'fileman_component_tree_array_' . $lang;
    if (isset($_GET['clear_comp2_cache']) && $_GET['clear_comp2_cache'] == 'Y') {
        $CACHE_MANAGER->CleanDir("fileman_component_tree_array");
    }
    $ttl = 10 * 24 * 60 * 60;
    // Time of life
    if ($CACHE_MANAGER->Read($ttl, $cache_name, "fileman_component_tree_array")) {
        $cache = $CACHE_MANAGER->Get($cache_name);
        if (isset($cache[$mask])) {
            $arTree = $cache[$mask];
        }
    }
    if ($arTree === false) {
        $arTree = $cache[$mask] = CComponentUtil::GetComponentsTree($components_namespace, $arAllowedComponents);
        $CACHE_MANAGER->Set($cache_name, $cache);
    }
    // *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
    if (isset($arTree['#'])) {
        handleChildren($arTree['#'], '');
    }
}
Exemple #2
0
	public static function GetComponents($Params, $bClearCache = false)
	{
		global $CACHE_MANAGER;

		$allowed = trim(COption::GetOptionString('fileman', "~allowed_components", ''));
		$mask = $allowed === '' ? 0 : substr(md5($allowed), 0, 10);

		$lang = isset($Params['lang']) ? $Params['lang'] : LANGUAGE_ID;
		$cache_name = 'component_tree_array_'.$lang.'_'.$mask;
		$table_id = "fileman_component_tree";

		if ($bClearCache)
		{
			$CACHE_MANAGER->CleanDir($table_id);
		}

		if($CACHE_MANAGER->Read(self::CACHE_TIME, $cache_name, $table_id))
		{
			self::$arComponents = $CACHE_MANAGER->Get($cache_name);
		}

		if (empty(self::$arComponents))
		{
			// Name filter exists
			if ($allowed !== '')
			{
				$arAC = explode("\n", $allowed);
				$arAC = array_unique($arAC);
				$arAllowed = Array();
				foreach ($arAC as $f)
				{
					$f = preg_replace("/\s/is", "", $f);
					$f = preg_replace("/\./is", "\\.", $f);
					$f = preg_replace("/\*/is", ".*", $f);
					$arAllowed[] = '/^'.$f.'$/';
				}
				$namespace = 'bitrix';
			}
			else
			{
				$arAllowed = false;
				$namespace = false;
			}

			$arTree = CComponentUtil::GetComponentsTree($namespace, $arAllowed);
			self::$arComponents = array(
				'items' => array(),
				'groups' => array()
			);
			self::$thirdLevelId = 0;

			if (isset($arTree['#']))
			{
				self::_HandleComponentElement($arTree['#'], '');
			}

			$CACHE_MANAGER->Set($cache_name, self::$arComponents);
		}

		return self::$arComponents;
	}
Exemple #3
0
	public static function GetComponents($Params, $bClearCache = false)
	{
		

		$allowed = trim(COption::GetOptionString('fileman', "~allowed_components", ''));
		$mask = $allowed === '' ? 0 : substr(md5($allowed), 0, 10);

		if (empty(self::$arComponents))
		{
			// Name filter exists
			if ($allowed !== '')
			{
				$arAC = explode("\n", $allowed);
				$arAC = array_unique($arAC);
				$arAllowed = Array();
				foreach ($arAC as $f)
				{
					$f = preg_replace("/\s/is", "", $f);
					$f = preg_replace("/\./is", "\\.", $f);
					$f = preg_replace("/\*/is", ".*", $f);
					$arAllowed[] = '/^'.$f.'$/';
				}
				$namespace = 'freetrix';
			}
			else
			{
				$arAllowed = false;
				$namespace = false;
			}

			$arTree = CComponentUtil::GetComponentsTree($namespace, $arAllowed);
			self::$arComponents = array(
				'items' => array(),
				'groups' => array()
			);
			self::$thirdLevelId = 0;

			if (isset($arTree['#']))
			{
				self::_HandleComponentElement($arTree['#'], '');
			}

		}

		return self::$arComponents;
	}