Skip to content

Commit

Permalink
removed addPageTypesToPage()-function and deletePageTypes() since pag…
Browse files Browse the repository at this point in the history
…e types are no longer stored in a second column in the database, but in one XML-file
  • Loading branch information
kanduvisla committed Apr 3, 2012
1 parent 62f51d8 commit 4ac380a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
42 changes: 21 additions & 21 deletions symphony/content/content.blueprintspages.php
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,27 @@ public function __actionEdit() {
// Clean up type list
$types = preg_split('/\s*,\s*/', $fields['type'], -1, PREG_SPLIT_NO_EMPTY);
$types = @array_map('trim', $types);

/**
* Just before the page's types are saved into `tbl_pages_types`.
* Use with caution as no further processing is done on the `$types`
* array to prevent duplicate `$types` from occurring (ie. two index
* page types). Your logic can use the PageManger::hasPageTypeBeenUsed
* function to perform this logic.
*
* @delegate PageTypePreCreate
* @since Symphony 2.2
* @see toolkit.PageManager#hasPageTypeBeenUsed
* @param string $context
* '/blueprints/pages/'
* @param integer $page_id
* The ID of the Page that was just created or updated
* @param array $types
* An associative array of the types for this page passed by reference.
*/
Symphony::ExtensionManager()->notifyMembers('PageTypePreCreate', '/blueprints/pages/', array('page_id' => $page_id, 'types' => &$types));

$fields['types'] = $types;
unset($fields['type']);

$fields['parent'] = ($fields['parent'] != __('None') ? $fields['parent'] : null);
Expand Down Expand Up @@ -943,27 +964,6 @@ public function __actionEdit() {

// Only proceed if there was no errors saving/creating the page
if(empty($this->_errors)) {
/**
* Just before the page's types are saved into `tbl_pages_types`.
* Use with caution as no further processing is done on the `$types`
* array to prevent duplicate `$types` from occurring (ie. two index
* page types). Your logic can use the PageManger::hasPageTypeBeenUsed
* function to perform this logic.
*
* @delegate PageTypePreCreate
* @since Symphony 2.2
* @see toolkit.PageManager#hasPageTypeBeenUsed
* @param string $context
* '/blueprints/pages/'
* @param integer $page_id
* The ID of the Page that was just created or updated
* @param array $types
* An associative array of the types for this page passed by reference.
*/
Symphony::ExtensionManager()->notifyMembers('PageTypePreCreate', '/blueprints/pages/', array('page_id' => $page_id, 'types' => &$types));

// Assign page types:
PageManager::addPageTypesToPage($page_id, $types);

// Find and update children:
if($this->_context[0] == 'edit') {
Expand Down
30 changes: 15 additions & 15 deletions symphony/lib/toolkit/class.pagemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,9 @@ private function __generatePageXML($fields)
}

// Generate datasources-xml:
//print_r($fields['data_sources']);
$datasources = empty($fields['data_sources']) ? '' :
'<datasource>'.implode('</datasource><datasource>', explode(',', $fields['data_sources'])) .'</datasource>';

//echo '<xmp>'.$datasources.'</xmp>';

//die();

// Generate events-xml:
$events = empty($fields['events']) ? '' :
'<event>'.implode('</event><event>', explode(',', $fields['events'])) .'</event>';
Expand Down Expand Up @@ -219,10 +214,10 @@ public static function fetchIDFromHandle($handle){
* An array of page types
* @return boolean
*/
public static function addPageTypesToPage($page_id = null, array $types) {
/* public static function addPageTypesToPage($page_id = null, array $types) {
if(is_null($page_id)) return false;
PageManager::deletePageTypes($page_id);
PageManager::deletePageTypes($page_id);*/

/* foreach ($types as $type) {
Symphony::Database()->insert(
Expand All @@ -234,7 +229,7 @@ public static function addPageTypesToPage($page_id = null, array $types) {
);
}*/

$_pages = self::fetch(false, array(), array(
/* $_pages = self::fetch(false, array(), array(
'id' => array('eq', $page_id)
));
Expand All @@ -244,7 +239,7 @@ public static function addPageTypesToPage($page_id = null, array $types) {
self::__generatePageXML($_page);
return true;
}
}*/


/**
Expand Down Expand Up @@ -409,11 +404,16 @@ public static function edit($page_id, array $fields, $delete_types = false){
$_data[$key] = $value;
}

self::__generatePageXML($_data);
if($delete_types) {
$_data['types'] = array();
}

if($delete_types) {
PageManager::deletePageTypes($page_id);
}
if(isset($fields['types']))
{
$_data['types'] = $fields['types'];
}

self::__generatePageXML($_data);

return true;

Expand Down Expand Up @@ -528,7 +528,7 @@ public static function delete($page_id = null, $delete_files = true) {
* The ID of the Page that should be deleted.
* @return boolean
*/
public static function deletePageTypes($page_id = null) {
/* public static function deletePageTypes($page_id = null) {
if(is_null($page_id)) return false;
// return Symphony::Database()->delete('tbl_pages_types', sprintf(" `page_id` = %d ", $page_id));
Expand All @@ -538,7 +538,7 @@ public static function deletePageTypes($page_id = null) {
self::__generatePageXML($_page);
return true;
}
}*/

/**
* Given a Page's `$path` and `$handle`, this function will remove
Expand Down

0 comments on commit 4ac380a

Please sign in to comment.