[pLog-svn] r5769 - in plog/trunk: class/action/admin class/view/admin templates/admin
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Wed Aug 1 17:02:04 EDT 2007
Author: oscar
Date: 2007-08-01 17:02:03 -0400 (Wed, 01 Aug 2007)
New Revision: 5769
Added:
plog/trunk/templates/admin/statistics_table.template
Modified:
plog/trunk/class/action/admin/admindeletereferreraction.class.php
plog/trunk/class/action/admin/adminstatisticsaction.class.php
plog/trunk/class/view/admin/adminreferrersview.class.php
plog/trunk/templates/admin/statistics.template
Log:
Implemented the ajax stuff for the referrers page.
Modified: plog/trunk/class/action/admin/admindeletereferreraction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeletereferreraction.class.php 2007-08-01 20:39:07 UTC (rev 5768)
+++ plog/trunk/class/action/admin/admindeletereferreraction.class.php 2007-08-01 21:02:03 UTC (rev 5769)
@@ -44,6 +44,22 @@
function perform()
{
+ $results = $this->_deleteReferrers();
+
+ $this->_view = new AdminReferrersView( $this->_blogInfo );
+ if( $results["errorMessage"] != "" ) $this->_view->setErrorMessage( $results["errorMessage"] );
+ if( $results["successMessage"] != "" ) $this->_view->setSuccessMessage( $results["successMessage"] );
+ $this->setCommonData();
+
+ // better to return true if everything fine
+ return true;
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function _deleteReferrers()
+ {
// collect the data and call the right method...
if( $this->_mode == "deleteReferrer" ) {
$this->_referrerId = $this->_request->getValue( "referrerId" );
@@ -51,18 +67,8 @@
$this->_referrerIds[] = $this->_referrerId;
}
else
- $this->_referrerIds = $this->_request->getValue( "referrerIds" );
-
- $this->_deleteReferrers();
-
- return true;
- }
-
- /**
- * Carries out the specified action
- */
- function _deleteReferrers()
- {
+ $this->_referrerIds = $this->_request->getValue( "referrerIds" );
+
$referrers = new Referers();
$errorMessage = "";
$successMessage = "";
@@ -97,16 +103,20 @@
if( $clearCache ) {
// clear the cache if needed
- CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
+ CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
}
- $this->_view = new AdminReferrersView( $this->_blogInfo );
- if( $errorMessage != "" ) $this->_view->setErrorMessage( $errorMessage );
- if( $successMessage != "" ) $this->_view->setSuccessMessage( $successMessage );
- $this->setCommonData();
+ return( Array( "errorMessage" => $errorMessage, "successMessage" => $successMessage ));
+ }
- // better to return true if everything fine
- return true;
- }
+ function performAjax()
+ {
+ $results = $this->_deleteReferrers();
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
+ $this->_view = new AdminAjaxView( $this->_blogInfo );
+ $this->_view->setMessage( $results );
+ $this->_view->setSuccess( true );
+ }
}
?>
\ No newline at end of file
Modified: plog/trunk/class/action/admin/adminstatisticsaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminstatisticsaction.class.php 2007-08-01 20:39:07 UTC (rev 5768)
+++ plog/trunk/class/action/admin/adminstatisticsaction.class.php 2007-08-01 21:02:03 UTC (rev 5769)
@@ -39,4 +39,4 @@
return true;
}
}
-?>
+?>
\ No newline at end of file
Modified: plog/trunk/class/view/admin/adminreferrersview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminreferrersview.class.php 2007-08-01 20:39:07 UTC (rev 5768)
+++ plog/trunk/class/view/admin/adminreferrersview.class.php 2007-08-01 21:02:03 UTC (rev 5769)
@@ -12,29 +12,33 @@
function AdminReferrersView( $blogInfo )
{
- $this->AdminTemplatedView( $blogInfo, "statistics" );
+ $r =& Request::getRequest();
+ if( $r->isTableOnly())
+ $this->AdminTemplatedView( $blogInfo, "statistics_table" );
+ else
+ $this->AdminTemplatedView( $blogInfo, "statistics" );
}
function render()
{
+ // get the current page
+ $this->_page = $this->getCurrentPageFromRequest();
+
$referers = new Referers();
$totalReferers = $referers->getBlogTotalReferers( $this->_blogInfo->getId());
- // get the current page
- $this->_page = $this->getCurrentPageFromRequest();
+ // calculate the links to the different pages
+ $pager = new Pager( "?op=Stats&page=",
+ $this->_page,
+ $totalReferers,
+ DEFAULT_ITEMS_PER_PAGE );
$blogReferers = $referers->getBlogReferers( $this->_blogInfo->getId(),
- $this->_page,
+ $pager->getCurrentPage(),
DEFAULT_ITEMS_PER_PAGE );
if( !$blogReferers ) {
$blogReferers = Array();
}
-
- // calculate the links to the different pages
- $pager = new Pager( "?op=Stats&page=",
- $this->_page,
- $totalReferers,
- DEFAULT_ITEMS_PER_PAGE );
$this->setValue( "referrers", $blogReferers );
$this->setValue( "pager", $pager );
Modified: plog/trunk/templates/admin/statistics.template
===================================================================
--- plog/trunk/templates/admin/statistics.template 2007-08-01 20:39:07 UTC (rev 5768)
+++ plog/trunk/templates/admin/statistics.template 2007-08-01 21:02:03 UTC (rev 5769)
@@ -6,55 +6,19 @@
var t = new Lifetype.UI.TableEffects( "list" );
t.stripe();
t.highlightRows();
- });
+
+ // reload the list when successfully deleting an item and processing one of the forms
+ Lifetype.Forms.Events.performRequestSuccessEvent.subscribe( Lifetype.UI.AjaxPager.reload );
+ Lifetype.Forms.Events.formProcessorSuccessEvent.subscribe( Lifetype.UI.AjaxPager.reload );
+});
{/literal}
</script>
- <form id="postStats" action="admin.php" method="post">
- <div id="list">
- {include file="$admintemplatepath/successmessage.template"}
- {include file="$admintemplatepath/errormessage.template"}
- <table id="list" class="info" summary="{$locale->tr("Stats")}">
- <thead>
- <tr>
- <th><input class="checkbox" type="checkbox" name="all" id="all" value="1" onclick="Lifetype.Forms.toggleAllChecks('postStats');" /></th>
- <th style="width:65%;">{$locale->tr("referrer")}</th>
- <th style="width:15%;">{$locale->tr("hits")}</th>
- <th style="width:10%;">{$locale->tr("date")}</th>
- <th style="width:10%;">{$locale->tr("actions")}</th>
- </tr>
- </thead>
- {if $referrers}
- <tbody>
- {foreach from=$referrers item=referrer}
- <tr>
- <td>
- <input class="checkbox" type="checkbox" name="referrerIds[{$referrer->getId()}]" id="checks_1" value="{$referrer->getId()}" />
- </td>
- <td class="col_highlighted">
- <a href="{$referrer->getUrl()}">{$referrer->getUrl()|utf8_wordwrap:55:"<br/>":true}</a>
- </td>
- <td>
- {$referrer->getHits()}
- </td>
- <td>
- {assign var=date value=$referrer->getDateObject()}
- {$locale->formatDate($date)}
- </td>
- <td>
- <div class="list_action_button">
- {check_perms perm=update_blog_stats}
- <a href="?op=deleteReferrer&referrerId={$referrer->getId()}"><img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete_trackback")}" /></a>
- {/check_perms}
- </div>
- </td>
- </tr>
- {/foreach}
- </tbody>
- {/if}
- </table>
+<form id="postStats" action="admin.php" method="post" onSubmit="Lifetype.Forms.performRequest(this);return(false);">
+{include file="$admintemplatepath/viewvalidateajax.template"}
+<div id="list">
+{include file="$admintemplatepath/statistics_table.template"}
</div>
<div id="list_action_bar">
- {adminpager style="list"}
{check_perms perm=update_blog_stats}
<input type="submit" name="delete" value="{$locale->tr("delete")}" class="submit" />
<input type="hidden" name="op" value="deleteReferrers" />
Added: plog/trunk/templates/admin/statistics_table.template
===================================================================
--- plog/trunk/templates/admin/statistics_table.template (rev 0)
+++ plog/trunk/templates/admin/statistics_table.template 2007-08-01 21:02:03 UTC (rev 5769)
@@ -0,0 +1,40 @@
+<table id="statsList" class="info" summary="{$locale->tr("Stats")}">
+ <thead>
+ <tr>
+ <th><input class="checkbox" type="checkbox" name="all" id="all" value="1" onclick="Lifetype.Forms.toggleAllChecks('postStats');" /></th>
+ <th style="width:65%;">{$locale->tr("referrer")}</th>
+ <th style="width:15%;">{$locale->tr("hits")}</th>
+ <th style="width:10%;">{$locale->tr("date")}</th>
+ <th style="width:10%;">{$locale->tr("actions")}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {foreach from=$referrers item=referrer}
+ <tr>
+ <td>
+ <input class="checkbox" type="checkbox" name="referrerIds[{$referrer->getId()}]" id="checks_1" value="{$referrer->getId()}" />
+ </td>
+ <td class="col_highlighted">
+ <a href="{$referrer->getUrl()}">{$referrer->getUrl()|utf8_wordwrap:55:"<br/>":true}</a>
+ </td>
+ <td>
+ {$referrer->getHits()}
+ </td>
+ <td>
+ {assign var=date value=$referrer->getDateObject()}
+ {$locale->formatDate($date)}
+ </td>
+ <td>
+ <div class="list_action_button">
+ {check_perms perm=update_blog_stats}
+ <a href="?op=deleteReferrer&referrerId={$referrer->getId()}" onClick="Lifetype.Forms.performRequest(this);return(false)">
+ <img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete_trackback")}" />
+ </a>
+ {/check_perms}
+ </div>
+ </td>
+ </tr>
+ {/foreach}
+ </tbody>
+</table>
+{adminpagerajax style=list}
\ No newline at end of file
More information about the pLog-svn
mailing list