本文整理汇总了PHP中pradoGetApplication函数的典型用法代码示例。如果您正苦于以下问题:PHP pradoGetApplication函数的具体用法?PHP pradoGetApplication怎么用?PHP pradoGetApplication使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pradoGetApplication函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor.
* Reads the configuration given in the app spec.
* In particular, the attribute 'enabled' and 'path' are read.
* @param mixed the configuration.
*/
function __construct($config)
{
if (isset($config['enabled']) && (string) $config['enabled'] == 'true') {
$this->enabled = true;
} else {
$this->enabled = false;
}
if (empty($config['path'])) {
$this->rootPath = null;
} else {
$this->rootPath = realpath(pradoGetContextPath((string) $config['path'], dirname(pradoGetApplication()->getSpecificationFile())));
if ($this->rootPath === false || !is_dir($this->rootPath)) {
throw new Exception("Unable to locate the cache path '{$this->rootPath}'.");
}
}
$this->savePath = $this->rootPath;
}
示例2: assess
function assess($parameters, $pageDefinition)
{
if (isset($parameters['Master'])) {
$pageDefinition->setMasterPageName($parameters['Master']);
}
$app = pradoGetApplication()->getGlobalization();
if (empty($app)) {
return;
}
if (isset($parameters['Culture'])) {
$app->Culture = $parameters['Culture'];
}
if (isset($parameters['Charset'])) {
$app->Charset = $parameters['Charset'];
}
if (isset($parameters['ContentType'])) {
$app->ContentType = $parameters['ContentType'];
}
if (isset($parameters['Catalogue'])) {
$app->Translation['catalogue'] = $parameters['Catalogue'];
}
}
示例3: saveMessages
/**
* Save untranslated messages to the catalogue.
*/
public static function saveMessages()
{
static $onceonly = true;
if (!is_null(self::$formatter)) {
if ($onceonly) {
$app = pradoGetApplication()->getGlobalization();
if (isset($app->Translation['autosave'])) {
$catalogue = null;
if (isset($app->Translation['catalogue'])) {
$catalogue = $app->Translation['catalogue'];
}
$auto = $app->Translation['autosave'];
if ($auto == 'true') {
self::$formatter->getSource()->save($catalogue);
} else {
self::$formatter->getSource()->setCulture($app->getDefaultCulture());
self::$formatter->getSource()->save($auto);
}
}
}
$onceonly = false;
}
}
示例4: dirname
<?php
require_once dirname(__FILE__) . '/../framework/prado.php';
pradoGetApplication('multiform/application.spec')->run();
示例5: using
/**
* Adds an include search path.
*
* A namespace is a dot-connected paths. The first segment of the string
* refers to a path alias that is defined in the application specification.
* The rest segments represent the subdirectories in order.
* For example, 'System.Web.UI' refers to the 'Web/UI' directory under the
* framework directory.
*
* If the namespace represents a path, it will be inserted
* at the front of the current include search path.
*
* If the namespace represents a file (without the extension),
* it will be included (require_once) at the position of calling this function.
*
* Do not call this function before the application singleton is created.
*
* @param string the namespace string
*/
function using($namespace)
{
global $pradoNamespaces;
if (isset($pradoNamespaces[$namespace])) {
return;
}
$path = pradoGetApplication()->translatePathAlias($namespace);
if (is_null($path)) {
throw new TPathAliasNotDefinedException($namespace);
} else {
if (is_dir($path)) {
$pradoNamespaces[$namespace] = $path;
} else {
if (is_file($path . PRADO_EXT_CLASS)) {
$pradoNamespaces[$namespace] = $path . PRADO_EXT_CLASS;
require_once $path . PRADO_EXT_CLASS;
} else {
throw new TNamespaceInvalidException($namespace);
}
}
}
}
示例6: onAuthenticationRequired
public function onAuthenticationRequired($pageName)
{
$this->setRedirectUrl($_SERVER['REQUEST_URI']);
pradoGetApplication()->transfer('User:LoginPage');
}
示例7: die
<?php
if (!extension_loaded('sqlite')) {
die('Sorry, the php sqlite module is required for this example to work.');
}
require_once dirname(__FILE__) . '/../framework/prado.php';
pradoGetApplication('mytest/application.spec')->run();
示例8: onPreInit
protected function onPreInit($param)
{
if (!strlen($this->masterPageName)) {
$this->masterPageName = $this->getDefinition(get_class($this))->getMasterPageName();
}
if (strlen($this->masterPageName)) {
$this->masterPage = pradoGetApplication()->loadPage($this->masterPageName);
$this->masterPage->onPreInit($param);
}
}
示例9: preprocessTemplate
/**
* Preprocesses a template string by inserting external templates (recursively).
* @param string the template string to be preprocessed
* @return string the processed result
*/
protected function preprocessTemplate($str)
{
if ($n = preg_match_all('/<%include(.*?)%>/', $str, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
$base = 0;
for ($i = 0; $i < $n; ++$i) {
$pathAlias = trim($matches[$i][1][0]);
$ext = $this->preprocessTemplate(pradoGetApplication()->getResourceLocator()->getExternalTemplate($pathAlias));
$length = strlen($matches[$i][0][0]);
$offset = $base + $matches[$i][0][1];
$str = substr_replace($str, $ext, $offset, $length);
$base += strlen($ext) - $length;
}
}
return $str;
}
示例10: getKey
protected function getKey()
{
$key = '';
if (strlen($this->key)) {
$key = $this->key;
} else {
$key = pradoGetApplication()->getApplicationID();
}
return $key;
}
示例11: getExternalTemplate
/**
* Gets the content of an external template.
* @param string the path alias to the external template.
* @return string the external template content
* @throw TTemplateNotExistsException
*/
public function getExternalTemplate($pathAlias)
{
$fname = pradoGetApplication()->translatePathAlias($pathAlias, self::EXT_TEMPLATE);
if (is_null($fname) || !is_file($fname)) {
throw new TTemplateNotExistsException($pathAlias);
} else {
return file_get_contents($fname);
}
}
示例12: instantiateTemplate
/**
* Instantiates a template for a component.
* Components declared in the template will be instantiated
* and added as children of the component. The container-containee
* relationship will also be established.
* @param TComponent the owner of the template
* @param array the parsing result returned by TResourceParser.
*/
public function instantiateTemplate($component, $template)
{
$application = pradoGetApplication();
if (is_string($template)) {
$template = $application->getResourceParser()->parseTemplate($template);
}
$components = array();
foreach ($template as $key => $object) {
//special directives
if ((string) $object[0] === 'directive') {
$directiveClass = 'T' . $object[1] . 'Directive';
$directive = new $directiveClass();
$directive->assess($object[2], $this);
} else {
if (count($object) > 2) {
// component
list($cid, $type, $id, $attributes) = $object;
$child = $application->createComponent($type, $id);
$childSpec = TComponent::getDefinition($type);
foreach ($attributes as $name => $value) {
if ($childSpec->canSetProperty($name)) {
if (strlen($value) > 1 && $value[0] === '#') {
if ($value[1] !== '#') {
$child->bindProperty($name, substr($value, 1));
} else {
$child->setPropertyInitValue($name, substr($value, 1));
}
} else {
$child->setPropertyInitValue($name, $value);
}
} else {
if ($childSpec->hasEvent($name)) {
$child->attachEventHandler($name, $value);
} else {
$child->setAttribute($name, $value);
}
}
}
if ($child instanceof TControl) {
$child->initSkin($child->getPropertyInitValue("Skin"));
}
$child->initProperties();
$components[$key] = $child;
$container = isset($components[$cid]) ? $components[$cid] : $component;
$container->addParsedObject($child, $component);
} else {
// static text
$cid = (string) $object[0];
$container = isset($components[$cid]) ? $components[$cid] : $component;
$container->addParsedObject($object[1], $component);
}
}
}
}
示例13: onDataBinding
/**
* Parses and intantiates templates.
* This method is invoked when <b>OnDataBinding</b> event is raised.
* It parses and instantiates all assoicated templates for the
* repeater control and raises related events.
* This method should only used by control developers.
* @param TEventParameter event parameter
*/
protected function onDataBinding($param)
{
parent::onDataBinding($param);
$this->setViewState('Items', null, null);
$this->removeChildren();
$this->removeBodies();
$this->items = array();
$this->itemCount = 0;
$this->header = null;
$this->footer = null;
$showEmpty = count($this->dataSource) <= 0 && strlen($this->emptyTemplate);
if (is_null($this->dataSource)) {
return;
}
if (strlen($this->headerTemplate) && !$showEmpty) {
$header = pradoGetApplication()->createComponent('TRepeaterItem', self::ID_HEADER);
$header->setType(TRepeaterItem::TYPE_HEADER);
$header->instantiateTemplate($this->headerTemplate);
$this->header = $header;
$this->addChild($header);
$this->addBody($header);
$p = new TRepeaterItemEventParameter();
$p->item = $header;
$this->onItemCreated($p);
}
$count = 0;
//when the datasource is empty
if ($showEmpty) {
$empty = pradoGetApplication()->createComponent('TRepeaterItem', self::ID_EMPTY);
$empty->setType(TRepeaterItem::TYPE_EMPTY);
$empty->instantiateTemplate($this->emptyTemplate);
$this->addChild($empty);
$this->addBody($empty);
$p = new TRepeaterItemEventParameter();
$p->item = $empty;
$this->onItemCreated($p);
}
foreach ($this->dataSource as $key => $value) {
if ($this->itemCount > 0 && strlen($this->separatorTemplate)) {
$separator = pradoGetApplication()->createComponent('TRepeaterItem');
$separator->setType(TRepeaterItem::TYPE_SEPARATOR);
$separator->instantiateTemplate($this->separatorTemplate);
$separator->setID(self::ID_SEPARATOR . "{$count}");
$this->addChild($separator);
$this->addBody($separator);
$p = new TRepeaterItemEventParameter();
$p->item = $separator;
$this->onItemCreated($p);
}
$item = null;
if ($count % 2 == 1 && strlen($this->alternatingItemTemplate)) {
$item = pradoGetApplication()->createComponent('TRepeaterItem');
$item->instantiateTemplate($this->alternatingItemTemplate);
} else {
if (strlen($this->itemTemplate)) {
$item = pradoGetApplication()->createComponent('TRepeaterItem');
$item->instantiateTemplate($this->itemTemplate);
}
}
if (!is_null($item)) {
$item->setID(self::ID_ITEM . "{$count}");
$item->setIndex($key);
$item->setItemIndex($count);
$item->setData($value);
$this->addChild($item);
$this->addBody($item);
$this->items[$this->itemCount] = $item;
$this->itemCount++;
$p = new TRepeaterItemEventParameter();
$p->item = $item;
$this->onItemCreated($p);
}
$count++;
}
if (strlen($this->footerTemplate) && !$showEmpty) {
$footer = pradoGetApplication()->createComponent('TRepeaterItem', self::ID_FOOTER);
$footer->setType(TRepeaterItem::TYPE_FOOTER);
$footer->instantiateTemplate($this->footerTemplate);
$this->footer = $footer;
$this->addChild($footer);
$this->addBody($footer);
$p = new TRepeaterItemEventParameter();
$p->item = $footer;
$this->onItemCreated($p);
}
}
示例14: logout
/**
* Sets authentication false for the user.
* Default implementation will destroy all session data related to the user visit.
* Derived classes may override this method to provide special treatment.
*/
public function logout()
{
$this->setAuthenticated(false);
$this->setUsername('');
$session = pradoGetApplication()->getSession();
$session->destroy();
}
示例15: pradoGetApplication
<?php
require_once '../framework/prado.php';
pradoGetApplication('web/application.spec')->run();