本文整理汇总了PHP中Layout::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Layout::set方法的具体用法?PHP Layout::set怎么用?PHP Layout::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Layout
的用法示例。
在下文中一共展示了Layout::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view
public function view($arguments)
{
if (empty($arguments[0])) {
return Error::set('No bug ID found.');
}
if (!empty($arguments[1])) {
$page = (int) array_pop($arguments);
if ($page < 1) {
$this->view['commentPage'] = 1;
} else {
$this->view['commentPage'] = $page;
}
} else {
$this->view['commentPage'] = 1;
}
$this->view['commentPageLoc'] = 'bugs/view/' . $arguments[0] . '/';
$bugs = new bugs(ConnectionFactory::get('mongo'));
$this->view['bug'] = $bugs->get($arguments[0], true, true);
if (is_string($this->view['bug'])) {
return Error::set($this->view['bug']);
}
if (!bugs::canView($this->view['bug'])) {
return Error::set('You are not allowed to view this bug.');
}
$this->view['valid'] = true;
Layout::set('title', $this->view['bug']['title']);
if ($this->view['bug']['flagged'] == true && CheckAcl::can('unflagBug')) {
$bugs->alter($this->view['bug']['_id'], array('flagged' => false));
}
}
示例2: index
public function index($arguments)
{
$news = new news(ConnectionFactory::get('mongo'));
$articles = new articles(ConnectionFactory::get('mongo'));
$notices = new notices(ConnectionFactory::get('redis'));
$irc = new irc(ConnectionFactory::get('redis'));
$quotes = new quotes(ConnectionFactory::get('mongo'));
$forums = new forums(ConnectionFactory::get('redis'));
// Set all site-wide notices.
foreach ($notices->getAll() as $notice) {
Error::set($notice, true);
}
// Fetch the easy data.
$this->view['news'] = $news->getNewPosts();
$this->view['shortNews'] = $news->getNewPosts(true);
$this->view['newArticles'] = $articles->getNewPosts('new', 1, 5);
$this->view['ircOnline'] = $irc->getOnline();
$this->view['randomQuote'] = $quotes->getRandom();
$this->view['fPosts'] = $forums->getNew();
// Get online users.
$apc = new APCIterator('user', '/' . Cache::PREFIX . 'user_.*/');
$this->view['onlineUsers'] = array();
while ($apc->valid()) {
$current = $apc->current();
array_push($this->view['onlineUsers'], substr($current['key'], strlen(Cache::PREFIX) + 5));
$apc->next();
}
// Set title.
Layout::set('title', 'Home');
}
示例3: index
public function index()
{
if (Session::isLoggedIn()) {
return Error::set(self::ERR_LOGGED_IN);
}
$this->view['valid'] = true;
Layout::set('title', 'Account Recovery');
}
示例4: set
/**
* Set Data
*
* @param string $key
* @param $value
*
* @return $this
*
* @since 1.0.0
*/
public function set($key, $value)
{
if (!$this->layout instanceof Layout) {
throw new ViewException(sprintf('View %s layout not started!', get_called_class()));
}
$this->layout->set($key, $value);
return $this;
}
示例5: index
public function index()
{
if (!CheckAcl::can('manageNotice')) {
return Error::set('You are not allowed to manage notices.');
}
$notices = new notices(ConnectionFactory::get('redis'));
$this->view['valid'] = true;
$this->view['notices'] = $notices->getAll();
Layout::set('title', 'Manage Notices');
}
示例6: index
public function index()
{
$lectures = new lectures(ConnectionFactory::get('mongo'));
$this->view['lectures'] = $lectures->getNew();
if (is_string($this->view['lectures'])) {
return Error::set($this->view['lectures']);
}
$this->view['valid'] = true;
Layout::set('title', 'Lectures');
}
示例7: index
public function index($arguments)
{
Layout::set('title', 'Search');
if (empty($_POST['query'])) {
return Error::set('No search query found.');
}
$query = substr(trim(htmlentities($_POST['query'], ENT_QUOTES, 'ISO8859-1', false)), 0, 250);
$results = Search::query($query);
if ($results['hits']['total'] == 0) {
return Error::set('No results found.');
}
$this->view['results'] = array();
$news = new news(ConnectionFactory::get('mongo'));
$articles = new articles(ConnectionFactory::get('mongo'));
$lectures = new lectures(ConnectionFactory::get('mongo'));
$i = 1;
if (empty($results['hits']['hits'])) {
return;
}
foreach ($results['hits']['hits'] as $result) {
$entry = $result['_source'];
switch ($entry['type']) {
case 'news':
$post = $news->get($result['_id'], false, true);
if (empty($post)) {
continue;
}
$post['type'] = 'news';
array_push($this->view['results'], $post);
break;
case 'article':
$article = $articles->get($result['_id'], false, true);
if (empty($article)) {
continue;
}
$article['type'] = 'article';
array_push($this->view['results'], $article);
break;
case 'lecture':
$lecture = $lectures->get($result['_id'], false, true);
if (empty($lecture)) {
continue;
}
$lecture['type'] = 'lecture';
array_push($this->view['results'], $lecture);
break;
}
if ($i == 5) {
break;
}
++$i;
}
}
示例8: view
public function view($arguments)
{
if (!empty($arguments[3])) {
$page = (int) array_pop($arguments);
if ($page < 1) {
$this->view['commentPage'] = 1;
} else {
$this->view['commentPage'] = $page;
}
} else {
$this->view['commentPage'] = 1;
}
if (!empty($_GET['p'])) {
$page = (int) $_GET['p'];
if ($page < 1) {
$this->view['page'] = 1;
} else {
$this->view['page'] = $page;
}
} else {
$this->view['page'] = 1;
}
@($id = implode('/', $arguments));
if (empty($id)) {
return Error::set('Invalid id.');
}
$newsModel = new news(ConnectionFactory::get('mongo'));
list($news, $this->view['total']) = $newsModel->get($id, true, false, true, $this->view['page']);
if (is_string($news)) {
return Error::set($news);
}
$this->view['news'] = $news;
$this->view['multiple'] = count($news) > 1;
$this->view['url'] = Url::format('/news/view/' . $id . '?p=');
if ($this->view['multiple']) {
return;
}
$this->view['commentPageLoc'] = 'news/view/' . $id . '/';
Layout::set('title', $this->view['news'][0]['title']);
$mlt = Search::mlt($this->view['news'][0]['_id'], 'news', 'title,body,tags');
$this->view['mlt'] = array();
if (empty($mlt['hits']['hits'])) {
return;
}
foreach ($mlt['hits']['hits'] as $post) {
$fetched = $newsModel->get($post['_id'], false, true);
if (empty($fetched)) {
continue;
}
array_push($this->view['mlt'], $fetched);
}
}
示例9: dispatch
private static function dispatch($request)
{
$controller = self::CONTROLLER_PREFIX . array_shift($request);
// if no route is set then default to index
if (!count($request)) {
$request = array(0 => self::DEFAULT_METHOD);
}
if (!class_exists($controller)) {
$controller = "controller_nil";
}
if (!method_exists($controller, $request[0])) {
$controller = "controller_nil";
}
$class = new $controller($request);
// pass the request to the controller and return the result
Layout::set("content", $class);
}
示例10: render
public static function render($view, $data, $finalCut)
{
Layout::set("leftNav", Config::get("display:leftnav"));
// localize all the view variables.
extract($data);
// Start capturing a new output buffer, load the view
// and apply all the display logic to the localized data
// and save the results in $parsed.
ob_start();
require $view;
$parsed = ob_get_clean();
if (!$finalCut) {
return $parsed;
}
Layout::set("content", $parsed);
ob_start();
echo Layout::render();
$full = ob_get_clean();
return $full;
}
示例11: handler
public static function handler($data = null)
{
Session::init();
$key = Cache::PREFIX . 'sessionReq_' . Session::getId();
if (apc_exists($key)) {
Session::setBatchVars(apc_fetch($key));
apc_delete($key);
}
$ip = Session::getVar('ip');
if (Session::isLoggedIn() && Session::getVar('lockToIP') && $ip != null && $ip != $_SERVER['REMOTE_ADDR']) {
Session::destroy();
header('Location: ' . Url::format('/'));
die;
}
Session::setVar('ip', $_SERVER['REMOTE_ADDR']);
$twitter = new twitter(ConnectionFactory::get('redis'));
Layout::set('tweets', $twitter->getOfficialTweets());
self::slowBan();
self::errorBan();
}
示例12: get
public static function get()
{
if (!\Current_User::isLogged()) {
return;
}
$modlist = PHPWS_Core::getModuleNames();
$tpl['MINIADMIN_TITLE'] = dgettext('miniadmin', 'MiniAdmin');
$tpl['MINIADMIN_TITLE_ALT'] = dgettext('miniadmin', 'Administrate');
if (isset($GLOBALS['MiniAdmin'])) {
foreach ($GLOBALS['MiniAdmin'] as $module => $links) {
$mod_title = $modlist[$module];
if (isset($links['title_link'])) {
$mod_title = sprintf('<a href="%s">%s</a>', $links['title_link'], $mod_title);
}
$module_links[$mod_title] = $links;
}
$tpl['module_links'] = $module_links;
}
$template = new \Template($tpl);
$template->setModuleTemplate('miniadmin', MINIADMIN_TEMPLATE);
$content = $template->get();
Layout::set($content, 'miniadmin', 'mini_admin');
}
示例13: settings
public function settings($arguments)
{
// Update
if (!Session::isLoggedIn()) {
return Error::set('You are not logged in!');
}
$user = new users(ConnectionFactory::get('mongo'));
$this->view['valid'] = true;
$this->view['user'] = $user->get(Session::getVar('username'));
$this->view['secure'] = !empty($_SERVER['SSL_CLIENT_RAW_CERT']) ? true : false;
if ($this->view['secure']) {
$this->view['clientSSLKey'] = certs::getKey($_SERVER['SSL_CLIENT_RAW_CERT']);
}
if (!empty($arguments[0]) && $arguments[0] == 'save') {
if (!empty($_POST['oldpassword']) && !empty($_POST['password'])) {
$old = $user->hash($_POST['oldpassword'], $this->view['user']['username']);
if ($old != $this->view['user']['password']) {
return Error::set('Previous password is invalid.');
}
}
$username = !empty($_POST['username']) ? $_POST['username'] : null;
$password = !empty($_POST['password']) ? $_POST['password'] : null;
$email = !empty($_POST['email']) ? $_POST['email'] : null;
$hideEmail = !empty($_POST['hideEmail']) ? true : false;
$lockToIp = !empty($_POST['lockToIp']) ? true : false;
$error = $user->edit(Session::getVar('_id'), $username, $password, $email, $hideEmail, null, $lockToIp);
if (is_string($error)) {
return Error::set($error);
}
$this->view['user'] = $user->get(Session::getVar('username'));
Session::setBatchVars($this->view['user']);
Error::set('User profile saved.', true);
}
if (!empty($arguments[0]) && $arguments[0] == 'saveAuth') {
$password = !empty($_POST['passwordAuth']) ? true : false;
$certificate = !empty($_POST['certificateAuth']) ? true : false;
$certAndPass = !empty($_POST['certAndPassAuth']) ? true : false;
$autoauth = !empty($_POST['autoAuth']) ? true : false;
$return = $user->changeAuth(Session::getVar('_id'), $password, $certificate, $certAndPass, $autoauth);
if (is_string($return)) {
return Error::set($return);
}
$this->view['user'] = $user->get(Session::getVar('username'));
}
Layout::set('title', 'Settings');
}
示例14: nil
public function nil()
{
Layout::set('title', 'Not Found');
}
示例15: revisions
public function revisions($arguments)
{
if (!$this->hasRevisions) {
return Error::set('Revisions are not enabled for ' . $this->name . '.');
}
if (!CheckAcl::can('view' . $this->permission . 'Revisions')) {
return Error::set('You are not allowed to view ' . $this->name . ' revisions.');
}
if (empty($arguments[0])) {
return Error::set('No ' . $this->name . ' id found.');
}
$model = new $this->model(ConnectionFactory::get($this->db));
$current = $model->get($arguments[0], false, true);
$this->view['current'] = $current;
if (empty($current)) {
return Error::set('Invalid id.');
}
if (is_string($current)) {
return Error::set($current);
}
Layout::set('title', ucwords($this->name) . ' Revisions');
$revisions = new revisions(ConnectionFactory::get('mongo'));
// Start excerpt soley for reverting
$revert = $this->revert($arguments, $model, $revisions, $current);
// End excerpt
$revisions = $revisions->getForId($arguments[0]);
$this->view['revisions'] = array();
if (empty($revisions)) {
return Error::set('This entry has no revisions.');
}
$this->view['revisions'] = revisions::resolve($current, $revisions, $this->diffdFields);
}