function Comp_Load($Element) { /****************************************************************************/ $__args_types = array('string', '*'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $HostsIDs = System_HostsIDs(SPrintF('comp/%s.comp.php', $Element)); if (Is_Error($HostsIDs)) { return ERROR | @Trigger_Error('[Comp_Load]: не возможно найти компонент'); } #----------------------------------------------------------------------------- $IsCascade = In_Array(COMP_ALL_HOSTS, $__args__, TRUE); #----------------------------------------------------------------------------- if ($IsCascade) { $HostsIDs = Array_Reverse($HostsIDs); } #----------------------------------------------------------------------------- $Result = array(); #----------------------------------------------------------------------------- foreach ($HostsIDs as $HostID) { #--------------------------------------------------------------------------- $Path = SPrintF('%s/hosts/%s/comp/%s.comp.php', SYSTEM_PATH, $HostID, $Element); #--------------------------------------------------------------------------- if (Is_Dir($Path)) { return ERROR | @Trigger_Error('[Comp_Load]: объект не является компонентом'); } #--------------------------------------------------------------------------- $Args = $__args__; #--------------------------------------------------------------------------- Array_UnShift($Args, $Path); #--------------------------------------------------------------------------- $Comp = Call_User_Func_Array('LoadComp', $Args); if (Is_Error($Comp)) { return ERROR | @Trigger_Error('[Comp_Load]: не возможно загрузить компонент'); } #--------------------------------------------------------------------------- if ($IsCascade) { $Result[] = $Comp; } else { #------------------------------------------------------------------------- $Result = $Comp; #------------------------------------------------------------------------- break; } } #----------------------------------------------------------------------------- $Loaded =& Link_Get('Comp/Loaded', 'array'); #----------------------------------------------------------------------------- $Loaded[] = $Element; #----------------------------------------------------------------------------- return $Result; }
function System_XML($Element, $HostsIDs = array()) { /****************************************************************************/ $__args_types = array('string', 'array,string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $HostsIDs = System_HostsIDs($Element, $HostsIDs); if (Is_Error($HostsIDs)) { return ERROR | @Trigger_Error('[System_XML]: список хостов содержащих элемент не найдены'); } #----------------------------------------------------------------------------- $IsUseCache = (bool) (Preg_Match('/^tmp\\//', $Element) < 1); #----------------------------------------------------------------------------- if ($IsUseCache) { #--------------------------------------------------------------------------- $CacheID = SPrintF('System_XML[%s]', Md5(SPrintF('%s-%s', Implode(':', $HostsIDs), $Element))); #--------------------------------------------------------------------------- $Result = CacheManager::get($CacheID); if ($Result) { return $Result; } } #----------------------------------------------------------------------------- $Result = array(); #----------------------------------------------------------------------------- foreach (Array_Reverse($HostsIDs) as $HostID) { #--------------------------------------------------------------------------- $Path = SPrintF('%s/hosts/%s/%s', SYSTEM_PATH, $HostID, $Element); #--------------------------------------------------------------------------- $File = IO_Read($Path); if (Is_Error($File)) { return ERROR | @Trigger_Error('[System_XML]: не удалось прочитать XML-файл'); } #--------------------------------------------------------------------------- $XML = String_XML_Parse($File, FALSE); if (Is_Exception($XML)) { return ERROR | @Trigger_Error('[System_XML]: не удалось разобрать XML-строку'); } #--------------------------------------------------------------------------- $Child = Current($XML->Childs); #--------------------------------------------------------------------------- if (isset($Child->Attribs['recursive'])) { $Result = array(); } #--------------------------------------------------------------------------- $Adding = $XML->ToArray(); #--------------------------------------------------------------------------- $Adding = $Adding['XML']; #--------------------------------------------------------------------------- Array_Union($Result, $Adding); } #----------------------------------------------------------------------------- if ($IsUseCache) { CacheManager::add($CacheID, $Result); } #----------------------------------------------------------------------------- return $Result; }