Skip to content

Commit

Permalink
Revises Exponent menu and adds some additional methods to clear cache…
Browse files Browse the repository at this point in the history
…s individually or all at once. Adds methods/menu items to try to fix some common database problems. Also moves ALL functions (found in Exponent menu) from the administration module to the controller.

[#208 state:resolved][#179 state:resolved][#143]
  • Loading branch information
dleffler committed Jun 17, 2011
1 parent da9cc4b commit b409fc6
Show file tree
Hide file tree
Showing 10 changed files with 666 additions and 48 deletions.

Large diffs are not rendered by default.

100 changes: 77 additions & 23 deletions framework/modules/administration/menus/admin.php
Expand Up @@ -83,7 +83,7 @@
'itemdata'=>array(
array(
'classname' => 'moreinfo',
'text'=>"Exponent Version : ".$my_version."<br />Release level : ".$my_type."<br />Release date : ".date("F-d-Y",EXPONENT_VERSION_BUILDDATE)."<br />PHP Version : ".phpversion(),"disabled"=>true
'text'=>"Exponent Version : ".$my_version."<br />Release level : ".$my_type."<br />Release date : ".date("F-d-Y",EXPONENT_VERSION_BUILDDATE),"disabled"=>true
)
)
)
Expand Down Expand Up @@ -184,17 +184,9 @@
array(
'text' => (DEVELOPMENT)?expLang::gettext('Turn Error Reporting off'):expLang::gettext('Turn Error Reporting on'),
'classname' => (DEVELOPMENT)?'develop_on_red':'develop_off',
'url' => makeLink(array(
'module' => 'administrationmodule',
'action' => 'toggle_dev'
))
),
array(
'text' => (MINIFY)?expLang::gettext('Turn Minification off'):expLang::gettext('Turn Minification on'),
'classname' => (MINIFY)?'develop_on_green':'develop_off',
'url' => makeLink(array(
'module' => 'administration',
'action' => 'toggle_minify'
'action' => 'toggle_dev'
))
),
array(
Expand All @@ -205,8 +197,8 @@
array(
'text' => $i18n['install_tables'],
'url' => makeLink(array(
'module' => 'administrationmodule',
'action' => 'installtables'
'module' => 'administration',
'action' => 'install_tables'
))
),
// array(
Expand All @@ -224,8 +216,22 @@
array(
'text' => $i18n['optimize_database'],
'url' => makeLink(array(
'module' => 'administrationmodule',
'action' => 'optimizedatabase'
'module' => 'administration',
'action' => 'optimize_database'
))
),
array(
'text' => 'Repair Database',
'url' => makeLink(array(
'module' => 'administration',
'action' => 'fix_database'
))
),
array(
'text' => 'Reset Sessions Table',
'url' => makeLink(array(
'module' => 'administration',
'action' => 'fix_sessions'
))
),
array(
Expand Down Expand Up @@ -292,7 +298,7 @@
'text' => $i18n['upload_extension'],
'classname'=>'fileuploader',
'url' => makeLink(array(
'module' => 'administrationmodule',
'module' => 'administration',
'action' => 'upload_extension'
))
),
Expand All @@ -316,19 +322,67 @@
)
),
array(
'text' => $i18n['clear_smarty'],
'classname' => 'remove',
'url' => makeLink(array(
'module' => 'administrationmodule',
'action' => 'clear_smarty_cache'
))
),
'text' => expLang::gettext('System Cache'),
'submenu' => array(
'id' => 'cache',
'itemdata' => array(
array(
'text' => (MINIFY)?expLang::gettext('Turn Minification off'):expLang::gettext('Turn Minification on'),
'classname' => (MINIFY)?'develop_on_green':'develop_off',
'url' => makeLink(array(
'module' => 'administration',
'action' => 'toggle_minify'
))
),
array(
'text' => $i18n['clear_smarty'],
'classname' => 'remove',
'url' => makeLink(array(
'module' => 'administration',
'action' => 'clear_smarty_cache'
))
),
array(
'text' => expLang::gettext('Clear CSS/Minify Cache'),
'classname' => 'remove',
'url' => makeLink(array(
'module' => 'administration',
'action' => 'clear_css_cache'
))
),
array(
'text' => expLang::gettext('Clear Image Cache'),
'classname' => 'remove',
'url' => makeLink(array(
'module' => 'administration',
'action' => 'clear_image_cache'
))
),
array(
'text' => expLang::gettext('Clear RSS/Podcast Cache'),
'classname' => 'remove',
'url' => makeLink(array(
'module' => 'administration',
'action' => 'clear_rss_cache'
))
),
array(
'text' => expLang::gettext('Clear All Caches'),
'classname' => 'remove',
'url' => makeLink(array(
'module' => 'administration',
'action' => 'clear_all_caches'
))
),
)
)
),
array(
'text' => (MAINTENANCE_MODE)?expLang::gettext('Turn Maintenance Mode off'):expLang::gettext('Turn Maintenance Mode on'),
'classname' => (MAINTENANCE_MODE)?'develop_on_red':'develop_off',
'text' => $i18n['toggle_maint'],
'url' => makeLink(array(
'module' => 'administrationmodule',
'module' => 'administration',
'action' => 'toggle_maintenance'
))
)
Expand Down
@@ -0,0 +1,66 @@
{*
* Copyright (c) 2004-2011 OIC Group, Inc.
* Written and Designed by James Hunt
*
* This file is part of Exponent
*
* Exponent is free software; you can redistribute
* it and/or modify it under the terms of the GNU
* General Public License as published by the Free
* Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* GPL: http://www.gnu.org/licenses/gpl.txt
*
*}

{css unique="install-tables" corecss="tables"}

{/css}

<div class="form_header">
<h1>Installing and Upgrading Database Tables</h1>
<p>
{$_TR.form_header}
</p>
</div>
<table cellpadding="2" cellspacing="0" width="100%" border="0" class="exp-skin-table">
<thead>
<tr>
<th>Table Name</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{foreach from=$status key=table item=statusnum}
<tr class="{cycle values='odd,even'}">
<td>
{$table}
</td>
<td>
{if $statusnum == $smarty.const.TMP_TABLE_EXISTED}
<div style="color: blue; font-weight: bold">
Exists
</div>
{elseif $statusnum == $smarty.const.TMP_TABLE_INSTALLED}
<div style="color: green; font-weight: bold">
Succeeded
</div>
{elseif $statusnum == $smarty.const.TMP_TABLE_FAILED}
<div style="color: red; font-weight: bold">
Failed
</div>
{elseif $statusnum == $smarty.const.TMP_TABLE_ALTERED}
<div style="color: green; font-weight: bold">
Altered Existing
</div>
{elseif $statusnum == $smarty.const.TABLE_ALTER_FAILED}
<div style="color: red; font-weight: bold">
Altering Failed
</div>
{/if}
</td>
</tr>
{/foreach}
<tbody>
</table>
Expand Up @@ -22,7 +22,7 @@
<h1>Deprecated/Unused Tables</h1>
<h2>{$unused_tables|@count} unused tables found</h2>
<p>
The list of tables below are ones that are no long used by Exponent. These tables probably
The list of tables below are ones that are no longer used by Exponent. These tables probably
aren't hurting anything. If you do not have a good idea of what a table does or why it is there
it is probably best to just leave it.
</p>
Expand Down
@@ -0,0 +1,37 @@
{*
* Copyright (c) 2004-2011 OIC Group, Inc.
* Written and Designed by James Hunt
*
* This file is part of Exponent
*
* Exponent is free software; you can redistribute
* it and/or modify it under the terms of the GNU
* General Public License as published by the Free
* Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* GPL: http://www.gnu.org/licenses/gpl.txt
*
*}

{css unique="optimize-database" corecss="tables"}

{/css}

<h1>Optimized the Database Tables</h1>
<table class="exp-skin-table" cellspacing="0" cellpadding="0" border="0" width="100%">
<thead>
<tr>
<th>Table Name</th>
<th>Size of Data (kb)</th>
</tr>
</thead>
<tbody>
{foreach from=$before key=table item=info}
<tr class="{cycle values="even, odd"}">
<td>{$table}</td>
<td align="right">{math format="%.3f" equation="x / 1024" x=$info->data_total} {$_TR.kb}</td>
</tr>
{/foreach}
</tbody>
</table>
@@ -0,0 +1,24 @@
{*
* Copyright (c) 2004-2011 OIC Group, Inc.
* Written and Designed by James Hunt
*
* This file is part of Exponent
*
* Exponent is free software; you can redistribute
* it and/or modify it under the terms of the GNU
* General Public License as published by the Free
* Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* GPL: http://www.gnu.org/licenses/gpl.txt
*
*}

<div class="info-header">
<div class="related-actions">
{help text="Get Help Uploading New Extensions" module="upload-extension"}
</div>
<h1>Upload new Extension</h1>
</div>
<div class="form_header"><h3>This form allows you to upload modules, themes, plugins, and views to the website. After you upload an archive containing an extension (or more) you will be shown a pre-installation summary page, outlining exactly what files will be installed where, and what each file contains (for security reasons).</h3></div>
{$form_html}
5 changes: 3 additions & 2 deletions install/upgrades/clear_cache.php
Expand Up @@ -48,14 +48,14 @@ function upgrade() {
// work our way through all the tmp files and remove them
if (!defined('SYS_FILES')) include_once(BASE.'subsystems/files.php');
$files = array(
BASE.'tmp/cache', // not used?? FIXME
BASE.'tmp/mail', // not used?? FIXME
BASE.'tmp/pods', // not used?? FIXME
BASE.'tmp/css', // exponent minified css cache
BASE.'tmp/minify', // minify cache
BASE.'tmp/pixidou', // (new) pixidou cache
BASE.'tmp/rsscache', // magpierss cache
BASE.'tmp/views_c', // smarty cache
BASE.'tmp/cache', // alternate smarty cache
);

// delete the files.
Expand All @@ -68,7 +68,8 @@ function upgrade() {
}

// phpThumb cache includes subfolders
if (file_exists(BASE.'tmp/img_cache')) $this->cleardir_recursive(BASE.'tmp/img_cache');
// if (file_exists(BASE.'tmp/img_cache')) $this->cleardir_recursive(BASE.'tmp/img_cache');
if (file_exists(BASE.'tmp/img_cache')) exponent_files_remove_files_in_directory(BASE.'tmp/img_cache');

return "Caches were cleared.<br>".$errors." files could not be removed.";
}
Expand Down
31 changes: 23 additions & 8 deletions install/upgrades/fix_database.php
Expand Up @@ -53,11 +53,17 @@ function needed() {
function upgrade() {
global $db;

print_r("<pre>");
print_r("<h3>Some Error Conditions can NOT be repaired by this Procedure!</h3><br>");
print_r("<pre>");
// upgrade sectionref's that have lost their originals
print_r("<b>Searching for sectionrefs that have lost their originals</b><br><br>");
$sectionrefs = $db->selectObjects('sectionref',"is_original=0");
print_r("Found: ".count($sectionrefs)." copies (not originals)<br>");
if (count($sectionrefs)) {
print_r("Found: ".count($sectionrefs)." copies (not originals)<br>");
} else {
print_r("None Found: Good!<br>");
}
foreach ($sectionrefs as $sectionref) {
if ($db->selectObject('sectionref',"module='".$sectionref->module."' AND source='".$sectionref->source."' AND is_original='1'") == null) {
// There is no original for this sectionref so change it to the original
Expand All @@ -72,14 +78,19 @@ function upgrade() {
// upgrade sectionref's that point to missing sections (pages)
print_r("<b>Searching for sectionrefs pointing to missing sections/pages <br>to fix for the Recycle Bin</b><br><br>");
$sectionrefs = $db->selectObjects('sectionref',"refcount!=0");
$found = 0;
foreach ($sectionrefs as $sectionref) {
if ($db->selectObject('section',"id='".$sectionref->section."'") == null) {
// There is no section/page for sectionref so change the refcount
$sectionref->refcount = 0;
$db->updateObject($sectionref,"sectionref");
print_r("Fixed: ".$sectionref->module." - ".$sectionref->source."<br>");
$found += 1;
}
}
if (!$found) {
print_r("None Found: Good!<br>");
}
print_r("</pre>");

// FIXME Not needed when locationrefs are removed
Expand All @@ -95,7 +106,7 @@ function upgrade() {
$newLocRef->source = $sectionref->source;
$newLocRef->internal = $sectionref->internal;
$newLocRef->refcount = $sectionref->refcount;
$db->insertObject($newLocRef,"locationref");
$db->insertObject($newLocRef,'locationref');
print_r("Copied: ".$sectionref->module." - ".$sectionref->source."<br>");
}
}
Expand All @@ -104,16 +115,20 @@ function upgrade() {
print_r("<pre>");
// delete sectionref's & locationref's that have empty sources since they are dead
print_r("<b>Searching for unassigned modules (no source)</b><br><br>");
$sectionrefs = $db->selectObjects('sectionref',"source=''");
$sectionrefs = $db->selectObjects('sectionref','source=""');
if ($sectionrefs != null) {
print_r("Removing: ".count($sectionrefs)." sectionref empties (no source)<br>");
$db->delete('sectionref',"source=''");
print_r("Removing: ".count($sectionrefs)." empty sectionref's (no source)<br>");
$db->delete('sectionref','source=""');
} else {
print_r("No Empties Found: Good!<br>");
}
// FIXME Not needed when locationrefs are removed
$locationrefs = $db->selectObjects('locationref',"source=''");
$locationrefs = $db->selectObjects('locationref','source=""');
if ($locationrefs != null) {
print_r("Removing: ".count($locationrefs)." locationref empties (no source)<br>");
$db->delete('locationref',"source=''");
print_r("Removing: ".count($locationrefs)." empty locationref's (no source)<br>");
$db->delete('locationref','source=""');
} else {
print_r("No Empties Found: Good!<br>");
}
print_r("</pre>");

Expand Down

0 comments on commit b409fc6

Please sign in to comment.