<commit_before><?php
	
	require_once(TOOLKIT . '/class.administrationpage.php');
	require_once(TOOLKIT . '/class.eventmanager.php');
	require_once(TOOLKIT . '/class.datasourcemanager.php');
	require_once(TOOLKIT . '/class.xsltprocess.php');
	
	class contentBlueprintsPages extends AdministrationPage {
		protected $_errors;
		protected $_hilights = array();
		
		public function __viewIndex() {
			$this->setPageType('table');
			$this->setTitle(__('%1$s &ndash; %2$s', array(__('Symphony'), __('Pages'))));
			
			$this->appendSubheading(__('Pages'), Widget::Anchor(
				__('Create New'), $this->_Parent->getCurrentPageURL() . 'new/',
				__('Create a new page'), 'create button'
			));
			
			$pages = Symphony::Database()->fetch("
				SELECT
					p.*
				FROM
					`tbl_pages` AS p
				ORDER BY
					p.sortorder ASC
			");
			
			$aTableHead = array(
				array(__('Title'), 'col'),
				array(__('Template'), 'col'),
				array(__('<acronym title="Universal Resource Locator">URL</acronym>'), 'col'),
				array(__('<acronym title="Universal Resource Locator">URL</acronym> Parameters'), 'col'),
				array(__('Type'), 'col')
			);	
			
			$aTableBody = array();
			
			if (!is_array($pages) or empty($pages)) {
				$aTableBody = array(Widget::TableRow(array(
					Widget::TableData(__('None found.'), 'inactive', null, count($aTableHead))
				), 'odd'));
				
			} else {
				$bOdd = true;
				
				foreach ($pages as $page) {
					$class = array();
					$page_title = $this->_Parent->resolvePageTitle($page['id']);
					$page_url = URL . '/' . $this->_Parent->resolvePagePath($page['id']) . '/';
					$page_edit_url = $this->_Parent->getCurrentPageURL() . 'edit/' . $page['id'] . '/';
					$page_template = $this->__createHandle($page['path'], $page['handle']);
					$page_template_url = $this->_Parent->getCurrentPageURL() . 'template/' . $page_template . '/';
					$page_types = Symphony::Database()->fetchCol('type', "
						SELECT
							t.type
						FROM
							`tbl_pages_types` AS t
						WHERE
							t.page_id = '".$page['id']."'
						ORDER BY
							t.type ASC
					");
					
					$col_title = Widget::TableData(Widget::Anchor(
						$page_title, $page_edit_url, $page['handle']
					));
					$col_title->appendChild(Widget::Input("items[{$page['id']}]", null, 'checkbox'));
					
					$col_template = Widget::TableData(Widget::Anchor(
						$page_template . '.xsl',
						$page_template_url
					));
					
					$col_url = Widget::TableData(Widget::Anchor($page_url, $page_url));
					
					if ($page['params']) {
						$col_params = Widget::TableData(trim($page['params'], '/'));
						
					} else {
						$col_params = Widget::TableData(__('None'), 'inactive');
					}
					
					if (!empty($page_types)) {
						$col_types = Widget::TableData(implode(', ', $page_types));
						
					} else {
						$col_types = Widget::TableData(__('None'), 'inactive');
					}
					
					if ($bOdd) $class[] = 'odd';
					if (in_array($page['id'], $this->_hilights)) $class[] = 'failed';
					
					$aTableBody[] = Widget::TableRow(
						array($col_title, $col_template, $col_url, $col_params, $col_types),
						implode(' ', $class)
					);
					
					$bOdd = !$bOdd;
				}
			}
			
			$table = Widget::Table(
				Widget::TableHead($aTableHead), null, 
				Widget::TableBody($aTableBody), 'orderable'
			);
			
			$this->Form->appendChild($table);
			
			$tableActions = new XMLElement('div');
			$tableActions->setAttribute('class', 'actions');
			
			$options = array(
				array(null, false, __('With Selected...')),
				array('delete', false, __('Delete'))							
			);
			
			$tableActions->appendChild(Widget::Select('with-selected', $options));
			$tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
			
			$this->Form->appendChild($tableActions);
		}
		
		public function __viewTemplate() {
			$this->setPageType('form');
			$this->Form->setAttribute('action', URL . '/symphony/blueprints/pages/template/' . $this->_context[1] . '/');
			
			$filename = $this->_context[1] . '.xsl';
			$file_abs = PAGES . '/' . $filename;
			
			$is_child = strpos($this->_context[1],'_');
			$pagename = ($is_child != false ? substr($this->_context[1], $is_child + 1) : $this->_context[1]);

			$pagedata = $this->_Parent->Database->fetchRow(0, "
					SELECT
						p.*
					FROM
						`tbl_pages` AS p
					WHERE
						p.handle = '{$pagename}'
					LIMIT 1<commit_msg>Fix link from Page Edit to Page Config on pages deep in hierarchy<commit_after><?php
	
	require_once(TOOLKIT . '/class.administrationpage.php');
	require_once(TOOLKIT . '/class.eventmanager.php');
	require_once(TOOLKIT . '/class.datasourcemanager.php');
	require_once(TOOLKIT . '/class.xsltprocess.php');
	
	class contentBlueprintsPages extends AdministrationPage {
		protected $_errors;
		protected $_hilights = array();
		
		public function __viewIndex() {
			$this->setPageType('table');
			$this->setTitle(__('%1$s &ndash; %2$s', array(__('Symphony'), __('Pages'))));
			
			$this->appendSubheading(__('Pages'), Widget::Anchor(
				__('Create New'), $this->_Parent->getCurrentPageURL() . 'new/',
				__('Create a new page'), 'create button'
			));
			
			$pages = Symphony::Database()->fetch("
				SELECT
					p.*
				FROM
					`tbl_pages` AS p
				ORDER BY
					p.sortorder ASC
			");
			
			$aTableHead = array(
				array(__('Title'), 'col'),
				array(__('Template'), 'col'),
				array(__('<acronym title="Universal Resource Locator">URL</acronym>'), 'col'),
				array(__('<acronym title="Universal Resource Locator">URL</acronym> Parameters'), 'col'),
				array(__('Type'), 'col')
			);	
			
			$aTableBody = array();
			
			if (!is_array($pages) or empty($pages)) {
				$aTableBody = array(Widget::TableRow(array(
					Widget::TableData(__('None found.'), 'inactive', null, count($aTableHead))
				), 'odd'));
				
			} else {
				$bOdd = true;
				
				foreach ($pages as $page) {
					$class = array();
					$page_title = $this->_Parent->resolvePageTitle($page['id']);
					$page_url = URL . '/' . $this->_Parent->resolvePagePath($page['id']) . '/';
					$page_edit_url = $this->_Parent->getCurrentPageURL() . 'edit/' . $page['id'] . '/';
					$page_template = $this->__createHandle($page['path'], $page['handle']);
					$page_template_url = $this->_Parent->getCurrentPageURL() . 'template/' . $page_template . '/';
					$page_types = Symphony::Database()->fetchCol('type', "
						SELECT
							t.type
						FROM
							`tbl_pages_types` AS t
						WHERE
							t.page_id = '".$page['id']."'
						ORDER BY
							t.type ASC
					");
					
					$col_title = Widget::TableData(Widget::Anchor(
						$page_title, $page_edit_url, $page['handle']
					));
					$col_title->appendChild(Widget::Input("items[{$page['id']}]", null, 'checkbox'));
					
					$col_template = Widget::TableData(Widget::Anchor(
						$page_template . '.xsl',
						$page_template_url
					));
					
					$col_url = Widget::TableData(Widget::Anchor($page_url, $page_url));
					
					if ($page['params']) {
						$col_params = Widget::TableData(trim($page['params'], '/'));
						
					} else {
						$col_params = Widget::TableData(__('None'), 'inactive');
					}
					
					if (!empty($page_types)) {
						$col_types = Widget::TableData(implode(', ', $page_types));
						
					} else {
						$col_types = Widget::TableData(__('None'), 'inactive');
					}
					
					if ($bOdd) $class[] = 'odd';
					if (in_array($page['id'], $this->_hilights)) $class[] = 'failed';
					
					$aTableBody[] = Widget::TableRow(
						array($col_title, $col_template, $col_url, $col_params, $col_types),
						implode(' ', $class)
					);
					
					$bOdd = !$bOdd;
				}
			}
			
			$table = Widget::Table(
				Widget::TableHead($aTableHead), null, 
				Widget::TableBody($aTableBody), 'orderable'
			);
			
			$this->Form->appendChild($table);
			
			$tableActions = new XMLElement('div');
			$tableActions->setAttribute('class', 'actions');
			
			$options = array(
				array(null, false, __('With Selected...')),
				array('delete', false, __('Delete'))							
			);
			
			$tableActions->appendChild(Widget::Select('with-selected', $options));
			$tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
			
			$this->Form->appendChild($tableActions);
		}
		
		public function __viewTemplate() {
			$this->setPageType('form');
			$this->Form->setAttribute('action', URL . '/symphony/blueprints/pages/template/' . $this->_context[1] . '/');
			
			$filename = $this->_context[1] . '.xsl';
			$file_abs = PAGES . '/' . $filename;
			
			$is_child = strrpos($this->_context[1],'_');
			$pagename = ($is_child != false ? substr($this->_context[1], $is_child + 1) : $this->_context[1]);

			$pagedata = $this->_Parent->Database->fetchRow(0, "
					SELECT
						p.*
					FROM
						`tbl_pages` AS p
					WHERE
						p.handle = '{$pagename}'
					LIMIT 1
{'fraction_non_alphanumeric': 0.19862006560343853, 'fraction_numerical': 0.0022621875353466803, 'mean_word_length': 3.1845716990061526, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5002480', 'n_tokens_mistral': 3826, 'n_tokens_neox': 2877, 'n_words': 491}