Parameterized component (application) is component or application than can be customized using parameter(s). Behavior of component or application will be different for different parameter(s) in used.
Here is an example of parameterized component,CIISONLINE_FileEditor, and its usage on web application as an example:
parameterized component (FileEditor.php): <?p class CIISONLINE_FileEditor extends CIISONLINE_PageProcessor{ static function MenuPath_Show() { if (GetCurrentUserConfig('bMenuPathShow')) { SetVar ('FileEditorPageMenuPath', ToHTML(GetTextLanguage('sFileEditorPageMenuPathTitle'))); } else { SetVar ('MenuPath', ''); } } protected static function CommonSetVar() { /* Common Javascript Setting Value */ CommonSetVar(); /*-------------------------------*/ SetVar ('msg_reallytoupdatefile', ToHTML(GetTextLanguage('sFileEditorMsgReallyToUpdateFile'))); SetVar ('msg_reallytocancelfile', ToHTML(GetTextLanguage('sFileEditorMsgReallyToCancelFile'))); } /*=============================== * Action of the Record Form *-------------------------------*/ static function FileEditorAction($sAction) { /*------------------------------- * Initialize variables *-------------------------------*/ /*------------------------------- * Validate fields *-------------------------------*/ if ((string)$sAction == 'update') { /*------------------------------- * Load all form fields into variables *-------------------------------*/ $fldfileeditor_contents = GetParam('fileeditor_contents'); /*------------------------------- * FileEditor Check Event begin * FileEditor Check Event end *-------------------------------*/ } switch ((string)$sAction) { case 'update': /*------------------------------- * FileEditor Update Event begin * FileEditor Update Event end *-------------------------------*/ if (isset(self::$config->fileeditor->source->path ) && ($fldfilename = self::$config->fileeditor->source->path ) && @file_put_contents($fldfilename,$fldfileeditor_contents)) { @chmod($fldfilename,0777); } else { SetCurrentPageConfig('sPageErrorMessage',GetTextLanguage('sFileEditorErrCanNotWriteFile')); } break; default: $sRedirectFileName = GetCurrentUserConfig('sDefaultPage'); ResponseRedirect ($sRedirectFileName); } /*------------------------------- * FileEditor BeforeExecute Event begin * FileEditor BeforeExecute Event end *-------------------------------*/ if (strlen(GetCurrentPageConfig('sPageErrorMessage')) > 0) { OnPageAccessWarningLogWrite (str_replace("<br>",'',GetCurrentPageConfig('sPageErrorMessage'))); return; } OnPageAccessInfoLogWrite (); /*------------------------------- * FileEditor Action end *-------------------------------*/ } /*=============================== * Display Record Form *-------------------------------*/ static function FileEditor_Show() { /*------------------------------- * FileEditor Show begin *-------------------------------*/ $sFormTitle = GetTextLanguage('sFileEditorFormTitle'); $sAction = GetCurrentPageConfig('sAction'); $sForm = GetCurrentPageConfig('sForm'); $fldfileeditor_contents = ''; /* Common Javascript Setting Value */ self::CommonSetVar(); /*-------------------------------*/ /*------------------------------- * Load primary key and form parameters *-------------------------------*/ $sPageErrorMessage = GetCurrentPageConfig('sPageErrorMessage'); $bIsUpdateMode = ((string)$sForm != 'FileEditor' && isset(self::$config->fileeditor->source->path ) && ($fldfilename = self::$config->fileeditor->source->path ) && file_exists($fldfilename)); if ((string)$sPageErrorMessage == '') { if ($bIsUpdateMode) { $fldfileeditor_contents = file_get_contents($fldfilename); SetVar ('ActionMessage', ''); OnPageAccessInfoLogWrite (); } else { $fldfileeditor_contents = file_get_contents(self::$config->fileeditor->source->path ); SetVar ('message', (GetTextLanguage('sFileEditorMsgUpdateSuccessfully'))); Parse ('ActionMessage', false); } } else { $fldfileeditor_contents = GetParam ('fileeditor_contents'); SetVar ('message', ($sPageErrorMessage)); SetVar ('FormTitle', ToHTML($sFormTitle)); Parse ('ActionMessage', false); } /*------------------------------- * Load all fields into variables from recordset or input parameters *-------------------------------*/ Parse ('FileEditorEdit', false); /*------------------------------- * FileEditor ShowEdit Event begin * FileEditor ShowEdit Event end *-------------------------------*/ SetVar ('FileEditorCancel', ''); /*------------------------------- * FileEditor Show Event begin * FileEditor Show Event end *-------------------------------*/ SetVar ('FormTitle', ToHTML($sFormTitle)); SetVar ('UpdateButton', ToHTML(GetTextLanguage('sFileEditorUpdateButtonTitle'))); SetVar ('CancelButton', ToHTML(GetTextLanguage('sFileEditorCancelButtonTitle'))); /*------------------------------- * Show form field *-------------------------------*/ SetVar ('fileeditor_contents', ToHTML($fldfileeditor_contents)); Parse ('FormFileEditor', false); /*------------------------------- * FileEditor Show end *-------------------------------*/ } } ?>application #1: manifest (AliasConfig.pageprop):
<?xml version="1.0" encoding="UTF-8"?> <configuration id="AliasConfig" > <section name="fileeditor"> <config name="source"> <config name="path"><![CDATA[./System/Configuration/CIISONLINE.dbconf]]></config> </config> </section> </configuration> configuration (AliasConfig.pageconf):
<?xml version="1.0" encoding="UTF-8"?> <page name="AliasConfig" id="AliasConfig" > <processor PageSecurityCode="1" HelpContext="LIGHTARMY-Applications.AliasConfig" sOnlyTemplateFileName="FileEditor.html" CanPublic="false"> <PageSecurityCode> <Name>Alias Configuration</Name> <Description></Description> <HelpContext>LIGHTARMY-Applications.AliasConfig</HelpContext> </PageSecurityCode> <PageActionSelectionScript><![CDATA[ switch ((string)GetCurrentPageConfig('sForm')) { case 'FileEditor': CIISONLINE_FileEditor::FileEditorAction(GetCurrentPageConfig('sAction')); } ]]></PageActionSelectionScript> <TemplateProcessingScript><![CDATA[ CIISONLINE_Header::Menu_Show(); CIISONLINE_Footer::FooterForm_Show(); CIISONLINE_FileEditor::MenuPath_Show(); CIISONLINE_FileEditor::FileEditor_Show(); ]]></TemplateProcessingScript> <ResponseProcessingScript><![CDATA[ ResponseWrite (PrintVar('main')); ]]></ResponseProcessingScript> <IncludeFile>PageClass/Header.php</IncludeFile> <IncludeFile>PageClass/Footer.php</IncludeFile> <IncludeFile>PageClass/FileEditor.php</IncludeFile> <TemplateSpaceHolder name="Header">Header.html</TemplateSpaceHolder> <TemplateSpaceHolder name="Footer">Footer.html</TemplateSpaceHolder> <TemplateSpaceHolder name="Space01">Space01.html</TemplateSpaceHolder> </processor> </page> application #2: manifest (AutoIncludeConfig.pageprop):
<?xml version="1.0" encoding="UTF-8"?> <configuration id="AutoIncludeConfig" > <section name="fileeditor"> <config name="source"> <config name="path"><![CDATA[./System/Configuration/CIISONLINE.coreconf]]></config> </config> </section> </configuration> configuration (AutoIncludeConfig.pageconf):
<?xml version="1.0" encoding="UTF-8"?> <page name="AutoIncludeConfig" id="AutoIncludeConfig" > <processor PageSecurityCode="2" HelpContext="LIGHTARMY-Applications.AutoIncludeConfig" sOnlyTemplateFileName="FileEditor.html" CanPublic="false"> <PageSecurityCode> <Name>AutoInclude Configuration</Name> <Description></Description> <HelpContext>LIGHTARMY-Applications.AutoIncludeConfig</HelpContext> </PageSecurityCode> <PageActionSelectionScript><![CDATA[ switch ((string)GetCurrentPageConfig('sForm')) { case 'FileEditor': CIISONLINE_FileEditor::FileEditorAction(GetCurrentPageConfig('sAction')); } ]]></PageActionSelectionScript> <TemplateProcessingScript><![CDATA[ CIISONLINE_Header::Menu_Show(); CIISONLINE_Footer::FooterForm_Show(); CIISONLINE_FileEditor::MenuPath_Show(); CIISONLINE_FileEditor::FileEditor_Show(); ]]></TemplateProcessingScript> <ResponseProcessingScript><![CDATA[ ResponseWrite (PrintVar('main')); ]]></ResponseProcessingScript> <IncludeFile>PageClass/Header.php</IncludeFile> <IncludeFile>PageClass/Footer.php</IncludeFile> <IncludeFile>PageClass/FileEditor.php</IncludeFile> <TemplateSpaceHolder name="Header">Header.html</TemplateSpaceHolder> <TemplateSpaceHolder name="Footer">Footer.html</TemplateSpaceHolder> <TemplateSpaceHolder name="Space01">Space01.html</TemplateSpaceHolder> </processor> </page> You can also use different style for that applications as needed.
No comments:
Post a Comment