<commit_before><?php

	Class Extension_Notifier extends Extension{
		
		public function getSubscribedDelegates(){
			return array(
				array(
					'page' => '/publish/',
					'delegate' => 'EntryPreDelete',
					'callback' => 'notify'
				),
				array(
					'page' => '/publish/new/',
					'delegate' => 'EntryPostCreate',
					'callback' => 'notify'
				),
				array(
					'page' => '/publish/edit/',
					'delegate' => 'EntryPostEdit',
					'callback' => 'notify'
				)
			);
		}
		
		public function notify($context){
			include_once(TOOLKIT . '/class.gateway.php');
			$ch = new Gateway;
			
			$ch->init();
			$ch->setopt('URL', 'http://rpc.pingomatic.com/');
			$ch->setopt('POST', 1);
			$ch->setopt('CONTENTTYPE', 'text/xml');
			
			$xml = new XMLElement('methodCall');
			$xml->appendChild(new XMLElement('methodName', 'weblogUpdates.ping'));
			
			$params = new XMLElement('params');
			
			$param = new XMLElement('param');       
			$param->appendChild(new XMLElement('value', Symphony::Configuration()->get('sitename', 'general')));
			$params->appendChild($param);            

			$param = new XMLElement('param');
			$param->appendChild(new XMLElement('value', URL));
			$params->appendChild($param);    
			
			$xml->appendChild($params);        

			$ch->setopt('POSTFIELDS', $xml->generate(true, 0));

			$ch->exec(GATEWAY_FORCE_SOCKET);

		}
		
	}<commit_msg>Hunting in the dark of PHP<commit_after><?php

	Class Extension_Notifier extends Extension{
	    
		public function getSubscribedDelegates(){
			return array(
				// Register for preferences
				array(
					'page' => '/system/preferences/',
					'delegate' => 'AddCustomPreferenceFieldsets',
					'callback' => 'appendPreferences'
				),
				array(
					'page' => '/system/preferences/',
					'delegate' => 'CustomActions',
					'callback' => 'savePreferences'
				),

				// Register for CRUD events
				array(
					'page' => '/publish/',
					'delegate' => 'EntryPreDelete',
					'callback' => 'notify'
				),
				array(
					'page' => '/publish/new/',
					'delegate' => 'EntryPostCreate',
					'callback' => 'notify'
				),
				array(
					'page' => '/publish/edit/',
					'delegate' => 'EntryPostEdit',
					'callback' => 'notify'
				)
			);
		}
		
		// Controller method
		public function notify($context){
			include_once(TOOLKIT . '/class.gateway.php');
     	$ch = new Gateway;
      
      $ch->init();
      $ch->setopt('URL', 'http://rpc.notifier.com/');
      $ch->setopt('POST', 1);
      $ch->setopt('CONTENTTYPE', 'text/xml');
      
      $xml = new XMLElement('methodCall');
      $xml->appendChild(new XMLElement('methodName', 'weblogUpdates.ping'));
      
      $params = new XMLElement('params');
      
      $param = new XMLElement('param');       
      $param->appendChild(new XMLElement('value', Symphony::Configuration()->get('sitename', 'general')));
      $params->appendChild($param);            

      $param = new XMLElement('param');
      $param->appendChild(new XMLElement('value', URL));
      $params->appendChild($param);    
      
      $xml->appendChild($params);        

      $ch->setopt('POSTFIELDS', $xml->generate(true, 0));

      $ch->exec(GATEWAY_FORCE_SOCKET);
		}

		
		public function appendPreferences($context){
			include_once(TOOLKIT . '/class.authormanager.php');
			include_once(TOOLKIT . '/class.sectionmanager.php');

			// Fieldset and layout
			$group = new XMLElement('fieldset');
			$group->setAttribute('class', 'settings');
			$legend = new XMLElement('legend', __('Notifier'));
			$group->appendChild($legend);

			$div = new XMLElement('div');
			$div->setAttribute('class', 'group triple');

			// notify url of notifier event
			$notify_url = Symphony::Configuration()->get('notify_url', 'notifier');
			$notify_label = Widget::Label(__('Send modification event to URL'));
			$notify_label->appendChild(Widget::Input('settings[notifier][notify_url]', $notify_url, 'text'));
			$group->appendChild($notify_label);
		}

		public function savePreferences() {
		
			// Remove existing configuration settings.
			Symphony::Configuration()->remove('notifier');
			Administration::instance()->saveConfig();
			
			// If there are Notifier settings, format them
			if(is_array($_POST['settings']['notifier'])){
				foreach($_POST['settings']['notifier'] as $preference => $value){
					if(is_array($value)){
						$_POST['settings']['notifier'][$preference] = implode(',',$value);
					}
				}
			}
		}
		
	}
{'fraction_non_alphanumeric': 0.1852267624607095, 'fraction_numerical': 0.000898069151324652, 'mean_word_length': 3.194915254237288, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 64, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '7445856', 'n_tokens_mistral': 1701, 'n_tokens_neox': 1391, 'n_words': 246}