Skip to content

Commit

Permalink
section id abstraction
Browse files Browse the repository at this point in the history
  • Loading branch information
scottkf committed May 12, 2011
1 parent ff9f5af commit e84cc5d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 6 deletions.
18 changes: 12 additions & 6 deletions content/content.index.php
Expand Up @@ -13,7 +13,16 @@ class contentExtensionMassUploadUtilityIndex extends AdministrationPage {
protected $_valid = false;
protected $_message = '';


public function getSectionID() {
$sectionManager = new SectionManager($this->_Parent);

$section_id = $sectionManager->fetchIDFromHandle(General::sanitize($_REQUEST['MUUsource']));

if(!$section = $sectionManager->fetch($section_id))
return NULL;
else
return $section_id;
}
/**
* ---------------------------------------------------------
* This functionality is essentially duplicated (and slightly changed)
Expand All @@ -30,13 +39,10 @@ public function view() {
if (!isset($_REQUEST['MUUsource']) or $_REQUEST['MUUsource'] == '')
{ $this->_message = __("You didn't choose a source, perhaps you don't have any sections with an upload field in them?"); $this->__response(); }

if (($section_id = $this->getSectionID()) === NULL)
{ $this->_message = __('The Section you are looking, <code>%s</code> for could not be found.', $this->_context['section_handle']); $this->__response(); }
$sectionManager = new SectionManager($this->_Parent);

$section_id = $sectionManager->fetchIDFromHandle(General::sanitize($_REQUEST['MUUsource']));

if(!$section = $sectionManager->fetch($section_id))
Administration::instance()->customError(__('Unknown Section'), __('The Section you are looking, <code>%s</code> for could not be found.', $this->_context['section_handle']));

$entryManager = new EntryManager($this->_Parent);

$entry =& $entryManager->create();
Expand Down
41 changes: 41 additions & 0 deletions events/event.mass_upload_utility_entry.php
@@ -0,0 +1,41 @@
<?php

require_once(TOOLKIT . '/class.event.php');

Class EventMass_Upload_Utility_Entry extends Event{

const ROOTELEMENT = 'response';

public $eParamFILTERS = array();

public static function about(){
return array(
'name' => 'Mass Upload Utility: Create an Entry',
'author' => array(
'name' => 'Scott Tesoriere',
'website' => 'http://tesoriere.com',
'email' => 'scott@tesoriere.com'),
'version' => '1.0',
'release-date' => '2009-11-13T11:35:07+00:00',
'trigger-condition' => 'action[api]');
}

public static function getSource(){
return contentExtensionMassUploadUtilityIndex::getSectionId();
}

public static function documentation(){
return '';
}

public function load(){
return $this->__trigger();
}

protected function __trigger(){

include(TOOLKIT . '/events/event.section.php');
return $result;
}

}

0 comments on commit e84cc5d

Please sign in to comment.