-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added media counts to admin homepage
- Loading branch information
1 parent
926a872
commit 5204f53
Showing
9 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
config.php | ||
.htaccess | ||
media/audio/* | ||
media/image/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
/** | ||
* This file is part of Kumva. | ||
* | ||
* Kumva 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 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Kumva is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Kumva. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Copyright Rowan Seymour 2010 | ||
* | ||
* Purpose: Roles page | ||
*/ | ||
|
||
include_once '../inc/kumva.php'; | ||
|
||
$audioCount = 0; | ||
$imageCount = 0; | ||
|
||
$function = Request::getPostParam('function', NULL); | ||
if ($function == 'scan' && Session::getCurrent()->hasRole(Role::ADMINISTRATOR)) { | ||
$entries = Dictionary::getDefinitionService()->getEntries(); | ||
|
||
foreach ($entries as $entry) { | ||
// Check for matching audio and image file | ||
$audioPath = KUMVA_DIR_MEDIA.'/audio/'.$entry->getId().'.mp3'; | ||
$imagePath = KUMVA_DIR_MEDIA.'/image/'.$entry->getId().'.jpg'; | ||
$flags = 0; | ||
if (file_exists($audioPath)) { | ||
$audioCount++; | ||
$flags = aka_setbit($flags, Media::AUDIO); | ||
} | ||
if (file_exists($imagePath)) { | ||
$imageCount++; | ||
$flags = aka_setbit($flags, Media::IMAGE); | ||
} | ||
|
||
// Update entry if flags have changed | ||
if ($entry->getMedia() != $flags) { | ||
$entry->setMedia($flags); | ||
Dictionary::getDefinitionService()->saveEntry($entry); | ||
} | ||
} | ||
} | ||
|
||
include_once 'tpl/header.php'; | ||
?> | ||
<h3><?php echo KU_STR_MEDIA ?></h3> | ||
|
||
<?php if (Session::getCurrent()->hasRole(Role::ADMINISTRATOR)) { ?> | ||
<div class="listcontrols"> | ||
<div style="float: right"> | ||
<form method="post" action=""> | ||
<input type="hidden" name="function" id="function" /> | ||
<?php Templates::button('scan', "$('#function').val('scan'); aka_submit(this);", KU_STR_SCAN); ?> | ||
</form> | ||
</div> | ||
</div> | ||
<?php } ?> | ||
|
||
<table class="list" cellspacing="0" border="0"> | ||
<tr> | ||
<th style="width: 30px"> </th> | ||
<th style="width: 20px"> </th> | ||
<th><?php echo KU_STR_PATH; ?></th> | ||
<th><?php echo KU_STR_TYPE; ?></th> | ||
<th><?php echo KU_STR_ENTRIES; ?></th> | ||
<th style="width: 30px"> </th> | ||
</tr> | ||
<tr> | ||
<td> </td> | ||
<td><?php Templates::icon('folder'); ?></td> | ||
<td class="primarycol">media/audio</td> | ||
<td><?php echo KU_STR_AUDIO; ?></td> | ||
<td style="text-align: center"><?php echo $audioCount; ?></td> | ||
<td> </td> | ||
</tr> | ||
<tr> | ||
<td> </td> | ||
<td><?php Templates::icon('folder'); ?></td> | ||
<td class="primarycol">media/image</td> | ||
<td><?php echo KU_STR_IMAGE; ?></td> | ||
<td style="text-align: center"><?php echo $imageCount; ?></td> | ||
<td> </td> | ||
</tr> | ||
</table> | ||
<div class="panel"></div> | ||
|
||
<?php include_once 'tpl/footer.php'; ?> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
/** | ||
* This file is part of Akabanga. | ||
* | ||
* Akabanga 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 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Akabanga is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Akabanga. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Copyright Rowan Seymour 2010 | ||
* | ||
* Purpose: Unit tests for utils functions | ||
*/ | ||
|
||
require_once "../akabanga.php"; | ||
|
||
/** | ||
* Test case for BeanUtils class | ||
*/ | ||
class UtilsTest extends PHPUnit_Framework_TestCase { | ||
|
||
public function test_getbit() { | ||
$val = 10; // 1010 | ||
|
||
$this->assertEquals(false, aka_getbit($val, 0)); | ||
$this->assertEquals(true, aka_getbit($val, 1)); | ||
$this->assertEquals(false, aka_getbit($val, 2)); | ||
$this->assertEquals(true, aka_getbit($val, 3)); | ||
} | ||
|
||
public function test_setbit() { | ||
$val1 = 2; // 0010 | ||
$val2 = 15; // 1111 | ||
|
||
$this->assertEquals(3, aka_setbit($val1, 0, true)); | ||
$this->assertEquals(11, aka_setbit($val2, 2, false)); | ||
} | ||
} | ||
|
||
?> |
Empty file.