Skip to content

Commit

Permalink
Updated extension for symphony 2.3, adhoc test passed
Browse files Browse the repository at this point in the history
Signed-off-by: PascalPiche <pascal@nitriques.com>
  • Loading branch information
PascalPiche committed Jun 12, 2012
1 parent 2d89833 commit a8e2357
Showing 1 changed file with 5 additions and 52 deletions.
57 changes: 5 additions & 52 deletions extension.driver.php
Expand Up @@ -10,38 +10,11 @@
*
* Duplicate Section Decorator/Extension
* Permits admin to duplicate/clone a section data model
* @author nicolasbrassard
* @author nicolasbrassard, pascalpiche
*
*/
class extension_duplicate_section extends Extension {

/*
* Name of the extension
* @var string
*
const EXT_NAME = 'Duplicate Section';
/*
* Credits for the extension
*
public function about() {
return array(
'name' => self::EXT_NAME,
'version' => '1.0',
'release-date' => '2011-07-08',
'author' => array(
'name' => 'Solutions Nitriques',
'website' => 'http://www.nitriques.com/open-source/',
'email' => 'open-source (at) nitriques.com'
),
'description' => __('Easily duplicate/clone your section parameters and fields'),
'compatibility' => array(
'2.2.1' => true,
'2.2' => true
)
);
}*/

/**
*
* Symphony utility function that permits to
Expand All @@ -50,11 +23,6 @@ public function about() {
*/
public function getSubscribedDelegates(){
return array(
array(
'page' => '/backend/',
'delegate' => 'AppendElementBelowView',
'callback' => 'appendElementBelowView'
),
array(
'page' => '/backend/',
'delegate' => 'AdminPagePreGenerate',
Expand All @@ -65,7 +33,7 @@ public function getSubscribedDelegates(){

/**
*
* Delegate fired when it's time to append elements into the backend page
* Fired on each backend page, detect when it's time to append elements into the backend page
* @param array $context
*/
public function appendElementBelowView(Array &$context) {
Expand All @@ -80,7 +48,6 @@ public function appendElementBelowView(Array &$context) {
'id' => 'duplicate-section'
));


$btn = new XMLElement('button', __('Clone'), array(
'id' => 'duplicate-section-clone',
'class' => 'button',
Expand All @@ -99,7 +66,6 @@ public function appendElementBelowView(Array &$context) {
$div_action->appendChild($button_wrap);
}
}

}

/**
Expand Down Expand Up @@ -128,31 +94,25 @@ private static function getChildrenWithClass($rootElement, $tagName, $className)
return $res;
}
}

return NULL;
}


/**
*
* Method that handles the click of the 'clone' button
* Delegate AdminPagePreGenerate that handles the click of the 'clone' button and append the button in the form
* @param array $context
*/
public function __action(Array &$context) {

self::appendElementBelowView($context);

// if the clone button was hit
if (is_array($_POST['action']) && isset($_POST['action']['clone'])) {
$c = Administration::instance()->getPageCallback();

$section_id = $c['context'][1];

/* Old code for symphony 2.2
$sm = new SectionManager($context['parent']);
$fm = new FieldManager($context['parent']);
$section = $sm->fetch($section_id);
*/

$section = SectionManager::fetch($section_id);

if ($section != null) {
Expand All @@ -166,9 +126,6 @@ public function __action(Array &$context) {
$section_settings['handle'] = Lang::createHandle($section_settings['name']);

// save it
/* Old code for symphony 2.2
$new_section_id = $sm->add($section_settings);
*/
$new_section_id = SectionManager::add($section_settings);

// if the create new section was successful
Expand All @@ -194,10 +151,6 @@ public function __action(Array &$context) {
$fs['parent_section'] = $new_section_id;

// create the new field

/* Old code for symphony 2.2
$f = $fm->create($fs['type']);
*/
$f = FieldManager::create($fs['type']);

// set its settings
Expand Down

0 comments on commit a8e2357

Please sign in to comment.