本文整理匯總了PHP中ViewManager::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP ViewManager::getInstance方法的具體用法?PHP ViewManager::getInstance怎麽用?PHP ViewManager::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ViewManager
的用法示例。
在下文中一共展示了ViewManager::getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
public function __construct()
{
$this->view = ViewManager::getInstance();
// get the current user and put it to the view
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
if (isset($_SESSION["currentuser"])) {
$this->currentUser = new User(NULL, $_SESSION["currentuser"]);
//add current user to the view, since some views require it
$usermapper = new UserMapper();
$this->tipo = $usermapper->buscarPorLogin($_SESSION["currentuser"]);
/* print_r($this->tipo);
die();*/
$this->view->setVariable("tipo", $this->tipo);
$this->view->setVariable("currentusername", $this->currentUser->getLogin());
}
if (isset($_SESSION["currentcod1"]) && isset($_SESSION["currentcod2"]) && isset($_SESSION["currentcod3"])) {
$codigomapper1 = new CodigoMapper();
$this->currentCod1 = $codigomapper1->buscarPinchoPorCodigo($_SESSION["currentcod1"]);
$codigomapper2 = new CodigoMapper();
$this->currentCod2 = $codigomapper2->buscarPinchoPorCodigo($_SESSION["currentcod2"]);
$codigomapper3 = new CodigoMapper();
$this->currentCod3 = $codigomapper3->buscarPinchoPorCodigo($_SESSION["currentcod3"]);
}
}
示例2: handleAdminOverview
/**
* handle admin overview request
*/
private function handleAdminOverview()
{
$view = ViewManager::getInstance();
$log = Logger::getInstance();
$logfile = $log->getLogFile();
if ($view->isType(self::VIEW_FILE)) {
$request = Request::getInstance();
$extension = ".log";
$filename = $request->getDomain() . $extension;
header("Content-type: application/{$extension}");
header("Content-Length: " . filesize($logfile));
// stupid bastards of microsnob: ie does not like attachment option
$browser = $request->getValue('HTTP_USER_AGENT', Request::SERVER);
if (strstr($browser, 'MSIE')) {
header("Content-Disposition: filename=\"{$filename}\"");
} else {
header("Content-Disposition: attachment; filename=\"{$filename}\"");
}
readfile($logfile);
exit;
} else {
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$template->setVariable('logfile', nl2br(file_get_contents($logfile)), false);
$url = new Url(true);
$url->setParameter($view->getUrlId(), self::VIEW_FILE);
$template->setVariable('href_export', $url->getUrl(true), false);
$this->template[$this->director->theme->getConfig()->main_tag] = $template;
}
}
示例3: __construct
public function __construct()
{
$this->view = ViewManager::getInstance();
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
if (isset($_SESSION["currentuser"])) {
$this->currentUser = $_SESSION["currentuser"];
$this->view->setVariable("currentusername", $this->currentUser);
}
}
示例4: handleHttpGetRequest
/**
* Handles data coming from a get request
* @param array HTTP request
*/
public function handleHttpGetRequest()
{
$viewManager = ViewManager::getInstance();
if ($viewManager->isType(ViewManager::OVERVIEW) && $this->director->isAdminSection()) {
$viewManager->setType(ViewManager::ADMIN_OVERVIEW);
}
switch ($viewManager->getType()) {
default:
$this->handleAdminOverviewGet();
break;
}
}
示例5: __construct
public function __construct()
{
$this->view = ViewManager::getInstance();
// get the current user and put it to the view
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
if (isset($_SESSION["currentuser"])) {
$this->currentUser = new User($_SESSION["currentuser"]);
//add current user to the view, since some views require it
$this->view->setVariable("currentusername", $this->currentUser->getUsername());
}
}
示例6: __construct
public function __construct()
{
$this->view = ViewManager::getInstance();
// get the current user and put it to the view
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
//inicializa la variable
$this->friendDAO = new FriendDAO();
if (isset($_SESSION["currentuser"])) {
//En la sesion de currentuser se encuentra todo el usuario
//ya que al hacer el login se introdujo todo el usuario en la sesion
$this->currentUser = $_SESSION["currentuser"];
$this->view->setVariable("currentusername", $this->currentUser);
//consigue el numero total de solicitudes de amistad
$numSolicitudes = $this->friendDAO->getNumSolicitudes($this->currentUser->getEmail());
//Carga el num solicitudes en la vista
$this->view->setVariable("numSolicitudes", $numSolicitudes);
}
}
示例7: handleDeleteGet
/**
* handle tree delete
*/
private function handleDeleteGet()
{
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$request = Request::getInstance();
$view = ViewManager::getInstance();
$view->setType(self::VIEW_DELETE);
if (!$request->exists('ip')) {
throw new Exception('id is missing.');
}
$ip = $request->getValue('ip');
$template->setVariable('ip', $ip);
$template->setVariable($this->getDetail(array('ip' => $ip)));
$this->director->theme->handleAdminLinks($template);
$this->template[$this->director->theme->getConfig()->main_tag] = $template;
}
示例8: handleTreeEditGet
/**
* handle tree edit
*/
private function handleTreeEditGet($retrieveFields = true)
{
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$request = Request::getInstance();
$view = ViewManager::getInstance();
$view->setType(ViewManager::TREE_EDIT);
if (!$request->exists('tree_id')) {
throw new Exception('Node ontbreekt.');
}
if (!$request->exists('tag')) {
throw new Exception('Tag ontbreekt.');
}
$tree_id = intval($request->getValue('tree_id'));
$tag = $request->getValue('tag');
$key = array('tree_id' => $tree_id, 'tag' => $tag);
$fields = array();
if ($retrieveFields) {
$fields = $this->exists($key) ? $this->getDetail($key) : $this->getFields(SqlParser::MOD_INSERT);
} else {
$fields = $this->getFields(SqlParser::MOD_UPDATE);
}
// get all tree nodes which have plugin modules
$site = new SystemSite();
$tree = $site->getTree();
$treelist = $tree->getList($tree_id);
foreach ($treelist as &$item) {
$item['name'] = $tree->toString($item['id'], '/', 'name');
}
$template->setVariable('cbo_tree_id', Utils::getHtmlCombo($treelist, $fields['ref_tree_id']));
$this->setFields($fields);
$template->setVariable($this->getFields(SqlParser::MOD_UPDATE), NULL, false);
$template->setVariable('tree_id', $tree_id, false);
$template->setVariable('tag', $tag, false);
$this->template[$this->director->theme->getConfig()->main_tag] = $template;
}
示例9: save
public function save($content, $postfix = '')
{
// only save if caching is enabled in config file
if (!$this->isCacheEnabled()) {
return;
}
$view = ViewManager::getInstance();
$url = md5($this->url . $postfix . $view->getType());
$filename = $this->path . $url;
if (!($fh = fopen($filename, "w"))) {
throw new Exception("could not open file {$filename} for writing. in " . __CLASS__ . " " . __FUNCTION__);
}
fputs($fh, $content);
fclose($fh);
chmod($filename, 0644);
return $filename;
}
示例10: handleConfGet
/**
* handle conf
*/
private function handleConfGet($retrieveFields = true)
{
viewManager::getInstance()->setType(ViewManager::CONF_EDIT);
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$template->setVariable('pageTitle', $this->description);
$request = Request::getInstance();
$view = ViewManager::getInstance();
$detail = $this->getDetail(array());
$fields = array();
if ($retrieveFields) {
$fields = $this->exists(array()) ? $detail : $this->getFields(SqlParser::MOD_INSERT);
} else {
$fields = $this->getFields(SqlParser::MOD_UPDATE);
}
$template->setVariable('cbo_display', Utils::getHtmlCombo(self::getDisplayTypeList(), $fields['display']));
$this->setFields($fields);
$template->setVariable($this->getFields(SqlParser::MOD_UPDATE));
$template->setVariable('id', $detail ? $detail['id'] : '');
$this->template[$this->director->theme->getConfig()->main_tag] = $template;
}
示例11: handleAdminDeleteGet
/**
* handle delete
*/
private function handleAdminDeleteGet()
{
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$request = Request::getInstance();
if (!$request->exists('id')) {
throw new Exception('Gebruikersgroep ontbreekt.');
}
$id = intval($request->getValue('id'));
$template->setVariable('id', $id, false);
$template->setVariable('name', $this->getName(array('id' => $id)), false);
$view = ViewManager::getInstance();
$url = new Url(true);
$url->setParameter($view->getUrlId(), ViewManager::ADMIN_OVERVIEW);
$template->setVariable('href_back', $url->getUrl(true), false);
$this->template[$this->director->theme->getConfig()->main_tag] = $template;
}
示例12: handleAdminSubLinks
/**
* handle navigation for sub classes / pages
*/
public function handleAdminSubLinks($keyName, $title, $addBreadcrumb = false)
{
$request = Request::getInstance();
$view = ViewManager::getInstance();
$template = new TemplateEngine();
if (!$request->exists('nl_id')) {
return;
}
$nl_id = $request->getValue('nl_id');
$newsLetterName = $this->getName(array('id' => $nl_id));
$template->setVariable('pageTitle', $newsLetterName, false);
$tree_id = $request->getValue('tree_id');
$tag = $request->getValue('tag');
$template->setVariable('tree_id', $tree_id, false);
$template->setVariable('tag', $tag, false);
$template->setVariable('nl_id', $nl_id, false);
if (!$addBreadcrumb) {
return;
}
$url = new Url(true);
$url->setParameter('tree_id', $tree_id);
$url->setParameter('tag', $tag);
$url->setParameter('id', $nl_id);
$url->setParameter($view->getUrlId(), ViewManager::TREE_EDIT);
$breadcrumb = array('name' => $newsLetterName, 'path' => $url->getUrl(true));
$this->addBreadcrumb($breadcrumb);
}
示例13: handleTreeEditGet
/**
* handle tree edit
*/
private function handleTreeEditGet($retrieveFields = true)
{
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$request = Request::getInstance();
$view = ViewManager::getInstance();
$view->setType(ViewManager::TREE_EDIT);
if (!$request->exists('tree_id')) {
throw new Exception('Node ontbreekt.');
}
if (!$request->exists('tag')) {
throw new Exception('Tag ontbreekt.');
}
$tree_id = intval($request->getValue('tree_id'));
$tag = $request->getValue('tag');
$key = array('tree_id' => $tree_id, 'tag' => $tag);
$fields = array();
if ($retrieveFields) {
if ($this->exists($key)) {
$fields = $this->getDetail($key);
$fields['online'] = $fields['online'] ? strftime('%Y-%m-%d', $fields['online']) : '';
$fields['offline'] = $fields['offline'] ? strftime('%Y-%m-%d', $fields['offline']) : '';
} else {
$fields = $this->getFields(SqlParser::MOD_INSERT);
}
} else {
$fields = $this->getFields(SqlParser::MOD_UPDATE);
}
// get all tree nodes which have plugin modules
$sitePlugin = $this->director->siteManager->systemSite->getSitePlugin();
$tree = $this->plugin->getReferer()->getTree();
$searchcriteria = array('classname' => 'Attachment', 'plugin_type' => Attachment::TYPE_DEFAULT);
$treeplugin = $sitePlugin->getList($searchcriteria);
$treelist = array();
foreach ($treeplugin['data'] as $item) {
if (!$tree->exists($item['tree_id'])) {
continue;
}
$treelist[] = array('id' => $item['tree_id'], 'name' => $tree->toString($item['tree_id'], '/', 'name'));
}
// get all selected tree node connections
$treeRef = new AttachmentTreeRef();
$treeRefTmp = $treeRef->getList($key);
$treeRefLink = array();
foreach ($treeRefTmp['data'] as $item) {
$treeRefLink[] = $item['ref_tree_id'];
}
$template->setVariable('ref_tree_id', Utils::getHtmlCheckbox($treelist, $treeRefLink, 'ref_tree_id', '<br />'));
$datefields = array();
$datefields[] = array('dateField' => 'online', 'triggerElement' => 'online');
$datefields[] = array('dateField' => 'offline', 'triggerElement' => 'offline');
Utils::getDatePicker($this->director->theme, $datefields);
$this->setFields($fields);
$template->setVariable($fields, NULL, false);
$template->setVariable('tree_id', $tree_id, false);
$template->setVariable('tag', $tag, false);
$this->template[$this->director->theme->getConfig()->main_tag] = $template;
}
示例14: handleExtensionPost
private function handleExtensionPost()
{
$request = Request::getInstance();
$template = new TemplateEngine();
$view = ViewManager::getInstance();
$this->renderExtension = true;
if (!$request->exists('ext_id')) {
throw new Exception('Extension ontbreekt.');
}
$id = intval($request->getValue('ext_id'));
$template->setVariable('ext_id', $id, false);
$url = new Url(true);
$url_back = clone $url;
$url_back->setParameter($view->getUrlId(), ViewManager::ADMIN_OVERVIEW);
$url_back->clearParameter('ext_id');
$extension = $this->director->extensionManager->getExtensionFromId(array('id' => $id));
$extension->setReferer($this);
$this->director->theme->handleAdminLinks($template, $this->getName(array('id' => $id)), $url_detail);
$extension->handleHttpPostRequest();
}
示例15: handleConfigGet
/**
* handle config
*/
private function handleConfigGet($retrieveFields = true)
{
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$request = Request::getInstance();
if (!$request->exists('id')) {
throw new Exception('Thema ontbreekt.');
}
$id = intval($request->getValue('id'));
$template->setVariable('id', $id, false);
$key = array('id' => $id);
$themedetail = $this->getDetail($key);
$theme = $this->director->themeManager->getThemeFromId($key);
if ($retrieveFields) {
$fileTpl = file_get_contents($theme->getTemplateFile());
$fileIni = file_get_contents($theme->getConfigFile());
$fileCss = file_get_contents($theme->getStyleSheetFile());
} else {
$fileTpl = $request->getValue('file_tpl');
$fileIni = $request->getValue('file_ini');
$fileCss = $request->getValue('file_css');
}
$template->setVariable('file_tpl', $fileTpl, false);
$template->setVariable('file_ini', $fileIni, false);
$template->setVariable('file_css', $fileCss, false);
$theme = $this->director->theme;
$theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/editarea/edit_area/edit_area_full.js"></script>');
$theme->addHeader('<script type="text/javascript">
editAreaLoader.init({ id: "area1",
start_highlight: true,
allow_toggle: true,
allow_resize: true,
language: "en",
syntax: "php",
syntax_selection_allow: "css,html,js,php",
});
editAreaLoader.init({ id: "area2",
start_highlight: true,
allow_toggle: true,
allow_resize: true,
language: "en",
syntax: "html",
syntax_selection_allow: "css,html,js,php",
});
editAreaLoader.init({ id: "area3",
start_highlight: true,
allow_toggle: true,
allow_resize: true,
language: "en",
syntax: "css",
syntax_selection_allow: "css,html,js,php",
});
</script>');
$template->setVariable('templateVars', $theme->getTemplateVars(), false);
$view = ViewManager::getInstance();
$url = new Url(true);
$url_back = clone $url;
$url_back->setParameter($view->getUrlId(), ViewManager::ADMIN_OVERVIEW);
$template->setVariable('href_back', $url_back->getUrl(true), false);
$theme->addBreadcrumb(array('name' => $themedetail['name'], 'path' => $url_back->getUrl(true)));
$theme->addBreadcrumb(array('name' => $view->getName(), 'path' => $url->getUrl(true)));
$this->template[$this->director->theme->getConfig()->main_tag] = $template;
}