Methods summary
public static
MvcCore\View
|
#
CreateInstance( )
Return always new instance of statically called class, no singleton.
Always called from \MvcCore\Controller::PreDispatch() and
\MvcCore\Controller::Render() to create layout view.
This is place where to customize any view creation process,
before it's created by MvcCore framework to fill and render it.
Return always new instance of statically called class, no singleton.
Always called from \MvcCore\Controller::PreDispatch() and
\MvcCore\Controller::Render() to create layout view.
This is place where to customize any view creation process,
before it's created by MvcCore framework to fill and render it.
Returns
|
public static
string
|
#
GetExtension( )
Get view scripts files extension with leading dot char.
Default value: ".phtml" .
Get view scripts files extension with leading dot char.
Default value: ".phtml" .
Returns
string
|
public static
string
|
#
SetExtension( string $extension = '.phtml' )
Set view scripts files extension.
given value could be with or without leading dot char.
Set view scripts files extension.
given value could be with or without leading dot char.
Parameters
- $extension
- An extension with or without leading dot char.
Returns
string
|
public static
string
|
#
GetDoctype( )
Get output document type (to automatically and optionally send proper
HTTP header Content-Type , if there is no Content-Type HTTP
header in response object yet).
This value could be used also for any other custom purposes.
Possible values:
- HTML4 - \MvcCore\IView::DOCTYPE_HTML4
- XHTML - \MvcCore\IView::DOCTYPE_XHTML
- HTML5 - \MvcCore\IView::DOCTYPE_HTML5
- XML - \MvcCore\IView::DOCTYPE_XML
Default value: HTML5 .
Get output document type (to automatically and optionally send proper
HTTP header Content-Type , if there is no Content-Type HTTP
header in response object yet).
This value could be used also for any other custom purposes.
Possible values:
- HTML4 - \MvcCore\IView::DOCTYPE_HTML4
- XHTML - \MvcCore\IView::DOCTYPE_XHTML
- HTML5 - \MvcCore\IView::DOCTYPE_HTML5
- XML - \MvcCore\IView::DOCTYPE_XML
Default value: HTML5 .
Returns
string
|
public static
string
|
#
SetDoctype( string $doctype = \MvcCore\IView::DOCTYPE_HTML5 )
Set output document type (to automatically and optionally send proper
HTTP header Content-Type , if there is no Content-Type HTTP
header in response object yet).
This value could be used also for any other custom purposes.
Possible values:
- HTML4 - \MvcCore\IView::DOCTYPE_HTML4
- XHTML - \MvcCore\IView::DOCTYPE_XHTML
- HTML5 - \MvcCore\IView::DOCTYPE_HTML5
- XML - \MvcCore\IView::DOCTYPE_XML
Default value: HTML5 .
Set output document type (to automatically and optionally send proper
HTTP header Content-Type , if there is no Content-Type HTTP
header in response object yet).
This value could be used also for any other custom purposes.
Possible values:
- HTML4 - \MvcCore\IView::DOCTYPE_HTML4
- XHTML - \MvcCore\IView::DOCTYPE_XHTML
- HTML5 - \MvcCore\IView::DOCTYPE_HTML5
- XML - \MvcCore\IView::DOCTYPE_XML
Default value: HTML5 .
Parameters
Returns
string
|
public static
string
|
#
GetLayoutsDir( )
Get layout templates directory placed by default
inside "/App/Views" directory. Default value
is "Layouts" , so layouts app path
is "/App/Views/Layouts" .
Get layout templates directory placed by default
inside "/App/Views" directory. Default value
is "Layouts" , so layouts app path
is "/App/Views/Layouts" .
Returns
string
|
public static
string
|
#
SetLayoutsDir( string $layoutsDir = 'Layouts' )
Set layout templates directory placed by default
inside "/App/Views" directory. Default value
is "Layouts" , so layouts app path
is "/App/Views/Layouts" .
Set layout templates directory placed by default
inside "/App/Views" directory. Default value
is "Layouts" , so layouts app path
is "/App/Views/Layouts" .
Parameters
Returns
string
|
public static
string
|
#
GetScriptsDir( )
Get controller/action templates directory
placed by default inside "/App/Views" directory.
Default value is "Scripts" , so scripts app path
is "/App/Views/Scripts" .
Get controller/action templates directory
placed by default inside "/App/Views" directory.
Default value is "Scripts" , so scripts app path
is "/App/Views/Scripts" .
Returns
string
|
public static
string
|
#
SetScriptsDir( string $scriptsDir = 'Scripts' )
Get controller/action templates directory
placed by default inside "/App/Views" directory.
Default value is "Scripts" , so scripts app path
is "/App/Views/Scripts" .
Get controller/action templates directory
placed by default inside "/App/Views" directory.
Default value is "Scripts" , so scripts app path
is "/App/Views/Scripts" .
Parameters
Returns
string
|
public static
string
|
#
GetHelpersDir( )
Get views helpers directory placed by default
inside "/App/Views" directory.
Default value is "Helpers" , so scripts app path
is "/App/Views/Helpers" .
Get views helpers directory placed by default
inside "/App/Views" directory.
Default value is "Helpers" , so scripts app path
is "/App/Views/Helpers" .
Returns
string
|
public static
string
|
#
SetHelpersDir( string $helpersDir = 'Helpers' )
Set views helpers directory placed by default
inside "/App/Views" directory.
Default value is "Helpers" , so scripts app path
is "/App/Views/Helpers" .
Set views helpers directory placed by default
inside "/App/Views" directory.
Default value is "Helpers" , so scripts app path
is "/App/Views/Helpers" .
Parameters
Returns
string
|
public static
|
#
AddHelpersNamespaces( string $helperNamespaces )
Add view helpers classes namespace(s),
Example: \MvcCore\View::AddHelpersNamespaces('Any\Other\ViewHelpers\Place', '...'); .
Add view helpers classes namespace(s),
Example: \MvcCore\View::AddHelpersNamespaces('Any\Other\ViewHelpers\Place', '...'); .
Parameters
- $helperNamespaces
- View helper classes namespace(s).
|
public static
|
#
SetHelpersNamespaces( string $helperNamespaces )
Set view helpers classes namespace(s). This method replace all previously configured namespaces.
If you want only to add namespace, use \MvcCore\View::AddHelpersNamespaces(); instead.
Example: \MvcCore\View::SetHelpersClassNamespaces('Any\Other\ViewHelpers\Place', '...'); .
Set view helpers classes namespace(s). This method replace all previously configured namespaces.
If you want only to add namespace, use \MvcCore\View::AddHelpersNamespaces(); instead.
Example: \MvcCore\View::SetHelpersClassNamespaces('Any\Other\ViewHelpers\Place', '...'); .
Parameters
- $helperNamespaces
- View helper classes namespace(s).
|
public static
string
|
#
GetViewScriptFullPath( string $typePath = '', string $corectedRelativePath = '' )
Get view script full path by internal application configuration,
by $typePath param and by $corectedRelativePath param.
Get view script full path by internal application configuration,
by $typePath param and by $corectedRelativePath param.
Parameters
- $typePath
- Usually
"Layouts" or "Scripts" .
- $corectedRelativePath
Returns
string
|
public
MvcCore\View
|
#
SetController( MvcCore\IController $controller )
This is INTERNAL method, do not use it in templates.
Method is always called in the most parent controller
\MvcCore\Controller:PreDispatch() moment when view instance is created.
Method sets controller instance into view.
This is INTERNAL method, do not use it in templates.
Method is always called in the most parent controller
\MvcCore\Controller:PreDispatch() moment when view instance is created.
Method sets controller instance into view.
Parameters
Returns
|
public
MvcCore\Controller
|
|
public
MvcCore\View
|
#
SetUpRender( integer $renderMode = \MvcCore\IView::RENDER_WITH_OB_FROM_ACTION_TO_LAYOUT, string $controllerOrActionNameDashed = NULL, string $actionNameDashed = NULL )
Set up view rendering arguments to render layout and action view in both modes properly.
Set up view instance helpers before rendering.
Set up view rendering arguments to render layout and action view in both modes properly.
Set up view instance helpers before rendering.
Parameters
- $renderMode
- $controllerOrActionNameDashed
- $actionNameDashed
Returns
|
public
MvcCore\View
|
#
SetUpStore( MvcCore\IView $view, boolean $overwriteExistingKeys = TRUE )
This is INTERNAL method, do not use it in templates.
Method is always called in the most parent controller
\MvcCore\Controller:Render() moment when view is rendered.
Set up all from given view object variables store into current store,
if there is any already existing key - overwrite it.
This is INTERNAL method, do not use it in templates.
Method is always called in the most parent controller
\MvcCore\Controller:Render() moment when view is rendered.
Set up all from given view object variables store into current store,
if there is any already existing key - overwrite it.
Parameters
- $view
- $overwriteExistingKeys
- If any property name already exist in view store, overwrite it by given value by default.
Returns
|
public
string
&
|
#
GetContent( )
Return rendered action template content as string reference.
You need to use this method always somewhere in layout template to
render rendered action result content.
If render mode is continuous, this method renders action view.
Return rendered action template content as string reference.
You need to use this method always somewhere in layout template to
render rendered action result content.
If render mode is continuous, this method renders action view.
Returns
string
|
public
string|null
|
#
GetCurrentViewFullPath( )
Get currently rendered view file full path.
If this method is called outside of rendering process, NULL is returned.
Get currently rendered view file full path.
If this method is called outside of rendering process, NULL is returned.
Returns
string|null
|
public
string|null
|
#
GetCurrentViewDirectory( )
Get currently rendered view file directory full path.
If this method is called outside of rendering process, NULL is returned.
Get currently rendered view file directory full path.
If this method is called outside of rendering process, NULL is returned.
Returns
string|null
|
public
string|null
|
#
GetParentViewFullPath( )
Get currently rendered parent view file full path.
Parent view file could be any view file, where is called $this->RenderScript(...);
method to render sub-view file (actual view file) or it could be any view file
from parent controller or if current controller has no parent controller,
it could be layout view script full path.
If this method is called outside of rendering process, NULL is returned.
Get currently rendered parent view file full path.
Parent view file could be any view file, where is called $this->RenderScript(...);
method to render sub-view file (actual view file) or it could be any view file
from parent controller or if current controller has no parent controller,
it could be layout view script full path.
If this method is called outside of rendering process, NULL is returned.
Returns
string|null
|
public
string|null
|
#
GetParentViewDirectory( )
Get currently rendered parent view file directory full path.
Parent view file could be any view file, where is called $this->RenderScript(...);
method to render sub-view file (actual view file) or it could be any view file
from parent controller or if current controller has no parent controller,
it could be layout view script full path.
If this method is called outside of rendering process, NULL is returned.
Get currently rendered parent view file directory full path.
Parent view file could be any view file, where is called $this->RenderScript(...);
method to render sub-view file (actual view file) or it could be any view file
from parent controller or if current controller has no parent controller,
it could be layout view script full path.
If this method is called outside of rendering process, NULL is returned.
Returns
string|null
|
public
string
&
|
#
RenderScript( string $relativePath = '' )
Render action template script or any include script and return it's result as reference.
Do not use this method in layout sub-templates, use method RenderLayout() instead.
Render action template script or any include script and return it's result as reference.
Do not use this method in layout sub-templates, use method RenderLayout() instead.
Parameters
Returns
string
|
public
string
&
|
#
RenderLayout( string $relativePath = '' )
Render layout template script or any include script and return it's result as reference.
Do not use this method in action sub-templates, use method RenderScript() instead.
Render layout template script or any include script and return it's result as reference.
Do not use this method in action sub-templates, use method RenderScript() instead.
Parameters
Returns
string
|
public
string
&
|
#
RenderLayoutAndContent( string $relativePath = '', string & $content = NULL )
This method is INTERNAL, always called from \MvcCore\Controller::Render(); .
Do not use this method in templates!
Method renders whole configured layout template and return it's result
as string reference with inner rendered action template content.
This method is INTERNAL, always called from \MvcCore\Controller::Render(); .
Do not use this method in templates!
Method renders whole configured layout template and return it's result
as string reference with inner rendered action template content.
Parameters
- $relativePath
- $relativePatht.
- $content
Returns
string
|
public
string
&
|
#
Render( string $typePath = '', string $relativePath = '' )
Render controller template and all necessary layout
templates and return rendered result as string reference.
Render controller template and all necessary layout
templates and return rendered result as string reference.
Parameters
- $typePath
- By default:
"Layouts" | "Scripts" . It could be "Forms" | "Forms/Fields" etc...
- $relativePath
Returns
string
Throws
InvalidArgumentException Template not found in path: $viewScriptFullPath .
|
public
string
|
#
Evaluate( string $content )
Evaluate given template code as PHP code by eval() in current view
context, any $this keyword will be used as current view context.
Returned result is content from output buffer as string reference.
Evaluated code is wrapped into try/catch automatically.
Evaluate given template code as PHP code by eval() in current view
context, any $this keyword will be used as current view context.
Returned result is content from output buffer as string reference.
Evaluated code is wrapped into try/catch automatically.
Parameters
Returns
string
|
public
string
|
#
Url( string $controllerActionOrRouteName = 'Index:Index', array $params = [] )
Generates url:
- By "Controller:Action" name and params array
(for routes configuration when routes array has keys with "Controller:Action" strings
and routes has not controller name and action name defined inside).
- By route name and params array
(route name is key in routes configuration array, should be any string
but routes must have information about controller name and action name inside).
Result address (url string) should have two forms:
- Nice rewritten URL by routes configuration
(for apps with URL rewrite support (Apache .htaccess or IIS URL rewrite module)
and when first param is key in routes configuration array).
- For all other cases is URL form like: "index.php?controller=ctrlName&action=actionName"
(when first param is not founded in routes configuration array).
Generates url:
- By "Controller:Action" name and params array (for routes configuration when routes array has keys with "Controller:Action" strings and routes has not controller name and action name defined inside).
- By route name and params array (route name is key in routes configuration array, should be any string but routes must have information about controller name and action name inside).
Result address (url string) should have two forms:
- Nice rewritten URL by routes configuration (for apps with URL rewrite support (Apache .htaccess or IIS URL rewrite module) and when first param is key in routes configuration array).
- For all other cases is URL form like: "index.php?controller=ctrlName&action=actionName" (when first param is not founded in routes configuration array).
Parameters
- $controllerActionOrRouteName
- Should be
"Controller:Action" combination or just any route name as custom specific string.
- $params
- Optional, array with params, key is param name, value is param value.
Returns
string
|
public
string
|
#
AssetUrl( string $path = '' )
Return asset path or single file mode URL for small assets
handled by internal controller action "Controller:Asset" .
Example: echo $this->AssetUrl('/static/img/favicon.ico');
Return asset path or single file mode URL for small assets
handled by internal controller action "Controller:Asset" .
Example: echo $this->AssetUrl('/static/img/favicon.ico');
Parameters
Returns
string
|
public
string
|
#
Escape( string $str, boolean $encoding = 'UTF-8', string $encoding,… )
Escape string for use inside HTML/XHTML/HTML5
node as text content.
Escape string for use inside HTML/XHTML/HTML5
node as text content.
Parameters
- $str
- $encoding
- $double
- $encoding,…
Returns
string
|
public
string
|
#
EscapeHtml( string $str, boolean $encoding = 'UTF-8', string $encoding,… )
Escape string for use inside HTML/XHTML/HTML5
node between < and > for attributes definitions.
Escape string for use inside HTML/XHTML/HTML5
node between < and > for attributes definitions.
Parameters
- $str
- $encoding
- $double
- $encoding,…
Returns
string
|
public
string
|
#
EscapeAttr( string $str, boolean $double = TRUE, string $encoding = 'UTF-8' )
Escape string for use inside HTML/XHTML/HTML5 attribute.
Escape string for use inside HTML/XHTML/HTML5 attribute.
Parameters
Returns
string
|
public
string
|
#
EscapeXml( string $str, string $encoding = 'UTF-8' )
Escape string for use inside XML template.
XML 1.0: \x09 \x0A \x0D and C1 allowed directly, C0 forbidden
XML 1.1: \x00 forbidden directly and as a character reference,
\x09 \x0A \x0D \x85 allowed directly, C0, C1 and \x7F allowed as character references
Escape string for use inside XML template.
XML 1.0: \x09 \x0A \x0D and C1 allowed directly, C0 forbidden
XML 1.1: \x00 forbidden directly and as a character reference, \x09 \x0A \x0D \x85 allowed directly, C0, C1 and \x7F allowed as character references
Parameters
Returns
string
|
public
string
|
#
EscapeJs( string $str, integer $flags = 0, integer $depth = 512 )
Escape string for use inside JS context, including trailing double quotes.
Escape string for use inside JS context, including trailing double quotes.
Parameters
Returns
string
|
public
string
|
#
EscapeCss( string $str )
Escape string for use inside CSS context.
Escape string for use inside CSS context.
Parameters
Returns
string
See
http://www.w3.org/TR/2006/WD-CSS21-20060411/syndata.html#q6
|
public
string
|
#
EscapeICal( string $str )
Escape string for use inside iCal template.
Escape string for use inside iCal template.
Parameters
Returns
string
See
https://www.ietf.org/rfc/rfc5545.txt
|
public
mixed
&
|
#
GetHelper( string $helperNameCamelCase, boolean $asClosure = FALSE )
Try to get view helper.
If view helper doesn't exist in global helpers store - create new helper instance.
If helper already exists in global helpers store - do not create it again - use instance from the store.
Example: echo $this->GetHelper('facebook')->RenderSomeSpecialWidgetMethod();
Try to get view helper.
If view helper doesn't exist in global helpers store - create new helper instance.
If helper already exists in global helpers store - do not create it again - use instance from the store.
Example: echo $this->GetHelper('facebook')->RenderSomeSpecialWidgetMethod();
Parameters
- $helperNameCamelCase
- View helper method name in camel case.
- $asClosure
- Get View helper prepared as closure function,
FALSE by default.
Returns
mixed View helper instance, always as \MvcCore\Ext\Views\Helpers\AbstractHelper|\MvcCore\Ext\Views\Helpers\IHelper instance.
Throws
InvalidArgumentException If view doesn't exist in configured namespaces.
|
public
MvcCore\View
|
#
SetHelper( string $helperNameCamelCase, mixed $instance, boolean $forAllTemplates = TRUE )
Set view helper for current template or for all templates globally by default.
If view helper already exist in global helpers store - it's overwritten.
Set view helper for current template or for all templates globally by default.
If view helper already exist in global helpers store - it's overwritten.
Parameters
- $helperNameCamelCase
- View helper method name in camel case.
- $instance
- View helper instance, always as
\MvcCore\Ext\Views\Helpers\AbstractHelper|\MvcCore\Ext\Views\Helpers\IHelper instance or \Closure .
- $forAllTemplates
- register this helper instance for all rendered views in the future.
Returns
|
public
boolean
|
#
__set( string $name, mixed $value )
Set any value into view context internal store.
Set any value into view context internal store.
Parameters
Returns
boolean
|
public
mixed
|
#
__get( string $name )
Get any value by given name existing in local store. If there is no value
in local store by given name, try to get result value into store by
controller reflection class from controller instance property.
Get any value by given name existing in local store. If there is no value
in local store by given name, try to get result value into store by
controller reflection class from controller instance property.
Parameters
Returns
mixed
|
public
boolean
|
#
__isset( string $name )
Get TRUE if any value by given name exists in
local view store or in local controller instance.
Get TRUE if any value by given name exists in
local view store or in local controller instance.
Parameters
Returns
boolean
|
public
|
#
__unset( string $name )
Unset any value from view context internal store.
Unset any value from view context internal store.
Parameters
|
public
string|mixed
|
#
__call( string $method, mixed $arguments )
Try to call view helper.
If view helper doesn't exist in global helpers store - create new helper instance.
If helper already exists in global helpers store - do not create it again - use instance from the store.
Then call it's public method named in the same way as helper and return result
as it is, without any conversion. So then there could be called any other helper method if whole helper instance is returned.
Try to call view helper.
If view helper doesn't exist in global helpers store - create new helper instance.
If helper already exists in global helpers store - do not create it again - use instance from the store.
Then call it's public method named in the same way as helper and return result
as it is, without any conversion. So then there could be called any other helper method if whole helper instance is returned.
Parameters
- $method
- View helper method name in pascal case.
- $arguments
- View helper method arguments.
Returns
string|mixed View helper string result or any other view helper result type or view helper instance, always as \MvcCore\Ext\Views\Helpers\AbstractHelper|\MvcCore\Ext\Views\Helpers\IHelper instance.
Throws
InvalidArgumentException If view doesn't exist in configured namespaces.
|
Magic methods summary
public
MvcCore\Ext\Views\Helpers\CssHelper
|
#
Css( string $groupName = self::GROUP_NAME_DEFAULT )
Get css helper instance by group name. To use this method, you need to install extension mvccore/ext-view-helper-assets .
Get css helper instance by group name. To use this method, you need to install extension mvccore/ext-view-helper-assets .
Parameters
Returns
|
public
MvcCore\Ext\Views\Helpers\JsHelper
|
#
Js( string $groupName = self::GROUP_NAME_DEFAULT )
Get js helper instance by group name. To use this method, you need to install extension mvccore/ext-view-helper-assets .
Get js helper instance by group name. To use this method, you need to install extension mvccore/ext-view-helper-assets .
Parameters
Returns
|
public
string
|
#
FormatDate( DateTime|IntlCalendar|integer $dateTimeOrTimestamp = NULL, integer|string $dateTypeOrFormatMask = NULL, integer $timeType = NULL, string|IntlTimeZone|DateTimeZone $timeZone = NULL, integer $calendar = NULL) Format given date time by `Intl` extension or by `strftime( )
as fallback. To use this method, you need to install extension mvccore/ext-view-helper-formatdatetime`.
as fallback. To use this method, you need to install extension mvccore/ext-view-helper-formatdatetime`.
Parameters
- $dateTimeOrTimestamp
- $dateTypeOrFormatMask
- $timeType
- $timeZone
- $calendar
Returns
string
|
public
string
|
#
FormatNumber( float|integer $number = 0.0, integer $decimals, string $dec_point = NULL, string $thousands_sep = NULL )
To use this method, you need to install extension mvccore/ext-view-helper-formatnumber .
To use this method, you need to install extension mvccore/ext-view-helper-formatnumber .
Parameters
- $number
- $decimals
- $dec_point
- $thousands_sep
Returns
string
|
public
string
|
#
FormatMoney( integer $decimals, string $dec_point = NULL, string $thousands_sep = NULL )
To use this method, you need to install extension mvccore/ext-view-helper-formatmoney .
To use this method, you need to install extension mvccore/ext-view-helper-formatmoney .
Parameters
- $decimals
- $dec_point
- $dec_point
- $thousands_sep
- $thousands_sep
Returns
string
|
public
string
|
#
LineBreaks( string $text, string $lang = '' )
Prevent breaking line inside numbers, after week words, shortcuts, numbers and units and much more, very configurable. To use this method, you need to install extension mvccore/ext-view-helper-linebreaks .
Prevent breaking line inside numbers, after week words, shortcuts, numbers and units and much more, very configurable. To use this method, you need to install extension mvccore/ext-view-helper-linebreaks .
Parameters
Returns
string
|
public
string
|
#
DataUrl( string $relativeOrAbsolutePath )
Return any file content by given relative or absolute path in data URL like data:image/png;base64,iVBOR.. . Path could be relative from currently rendered view, relative from application root or absolute path to file. To use this method, you need to install extension mvccore/ext-view-helper-dataurl .
Return any file content by given relative or absolute path in data URL like data:image/png;base64,iVBOR.. . Path could be relative from currently rendered view, relative from application root or absolute path to file. To use this method, you need to install extension mvccore/ext-view-helper-dataurl .
Parameters
Returns
string
|
public
string
|
#
WriteByJS( )
;. To use this method, you need to install extension mvccore/ext-view-helper-writebyjs`.
;. To use this method, you need to install extension mvccore/ext-view-helper-writebyjs`.
Returns
string
|
public
string
|
#
Truncate( string $text, integer $maxChars = 200, boolean $isHtml = NULL )
Truncate plain text or text with html tags by given max. characters number and add three dots at the end. To use this method, you need to install extension mvccore/ext-view-helper-truncate .
Truncate plain text or text with html tags by given max. characters number and add three dots at the end. To use this method, you need to install extension mvccore/ext-view-helper-truncate .
Parameters
Returns
string
|