本文整理汇总了PHP中Controller::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::getInstance方法的具体用法?PHP Controller::getInstance怎么用?PHP Controller::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_modifier_msg
function smarty_modifier_msg($name)
{
$c =& Controller::getInstance();
$messages = $c->request->getAttribute('messages');
$messages[$name] = str_replace('\\n', "\n", $messages[$name]);
return $messages[$name];
}
示例2: init
/**
* Initialization
*
* Determine error handling configuration ans setup correspondent properties.
*
* This functions wiil be executes one time before first error/eception or never
* if error/exception hasn't occur.
*/
static function init()
{
if (self::$rootDir) {
return;
}
try {
$c = Config::getInstance();
$root_dir = $c->root_dir;
$data_dir = $c->data_dir;
} catch (Exception $e) {
$root_dir = dirname(dirname(__FILE__));
$data_dir = '/data';
}
self::$rootDir = $root_dir;
$textTemplate = $root_dir . $data_dir . '/exceptionTemplate.text.php';
$webTemplate = $root_dir . $data_dir . '/exceptionTemplate.web.php';
// errors will be logged
if (self::iniToBool(ini_get('log_errors'))) {
self::$logTemplate = $textTemplate;
}
// errors wiil be displayed
if (self::iniToBool(ini_get('display_errors'))) {
// in console(CLI) and Ajax we preffered to display errors in plain text
self::$displayTemplate = php_sapi_name() == 'cli' || Controller::getInstance()->isAjax() ? $textTemplate : $webTemplate;
}
}
示例3: smarty_function_widget
/**
* This method will get a module/action or module template result
*
* @param array $params
* @param Smarty $smarty
*/
function smarty_function_widget($params, &$smarty)
{
if (!isset($params['module']) || !isset($params['action']) && !isset($params['template']) || isset($params['action']) && isset($params['template'])) {
throw new SmartyException('{widget} : module and action (or template) parameters must be defined');
}
$args = array();
if (count($params) > 2) {
foreach ($params as $k => $v) {
if ($k !== 'module' && $k !== 'action' && $k !== 'template') {
$args[$k] = $v;
}
}
}
if (isset($params['action'])) {
Controller::getInstance()->setModule($params['module'])->setAction($params['action'])->setArgs(array($args))->dispatch();
} else {
if ($file = get_module_file($params['module'], 'template/' . $params['template'], true)) {
$tpl = Template::getInstance($file);
foreach ($smarty->tpl_vars as $k => $v) {
if ($k !== 'SCRIPT_NAME' && $k !== 'smarty' && !isset($args[$k])) {
$args[$k] = $v->value;
}
}
if (empty($args)) {
return $tpl->get();
}
foreach ($args as $name => $value) {
$tpl->assign($name, $value);
}
return $tpl->get();
}
}
}
示例4: getItems
/**
* @return array<list_Item>
*/
public final function getItems()
{
$request = Controller::getInstance()->getContext()->getRequest();
$form = null;
$conditionOn = null;
try {
$conditionOnId = intval($request->getParameter('documentId', 0));
if ($conditionOnId > 0) {
$conditionOn = DocumentHelper::getDocumentInstance($conditionOnId);
$form = $conditionOn->getForm();
} else {
$parent = DocumentHelper::getDocumentInstance(intval($request->getParameter('parentId', 0)));
if ($parent instanceof form_persistentdocument_baseform) {
$form = $parent;
} else {
if ($parent instanceof form_persistentdocument_group) {
$form = $parent->getForm();
}
}
}
} catch (Exception $e) {
Framework::exception($e);
}
if (!$form instanceof form_persistentdocument_baseform) {
return array();
}
$results = array();
$excludeIds = $this->getExcludeIds($conditionOn);
foreach ($form->getDocumentService()->getValidActivationFields($form, $excludeIds) as $field) {
$results[] = new list_Item($field->getLabel(), $field->getId());
}
return $results;
}
示例5: getItems
/**
* @return array<list_Item>
*/
public final function getItems()
{
try {
$request = Controller::getInstance()->getContext()->getRequest();
$questionId = intval($request->getParameter('questionId', 0));
$question = DocumentHelper::getDocumentInstance($questionId);
} catch (Exception $e) {
if (Framework::isDebugEnabled()) {
Framework::debug(__METHOD__ . ' EXCEPTION: ' . $e->getMessage());
}
return array();
}
// Here we must use instanceof and not getDocumentModelName to work with injection.
$results = array();
if ($question instanceof form_persistentdocument_boolean) {
$trueLabel = $question->getTruelabel();
$falseLabel = $question->getFalselabel();
$results[$trueLabel] = new list_Item($trueLabel, $trueLabel);
$results[$falseLabel] = new list_Item($falseLabel, $falseLabel);
} else {
if ($question instanceof form_persistentdocument_list) {
$results = $question->getDataSource()->getItems();
}
}
return $results;
}
示例6: findPage
public static function findPage(Controller $oController)
{
if (self::$currentPageID > 0) {
return;
}
if ($oController->indexPage()) {
$oPage = new Page();
if ($oPage->loadIndexPage()) {
if (Controller::getInstance()->controllerExists($oPage["Link"])) {
$oController->route[self::$level] = $oPage["Link"];
}
self::$level = 1;
self::$page = $oPage;
self::$currentPageID = $oPage->PageID;
}
} else {
$db = MySQL::getInstance();
$db->query("SELECT PageID, StaticPath, Level, LeftKey, RightKey, Link\n\t\t\t\tFROM `page` WHERE\n\t\t\t\t\tWebsiteID = " . $db->escape(WEBSITE_ID) . "\n\t\t\t\t\tAND StaticPath IN (" . implode(", ", $db->escape($oController->route)) . ")\n\t\t\t\t\tAND LanguageCode = " . $db->escape(LANG) . "\n\t\t\t\t\tAND Level > 1\n\t\t\t\tORDER BY LeftKey");
self::$level = 0;
$moduleFound = false;
$currentPageID = null;
while ($row = $db->fetchRow()) {
if ($row["StaticPath"] == $oController->route[0] && $row["Level"] == 2) {
$currentPageID = $row["PageID"];
self::$currentLeftKey = $row["LeftKey"];
self::$currentRightKey = $row["RightKey"];
if ($moduleFound = Controller::getInstance()->controllerExists($row["Link"])) {
$oController->route[0] = $row["Link"];
break;
}
self::$level++;
continue;
}
if (!is_null($currentPageID) && count($oController->route) > self::$level) {
if ($row["StaticPath"] == $oController->route[self::$level] && $row["LeftKey"] > self::$currentLeftKey && $row["RightKey"] < self::$currentRightKey) {
$currentPageID = $row["PageID"];
self::$currentLeftKey = $row["LeftKey"];
self::$currentRightKey = $row["RightKey"];
if ($moduleFound = Controller::getInstance()->controllerExists($row["Link"])) {
$oController->route[self::$level] = $row["Link"];
break;
}
self::$level++;
}
}
}
if (self::$level == count($oController->route) || $moduleFound != false) {
$oPage = new Page();
if ($oPage->loadByID($currentPageID)) {
self::$page = $oPage;
self::$currentPageID = $oPage->PageID;
}
}
}
for ($i = 0; $i < self::$level; $i++) {
array_shift($oController->route);
}
}
示例7: smarty_function_mojavi_error
function smarty_function_mojavi_error($params, &$smarty)
{
$controller =& Controller::getInstance();
$request =& $controller->request;
if ($request->hasError($params['name'])) {
return $request->getError($params['name']);
}
return null;
}
示例8: generateCache
/**
* Generate a new cache file from the buffer of the controller.
* @return string
*/
private function generateCache()
{
$instance =& Controller::getInstance();
$size = file_put_contents($this->_cachefile, $instance->buffer);
if ($size > 0) {
return file_get_contents($this->_cachefile);
} else {
die("Error writing to cache file.");
}
}
示例9: buildComplete
/**
* Method description
*
* More detailed method description
* @param void
* @return void
*/
function buildComplete()
{
if (!isset($this->tpl)) {
$this->tpl = $this->createTemplate();
}
$controller = Controller::getInstance();
$controller->addScript("colorpicker.js");
$controller->addCSS("colorpicker.css");
parent::buildComplete();
}
示例10: buildComplete
/**
* Method description
*
* More detailed method description
* @param void
* @return void
*/
function buildComplete()
{
if (!isset($this->tpl)) {
$this->tpl = $this->createTemplate();
}
$this->setHREF(Controller::getInstance()->getNavigator()->getStepURL(-1));
if ($this->items->isEmpty()) {
$this->items->setText(Language::message('widgets', 'back_link'));
}
parent::buildComplete();
}
示例11: buildComplete
/**
* Method description
*
* More detailed method description
* @param void
* @return void
*/
function buildComplete()
{
if (!isset($this->tpl)) {
$this->tpl = $this->createTemplate();
}
$controller = Controller::getInstance();
$controller->addScript("jquery.ui.js");
$controller->addCSS("jquery-ui.css");
$this->tabs->filter("WTab");
parent::buildComplete();
}
示例12: __construct
/**
* Creating instance and initializing class properties.
* Trying to restore steps saved in persistent storage.
* @param null
* @return null
*/
function __construct()
{
$this->storage = Storage::createWithSession('AdminNavigator' . Controller::getInstance()->getStoragePostfix());
$this->controller_name = Controller::getInstance()->getControllerName();
if (empty($this->controller_name)) {
$this->controller_name = "index";
}
$this->user_path = $this->storage->get("user_path");
if (empty($this->user_path) || $this->user_path === false) {
$this->user_path = array();
}
}
示例13: buildComplete
/**
* Method description
*
* More detailed method description
* @param void
* @return void
*/
function buildComplete()
{
if (!isset($this->tpl)) {
$this->tpl = $this->createTemplate();
}
$controller = Controller::getInstance();
$controller->addScript("jquery.ui.js");
$controller->addScript("jquery.markitup_set.js");
$controller->addScript("jquery.markitup.js");
$controller->addCSS("jquery-ui.css");
$controller->addCSS("jquery.markitup_main.css");
$controller->addCSS("jquery.markitup_markdown.css");
parent::buildComplete();
}
示例14: findDefault
/**
* Tries to find default data, composing it to the
* {@link WidgetResultSet} and injecting this result set
* to the data-setter method of particular widget, specified
* by widget_id parameter.
*
* If no data was found, empty {@link WidgetResultSet}
* will be passed to widget.
*
* @param string id of the widget for which to make a lookup
* @return WidgetResultSet with default data
*/
static function findDefault($widget_id)
{
$wrs = new WidgetResultSet();
if (($widget = Controller::getInstance()->getWidget($widget_id)) === null) {
return $wrs;
}
if (($data_setter = $widget->getDataSetterMethod()) === null || $widget instanceof iNotSelectable) {
return $wrs;
}
foreach (self::$pool as $v) {
$d_o = $v['data_object'];
if (($def = $d_o->getData($widget_id)) !== null && !$def instanceof WidgetResultSet) {
$wrs->setDef($def);
}
}
$widget->{$data_setter}($wrs);
}
示例15: SmartyRenderer
function &getSmartyRenderer()
{
global $messages;
$controller =& Controller::getInstance();
$request =& $controller->request;
$user =& $controller->user;
$renderer =& new SmartyRenderer($controller, $request, $user);
$smarty =& $renderer->getEngine();
$smarty->cache_dir = SMARTY_CACHE_DIR;
$smarty->caching = SMARTY_CACHING;
$smarty->force_compile = SMARTY_FORCE_COMPILE;
$smarty->compile_dir = SMARTY_COMPILE_DIR;
$smarty->config_dir = $controller->getModuleDir() . 'config/';
$smarty->debugging = SMARTY_DEBUGGING;
$smarty->compile_id = $controller->currentModule . '_' . $controller->currentAction;
$smarty->register_function('mojavi_url', 'smarty_function_mojavi_url');
$smarty->register_function('mojavi_action', 'smarty_function_mojavi_action');
$smarty->register_function('mojavi_error', 'smarty_function_mojavi_error');
$smarty->register_function('css_link_tag', 'smarty_function_css_link_tag');
$smarty->register_function('js_link_tag', 'smarty_function_js_link_tag');
$smarty->register_function('to_json', 'smarty_function_to_json');
$smarty->register_function('html_select_date_simple', 'smarty_function_html_select_date_simple');
$smarty->register_modifier('format_price', 'smarty_modifier_format_price');
$smarty->register_modifier('mb_truncate', 'smarty_modifier_mb_truncate');
$smarty->register_modifier('tofavicon', 'smarty_modifier_tofavicon');
$smarty->register_modifier('date_RFC822', 'smarty_modifier_date_RFC822');
$smarty->register_modifier('date_W3C', 'smarty_modifier_date_W3C');
$smarty->register_modifier('msg', 'smarty_modifier_msg');
if ($user->isAuthenticated() && $user->hasAttribute('member', GLU_NS)) {
$smarty->assign('member', $user->getAttribute('member', GLU_NS));
}
$smarty->assign($_SERVER);
$smarty->assign('params', $request->getParameters());
$smarty->assign('errors', $request->getErrors());
$smarty->assign('module', $controller->requestModule);
$smarty->assign('action', $controller->requestAction);
$smarty->assign(array('webmod' => WEB_MODULE_DIR, 'curmod' => WEB_MODULE_DIR . $controller->currentModule . '/', 'SCRIPT_PATH' => SCRIPT_PATH, 'PLNET_CUSTOM_TEMPLATE_ID' => PLNET_CUSTOM_TEMPLATE_ID));
$smarty->assign('shared_dir', BASE_DIR . 'templates');
$smarty->assign($request->getAttributes());
return $renderer;
}