Exemplo n.º 1
0
 /**
  * Display a list of cron jobs that have ran.
  * @return int
  */
 public function admin()
 {
     $view = $this->getView();
     $request = $this->getPageRequest();
     if (!\Core\user()->checkAccess('p:/cron/viewlog')) {
         return View::ERROR_ACCESSDENIED;
     }
     $listings = new Core\ListingTable\Table();
     $listings->setModelName('CronLogModel');
     $listings->addFilter('select', array('title' => 'Cron', 'name' => 'cron', 'options' => array('' => '-- All --', '1-minute' => '1-minute', '5-minute' => '5-minute', '15-minute' => '15-minute', '30-minute' => '30-minute', 'hourly' => 'hourly', 'daily' => 'daily', 'weekly' => 'weekly', 'monthly' => 'monthly'), 'link' => FilterForm::LINK_TYPE_STANDARD));
     $listings->addFilter('select', array('title' => 'Status', 'name' => 'status', 'options' => array('' => '-- All --', 'pass' => 'pass', 'fail' => 'fail'), 'link' => FilterForm::LINK_TYPE_STANDARD));
     $listings->addColumn('Cron', 'cron');
     $listings->addColumn('Date Started', 'created');
     $listings->addColumn('Duration', 'Duration');
     $listings->setDefaultSort('created');
     $listings->loadFiltersFromRequest($request);
     $view->mastertemplate = 'admin';
     $view->title = 't:STRING_CRON_RESULTS';
     $view->assign('listings', $listings);
 }
	/**
	 * 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);
	}
Exemplo n.º 3
0
	/**
	 * Display a listing of all pages registered in the system.
	 */
	public function pages(){
		$view = $this->getView();
		$request = $this->getPageRequest();

		if(!\Core\user()->checkAccess('p:/core/pages/view')){
			return View::ERROR_ACCESSDENIED;
		}

		// Build a list of create pages for all registered components.
		$components = Core::GetComponents();
		$links = [];
		$componentopts = ['' => '-- ' . t('STRING_VIEW_ALL_COMPONENTS') . ' --'];
		foreach($components as $c){
			/** @var Component_2_1 $c */
			foreach($c->getXML()->getElements('/pages/pagecreate') as $node){
				/** @var DOMElement $node */
				$links[] = ['baseurl' => $node->getAttribute('baseurl'), 'title' => $node->getAttribute('title')];
			}

			$componentopts[$c->getKeyName()] = $c->getName();
		}
		// Sort them by name!
		asort($componentopts);

		$pageschema = PageModel::GetSchema();

		$table = new Core\ListingTable\Table();

		$table->setLimit(20);

		// Set the model that this table will be pulling data from.
		$table->setModelName('PageModel');

		// Gimme filters!
		$table->addFilter(
			'text',
			[
				'name' => 'title',
				'title' => t('STRING_TITLE'),
				'link' => FilterForm::LINK_TYPE_CONTAINS,
			]
		);

		$table->addFilter(
			'text',
			[
				'name' => 'rewriteurl',
				'title' => t('STRING_URL'),
				'link' => FilterForm::LINK_TYPE_CONTAINS,
			]
		);

		$table->addFilter(
			'text',
			[
				'name' => 'parenturl',
				'title' => t('STRING_PARENT_URL'),
				'link' => FilterForm::LINK_TYPE_STARTSWITH,
			]
		);

		$table->addFilter(
			'select',
			[
				'name' => 'component',
				'title' => t('STRING_COMPONENT'),
				'options' => $componentopts,
				'link' => FilterForm::LINK_TYPE_STANDARD,
			]
		);

		$table->addFilter(
			'select',
			[
				'name' => 'page_types',
				'title' => t('STRING_INCLUDE_ADMIN_PAGES'),
				'options' => ['all' => t('STRING_VIEW_ALL_PAGES'), 'no_admin' => t('STRING_EXCLUDE_ADMIN_PAGES')],
				'value' => 'no_admin',
			]
		);

		// Add in all the columns for this listing table.
		if(Core::IsComponentAvailable('multisite') && MultiSiteHelper::IsEnabled() && \Core\user()->checkAccess('g:admin')){
			$table->addColumn('Site', 'site', false);
			$ms = true;
		}
		else{
			$ms = false;
		}
		$table->addColumn(t('STRING_TITLE'), 'title');
		$table->addColumn(t('STRING_URL'), 'rewriteurl');
		$table->addColumn(t('STRING_VIEWS'), 'pageviews', false);
		$table->addColumn(t('STRING_SCORE'), 'popularity');
		$table->addColumn(t('STRING_CACHE'), 'expires');
		$table->addColumn(t('STRING_CREATED'), 'created', false);
		$table->addColumn(t('STRING_LAST_UPDATED'), 'updated', false);
		$table->addColumn(t('STRING_STATUS'));
		$table->addColumn(t('STRING_PUBLISHED'), 'published');
		$table->addColumn(t('STRING_EXPIRES'), 'published_expires');
		$table->addColumn(t('STRING_SEO_TITLE'));
		$table->addColumn(t('STRING_SEO_DESCRIPTION'), null, false);
		$table->addColumn(t('STRING_ACCESS'), 'access');
		$table->addColumn(t('STRING_COMPONENT'), 'component', false);

		// This page will also feature a quick-edit feature.
		//$table->setEditFormCaller('AdminController::PagesSave');

		$table->loadFiltersFromRequest();

		if($table->getFilterValue('page_types') == 'no_admin'){
			$table->getModelFactory()->where('admin = 0');
			$table->getModelFactory()->where('selectable = 1');
		}



		$view->title = 't:STRING_ALL_PAGES';
		//$view->assign('filters', $filters);
		//$view->assign('listings', $listings);
		$view->assign('links', $links);

		$view->assign('multisite', $ms);
		$view->assign('listing', $table);
		$view->assign('page_opts', PageModel::GetPagesAsOptions(false, '-- Select Parent URL --'));
		$view->assign('expire_opts', $pageschema['expires']['form']['options']);
	}