当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::node方法代码示例

本文整理汇总了PHP中Pagekit\Application::node方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::node方法的具体用法?PHP Application::node怎么用?PHP Application::node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pagekit\Application的用法示例。


在下文中一共展示了Application::node方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: indexAction

 public function indexAction($id = 0)
 {
     if (!($page = Page::find($id))) {
         App::abort(404, __('Page not found.'));
     }
     $page->content = App::content()->applyPlugins($page->content, ['page' => $page, 'markdown' => $page->get('markdown')]);
     return ['$view' => ['title' => $page->title, 'name' => 'system/site/page.php'], 'page' => $page, 'node' => App::node()];
 }
开发者ID:pagekit,项目名称:pagekit,代码行数:8,代码来源:PageController.php

示例2: detailsAction

 /**
  * @Access("userprofile: view profiles")
  * @Route("/{id}", methods="GET", name="id")
  * @Request({"id": "int"})
  */
 public function detailsAction($id)
 {
     if (!($user = App::auth()->getUserProvider()->find((int) $id)) or !($profileUser = ProfileUser::load($user))) {
         App::abort(404, __('User not found.'));
     }
     if ($breadcrumbs = App::module('bixie/breadcrumbs')) {
         $breadcrumbs->addUrl(['title' => $user->name, 'url' => '']);
     }
     return ['$view' => ['title' => __('User Profile'), 'name' => 'bixie/userprofile/profile-details.php'], '$data' => [], 'config' => App::module('bixie/userprofile')->config(), 'profileUser' => $profileUser, 'node' => App::node()];
 }
开发者ID:Bixie,项目名称:pagekit-userprofile,代码行数:15,代码来源:ProfilesController.php

示例3: projectAction

 /**
  * @Route("/{id}", name="id")
  */
 public function projectAction($id = 0)
 {
     if (!($project = Project::where(['id = ?', 'date < ?', 'status = 1'], [$id, new \DateTime()])->first())) {
         App::abort(404, __('Project not found.'));
     }
     $project->intro = App::content()->applyPlugins($project->intro, ['project' => $project, 'markdown' => $project->get('markdown')]);
     $project->content = App::content()->applyPlugins($project->content, ['project' => $project, 'markdown' => $project->get('markdown')]);
     $previous = Project::getPrevious($project);
     $next = Project::getNext($project);
     if ($breadcrumbs = App::module('bixie/breadcrumbs')) {
         $breadcrumbs->addUrl(['title' => $project->title, 'url' => '']);
     }
     return ['$view' => ['title' => __($project->title), 'name' => 'bixie/portfolio/project.php'], 'portfolio' => $this->portfolio, 'config' => $this->portfolio->config(), 'previous' => $previous, 'next' => $next, 'project' => $project, 'node' => App::node()];
 }
开发者ID:Bixie,项目名称:pagekit-portfolio,代码行数:17,代码来源:SiteController.php

示例4: formAction

 /**
  * @Route("/{id}")
  */
 public function formAction($id = 0)
 {
     $user = App::user();
     if (!($form = Form::where(['id = ?'], [$id])->where(function ($query) use($user) {
         if (!$user->isAdministrator()) {
             $query->where('status = 1');
         }
     })->related('fields')->first())) {
         App::abort(404, __('Form not found!'));
     }
     if (!App::node()->hasAccess(App::user())) {
         App::abort(403, __('Insufficient User Rights.'));
     }
     return ['$view' => ['title' => __($form->title), 'name' => 'formmaker:views/form.php'], '$data' => ['formitem' => $form, 'fields' => array_values($form->fields)]];
 }
开发者ID:nagyistoce,项目名称:pagekit-formmaker,代码行数:18,代码来源:SiteController.php

示例5: indexAction

 /**
  * @Route("/")
  */
 public function indexAction()
 {
     if (!App::node()->hasAccess(App::user())) {
         App::abort(403, __('Insufficient User Rights.'));
     }
     $query = Project::where(['date < ?'], [new \DateTime()])->orderBy('date', 'DESC');
     $portfolio_text = '';
     if ($this->portfolio->config('portfolio_text')) {
         $portfolio_text = App::content()->applyPlugins($this->portfolio->config('portfolio_text'), ['markdown' => $this->portfolio->config('markdown_enabled')]);
     }
     foreach ($projects = $query->get() as $project) {
         $project->intro = App::content()->applyPlugins($project->intro, ['project' => $project, 'markdown' => $project->get('markdown')]);
         $project->content = App::content()->applyPlugins($project->content, ['project' => $project, 'markdown' => $project->get('markdown'), 'readmore' => true]);
     }
     return ['$view' => ['title' => $this->portfolio->config('portfolio_title') ?: App::node()->title, 'name' => 'bixie/portfolio/portfolio.php'], 'tags' => Project::allTags(), 'portfolio' => $this->portfolio, 'config' => $this->portfolio->config(), 'portfolio_text' => $portfolio_text, 'projects' => $projects];
 }
开发者ID:4nxiety,项目名称:pagekit-portfolio,代码行数:19,代码来源:SiteController.php

示例6: feedAction

 /**
  * @Route("/feed")
  * @Route("/feed/{type}")
  */
 public function feedAction($type = '')
 {
     if (!App::node()->hasAccess(App::user())) {
         App::abort(403, __('Insufficient User Rights.'));
     }
     // fetch locale and convert to ISO-639 (en_US -> en-us)
     $locale = App::module('system')->config('site.locale');
     $locale = str_replace('_', '-', strtolower($locale));
     $site = App::module('system/site');
     $feed = App::feed()->create($type ?: $this->blog->config('feed.type'), ['title' => $site->config('title'), 'link' => App::url('@blog', [], true), 'description' => $site->config('description'), 'element' => ['language', $locale], 'selfLink' => App::url('@blog/feed', [], true)]);
     if ($last = Post::where(['status = ?', 'date < ?'], [Post::STATUS_PUBLISHED, new \DateTime()])->limit(1)->orderBy('modified', 'DESC')->first()) {
         $feed->setDate($last->modified);
     }
     foreach (Post::where(['status = ?', 'date < ?'], [Post::STATUS_PUBLISHED, new \DateTime()])->related('user')->limit($this->blog->config('feed.limit'))->orderBy('date', 'DESC')->get() as $post) {
         $url = App::url('@blog/id', ['id' => $post->id], true);
         $feed->addItem($feed->createItem(['title' => $post->title, 'link' => $url, 'description' => App::content()->applyPlugins($post->content, ['post' => $post, 'markdown' => $post->get('markdown'), 'readmore' => true]), 'date' => $post->date, 'author' => [$post->user->name, $post->user->email], 'id' => $url]));
     }
     return App::response($feed->output(), 200, ['Content-Type' => $feed->getMIMEType() . '; charset=' . $feed->getEncoding()]);
 }
开发者ID:bcismariu,项目名称:extension-blog,代码行数:23,代码来源:SiteController.php

示例7: getRoot

 /**
  * @param  string $menu
  * @param  array  $parameters
  * @return Node|null
  */
 public function getRoot($menu, $parameters = [])
 {
     $parameters = array_replace(['start_level' => 1, 'depth' => PHP_INT_MAX, 'mode' => 'all'], $parameters);
     $user = App::user();
     $startLevel = (int) $parameters['start_level'] ?: 1;
     $maxDepth = $startLevel + ($parameters['depth'] ?: PHP_INT_MAX);
     $nodes = Node::findByMenu($menu, true);
     $nodes[0] = new Node(['path' => '/']);
     $nodes[0]->status = 1;
     $nodes[0]->parent_id = null;
     $node = App::node();
     $path = $node->path;
     if (!isset($nodes[$node->id])) {
         foreach ($nodes as $node) {
             if ($node->getUrl('base') === $path) {
                 $path = $node->path;
                 break;
             }
         }
     }
     $path .= '/';
     $segments = explode('/', $path);
     $rootPath = count($segments) > $startLevel ? implode('/', array_slice($segments, 0, $startLevel + 1)) . '/' : '/';
     foreach ($nodes as $node) {
         $depth = substr_count($node->path, '/');
         $parent = isset($nodes[$node->parent_id]) ? $nodes[$node->parent_id] : null;
         $node->set('active', 0 === strpos($path, $node->path . '/'));
         if ($node->status !== 1 || $depth >= $maxDepth || !$node->hasAccess($user) || $node->get('menu_hide') || !($parameters['mode'] == 'all' || $node->get('active') || 0 === strpos($node->path . '/', $rootPath) || $depth == $startLevel)) {
             $node->setParent();
             continue;
         }
         $node->setParent($parent);
         if ($node->get('active') && $depth == $startLevel - 1) {
             $root = $node;
         }
     }
     if (!isset($root)) {
         return null;
     }
     $root->setParent();
     return $root;
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:47,代码来源:MenuHelper.php

示例8: formAction

 /**
  * @Route("/{id}", name="form/front")
  */
 public function formAction($id = 0)
 {
     $user = App::user();
     if (!($form = Form::where(['id = ?'], [$id])->where(function ($query) use($user) {
         if (!$user->isAdministrator()) {
             $query->where('status = 1');
         }
     })->related('fields')->first())) {
         App::abort(404, __('Form not found!'));
     }
     if (!App::node()->hasAccess(App::user())) {
         App::abort(403, __('Insufficient User Rights.'));
     }
     if ($form->get('recaptcha')) {
         App::view()->on('footer', function ($event) {
             $event->addResult('<script src="https://www.google.com/recaptcha/api.js?onload=grecacapthaCallback&render=explicit" async defer></script>');
         });
     }
     return ['$view' => ['title' => __($form->title), 'name' => 'formmaker:views/form.php'], '$data' => ['config' => App::module('formmaker')->publicConfig(), 'formitem' => $form, 'fields' => array_values($form->fields)]];
 }
开发者ID:4nxiety,项目名称:pagekit-formmaker,代码行数:23,代码来源:SiteController.php

示例9: formAction

 /**
  * @Route("/{id}", name="form/front")
  */
 public function formAction($id = 0)
 {
     if (!($formmaker = App::module('bixie/formmaker'))) {
         return 'Formmaker extension is disabled!';
     }
     $user = App::user();
     /** @var Form $form */
     if (!($form = Form::where(['id = ?'], [$id])->where(function ($query) use($user) {
         if (!$user->isAdministrator()) {
             $query->where('status = 1');
         }
     })->related('fields')->first())) {
         App::abort(404, __('Form not found!'));
     }
     if (!App::node()->hasAccess(App::user())) {
         App::abort(403, __('Insufficient User Rights.'));
     }
     $app = App::getInstance();
     $form->prepareView($app, $formmaker);
     return ['$view' => ['title' => __($form->title), 'name' => 'bixie/formmaker/form.php'], '$formmaker' => ['config' => $formmaker->publicConfig(), 'formitem' => $form, 'fields' => array_values($form->getFields())], 'node' => App::node()];
 }
开发者ID:Eichi,项目名称:pagekit-formmaker,代码行数:24,代码来源:SiteController.php

示例10: getWidgets

 /**
  * @param  string|null $position
  * @return Widget[]
  */
 protected function getWidgets($position)
 {
     static $widgets, $positions = [];
     if (null === $widgets) {
         $widgets = Widget::where(['status' => 1])->get();
     }
     if (!($pos = $this->positions->get($position))) {
         return [];
     }
     if (!isset($positions[$position])) {
         $positions[$position] = [];
         foreach ($pos['assigned'] as $id) {
             if (!isset($widgets[$id]) or !($widget = $widgets[$id]) or !$widget->hasAccess(App::user()) or $nodes = $widget->nodes and !in_array(App::node()->id, $nodes) or !($type = App::widget($widget->type))) {
                 continue;
             }
             $result = $type->render($widget);
             $widget->set('result', $result);
             $positions[$position][] = $widget;
         }
     }
     return $positions[$position];
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:26,代码来源:PositionHelper.php

示例11: fileAction

 /**
  * @Route("/{id}", name="id")
  * @Request({"id":"int", "category_id":"int"})
  */
 public function fileAction($id = 0, $category_id = 0)
 {
     /** @var File $file */
     if (!($file = File::where(['id = ?', 'status = ?'], [$id, '1'])->where(function ($query) {
         return $query->where('roles IS NULL')->whereInSet('roles', App::user()->roles, false, 'OR');
     })->first())) {
         App::abort(404, __('File not found.'));
     }
     $file->setActiveCategory($category_id);
     App::trigger('bixie.prepare.file', [$file, App::view()]);
     $file->content = App::content()->applyPlugins($file->content, ['file' => $file, 'markdown' => $file->get('markdown')]);
     $previous = File::getPrevious($file);
     $next = File::getNext($file);
     /** @var Category $category */
     if ($category_id && !($category = Category::where(['id = ?', 'status = ?'], [$category_id, '1'])->where(function ($query) {
         return $query->where('roles IS NULL')->whereInSet('roles', App::user()->roles, false, 'OR');
     })->related('files')->first())) {
         App::abort(404, __('Category not found.'));
     }
     if ($breadcrumbs = App::module('bixie/breadcrumbs')) {
         if ($category_id) {
             $cat = $category;
             $crumbs = [['title' => $category->title, 'url' => $category->getUrl()]];
             while ($parent_id = $cat->parent_id) {
                 if ($cat = $cat->find($parent_id, true)) {
                     $crumbs[] = ['title' => $cat->title, 'url' => $cat->getUrl()];
                 }
             }
             foreach (array_reverse($crumbs) as $data) {
                 $breadcrumbs->addUrl($data);
             }
         }
         //add file
         $breadcrumbs->addUrl(['title' => $file->title, 'url' => $file->getUrl()]);
     }
     return ['$view' => ['title' => __($file->title), 'name' => 'bixie/download/file.php'], 'download' => $this->download, 'config' => $this->download->config(), 'previous' => $previous, 'next' => $next, 'file' => $file, 'node' => App::node()];
 }
开发者ID:Bixie,项目名称:pagekit-download,代码行数:41,代码来源:SiteController.php

示例12: function

<?php

use Pagekit\Application as App;
return ['name' => 'bixie/breadcrumbs', 'type' => 'extension', 'main' => 'Bixie\\Breadcrumbs\\BreadcrumbsModule', 'autoload' => ['Bixie\\Breadcrumbs\\' => 'src'], 'widgets' => ['widgets/breadcrumbs.php'], 'resources' => ['bixie/breadcrumbs:' => ''], 'config' => [], 'events' => ['site' => function ($event, $app) {
    if ($app->isAdmin()) {
        return;
    }
    /** @var \Pagekit\Site\Model\Node $node */
    $node = App::node();
    if ($node->id) {
        /** @var \Bixie\Breadcrumbs\BreadcrumbsModule $breadcrumbs */
        $breadcrumbs = $app->module('bixie/breadcrumbs');
        $frontpage = $app->config('system/site')->get('frontpage');
        $frontpageSet = $frontpage == $node->id;
        $nodes = [$node];
        while ($parent_id = $node->parent_id) {
            if ($node = $node->find($parent_id, true)) {
                $frontpageSet = $frontpageSet ?: $frontpage == $node->id;
                $nodes[] = $node;
            }
        }
        if (!$frontpageSet) {
            $breadcrumbs->addNode($node->find($frontpage, true));
        }
        foreach (array_reverse($nodes) as $node) {
            $breadcrumbs->addNode($node);
        }
    }
}, 'view.blog/post' => function ($event, $view) {
    if ($post = $event['post']) {
        $this->addUrl(['title' => $post->title, 'url' => '']);
开发者ID:Bixie,项目名称:pagekit-breadcrumbs,代码行数:31,代码来源:index.php


注:本文中的Pagekit\Application::node方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。