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


PHP PageModel::Find方法代码示例

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


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

示例1: getFormSettings

 public function getFormSettings()
 {
     $pages = PageModel::Find(['baseurl LIKE /blog/view/%'], null, 'title');
     $opts = array('' => 'All Blogs');
     foreach ($pages as $page) {
         $id = substr($page->get('baseurl'), 11);
         $opts[$id] = $page->get('title');
     }
     $settings = [['type' => 'text', 'name' => 'title', 'title' => 'Displayed Title', 'description' => 'Displayed title on the page where this widget is added to.'], ['type' => 'select', 'name' => 'blog', 'title' => 'Blog', 'options' => $opts, 'description' => 'Choose a specific blog if you wish to retrieve posts from a specific blog.'], ['type' => 'select', 'name' => 'count', 'title' => 'Number of results', 'options' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)], ['type' => 'select', 'name' => 'sort', 'title' => 'Sort By', 'options' => array('newest' => 'Newest', 'popular' => 'Most Popular', 'random' => 'Random')]];
     return $settings;
 }
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:11,代码来源:BlogArticleWidget.php

示例2: quickdraft

 /**
  * Widget to quickly create a new Content page as a draft.
  */
 public function quickdraft()
 {
     $view = $this->getView();
     if (!\Core\user()->checkAccess('p:/content/manage_all')) {
         // Users who do not have access to manage page content do not get this.
         return '';
     }
     $form = new Form();
     $form->set('orientation', 'vertical');
     $form->set('callsmethod', 'ContentAdminWidget::QuickDraftSave');
     $form->addElement('text', ['name' => 'title', 'placeholder' => 'Page or Post Title']);
     $form->addElement('textarea', ['name' => 'content', 'placeholder' => "What's up?", 'cols' => 50]);
     $form->addElement('submit', ['value' => 'Save Draft']);
     // Load in all the pages on the site that are currently set as draft too, why not? ;)
     $drafts = PageModel::Find(['published_status = draft'], 10, 'updated DESC');
     $view->assign('form', $form);
     $view->assign('drafts', $drafts);
 }
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:21,代码来源:ContentAdminWidget.php

示例3: testBug

	public function testBug(){
		$selectablepage = PageModel::Find(['selectable' => 1], null);
		$notselectablepage = PageModel::Find(['selectable' => 0], null);

		// Both of these should return an array!
		$this->assertNotEmpty($selectablepage);
		$this->assertNotEmpty($notselectablepage);

		// And this needs to be an array too.
		$pagearray = PageModel::GetPagesAsOptions();
		$this->assertNotEmpty($pagearray);

		// Run through each selectable page and make sure that it displays in the list.
		foreach($selectablepage as $page){
			$this->assertInstanceOf('PageModel', $page);
			$this->assertArrayHasKey($page->get('baseurl'), $pagearray);
		}

		foreach($notselectablepage as $page){
			$this->assertInstanceOf('PageModel', $page);
			$this->assertArrayNotHasKey($page->get('baseurl'), $pagearray);
		}
	}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:23,代码来源:Bug250Test.php

示例4: index

	/**
	 * Display the admin dashboard.
	 *
	 * This page is primarily made up of widgets added by other systems.
	 *
	 * @return int
	 */
	public function index() {

		$view     = $this->getView();
		$pages    = PageModel::Find(array('admin' => '1'));
		$viewable = array();

		foreach ($pages as $p) {
			if (!\Core\user()->checkAccess($p->get('access'))) continue;

			$viewable[] = $p;
		}

		// If there are no viewable pages... don't display any admin dashboard.
		if(!sizeof($viewable)){
			return View::ERROR_ACCESSDENIED;
		}

		$view->title = 't:STRING_ADMIN';
		$view->assign('links', $viewable);

		// Dispatch the hook that other systems can hook into and perform checks or operations on the admin dashboard page.
		HookHandler::DispatchHook('/core/admin/view');
	}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:30,代码来源:AdminController.php

示例5: details

	/**
	 * See the details of a given search criteria, be it IP address, session, or user.
	 */
	public function details(){
		$view = $this->getView();
		$request = $this->getPageRequest();
		
		$listing = new Core\ListingTable\Table();
		$listing->setName('useractivity-details');
		$listing->setLimit(100);

		$listing->addFilter(
			'text',
			['name' => 'user_id', 'title' => 'User ID', 'link' => FilterForm::LINK_TYPE_STANDARD]
		);

		$listing->addFilter(
			'text',
			['name' => 'ip_addr', 'title' => 'IP Address', 'link' => FilterForm::LINK_TYPE_STANDARD]
		);

		$listing->addFilter(
			'text',
			['name' => 'session_id', 'title' => 'Session ID', 'link' => FilterForm::LINK_TYPE_STANDARD]
		);

		$pages = PageModel::Find(null, null, 'baseurl');
		$allPages = ['' => '-- ' . t('STRING_ALL_PAGES') . ' --'];
		foreach($pages as $p){
			/** @var PageModel $p */
			$allPages[$p->get('baseurl')] = $p->get('baseurl');
		}
		$listing->addFilter(
			'select',
			[
				'name' => 'baseurl',
			    'title' => 'Page',
			    'options' => $allPages,
			    'link' => FilterForm::LINK_TYPE_STANDARD,
			]
		);
		
		$listing->addColumn('Time', 'datetime');
		$listing->addColumn('User & Browser');
		$listing->addColumn('Type', 'type');
		$listing->addColumn('URL & Referrer', 'request');
		$listing->addColumn('Referrer', 'referrer', false);
		$listing->addColumn('Session', 'session_id', false);
		$listing->addColumn('IP Address', 'ip_addr', false);
		$listing->addColumn('User Agent', 'useragent', false);
		$listing->addColumn('Generation', 'processing_time', false);
		$listing->addColumn('DB Reads', 'db_reads', false);
		$listing->addColumn('DB Writes', 'db_writes', false);
		
		$listing->setModelName('UserActivityModel');
		$listing->setDefaultSort('datetime', 'DESC');

		$listing->loadFiltersFromRequest($request);

		$view->title = 'User Activity Details';
		$view->assign('listings', $listing);
	}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:62,代码来源:UserActivityController.php

示例6: view

	public function view(){
		$v = $this->getView();

		$pages = PageModel::Find(array('admin' => '1'));
		$groups = array();
		$flatlist = array();

		if(isset($_SESSION['user_sudo'])){
			$p = new PageModel('/user/sudo');
			$p->set('title', 'Exit SUDO Mode');
			$groups['SUDO'] = [
				'title' => 'SUDO',
				'href' => '',
				'children' => [
					'Exit SUDO Mode' => $p,
				],
			];
			$flatlist[ 'Exit SUDO Mode' ] = $p;
		}


		if(\Core\user()){
			foreach($pages as $p){
				/** @var PageModel $p */
				if(!\Core\user()->checkAccess($p->get('access'))) continue;

				// Pages can define which sub-menu they get grouped under.
				// The 'Admin' submenu is the default.
				$group = $p->get('admin_group') ? $p->get('admin_group') : 't:STRING_ADMIN';
				// Support i18n here!
				if(strpos($group, 't:') === 0){
					$group = t(substr($group, 2));
				}

				if(!isset($groups[$group])){
					$groups[$group] = [
						'title'    => $group,
						'href'     => '',
						'children' => [],
					];
				}

				if($p->get('baseurl') == '/admin'){
					// Admin gets special treatment.
					$groups[t('STRING_ADMIN')]['href'] = '/admin';
					continue;
				}

				switch($p->get('title')){
					case 'System Configuration':
						$p->set('title', "System Config");
						break;
					case 'Navigation Listings':
						$p->set('title', "Navigation");
						break;
					case 'Content Page Listings':
						$p->set('title', "Content Pages");
						break;
					default:
						$p->set(
							'title',
							trim( str_replace(['Administration', 'Admin'],'', $p->get('title')) )
						);
				}

				$title = $p->get('title');
				// Support i18n here!
				if(strpos($title, 't:') === 0){
					$title = t(substr($title, 2));
				}

				if(isset($groups[$title])){
					// Link the main group to this page instead of an empty link.
					// This removes duplicate links such as the group "User" and page "User".
					$groups[$title]['href'] = $p->get('rewriteurl');
				}
				else{
					// The new grouped pages
					$groups[$group]['children'][ $title ] = $p;
					// And the flattened list to support legacy templates.
					$flatlist[ $title ] = $p;
				}
			}

			// This is a hack to make sure that users can view the /admin link if they can view other admin pages.
			/*if(sizeof($flatlist) && !isset($groups['Admin']['Dashboard'])){
				$p = new PageModel('/admin');
				$p->set('title', 'Dashboard');
				$groups['Admin']['Dashboard'] = $p;
			}*/
		}

		ksort($flatlist);
		ksort($groups);

		foreach($groups as $gname => $dat){
			ksort($groups[$gname]['children']);
		}

		// Build a list of languages that can be set by the user.
//.........这里部分代码省略.........
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:101,代码来源:AdminMenuWidget.php

示例7: execute


//.........这里部分代码省略.........
						'required'  => 'required',
						'maxlength' => 128
					]
				);
				$form->addElement(
					'submit', [
						'value' => 'Submit'
					]
				);

				$view->assign('form', $form);

				return;
			}
		}

		// If the parent Controller object has a method named $pagedat['method'], assume it's a security error!
		// This is because if the parent Controller object has a method, it's most likely a utility method
		// that shouldn't be called from the public web!
		foreach(get_class_methods('Controller_2_1') as $parentmethod){
			$parentmethod = strtolower($parentmethod);
			if($parentmethod == $pagedat['method']){
				$view->error = View::ERROR_BADREQUEST;
				return;
			}
		}

		// Additional security logic for existing pages in multi-site mode.
		// If this exact URL is registered to another site, then
		// don't allow this site to display it.
		if(!$page->exists() && Core::IsComponentAvailable('multisite') && MultiSiteHelper::IsEnabled()){
			$site = MultiSiteHelper::GetCurrentSiteID();

			$anypage = PageModel::Find(['baseurl = ' . $page->get('baseurl')], 1);

			if($anypage){

				if($anypage->get('site') == -1){
					// If this is a global page.... that's ok.
					// Just remap the page variable to this one!
					$page = $anypage;
				}
				elseif($anypage->get('site') == $site){
					// Strange... it should have located this page...
					// Anyway, it's allowed, the site matches up.
					$page = $anypage;
				}
				else{
					\Core\redirect($anypage->getResolvedURL());
				}
			}
		}

		$return = call_user_func(array($controller, $pagedat['method']));
		if (is_int($return)) {
			// A generic error code was returned.  Create a View with that code and return that instead.
			$view->error = $return;
			//return;
		}
		elseif(is_a($return, 'View') && $return != $view){
			// The controller method changed the view, (which is allowed),
			// but this needs to be remapped to this object so render knows about it.
			$this->_pageview = $view = $return;
		}
		elseif ($return === null) {
			// Hopefully it's setup!
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:67,代码来源:PageRequest.class.php

示例8: children

 /**
  * This is a widget to display children of the current page
  *
  * The page is dynamic based on the currently viewed page.
  *
  * @return int
  */
 public function children()
 {
     $view = $this->getView();
     $current = PageRequest::GetSystemRequest();
     $model = $current->getPageModel();
     if (!$model) {
         return '';
     }
     $baseurl = $model->get('baseurl');
     // Give me all the siblings of that baseurl.
     $pages = PageModel::Find(['parenturl' => $baseurl, 'selectable' => 1], null, 'title');
     $entries = [];
     foreach ($pages as $page) {
         $subpages = PageModel::Find(['parenturl' => $page->get('baseurl'), 'selectable' => 1], null, 'title');
         $subentries = [];
         foreach ($subpages as $subpage) {
             $subentries[] = ['obj' => $subpage, 'children' => [], 'class' => ''];
         }
         $entries[] = ['obj' => $page, 'children' => $subentries, 'class' => 'active'];
     }
     $view->assign('entries', $entries);
 }
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:29,代码来源:NavigationWidget.php

示例9:

<?php

/**
 * Created by JetBrains PhpStorm.
 * User: powellc
 * Date: 1/17/13
 * Time: 10:20 PM
 * This is the upgrade file from 1.3.0 to 1.4.0
 *
 * Now that core supports selectable and non-selectable pages, I need to update all the existing blog articles to make them not selectable.
 */
$pages = PageModel::Find(array('baseurl LIKE /blog/article/view/%'));
foreach ($pages as $page) {
    $page->set('selectable', 0);
    $page->save();
}
// return
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:17,代码来源:130_to_140_selectable.php

示例10: _AutoRegisterFiles

 /**
  * Hook to check for any new files in the system and register pages (or deregister them as necessary).
  * 
  * Only runs if the config option is enabled to do so.
  */
 public static function _AutoRegisterFiles()
 {
     if (!\ConfigHandler::Get('/markdownbrowser/autoregister')) {
         echo 'Skipping autoregistration of markdown files, configuration option for this feature is disabled.' . "\n";
         return true;
     }
     $dir = \ConfigHandler::Get('/markdownbrowser/basedir');
     $markdownFiles = [];
     if (!$dir) {
         echo 'Skipping autoregistration of markdown files, no markdown directory configured.' . "\n";
         return true;
     }
     // Make sure it's readable!
     $dir = \Core\Filestore\Factory::Directory($dir);
     $dirbase = $dir->getPath();
     $dirlen = strlen($dirbase);
     if (!$dir->exists()) {
         echo 'Skipping autoregistration of markdown files, ' . $dir->getPath() . ' does not exist.' . "\n";
         return true;
     }
     $all = [];
     $files = $dir->ls('md', true);
     foreach ($files as $file) {
         /** @var \Core\Filestore\File $file */
         $fileBase = substr($file->getFilename(), $dirlen);
         if (strpos($fileBase, 'index.md') !== false) {
             $fileRel = substr($fileBase, 0, -8);
         } else {
             $fileRel = substr($fileBase, 0, -3);
         }
         if (preg_match('/[A-Z]/', $fileRel) !== 0) {
             $warning = t('STRING_MARKDOWNBROWSER_WARNING_FILE_HAS_CAPITALS');
         } elseif (strpos($fileRel, ' ')) {
             $warning = t('STRING_MARKDOWNBROWSER_WARNING_FILE_HAS_SPACES');
         } else {
             $warning = '';
         }
         if ($warning == '') {
             $url = '/markdownbrowser/view/' . $fileRel;
             $all[$url] = ['file' => $file, 'page' => null];
         } else {
             echo $warning . ' - ' . $fileRel . "\n";
         }
     }
     // Now that the files are loaded into memory, load any page that may already exist.
     // This will be used to ignore entries that already have a page, to create ones without,
     // and to remove pages that no longer have a corresponding file.
     $pages = PageModel::Find(['baseurl LIKE /markdownbrowser/view%']);
     foreach ($pages as $p) {
         $url = $p->get('baseurl');
         if (!isset($all[$url])) {
             $all[$url] = ['file' => null, 'page' => null];
         }
         $all[$url]['page'] = $p;
     }
     // Now $all contains everything I need to process on! :)
     foreach ($all as $url => &$dat) {
         /** @var PageModel|null $page */
         $page = $dat['page'];
         /** @var \Core\Filestore\File|null $file */
         $file = $dat['file'];
         if ($page && !$file) {
             // There is a page but no file, DELETE!
             $page->delete();
             echo 'Deleted page for non-existent file: ' . $url . "\n";
         } elseif (!$page && $file) {
             // There is a file but no page, create.
             $contents = $file->getContents();
             // Convert these contents from markdown to HTML.
             $processor = new \Core\MarkdownProcessor();
             $html = $processor->transform($contents);
             // Pre-populate this page with information from the rendered markdown document.
             // If this page exists, then it'll be updated and kept in sync.
             // Else, it'll still be set with what's in the document and kept in sync.
             $page = PageModel::Construct($url);
             $page->set('title', $processor->getMeta('title'));
             $page->set('body', $html);
             $page->set('baseurl', $url);
             $page->set('rewriteurl', $url);
             $page->set('editurl', str_replace('/markdownbrowser/view', '/markdownbrowser/update', $url));
             $page->set('component', 'markdown-browser');
             $page->set('selectable', 1);
             $page->set('published', $file->getMTime());
             $page->set('updated', $file->getMTime());
             $page->set('created', $file->getMTime());
             $page->save();
             echo 'Created page for new file: ' . $url . "\n";
         }
     }
     return true;
 }
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:96,代码来源:MarkdownBrowserController.php


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