PHP Classes

File: pages.json

Recommend this page to a friend!
  Classes of Aleksey Nemiro   PHP ASP.NET WebForms   pages.json   Download  
File: pages.json
Role: Documentation
Content type: text/plain
Description: Documentation
Class: PHP ASP.NET WebForms
Emulation of ASP.NET WebForms engine in PHP
Author: By
Last change:
Date: 8 years ago
Size: 17,013 bytes
 

Contents

Class file image Download
[ { "Key": "PageTitle", "Value": "Pages" }, { "Key": "HeaderTitle", "Value": "Pages" }, { "Key": "HeaderDescription", "Value": "Pages are automatically merged with the templates and output the content blocks. The Page class is the basic element of the WebForms.PHP. Pages can contain custom properties, methods and event handlers." }, { "Key": "IntroductionText1", "Value": "To use the template engine files of pages to be processed <strong>PHP</strong> (as a rule, have the extension <strong>.php</strong>)." }, { "Key": "IntroductionText2", "Value": "Pages can be simple, consisting of one file with the <strong>HTML</strong> and <strong>PHP</strong> code." }, { "Key": "IntroductionText3", "Value": "But to take full advantage of the engine will require the separation of code (<strong>HTML</strong> and <strong>PHP</strong>), at least two files. The main file should contain an object representation of the page - the class. In the second file - Page Layout (<strong>HTML</strong>)." }, { "Key": "IntroductionText4", "Value": "File with page layout should have the same name as the class file, but with the <strong>.html.php</strong> extension." }, { "Key": "IntroductionText5", "Value": "In addition, each page can have the resources localization, which should be located in <strong>.json</strong> files." }, { "Key": "ContentBlocks", "Value": "Content blocks" }, { "Key": "SimplePages", "Value": "Simple pages" }, { "Key": "SeparationPHPAndHTML", "Value": "Separation PHP and HTML" }, { "Key": "OnlyPHP", "Value": "Only PHP code" }, { "Key": "MarkerName", "Value": "markerName" }, { "Key": "ContentBlockExample", "Value": "\n Contents of the block here.\n Acceptable use any tag, \n server code and \n user controls.\n" }, { "Key": "ContentBlocksText1", "Value": "Content for blocks of content must be placed in tags: <code>&lt;php:Content /&gt;</code>. Name of the block is specified in the parameter <code>ID</code>." }, { "Key": "ContentBlocksText2", "Value": "All that is outside of the <code>&lt;php:Content /&gt;</code> tags will be ignored." }, { "Key": "ContentBlocksIgnoredText", "Value": "This text will be ignored becauseIt is located outside the &lt;php:Content /&gt; block." }, { "Key": "ContentBlocksOuntputText", "Value": "This text will be output in the place &lt;php:MainContent/&gt;." }, { "Key": "ContentBlocksText3", "Value": "You can specify blocks of content for non-existent markers in the template. Using this feature, you can dynamically change the template file and output on a single page output blocks that are defined only in the included template." }, { "Key": "ContentBlocksText4", "Value": "The following example shows two templates. In the first defined block <code>&lt;php:MainContent/&gt;</code>, in the second two blocks : <code>&lt;php:MainContent/&gt;</code> and <code>&lt;php:RightPanel/&gt;</code>. The page is defined content for both blocks. When using the template <strong>Layout1.php</strong> client receives only the contents of the block <code>&lt;php:MainContent/&gt;</code> (see Result #1). When using template <strong>Layout2.php</strong>, the client will be given a specific content for both blocks (see Result #2)." }, { "Key": "ContentBlocksText5", "Value": "If on one page will be located several blocks with the same identifier, it will use the last block. It is not recommended, because it will affect the performance." }, { "Key": "ContentBlocksCloneText1", "Value": "This text will be processed, but will not be displayed, because below is a second block with identifier MainContent." }, { "Key": "ContentBlocksCloneText2", "Value": "This text will display in place &lt;php:MainContent/&gt;." }, { "Key": "SimplePagesText1", "Value": "Simple pages consist of a single file containing <strong>HTML</strong> code and blocks of content, and may also contain directives, user controls and any server-side code." }, { "Key": "SimplePagesText2", "Value": "Simple pages can be useful for output static content, when it is not require control the process of building a page on the server." }, { "Key": "SimplePagesText3", "Value": "To use the template engine, is necessary to include the file <strong>global.php</strong> to the page, and also call the the processing by command <code>App::Magic()</code>." }, { "Key": "SimplePagesText4", "Value": "The following example shows the implementation of a simple page that generates content for the <code>&lt;php:MainContent/&gt;</code>. The directive <code>#Page</code> contains a reference to the template file, and also title of the page (<code>&lt;title /&gt;</code>)." }, { "Key": "SimplePagesTitle", "Value": "Simple page" }, { "Key": "SimplePagesText5", "Value": "Simple pages do not provide access to the object representation of the page and have limited functionality for managing templates and user controls." }, { "Key": "SeparationPHPAndHTMLText1", "Value": "To use all the features, it is recommended to separate the <strong>HTML</strong> and <strong>PHP</strong>." }, { "Key": "SeparationPHPAndHTMLText2", "Value": "In the main page file is created class. The class name must match the name of the page file (without extension). The markup must be in a file with the extension <strong>.html.php</strong>." }, { "Key": "SeparationPHPAndHTMLText3", "Value": "For example, there is a page <strong>index.php</strong>:" }, { "Key": "SeparationPHPAndHTMLText4", "Value": "The markup must be placed in the file <strong>index.html.php</strong>. The following example shows the possible contents of the <strong>index.html.php</strong>." }, { "Key": "SeparationPHPAndHTMLText5", "Value": "This model reduces the mixing of server and client code, and allows you to fully control the process of the page building." }, { "Key": "SeparationPHPAndHTMLText6", "Value": "The class of page can contain any public properties and functions that can be used in the code markup through the keyword <code>$this</code>. For example, the base class <code>\\Nemiro\\UI\\Page</code> has the <code>Title</code> property, which contains the title of the current page and can be outputed to the page as follows:" }, { "Key": "ReadMoreAboutPageClass", "Value": "About Page class" }, { "Key": "OnlyPHPText1", "Value": "Allowed does not create files of markup. In this case, the page will only consist of the class, and blocks of content must be built programmatically." }, { "Key": "OnlyPHPText2", "Value": "For example, the <strong>index.php</strong> file can have the following content." }, { "Key": "OnlyPHPText3", "Value": "The page without markup" }, { "Key": "OnlyPHPText4", "Value": "Any content for MainContent." }, { "Key": "OnlyPHPText5", "Value": "But this method is rarely used, since in most cases it is not convenient." }, { "Key": "DirectivePageText1", "Value": "Directive <code>&lt;?#Page ?&gt;</code> allows to override default parameters of the page initialization. (<strong>config.php</strong>)." }, { "Key": "DirectivePageText2", "Value": "Directive located at the top of the <strong>HTML</strong> page, parameters are written in the style attribute of tags <strong>HTML/XML</strong>. For example: <code>&lt;?#Page Title=\"Page title\" Layout=\"~/Layouts/_Layout.php\" ?&gt;</code>" }, { "Key": "DirectivePageText3", "Value": "Supported parameters presented in the following table." }, { "Key": "DirectivePageLayout", "Value": "Contains the path to the template file to be used in the build of the page." }, { "Key": "DirectivePageTitle", "Value": "Contains html-page title (&lt;title&gt;&lt;/title&gt;)." }, { "Key": "DirectivePageOptimized", "Value": "Enables optimization of the resulting html-code of the page." }, { "Key": "DirectivePageCache", "Value": "Enables caching of the page." }, { "Key": "DirectivePageCulture", "Value": "Sets the culture (language) for the page. For example: ru, en." }, { "Key": "DirectivePageText4", "Value": "The following example illustrates the use of the <code>&lt;?#Page ?&gt;</code> for to set the title of the page and activation the optimization of <strong>HTML</strong>." }, { "Key": "DirectivePageText5", "Value": "The <code>&lt;?#Page ?&gt;</code> directive actual for a <a href=\"#simple\">simple pages</a>." }, { "Key": "DirectiveRegister1", "Value": "Directive <code>&lt;?#Register ?&gt;</code> allows to register the necessary <a href=\"/controls.php${Lang}\">user controls</a>." }, { "Key": "DirectiveRegister2", "Value": "The <code>&lt;?#Register ?&gt;</code> accept four parameters, the list of which is presented in the following table." }, { "Key": "DirectiveRegisterSrc", "Value": "The path to the main file of the control." }, { "Key": "DirectiveRegisterTagPrefix", "Value": "Prefix the name of the control that will be used when placing an instance of an element on the page." }, { "Key": "DirectiveRegisterTagName", "Value": "Name of the control to be used when placing an instance of an element on the page." }, { "Key": "DirectiveRegisterClassName", "Value": "Specifies the class name of the element. For example, user control file <strong>Message.php</strong>, the <strong>ClassName</strong> by default <code>Message</code>." }, { "Key": "DirectiveRegister3", "Value": "The number <code>&lt;?#Register ?&gt;</code> directives on one page is not limited." }, { "Key": "DirectiveRegister4", "Value": "The following example shows how to use the directive <code>&lt;?#Register ?&gt;</code> for registration on the page <a href=\"/controls.php${Lang}\">user controls</a> <code>Message</code> and <code>TabControl</code>, and their subsequent use." }, { "Key": "AllOk", "Value": "Success!" }, { "Key": "ExamplePleaseNote", "Value": "Attention" }, { "Key": "ExampleTab1", "Value": "\n Controls TabControl and Message is not WebForms.PHP,\n the controls are made specifically for the demo site.\n" }, { "Key": "ExampleBut", "Value": "But..." }, { "Key": "ExampleTab2", "Value": "\n If you wish, you can use these elements into your own projects, \n just copy the files from the folder /Controls.\n Please note, Bootstrap3 is required.\n " }, { "Key": "ClassPageText1", "Value": "Class <code>\\Nemiro\\UI\\Page</code> (hereinafter <code>Page</code>) - this basic class that is responsible for building a pages." }, { "Key": "ClassPageText2", "Value": "From the <code>Page</code> class must be inherited (<code>extends</code>) classes of all pages." }, { "Key": "ClassPageText3", "Value": "If a page has no class, it will use the default instance of the <code>Page</code>." }, { "Key": "ClassPageText4", "Value": "The following code shows a variant of the page <code>Forum</code> class inheritance from the base class <code>Page</code>." }, { "Key": "PropertiesText1", "Value": "The <code>Page</code> class has the following public properties." }, { "Key": "PageClassOptimized", "Value": "Gets or sets the mode to optimize the resulting html-code of the page.<br />Programmatically change the value of this property can be in the event handler <a href=\"#preload\">PreLoad</a> ??? <a href=\"#load\">Load</a>." }, { "Key": "PageClassCache", "Value": "Gets or sets the cache mode of the page.<br />Programmatically change the value of this property can be in the event handler <a href=\"#preload\">PreLoad</a>." }, { "Key": "PageClassLayout", "Value": "Gets or sets the path to the template file.<br />Programmatically change the value of this property can be in the event handler <a href=\"#preload\">PreLoad</a>." }, { "Key": "PageClassEncode", "Value": "Gets or sets the page encoding.<br />Programmatically change the value of this property can be in the event handler <a href=\"#preload\">PreLoad</a>." }, { "Key": "PageClassCulture", "Value": "Gets or sets the code of culture (language) for the page. For example: ru, en.<br />Programmatically change the value of this property can be in the event handler <a href=\"#preload\">PreLoad</a> or <a href=\"#load\">Load</a>." }, { "Key": "PageClassTitle", "Value": "Gets or sets the page title (&lt;title&gt;&lt;/title&gt;).<br />Programmatically change the value of this property can be in the event handler <a href=\"#preload\">PreLoad</a> or <a href=\"#load\">Load</a>." }, { "Key": "PageClassContent", "Value": "Collection blocks of content of the page; where the key is a name (identifier) of the block, the value - is content.<br />Programmatically change the value of this property can be in the event handler <a href=\"#preload\">PreLoad</a> or <a href=\"#load\">Load</a>.<br />For example: <code>$this->Content['MainContent'] = 'Content for MainContent.';</code>" }, { "Key": "PageClassMeta", "Value": "Gets or sets the meta tags of the page.<br />Programmatically change the value of this property can be in the event handler <a href=\"#preload\">PreLoad</a> or <a href=\"#load\">Load</a>.<br />For example: <code>$this->Meta['DESCRIPTION'] = 'Page description.';</code>, output:<br /><code>&lt;meta name=\"DESCRIPTION\" content=\"Page description.\" /&gt;</code>.<br />For keywods and description you can use <code>SetDescription</code> and <code>SetKeyWords</code> methods.<br />For example: <code>$this->SetDescription('Page description.');</code>" }, { "Key": "PageClassScripts", "Value": "An array of links to client scripts to be included in the page.<br />Programmatically change the value of this property can be in the event handler <a href=\"#preload\">PreLoad</a> or <a href=\"#load\">Load</a>." }, { "Key": "PageClassControls", "Value": "Collection controls; where the key - control identifier (<code>ID</code>), value - control instance.<br />Programmatically change the value of this property can be in the event handler <a href=\"#load\">Load</a>.<br />Note that through this collection can not get direct access to the control instance, it is only possible to determine the values of the properties of the elements that will be created during the building of the page. Also through this collection can not access the public methods of the control." }, { "Key": "PageClassResources", "Value": "Collection of localization resources; where the key - the name of the resource, the value - localized string.<br />Programmatically change the value of this property can be in the event handler <a href=\"#load\">Load</a>." }, { "Key": "PropertiesText2", "Value": "All public properties are available for the descendant classes, ie classes of pages." }, { "Key": "PropertiesText3", "Value": "To avoid conflicts, the names of the custom properties should not overlap with the names of the properties of the base class." }, { "Key": "EventsText1", "Value": "The <code>Page</code> class has three events that can be processed." }, { "Key": "PreLoadText1", "Value": "The <code>PreLoad</code> event occurs after page initialization and before the start of the HTTP-headers output, loading template and resources." }, { "Key": "PreLoadText2", "Value": "In the <code>PreLoad</code> event handler you can change the path to the template file and add a new <strong>HTTP</strong> headers." }, { "Key": "PreLoadText3", "Value": "You can not control the resources localization in this event, but you can change the current culture." }, { "Key": "PreLoadText4", "Value": "The following example shows how to change the link to the template file in the event <code>PreLoad</code> handler." }, { "Key": "LoadText1", "Value": "The <code>Load</code> event occurs before building data for output." }, { "Key": "LoadText2", "Value": "In handler of this event, you can change the page title, meta tags, a list of client-side scripts, content and change values of the user controls properties." }, { "Key": "LoadText3", "Value": "The following example shows how to change the page title and add a description of the page." }, { "Key": "LoadText4", "Value": "New title" }, { "Key": "LoadText5", "Value": "New description." }, { "Key": "LoadCompleteText1", "Value": "The <code>LoadComplete</code> event occurs after data output." }, { "Key": "LoadCompleteText2", "Value": "In handler of this event, you can be notified of the page creation." }, { "Key": "LoadCompleteText3", "Value": "The page is created and outputed!" }, { "Key": "LocalizationText1", "Value": "For localization of pages can be be used local and global resources." }, { "Key": "LocalizationText2", "Value": "Local Resources - a text file with the extension <strong>.json</strong>. The file names (without extensions) must contain the name of the main page file. The file names must contain the code of culture (language), for which resources is designed." }, { "Key": "LocalizationText3", "Value": "For example, for page <strong>index.php</strong> may be the following resource files: <strong>index.json</strong> - the default resources, <strong>index.en.json</strong> - for English, <strong>index.ru.json</strong> - for Russain, <strong>index.de.json</strong> - for German etc." }, { "Key": "LocalizationText4", "Value": "The scope of local resources also applies to templates and user controls." } ]