<commit_before><?php
	/**
	 * @package content
	 */

	/**
	 * This page controls the creation and maintenance of Symphony
	 * Sections through the Section Index and Section Editor.
	 */
	require_once(TOOLKIT . '/class.administrationpage.php');
	require_once(TOOLKIT . '/class.sectionmanager.php');
	require_once(TOOLKIT . '/class.fieldmanager.php');
	require_once(TOOLKIT . '/class.entrymanager.php');

	Class contentBlueprintsSections extends AdministrationPage{

		public $_errors = array();

		public function __viewIndex(){
			$this->setPageType('table');
			$this->setTitle(__('%1$s &ndash; %2$s', array(__('Sections'), __('Symphony'))));
			$this->appendSubheading(__('Sections'), Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL().'new/', __('Create a section'), 'create button', NULL, array('accesskey' => 'c')));

			$sections = SectionManager::fetch(NULL, 'ASC', 'sortorder');

			$aTableHead = array(
				array(__('Name'), 'col'),
				array(__('Entries'), 'col'),
				array(__('Navigation Group'), 'col')
			);

			$aTableBody = array();

			if(!is_array($sections) || empty($sections)){
				$aTableBody = array(
					Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd')
				);
			}

			else{
				foreach($sections as $s){

					$entry_count = EntryManager::fetchCount($s->get('id'));

					// Setup each cell
					$td1 = Widget::TableData(Widget::Anchor($s->get('name'), Administration::instance()->getCurrentPageURL() . 'edit/' . $s->get('id') .'/', NULL, 'content'));
					$td2 = Widget::TableData(Widget::Anchor("$entry_count", SYMPHONY_URL . '/publish/' . $s->get('handle') . '/'));
					$td3 = Widget::TableData($s->get('navigation_group'));

					$td3->appendChild(Widget::Input('items['.$s->get('id').']', 'on', 'checkbox'));

					// Add a row to the body array, assigning each cell to the row
					$aTableBody[] = Widget::TableRow(array($td1, $td2, $td3));

				}
			}

			$table = Widget::Table(
				Widget::TableHead($aTableHead),
				NULL,
				Widget::TableBody($aTableBody),
				'orderable selectable'
			);

			$this->Form->appendChild($table);

			$tableActions = new XMLElement('div');
			$tableActions->setAttribute('class', 'actions');

			$options = array(
				array(NULL, false, __('With Selected...')),
				array('delete', false, __('Delete'), 'confirm', null, array(
					'data-message' => __('Are you sure you want to delete the selected sections?')
				)),
				array('delete-entries', false, __('Delete Entries'), 'confirm', null, array(
					'data-message' => __('Are you sure you want to delete all entries in the selected sections?')
				))
			);

			if (is_array($sections) && !empty($sections))  {
				$index = 3;
				$options[$index] = array('label' => __('Set navigation group'), 'options' => array());

				$groups = array();
				foreach($sections as $s){
					if(in_array($s->get('navigation_group'), $groups)) continue;
					$groups[] = $s->get('navigation_group');

					$value = 'set-navigation-group-' . urlencode($s->get('navigation_group'));
					$options[$index]['options'][] = array($value, false, $s->get('navigation_group'));
				}
			}

			/**
			 * Allows an extension to modify the existing options for this page's
			 * With Selected menu. If the `$options` parameter is an empty array,
			 * the 'With Selected' menu will not be rendered.
			 *
			 * @delegate AddCustomActions
			 * @since Symphony 2.3.2
			 * @param string $context
			 * '/blueprints/sections/'
			 * @param array $options
			 *  An array of arrays, where each child array represents an option
			 *  in the With Selected menu. Options should follow the same format
			 *  expected by `Widget::__SelectBuildOption`. Passed by reference.
			 */
			Symphony::ExtensionManager()->notifyMembers('AddCustomActions', '/blueprints/sections/', array(
				'options' => &$options
			));

			if(!empty($options)) {
				$tableActions->appendChild(Widget::Apply($options));
				$this->Form->appendChild($tableActions);
			}
		}

		public function __viewNew(){
			$this->setPageType('form');
			$this->setTitle(__('%1$s &ndash; %2$s', array(__('Sections'), __('Symphony'))));
			$this->appendSubheading(__('Untitled'));
			$this->insertBreadcrumbs(array(
				Widget::Anchor(__('Sections'), SYMPHONY_URL . '/blueprints/sections/'),
			));

			$types = array();

			$fields = is_array($_POST['fields']) ? $_POST['fields'] : array();
			$meta = $_POST['meta'];

			$formHasErrors = (is_array($this->_errors) && !empty($this->_errors));

			if($formHasErrors) {
				$this->pageAlert(
					__('An error occurred while processing this form. See below for details.')
					, Alert::ERROR
				);
			}

			$showEmptyTemplate = (is_array($fields) && !empty($fields) ? false : true);

			if(!$showEmptyTemplate) ksort($fields);

			$meta['hidden'] = (isset($meta['hidden']) ? 'yes' : 'no');

			// Set navigation group, if not already set<commit_msg>Fixes notices for the section editor<commit_after><?php
	/**
	 * @package content
	 */

	/**
	 * This page controls the creation and maintenance of Symphony
	 * Sections through the Section Index and Section Editor.
	 */
	require_once(TOOLKIT . '/class.administrationpage.php');
	require_once(TOOLKIT . '/class.sectionmanager.php');
	require_once(TOOLKIT . '/class.fieldmanager.php');
	require_once(TOOLKIT . '/class.entrymanager.php');

	Class contentBlueprintsSections extends AdministrationPage{

		public $_errors = array();

		public function __viewIndex(){
			$this->setPageType('table');
			$this->setTitle(__('%1$s &ndash; %2$s', array(__('Sections'), __('Symphony'))));
			$this->appendSubheading(__('Sections'), Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL().'new/', __('Create a section'), 'create button', NULL, array('accesskey' => 'c')));

			$sections = SectionManager::fetch(NULL, 'ASC', 'sortorder');

			$aTableHead = array(
				array(__('Name'), 'col'),
				array(__('Entries'), 'col'),
				array(__('Navigation Group'), 'col')
			);

			$aTableBody = array();

			if(!is_array($sections) || empty($sections)){
				$aTableBody = array(
					Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd')
				);
			}

			else{
				foreach($sections as $s){

					$entry_count = EntryManager::fetchCount($s->get('id'));

					// Setup each cell
					$td1 = Widget::TableData(Widget::Anchor($s->get('name'), Administration::instance()->getCurrentPageURL() . 'edit/' . $s->get('id') .'/', NULL, 'content'));
					$td2 = Widget::TableData(Widget::Anchor("$entry_count", SYMPHONY_URL . '/publish/' . $s->get('handle') . '/'));
					$td3 = Widget::TableData($s->get('navigation_group'));

					$td3->appendChild(Widget::Input('items['.$s->get('id').']', 'on', 'checkbox'));

					// Add a row to the body array, assigning each cell to the row
					$aTableBody[] = Widget::TableRow(array($td1, $td2, $td3));

				}
			}

			$table = Widget::Table(
				Widget::TableHead($aTableHead),
				NULL,
				Widget::TableBody($aTableBody),
				'orderable selectable'
			);

			$this->Form->appendChild($table);

			$tableActions = new XMLElement('div');
			$tableActions->setAttribute('class', 'actions');

			$options = array(
				array(NULL, false, __('With Selected...')),
				array('delete', false, __('Delete'), 'confirm', null, array(
					'data-message' => __('Are you sure you want to delete the selected sections?')
				)),
				array('delete-entries', false, __('Delete Entries'), 'confirm', null, array(
					'data-message' => __('Are you sure you want to delete all entries in the selected sections?')
				))
			);

			if (is_array($sections) && !empty($sections))  {
				$index = 3;
				$options[$index] = array('label' => __('Set navigation group'), 'options' => array());

				$groups = array();
				foreach($sections as $s){
					if(in_array($s->get('navigation_group'), $groups)) continue;
					$groups[] = $s->get('navigation_group');

					$value = 'set-navigation-group-' . urlencode($s->get('navigation_group'));
					$options[$index]['options'][] = array($value, false, $s->get('navigation_group'));
				}
			}

			/**
			 * Allows an extension to modify the existing options for this page's
			 * With Selected menu. If the `$options` parameter is an empty array,
			 * the 'With Selected' menu will not be rendered.
			 *
			 * @delegate AddCustomActions
			 * @since Symphony 2.3.2
			 * @param string $context
			 * '/blueprints/sections/'
			 * @param array $options
			 *  An array of arrays, where each child array represents an option
			 *  in the With Selected menu. Options should follow the same format
			 *  expected by `Widget::__SelectBuildOption`. Passed by reference.
			 */
			Symphony::ExtensionManager()->notifyMembers('AddCustomActions', '/blueprints/sections/', array(
				'options' => &$options
			));

			if(!empty($options)) {
				$tableActions->appendChild(Widget::Apply($options));
				$this->Form->appendChild($tableActions);
			}
		}

		public function __viewNew(){
			$this->setPageType('form');
			$this->setTitle(__('%1$s &ndash; %2$s', array(__('Sections'), __('Symphony'))));
			$this->appendSubheading(__('Untitled'));
			$this->insertBreadcrumbs(array(
				Widget::Anchor(__('Sections'), SYMPHONY_URL . '/blueprints/sections/'),
			));

			$types = array();

			$m = array('name'=>null, 'something'=>null);

			$fields = (isset($_POST['fields']) && is_array($_POST['fields'])) ? $_POST['fields'] : array();
			$meta = (isset($_POST['meta']) && is_array($_POST['meta'])) ? $_POST['fields'] : array('name'=>null);

			$formHasErrors = (is_array($this->_errors) && !empty($this->_errors));

			if($formHasErrors) {
				$this->pageAlert(
					__('An error occurred while processing this form. See below for details.')
					, Alert::ERROR
				);
			}

			$showEmptyTemplate = (is_array($fields) && !empty($fields) ? false : true);

			if(!$showEmptyTemplate) ksort($fields);

			$meta['hidden'] = (isset($meta['hidden']) ? 'yes' : 'no');

			// Set navigation group, if not already set
{'fraction_non_alphanumeric': 0.19363500745897563, 'fraction_numerical': 0.0029835902536051715, 'mean_word_length': 4.109756097560975, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 78, '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': '3825836', 'n_tokens_mistral': 3669, 'n_tokens_neox': 3030, 'n_words': 701}