Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
kstenschke committed May 23, 2015
2 parents c82899e + 7e927ee commit 00b8026
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 5 deletions.
4 changes: 2 additions & 2 deletions application/controllers/admin/element_definition.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct()


/**
* Outputs the Definiton list
* Outputs the Definition list
*
*/
function index()
Expand Down Expand Up @@ -154,7 +154,7 @@ function get_element_definition_list()


/**
* Returns the list of definition for a given parent
* Returns the list definition for a given parent
* Used to build the tabs of elements definitions in parents panels (page, article)
*
* @returns String JSON object of all definitions containing elements
Expand Down
40 changes: 38 additions & 2 deletions application/controllers/admin/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ public function remove_link()

/**
* Deletes one page
* @note For the moment, this method doesn't delete the linked articles, wich will stay in database as phantom
* @note For the moment, this method doesn't delete the linked articles, which will stay in database as phantom
*
* @param int Page ID
*
Expand All @@ -973,7 +973,7 @@ public function delete($id)
{
$affected_rows = $this->page_model->delete($id);

// Delete was successfull
// Delete was successful
if ($affected_rows > 0)
{
// Clean URL table
Expand Down Expand Up @@ -1012,6 +1012,42 @@ public function delete($id)
// ------------------------------------------------------------------------


/**
* Remove deleted page records and relations to it from DB.
*
* @return int
*/
public function remove_deleted_pages()
{
// Remove relations of deleted pages
foreach(array('page_article', 'page_lang', 'page_media') as $relation)
{
$this->{$this->db_group}->query("
DELETE FROM $relation
WHERE $relation.id_page IN (SELECT id_page FROM page WHERE page.id_menu = 0 AND page.id_parent = 0)"
);
}
// Remove relation where page is parent
foreach(array('element') as $relation)
$this->{$this->db_group}->query("
DELETE FROM $relation
WHERE $relation.parent = 'page' AND $relation.id_parent IN (SELECT id_page FROM page WHERE page.id_menu = 0 AND page.id_parent = 0)"
);

// Remove deleted pages
$this->{$this->db_group}->query('
DELETE FROM page
WHERE id_menu=0
AND id_parent = 0'
);

return $this->{$this->db_group}->affected_rows();
}


// ------------------------------------------------------------------------


protected function _get_resource_name($type, $element, $id)
{
return $type . '/' . $element . '/' . $id;
Expand Down
4 changes: 4 additions & 0 deletions application/language/en/admin_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,7 @@
$lang['ionize_title_check_lang'] = 'Check Languages';
$lang['ionize_title_check_folder'] = 'Folder';
$lang['ionize_title_check_page_level'] = 'Pages Levels';
$lang['ionize_title_remove_deleted_pages'] = 'Clean Pages Tree';
$lang['ionize_title_check_article_context'] = 'Articles Contexts';
$lang['ionize_title_check_views'] = 'Check Views';
$lang['ionize_title_rebuild_urls'] = 'Rebuild URLs';
Expand All @@ -1236,6 +1237,7 @@
$lang['ionize_text_rebuild_urls'] = 'Rebuilds the whole pages and articles URLs.<br/> Removes the old URLs in the URL table.';
$lang['ionize_text_check_lang'] = 'Check if all languages defined in DB are set in the config file.<br/> Corrects the config file if needed.';
$lang['ionize_text_check_page_level'] = 'Checks the page level integrity and correct if needed.';
$lang['ionize_text_remove_deleted_pages'] = 'Removes records of deleted pages from the DB.';
$lang['ionize_text_check_article_context'] = 'Checks if all articles which have only one page context have the page as "Main Parent".<br/>Corrects if needed.';
$lang['ionize_text_clean_media'] = 'Removes the non used medias from media tables. Does not remove any file.';
$lang['ionize_text_broken_media_links'] = 'Lists the media files which are in media table (means used) but not found on the server (file missing).';
Expand All @@ -1245,11 +1247,13 @@
$lang['ionize_message_check_corrected'] = ' corrected.';
$lang['ionize_message_check_ok'] = 'OK';
$lang['ionize_message_check_folder_nok'] = 'No Write rights';
$lang['ionize_message_removed_deleted_pages'] = ' page records removed';
$lang['ionize_message_message_no_write_rights'] = 'No Write rights';
$lang['ionize_message_nb_media_cleaned'] = ' media cleaned';
$lang['ionize_message_no_broken_media_links'] = 'No broken media found';
$lang['ionize_message_no_unused_media'] = 'No unused media found';
$lang['ionize_message_thumbs_deleted'] = 'Thumbnails deleted';
$lang['ionize_message_no_deleted_pages'] = 'No deleted pages found';
$lang['ionize_label_square_crop_area'] = 'Square crop area';
$lang['ionize_label_top_left'] = 'top-left';
$lang['ionize_label_middle'] = 'middle';
Expand Down
30 changes: 30 additions & 0 deletions application/models/page_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,36 @@ public function get_roles_select()
// ------------------------------------------------------------------------


/**
* Remove deleted page records from DB.
*
* @return int
*/
public function remove_deleted_pages()
{
// Remove relations of deleted pages
foreach(array('page_article', 'page_lang', 'page_media') as $relation)
{
$this->{$this->db_group}->query("
DELETE FROM $relation
WHERE $relation.id_page IN (SELECT id_page FROM page WHERE page.id_menu = 0 AND page.id_parent = 0)"
);
}

// Remove deleted pages
$sql = 'DELETE FROM page
WHERE id_menu = 0
AND id_parent = 0';

$this->{$this->db_group}->query($sql);

return $this->{$this->db_group}->affected_rows();
}


// ------------------------------------------------------------------------


/**
* Get the current groups from parent element
*
Expand Down
9 changes: 9 additions & 0 deletions themes/admin/views/system/check.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@
</td>
<td class="middle"><?php echo lang('ionize_text_check_page_level'); ?></td>
</tr>
<!-- Clean pages tree: remove deleted page records -->
<tr>
<td class="middle pr10">
<a class="button light check-btn" data-href="page/remove_deleted_pages">
<i class="icon-folder"></i><?php echo lang('ionize_title_remove_deleted_pages'); ?>
</a>
</td>
<td class="middle"><?php echo lang('ionize_text_remove_deleted_pages'); ?></td>
</tr>
<!-- Media table -->
<tr>
<td class="middle pr10">
Expand Down
2 changes: 1 addition & 1 deletion themes/admin/views/toolboxes/page_toolbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
*/

// Check if at least on Item instance exists (same for Content Element Definition)
// Check if at least one Item instance exists (same for Content Element Definition)
$is_item_empty = $this->base_model->is_empty(NULL, 'item');
$is_element_empty = $this->base_model->is_empty(NULL, 'element_definition');

Expand Down

0 comments on commit 00b8026

Please sign in to comment.