<commit_before><?php

	require_once 'lib/sectionsdatasource.php';

	Class Extension_DS_Sections extends Extension {
		public function about() {
			return array(
				'name'			=> 'Sections',
				'version'		=> '1.0.0',
				'release-date'	=> '2010-03-02',
				'type'			=> array(
					'Data Source', 'Core'
				),
				'author'		=> array(
					'name'			=> '<NAME>',
					'website'		=> 'http://symphony-cms.com/',
					'email'			=> '<EMAIL>'
				),
				'provides'		=> array(
					'datasource_template'
				),
				'description'	=> 'Create data sources from an XML string.'
			);
		}

		public function prepare(array $data=NULL, DataSource $datasource=NULL) {

			if(is_null($datasource)){
				$datasource = new SectionsDataSource;
			}

			if(!is_null($data)){
				if(isset($data['about']['name'])) $datasource->about()->name = $data['about']['name'];
				$datasource->parameters()->section = $data['section'];

				$datasource->parameters()->conditions = $datasource->parameters()->filter = array();

				if(isset($data['conditions']) && is_array($data['conditions'])){
					foreach($data['conditions']['parameter'] as $index => $parameter){
						$datasource->parameters()->conditions[$index] = array(
							'parameter' => $parameter,
							'logic' => $data['conditions']['logic'][$index],
							'action' => $data['conditions']['action'][$index]
						);
					}
				}

				if(isset($data['filter']) && is_array($data['filter'])){
					$datasource->parameters()->filter = $data['filter'];
				}

				$datasource->parameters()->{'redirect-404-on-empty'} = (isset($data['redirect-404-on-empty']) && $data['redirect-404-on-empty'] == 'yes');
				$datasource->parameters()->{'append-pagination'} = (isset($data['append-pagination']) && $data['append-pagination'] == 'yes');
				$datasource->parameters()->{'append-associated-entry-count'} = (isset($data['append-associated-entry-count']) && $data['append-associated-entry-count'] == 'yes');
				$datasource->parameters()->{'html-encode'} = (isset($data['html-encode']) && $data['html-encode'] == 'yes');

				if(isset($data['sort-field'])) $datasource->parameters()->{'sort-field'} = $data['sort-field'];
				if(isset($data['sort-order'])) $datasource->parameters()->{'sort-order'} = $data['sort-order'];
				if(isset($data['limit'])) $datasource->parameters()->{'limit'} = $data['limit'];
				if(isset($data['page'])) $datasource->parameters()->{'page'} = $data['page'];

				$datasource->parameters()->{'included-elements'} = (array)$data['included-elements'];
				$datasource->parameters()->{'parameter-output'} = (array)$data['parameter-output'];

			}

			return $datasource;

		}

		public function view(Datasource $datasource, SymphonyDOMElement &$wrapper, MessageStack $errors) {
			$page = Administration::instance()->Page;
			$page->insertNodeIntoHead($page->createScriptElement(URL . '/extensions/ds_sections/assets/view.js'), 55533140);

			$layout = new Layout();
			$left = $layout->createColumn(Layout::SMALL);
			$middle = $layout->createColumn(Layout::LARGE);

		//	Essentials --------------------------------------------------------

			$fieldset = Widget::Fieldset(__('Essentials'));

			// Name:
			$label = Widget::Label(__('Name'));
			$input = Widget::Input('fields[about][name]', General::sanitize($datasource->about()->name));
			$label->appendChild($input);

			if (isset($errors->{'about::name'})) {
				$label = Widget::wrapFormElementWithError($label, $errors->{'about::name'});
			}

			$fieldset->appendChild($label);<commit_msg>Ensured that included-elements and parameter-output properties of Data Sources are always arrays<commit_after><?php

	require_once 'lib/sectionsdatasource.php';

	Class Extension_DS_Sections extends Extension {
		public function about() {
			return array(
				'name'			=> 'Sections',
				'version'		=> '1.0.0',
				'release-date'	=> '2010-03-02',
				'type'			=> array(
					'Data Source', 'Core'
				),
				'author'		=> array(
					'name'			=> '<NAME>',
					'website'		=> 'http://symphony-cms.com/',
					'email'			=> '<EMAIL>'
				),
				'provides'		=> array(
					'datasource_template'
				),
				'description'	=> 'Create data sources from an XML string.'
			);
		}

		public function prepare(array $data=NULL, DataSource $datasource=NULL) {

			if(is_null($datasource)){
				$datasource = new SectionsDataSource;
			}

			if(!is_null($data)){
				if(isset($data['about']['name'])) $datasource->about()->name = $data['about']['name'];
				$datasource->parameters()->section = $data['section'];

				$datasource->parameters()->conditions = $datasource->parameters()->filter = array();

				if(isset($data['conditions']) && is_array($data['conditions'])){
					foreach($data['conditions']['parameter'] as $index => $parameter){
						$datasource->parameters()->conditions[$index] = array(
							'parameter' => $parameter,
							'logic' => $data['conditions']['logic'][$index],
							'action' => $data['conditions']['action'][$index]
						);
					}
				}

				if(isset($data['filter']) && is_array($data['filter'])){
					$datasource->parameters()->filter = $data['filter'];
				}

				$datasource->parameters()->{'redirect-404-on-empty'} = (isset($data['redirect-404-on-empty']) && $data['redirect-404-on-empty'] == 'yes');
				$datasource->parameters()->{'append-pagination'} = (isset($data['append-pagination']) && $data['append-pagination'] == 'yes');
				$datasource->parameters()->{'append-associated-entry-count'} = (isset($data['append-associated-entry-count']) && $data['append-associated-entry-count'] == 'yes');
				$datasource->parameters()->{'html-encode'} = (isset($data['html-encode']) && $data['html-encode'] == 'yes');

				if(isset($data['sort-field'])) $datasource->parameters()->{'sort-field'} = $data['sort-field'];
				if(isset($data['sort-order'])) $datasource->parameters()->{'sort-order'} = $data['sort-order'];
				if(isset($data['limit'])) $datasource->parameters()->{'limit'} = $data['limit'];
				if(isset($data['page'])) $datasource->parameters()->{'page'} = $data['page'];
				
				if(isset($data['included-elements'])){
					$datasource->parameters()->{'included-elements'} = (array)$data['included-elements'];
				}
				
				if(isset($data['parameter-output'])){
					$datasource->parameters()->{'parameter-output'} = (array)$data['parameter-output'];
				}

			}

			return $datasource;

		}

		public function view(Datasource $datasource, SymphonyDOMElement &$wrapper, MessageStack $errors) {
			$page = Administration::instance()->Page;
			$page->insertNodeIntoHead($page->createScriptElement(URL . '/extensions/ds_sections/assets/view.js'), 55533140);

			$layout = new Layout();
			$left = $layout->createColumn(Layout::SMALL);
			$middle = $layout->createColumn(Layout::LARGE);

		//	Essentials --------------------------------------------------------

			$fieldset = Widget::Fieldset(__('Essentials'));

			// Name:
			$label = Widget::Label(__('Name'));
			$input = Widget::Input('fields[about][name]', General::sanitize($datasource->about()->name));
			$label->appendChild($input);

			if (isset($errors->{'about::name'})) {
				$label = Widget::wrapFormElementWithError($label, $errors->{'about::name'});
			}

			$fieldset->appendChild($label);
{'fraction_non_alphanumeric': 0.2421125781792912, 'fraction_numerical': 0.00778318276580959, 'mean_word_length': 4.180705543556516, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 121, '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': '922642', 'n_tokens_mistral': 2715, 'n_tokens_neox': 2161, 'n_words': 310}