diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index e1d4563a06a2d036336f712771a0c31fbab6aa43..ef918e24e89798d5bb2141e6fb656aeb9a8d4725 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -576,8 +576,8 @@ $listRoutes = array('userList' => 'MyList', 'editList' => 'EditList'); // Define static routes -- Controller/Action strings $staticRoutes = array( 'Admin/Config', 'Admin/DeleteExpiredSearches', 'Admin/EnableAutoConfig', - 'Admin/Home', 'Admin/Maintenance', 'Admin/Statistics', 'Alphabrowse/Home', - 'Author/Home', 'Author/Search', + 'Admin/Home', 'Admin/Maintenance', 'Admin/SocialStats', 'Admin/Statistics', + 'Alphabrowse/Home', 'Author/Home', 'Author/Search', 'Authority/Home', 'Authority/Record', 'Authority/Search', 'Browse/Author', 'Browse/Dewey', 'Browse/Era', 'Browse/Genre', 'Browse/Home', 'Browse/LCC', 'Browse/Region', 'Browse/Tag', 'Browse/Topic', diff --git a/module/VuFind/src/VuFind/Controller/AdminController.php b/module/VuFind/src/VuFind/Controller/AdminController.php index 93b78d5ae9c54cc54d74fd004a7cc9bd19e411c1..86d1b651abb8a969e1eda55792475c9115af736f 100644 --- a/module/VuFind/src/VuFind/Controller/AdminController.php +++ b/module/VuFind/src/VuFind/Controller/AdminController.php @@ -139,6 +139,20 @@ class AdminController extends AbstractBase return $view; } + /** + * Social statistics reporting + * + * @return \Zend\View\Model\ViewModel + */ + public function socialstatsAction() + { + $view = $this->createViewModel(); + $view->comments = $this->getTable('comments')->getStatistics(); + $view->favorites = $this->getTable('userresource')->getStatistics(); + $view->tags = $this->getTable('resourcetags')->getStatistics(); + return $view; + } + /** * Statistics reporting * diff --git a/module/VuFind/src/VuFind/Db/Table/Comments.php b/module/VuFind/src/VuFind/Db/Table/Comments.php index 41fc90718420cb8a04d829907a1ec7c0ecfa7619..5c412c9fbc35c14fb682972fafd9c02b0b246df6 100644 --- a/module/VuFind/src/VuFind/Db/Table/Comments.php +++ b/module/VuFind/src/VuFind/Db/Table/Comments.php @@ -26,6 +26,7 @@ * @link http://vufind.org Main Site */ namespace VuFind\Db\Table; +use Zend\Db\Sql\Expression; /** * Table Definition for comments @@ -105,4 +106,30 @@ class Comments extends Gateway $row->delete(); return true; } + + /** + * Get statistics on use of comments. + * + * @return array + */ + public function getStatistics() + { + $select = $this->sql->select(); + $select->columns( + array( + 'users' => new Expression( + 'COUNT(DISTINCT(?))', array('user_id'), + array(Expression::TYPE_IDENTIFIER) + ), + 'resources' => new Expression( + 'COUNT(DISTINCT(?))', array('resource_id'), + array(Expression::TYPE_IDENTIFIER) + ), + 'total' => new Expression('COUNT(*)') + ) + ); + $statement = $this->sql->prepareStatementForSqlObject($select); + $result = $statement->execute(); + return (array)$result->current(); + } } diff --git a/module/VuFind/src/VuFind/Db/Table/ResourceTags.php b/module/VuFind/src/VuFind/Db/Table/ResourceTags.php index b1085ed22fae07323f0e96c773703e4a27eb6f74..fb74c103bd7fc55673116c00c15639d3dd734a32 100644 --- a/module/VuFind/src/VuFind/Db/Table/ResourceTags.php +++ b/module/VuFind/src/VuFind/Db/Table/ResourceTags.php @@ -158,6 +158,32 @@ class ResourceTags extends Gateway return $this->select($callback); } + /** + * Get statistics on use of tags. + * + * @return array + */ + public function getStatistics() + { + $select = $this->sql->select(); + $select->columns( + array( + 'users' => new Expression( + 'COUNT(DISTINCT(?))', array('user_id'), + array(Expression::TYPE_IDENTIFIER) + ), + 'resources' => new Expression( + 'COUNT(DISTINCT(?))', array('resource_id'), + array(Expression::TYPE_IDENTIFIER) + ), + 'total' => new Expression('COUNT(*)') + ) + ); + $statement = $this->sql->prepareStatementForSqlObject($select); + $result = $statement->execute(); + return (array)$result->current(); + } + /** * Unlink rows for the specified resource. * diff --git a/module/VuFind/src/VuFind/Db/Table/UserResource.php b/module/VuFind/src/VuFind/Db/Table/UserResource.php index 4fef8686756c227f3ad163cd2e6909f5a055a1fa..a619cbfd1808323fdd2f947eb78ffc16b11cc69c 100644 --- a/module/VuFind/src/VuFind/Db/Table/UserResource.php +++ b/module/VuFind/src/VuFind/Db/Table/UserResource.php @@ -163,4 +163,34 @@ class UserResource extends Gateway // Delete the rows: $this->delete($callback); } + + /** + * Get statistics on use of lists. + * + * @return array + */ + public function getStatistics() + { + $select = $this->sql->select(); + $select->columns( + array( + 'users' => new Expression( + 'COUNT(DISTINCT(?))', array('user_id'), + array(Expression::TYPE_IDENTIFIER) + ), + 'lists' => new Expression( + 'COUNT(DISTINCT(?))', array('list_id'), + array(Expression::TYPE_IDENTIFIER) + ), + 'resources' => new Expression( + 'COUNT(DISTINCT(?))', array('resource_id'), + array(Expression::TYPE_IDENTIFIER) + ), + 'total' => new Expression('COUNT(*)') + ) + ); + $statement = $this->sql->prepareStatementForSqlObject($select); + $result = $statement->execute(); + return (array)$result->current(); + } } diff --git a/themes/blueprint/templates/admin/menu.phtml b/themes/blueprint/templates/admin/menu.phtml index 85338e43d69cfa54676b2408776037c9185d1fcb..b3c513087257b5cac4e024ce4e9013a3843270d5 100644 --- a/themes/blueprint/templates/admin/menu.phtml +++ b/themes/blueprint/templates/admin/menu.phtml @@ -1,6 +1,7 @@ <ul id="list1"> - <li<?=ucwords($this->layout()->templateName) == "Home" ? ' class="active"' : ''?>><a href="<?=$this->url('admin-home')?>"><?=$this->transEsc('Home')?></a></li> - <li<?=ucwords($this->layout()->templateName) == "Statistics" ? ' class="active"' : ''?>><a href="<?=$this->url('admin-statistics')?>"><?=$this->transEsc('Statistics')?></a></li> - <li<?=ucwords($this->layout()->templateName) == "Config" ? ' class="active"' : ''?>><a href="<?=$this->url('admin-config')?>"><?=$this->transEsc('Configuration')?></a> - <li<?=ucwords($this->layout()->templateName) == "Maintenance" ? ' class="active"' : ''?>><a href="<?=$this->url('admin-maintenance')?>"><?=$this->transEsc('System Maintenance')?></a></li> + <li<?=strtolower($this->layout()->templateName) == "home" ? ' class="active"' : ''?>><a href="<?=$this->url('admin-home')?>"><?=$this->transEsc('Home')?></a></li> + <li<?=strtolower($this->layout()->templateName) == "socialstats" ? ' class="active"' : ''?>><a href="<?=$this->url('admin-socialstats')?>"><?=$this->transEsc('Social Statistics')?></a></li> + <li<?=strtolower($this->layout()->templateName) == "statistics" ? ' class="active"' : ''?>><a href="<?=$this->url('admin-statistics')?>"><?=$this->transEsc('Statistics')?></a></li> + <li<?=strtolower($this->layout()->templateName) == "config" ? ' class="active"' : ''?>><a href="<?=$this->url('admin-config')?>"><?=$this->transEsc('Configuration')?></a> + <li<?=strtolower($this->layout()->templateName) == "maintenance" ? ' class="active"' : ''?>><a href="<?=$this->url('admin-maintenance')?>"><?=$this->transEsc('System Maintenance')?></a></li> </ul> diff --git a/themes/blueprint/templates/admin/socialstats.phtml b/themes/blueprint/templates/admin/socialstats.phtml new file mode 100644 index 0000000000000000000000000000000000000000..be43c79a91c8df30a892763c4f9a0feafd97cab9 --- /dev/null +++ b/themes/blueprint/templates/admin/socialstats.phtml @@ -0,0 +1,31 @@ +<? + // Set page title. + $this->headTitle($this->translate('VuFind Administration - Social Statistics')); +?> +<div class="span-5"> + <?=$this->render("admin/menu.phtml")?> +</div> + +<div class="span-18 last"> + <h1><?=$this->transEsc('Social Statistics')?></h1> + + <h2>Comments</h2> + <table> + <tr><th>Total Users</th><th>Total Resources</th><th>Total Comments</th></tr> + <tr><td><?=$comments['users']?></td><td><?=$comments['resources']?></td><td><?=$comments['total']?></td></tr> + </table> + + <h2>Favorites</h2> + <table> + <tr><th>Total Users</th><th>Total Resources</th><th>Total Lists</th><th>Total Saved Items</th></tr> + <tr><td><?=$favorites['users']?></td><td><?=$favorites['resources']?></td><td><?=$favorites['lists']?></td><td><?=$favorites['total']?></td></tr> + </table> + + <h2>Tags</h2> + <table> + <tr><th>Total Users</th><th>Total Resources</th><th>Total Tags</th></tr> + <tr><td><?=$tags['users']?></td><td><?=$tags['resources']?></td><td><?=$tags['total']?></td></tr> + </table> +</div> + +<div class="clear"></div>