示例#1
0
function TemplateReplace($Text, $Params = array(), $NoBody = TRUE)
{
    #-------------------------------------------------------------------------------
    $Text = Trim($Text);
    #-------------------------------------------------------------------------------
    # проверяем что нам сунули - текст или файл
    if (!Preg_Match('/\\s/', $Text)) {
        #-------------------------------------------------------------------------------
        # достаём текст из файла
        $Path = System_Element(SPrintF('templates/modules/%s.html', $Text));
        #-------------------------------------------------------------------------------
        if (Is_Error($Path)) {
            #-------------------------------------------------------------------------------
            $Text = SprintF('Отсутствует шаблон сообщения (templates/modules/%s.html)', $Text);
            #-------------------------------------------------------------------------------
        } else {
            #-------------------------------------------------------------------------------
            $Text = Trim(IO_Read($Path));
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    if ($NoBody) {
        $Text = SPrintF('<NOBODY><SPAN>%s</SPAN></NOBODY>', $Text);
    }
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    $Replace = Array_ToLine($Params, '%');
    #-------------------------------------------------------------------------------
    foreach (Array_Keys($Replace) as $Key) {
        $Text = Str_Replace($Key, $Replace[$Key], $Text);
    }
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    return $Text;
    #-------------------------------------------------------------------------------
}
            if (!In_Array($Key, $ShareConfigsParams)) {
                $ShareConfigsParams[] = $Key;
            }
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$Config = System_XML('config/Config.xml', array(HOST_ID));
if (Is_Error($Config)) {
    return new gException('ERROR_TEMPLATE_LOAD', 'Ошибка загрузки шаблона');
}
#-------------------------------------------------------------------------------
$Params = Array_ToLine($Config);
#-------------------------------------------------------------------------------
foreach (Array_Keys($Params) as $Key) {
    #-------------------------------------------------------------------------------
    if (!In_Array($Key, $ShareConfigsParams)) {
        #-------------------------------------------------------------------------------
        Debug(SPrintF('[comp/Tasks/GC/CheckConfigParams]: в конфигурационном файле обнаружен не используемый параметр: %s', $Key));
        #-------------------------------------------------------------------------------
        if ($Settings['IsEvent']) {
            #-------------------------------------------------------------------------------
            $Event = array('IsReaded' => FALSE, 'PriorityID' => 'System', 'Text' => SPrintF('Обнаружен неиспользуемый параметр конфигурационного файла: %s, со значением (%s). Удалите его, или отключите задачу поиска неиспользуемых параметров. При удалении, будте аккуратны и внимательны, сохраняйте бэкап конфигурационного файла.', $Key, $Params[$Key]));
            $Event = Comp_Load('Events/EventInsert', $Event);
            if (!$Event) {
                return ERROR | @Trigger_Error(500);
            }
            #-------------------------------------------------------------------------------
 }
 #-------------------------------------------------------
 $Nds = Comp_Load('Formats/Currency', $Summ * 18 / 118);
 if (Is_Error($Nds)) {
     return ERROR | @Trigger_Error(500);
 }
 #-------------------------------------------------------
 $Config = Config();
 #-------------------------------------------------------
 $Wizard = SPrintF('%s. %s', $Wizard, $Config['Executor']['IsNds'] ? SPrintF('(в том числе НДС %s)', $Nds) : '(НДС не облагается)');
 #-------------------------------------------------------
 $Report['Wizard'] = $Wizard;
 #-------------------------------------------------------
 $Replace['Report'] = $Report;
 #-------------------------------------------------------
 $Replace = Array_ToLine($Replace);
 #-------------------------------------------------------
 foreach (Array_Keys($Replace) as $LinkID) {
     #-----------------------------------------------------
     $Text = (string) $Replace[$LinkID];
     #-----------------------------------------------------
     $DOM->AddText($LinkID, $Text ? $Text : '-', TRUE);
 }
 #-------------------------------------------------------
 if ($IsStamp) {
     #-----------------------------------------------------
     @($DOM->Links['Sign']->Childs = array());
     #-----------------------------------------------------
     $DOM->AddChild('Sign', new Tag('IMG', array('src' => 'SRC:{Images/dSign.bmp}')));
     #-----------------------------------------------------
     @($DOM->Links['Stamp']->Childs = array());
示例#4
0
         #---------------------------------------------------------------------
         $Template = System_XML(SPrintF('profiles/%s.xml', $Profile['TemplateID']));
         if (Is_Error($Template)) {
             return ERROR | @Trigger_Error(500);
         }
         #---------------------------------------------------------------------
         $tAttribs = $Template['Attribs'];
         #---------------------------------------------------------------------
         foreach (Array_Keys($tAttribs) as $AttribID) {
             #-------------------------------------------------------------------
             if (!isset($pAttribs[$AttribID])) {
                 $pAttribs[$AttribID] = $tAttribs[$AttribID]['Value'];
             }
         }
         #---------------------------------------------------------------------
         $Replace = Array_ToLine($pAttribs, '%');
         #---------------------------------------------------------------------
         $ProfileName = $Template['ProfileName'];
         #---------------------------------------------------------------------
         foreach (Array_Keys($Replace) as $Key) {
             $ProfileName = Str_Replace($Key, $Replace[$Key], $ProfileName);
         }
         #---------------------------------------------------------------------
         $IProfile = array('CreateDate' => GetTime($Profile['CreateDate']), 'UserID' => $UserID, 'TemplateID' => $Profile['TemplateID'], 'Name' => $ProfileName, 'Attribs' => $pAttribs, 'StatusID' => 'Checked', 'StatusDate' => GetTime($Profile['CreateDate']));
         #---------------------------------------------------------------------
         $ProfileID = DB_Insert('Profiles', $IProfile);
         if (Is_Error($ProfileID)) {
             return ERROR | @Trigger_Error(500);
         }
     }
 }
示例#5
0
     #-------------------------------------------------------------------------------
 }
 #-------------------------------------------------------------------------------
 #-------------------------------------------------------------------------------
 $Template = System_XML(SPrintF('servers/%s.xml', $TemplateID));
 if (Is_Error($Template)) {
     return ERROR | @Trigger_Error(500);
 }
 #-------------------------------------------------------------------------------
 #-------------------------------------------------------------------------------
 if (isset($Template['Attribs'])) {
     #-------------------------------------------------------------------------------
     $Attribs = $Template['Attribs'];
     #-------------------------------------------------------------------------------
     #-------------------------------------------------------------------------------
     $Replace = Array_ToLine($__USER, '%');
     #-------------------------------------------------------------------------------
     foreach (Array_Keys($Attribs) as $AttribID) {
         #-------------------------------------------------------------------------------
         $Attrib = $Attribs[$AttribID];
         #-------------------------------------------------------------------------------
         if (isset($Attrib['Title'])) {
             $Table[] = $Attrib['Title'];
         }
         #-------------------------------------------------------------------------------
         if ($ServerID) {
             #-------------------------------------------------------------------------------
             $Value = (string) @$Server['Params'][$AttribID];
             #-------------------------------------------------------------------------------
         } else {
             #-------------------------------------------------------------------------------
示例#6
0
            #-------------------------------------------------------------------------
            foreach (Array_Keys($Array) as $ElementID) {
                #-----------------------------------------------------------------------
                $Element = $Array[$ElementID];
                #-----------------------------------------------------------------------
                $Result[$ElementID] = Is_Array($Element) ? Table_Super_Replace($Element, $Matches) : Str_Replace(Array_Keys($Matches), Array_Values($Matches), $Element);
            }
        }
        #---------------------------------------------------------------------------
        return $Result;
    }
}
#-------------------------------------------------------------------------------
foreach ($Data as $Row) {
    #-----------------------------------------------------------------------------
    $Replace = Array_ToLine($Row, '%');
    #-----------------------------------------------------------------------------
    $Tr = new Tag('TR');
    #-----------------------------------------------------------------------------
    if (StrLen($Comp = $Appearance['Row']['Comp'])) {
        #---------------------------------------------------------------------------
        $Args = Table_Super_Replace($Appearance['Row']['Args'], $Replace);
        #---------------------------------------------------------------------------
        Array_UnShift($Args, $Comp);
        #---------------------------------------------------------------------------
        $Comp = Call_User_Func_Array('Comp_Load', $Args);
        if (Is_Error($Comp)) {
            return ERROR | @Trigger_Error(500);
        }
        #---------------------------------------------------------------------------
        $Tr->AddAttribs($Comp);
示例#7
0
        if (isset($Item['JavaScript'])) {
            #-------------------------------------------------------------------------------
            $Script = new Tag('SCRIPT', array('type' => 'text/javascript', 'src' => SPrintF('SRC:{Js/%s}', $Item['JavaScript'])));
            #-------------------------------------------------------------------------------
            $DOM->AddChild('Head', $Script);
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$Links[$CacheID] = UniqID();
#-------------------------------------------------------------------------------
$Replace = Array_ToLine(Is_Array($Replace) ? $Replace : array('Replace' => $Replace), '%');
#-------------------------------------------------------------------------------
foreach ($Items as $Item) {
    #-------------------------------------------------------------------------------
    $Href = $Item['Href'];
    #-------------------------------------------------------------------------------
    foreach (Array_Keys($Replace) as $Key) {
        $Href = Str_Replace($Key, $Replace[$Key] ? $Replace[$Key] : '0000', $Href);
    }
    #-------------------------------------------------------------------------------
    $Array[] = SPrintF("{Text:'%s',Href:'%s',Icon:'SRC:{Images/Icons/%s}'}", $Item['Text'], $Href, $Item['Icon']);
    #-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$String = Implode(',', $Array);
示例#8
0
function Array_ToLine($Array, $Border = '', $Path = '', &$Result = array())
{
    /****************************************************************************/
    $__args_types = array('array', 'string', 'string', 'array');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    foreach (Array_Keys($Array) as $Key) {
        #---------------------------------------------------------------------------
        $Name = $Path ? SPrintF('%s.%s', $Path, $Key) : $Key;
        #---------------------------------------------------------------------------
        if (Is_Array($Child = $Array[$Key])) {
            #-------------------------------------------------------------------------
            if (Is_Error(Array_ToLine($Child, $Border, $Name, $Result))) {
                return ERROR | Trigger_Error('[Array_ToLine]: ошибка рекурсивного вызова');
            }
        } else {
            #-------------------------------------------------------------------------
            $Result[$Border . $Name . $Border] = $Child;
        }
    }
    #-----------------------------------------------------------------------------
    return $Result;
}