From: <al...@us...> - 2008-10-20 20:43:35
|
Revision: 738 http://sciret.svn.sourceforge.net/sciret/?rev=738&view=rev Author: alpeb Date: 2008-10-20 20:43:21 +0000 (Mon, 20 Oct 2008) Log Message: ----------- removed the Manage Categories section, and replaced all the functionality with some icons and links in the main view when navigating through the categories Modified Paths: -------------- trunk/actions/HideCategory.php trunk/actions/ShowCategory.php trunk/templates/EditCategory.tpl trunk/templates/MainView.tpl trunk/templates/header.tpl trunk/views/EditCategory.php trunk/views/MainView.php trunk/views/View.php Added Paths: ----------- trunk/images/hide.png trunk/images/show_hidden.png Removed Paths: ------------- trunk/templates/EditCategories.tpl trunk/views/EditCategories.php Modified: trunk/actions/HideCategory.php =================================================================== --- trunk/actions/HideCategory.php 2008-10-20 14:50:58 UTC (rev 737) +++ trunk/actions/HideCategory.php 2008-10-20 20:43:21 UTC (rev 738) @@ -25,7 +25,7 @@ $this->user->save(); $_SESSION['message'] = $this->user->lang('Category won\'t be shown in the future'); - Library::redirect(Library::getLink(array('view' => 'EditCategories'))); + Library::redirect(Library::getLink(array('view' => 'MainView'))); } } Modified: trunk/actions/ShowCategory.php =================================================================== --- trunk/actions/ShowCategory.php 2008-10-20 14:50:58 UTC (rev 737) +++ trunk/actions/ShowCategory.php 2008-10-20 20:43:21 UTC (rev 738) @@ -33,7 +33,9 @@ $this->user->save(); $_SESSION['message'] = $this->user->lang('Category will be shown in the future'); - Library::redirect(Library::getLink(array('view' => 'EditCategories'))); + Library::redirect(Library::getLink(array( + 'view' => 'MainView', + 'catId' => $_GET['catId']))); } } Added: trunk/images/hide.png =================================================================== (Binary files differ) Property changes on: trunk/images/hide.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/images/show_hidden.png =================================================================== (Binary files differ) Property changes on: trunk/images/show_hidden.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Deleted: trunk/templates/EditCategories.tpl =================================================================== --- trunk/templates/EditCategories.tpl 2008-10-20 14:50:58 UTC (rev 737) +++ trunk/templates/EditCategories.tpl 2008-10-20 20:43:21 UTC (rev 738) @@ -1,62 +0,0 @@ -<!-- -/* -* @copyright Copyright (C) 2005-2008 Keyboard Monkeys Ltd. http://www.kb-m.com -* @license http://www.fsf.org/copyleft/lgpl.html GNU Lesser General Public License -* @author Alejandro Pedraza -* @since Sciret 1.2 -* @package Sciret -* @packager Keyboard Monkeys -*/ ---> - -<script type="text/javascript"> -function deleteCategory(catId, catName) { - if (!confirm('[l]Are you sure you want to delete the category [/l]\''+ catName +'\' ?')) { - return; - } - location.href = '{deleteCatRedirect}&catId='+catId; -} -</script> - -<h1>[l]Manage Categories[/l]</h1> - -<table cellpadding="3" cellspacing="2" border="0" class="table1"> - <tr> - <th class="th_h">[l]Name[/l]</th> - <th>[l]Description[/l]</th> - <th>[l]Icon[/l]</th> - <th></th> - </tr> - <!-- BEGIN categories_block --> - <tr class="{rowClass}"> - <td class="td_h"> - <!-- BEGIN boldCategory_block --> - {indent}<b>{catLabel}</b> - <!-- END boldCategory_block --> - <!-- BEGIN nonBoldCategory_block --> - {indent}{catLabel} - <!-- END nonBoldCategory_block --> - </td> - <td>{catDescription}</td> - <td>{catIcon}</td> - <td> - <!-- BEGIN hideCategory_block --> - <a href="{hideCatLink}">[l]Hide[/l]</a> - <!-- END hideCategory_block --> - <!-- BEGIN showCategory_block --> - <a href="{showCatLink}">[l]Show[/l]</a> - <!-- END showCategory_block --> - <!-- BEGIN categoryAdminOps_block --> - <a href="{addSubCatLink}">[l]Add subcategory[/l]</a> - <a href="{editCatLink}">[l]Edit[/l]</a> - <!-- BEGIN deleteCategory_block --> - <a href="#" onclick="deleteCategory({catId}, '{catLabelSlashed}')">[l]Delete[/l]</a> - <!-- END deleteCategory_block --> - <!-- END categoryAdminOps_block --> - </td> - </tr> - <!-- END categories_block --> -</table> - <div class="toolbar"> - <input type="button" value="[l]Add Category[/l]" onclick="location.href = '{addCatRedirect}'" /> - </div> Modified: trunk/templates/EditCategory.tpl =================================================================== --- trunk/templates/EditCategory.tpl 2008-10-20 14:50:58 UTC (rev 737) +++ trunk/templates/EditCategory.tpl 2008-10-20 20:43:21 UTC (rev 738) @@ -15,6 +15,13 @@ return true; } + +function deleteCategory(catId, catName) { + if (!confirm('[l]Are you sure you want to delete the category [/l]{catLabelSlashed} ?')) { + return; + } + location.href = '{deleteCatRedirect}&catId={catId}'; +} </script> <h1>[l]Edit/Add Category[/l]</h1> @@ -56,6 +63,9 @@ <tr class="row_off"> <td colspan="2"> <input type="submit" value="[l]Save[/l]" /> + <!-- BEGIN deleteButton_block --> + <input type="button" value="[l]Delete[/l]" onclick="deleteCategory()" /> + <!-- END deleteButton_block --> </td> </tr> </table> Modified: trunk/templates/MainView.tpl =================================================================== --- trunk/templates/MainView.tpl 2008-10-20 14:50:58 UTC (rev 737) +++ trunk/templates/MainView.tpl 2008-10-20 20:43:21 UTC (rev 738) @@ -28,9 +28,30 @@ </ul> <div class="yui-content"> <div> - <table id="categoriesTable"> + <table id="categoriesTable" border="0"> <tr> - <td>{path}</td> + <td> + <div style="position:relative"> + {path} + <!-- BEGIN editCategory_block --> + <a href="{editCategoryLink}">[l](edit)[/l]</a> + <!-- END editCategory_block --> + <!-- BEGIN showCatAgain_block --> + <div> + [l]You have hidden this category. <a href="{showCatAgainLink}">Show it again</a>.[/l] + </div> + <!-- END showCatAgain_block --> + <div style="position:absolute; top:0; right:0"> + <!-- BEGIN hideCategory_block --> + <img src="images/hide.png" alt="[l]Hide Category[/l]" title="[l]Hide Category[/l]" style="cursor:pointer" onclick="location.href='{linkHideCat}'" /> + <!-- END hideCategory_block --> + <!-- BEGIN showHiddenCategories_block --> + + <img src="images/show_hidden.png" alt="[l]Show Hidden Categories[/l]" title="[l]Show Hidden Categories[/l]" style="cursor:pointer" onclick="location.href='{linkShowHiddenCats}'" /> + <!-- END showHiddenCategories_block --> + </div> + </div> + </td> </tr> <tr> <td> @@ -39,7 +60,15 @@ </table> </td> </tr> - + <!-- BEGIN addCategoryButton_block --> + <tr> + <td align="right"> + <span class="button_green"> + <a href="{addCategoryLink}">{addCategoryLabel}</a> + </span> + </td> + </tr> + <!-- END addCategoryButton_block --> </table> </td> Modified: trunk/templates/header.tpl =================================================================== --- trunk/templates/header.tpl 2008-10-20 14:50:58 UTC (rev 737) +++ trunk/templates/header.tpl 2008-10-20 20:43:21 UTC (rev 738) @@ -54,9 +54,6 @@ <!-- BEGIN addBookmarkLink_block --> <a href="{addBookmarkHref}">[l]Add Bookmark[/l]</a> <!-- END addBookmarkLink_block --> - <!-- BEGIN editCategoriesLink_block --> - <a href="{editCategoriesHref}">[l]Manage Categories[/l]</a> - <!-- END editCategoriesLink_block --> <!-- BEGIN manageUsersLink_block --> <a href="{manageUsersHref}">[l]Manage Users[/l]</a> <!-- END manageUsersLink_block --> Deleted: trunk/views/EditCategories.php =================================================================== --- trunk/views/EditCategories.php 2008-10-20 14:50:58 UTC (rev 737) +++ trunk/views/EditCategories.php 2008-10-20 20:43:21 UTC (rev 738) @@ -1,114 +0,0 @@ -<?php - -/* -* @copyright Copyright (C) 2005-2008 Keyboard Monkeys Ltd http://www.kb-m.com -* @license http://www.fsf.org/copyleft/lgpl.html GNU Lesser General Public License -* @author Alejandro Pedraza -* @since Sciret 1.0 -* @package Sciret -* @packager Keyboard Monkeys -*/ - -require_once 'views/View.php'; -require_once 'models/CategoryGateway.php'; - -class EditCategories extends View { - - var $hiddenCategories; - - function dispatch() { - $this->tpl->set_file('edit_categories', 'EditCategories.tpl'); - $this->tpl->set_block('edit_categories', 'categories_block', 'categories'); - $this->tpl->set_block('categories_block', 'boldCategory_block', 'boldCategory'); - $this->tpl->set_block('categories_block', 'nonBoldCategory_block', 'nonBoldCategory'); - $this->tpl->set_block('categories_block', 'categoryAdminOps_block', 'categoryAdminOps'); - $this->tpl->set_block('categoryAdminOps_block', 'deleteCategory_block', 'deleteCategory'); - $this->tpl->set_block('categories_block', 'hideCategory_block', 'hideCategory'); - $this->tpl->set_block('categories_block', 'showCategory_block', 'showCategory'); - $this->tpl->set_var(array( - 'deleteCatRedirect' => Library::getLink(array('action' => 'DeleteCategory')), - 'addCatRedirect' => Library::getLink(array('view' => 'EditCategory', 'subAction' => 'add')), - )); - - $categoryGateway = new CategoryGateway; - $categories = $categoryGateway->getCategories(); - if (!$this->user->getPreference('hiddenCategories')) { - $this->hiddenCategories = array(); - } else { - $this->hiddenCategories = explode(',', $this->user->getPreference('hiddenCategories')); - } - foreach ($categories[0]->getChildren() as $category) { - $this->_showCategories($category); - } - if (count($categories) == 1) { - $this->tpl->set_var('categories', $this->user->lang('There are no categories')); - } - - $this->tpl->pparse('out', 'edit_categories'); - } - - // @access private - function _showCategories($category, $depth = 0) { - static $firstIteration = true; - static $rowClass = 'row_off'; - - $indent = str_repeat(' ', $depth); - $this->tpl->set_var(array( - 'hideCatLink' => Library::getLink(array('action' => 'HideCategory', 'catId' => $category->getId())), - 'showCatLink' => Library::getLink(array('action' => 'ShowCategory', 'catId' => $category->getId())), - 'addSubCatLink' => Library::getLink(array('view' => 'EditCategory', 'subAction' => 'addSubCategory', 'catId' => $category->getId())), - 'editCatLink' => Library::getLink(array('view' => 'EditCategory', 'catId' => $category->getId())), - 'rowClass' => $rowClass, - 'catId' => $category->getId(), - 'indent' => $indent, - 'catLabel' => $category->getLabel(), - 'catLabelSlashed' => addslashes($category->getLabel()), - 'catDescription' => $category->getDescription(), - 'catIcon' => ($category->getIconFileName() != '')? '<img src="uploads/icons/'.$category->getIconFileName().'" />' : '', - )); - - if (in_array($category->getParentId(), $this->hiddenCategories)) { - $this->tpl->set_var('hideCategory', ''); - $this->tpl->set_var('showCategory', ''); - } elseif (in_array($category->getId(), $this->hiddenCategories)) { - $this->tpl->parse('showCategory', 'showCategory_block'); - $this->tpl->set_var('hideCategory', ''); - } else { - $this->tpl->parse('hideCategory', 'hideCategory_block'); - $this->tpl->set_var('showCategory', ''); - } - - if ($depth == 0) { - $this->tpl->parse('boldCategory', 'boldCategory_block'); - $this->tpl->set_var('nonBoldCategory', ''); - } else { - $this->tpl->parse('nonBoldCategory', 'nonBoldCategory_block'); - $this->tpl->set_var('boldCategory', ''); - } - - if ($category->hasChildren()) { - $this->tpl->set_var('deleteCategory', ''); - } else { - $this->tpl->parse('deleteCategory', 'deleteCategory_block'); - } - - if ($this->user->isAdmin()) { - $this->tpl->parse('categoryAdminOps', 'categoryAdminOps_block'); - } else { - $this->tpl->set_var('categoryAdminOps', ''); - } - - $this->tpl->parse('categories', 'categories_block', !$firstIteration); - $firstIteration = false; - $rowClass = $rowClass == 'row_off'? 'row_on' : 'row_off'; - - if ($category->hasChildren()) { - ++$depth; - foreach ($category->getChildren() as $childCategory) { - $this->_showCategories($childCategory, $depth); - } - } - } -} - -?> Modified: trunk/views/EditCategory.php =================================================================== --- trunk/views/EditCategory.php 2008-10-20 14:50:58 UTC (rev 737) +++ trunk/views/EditCategory.php 2008-10-20 20:43:21 UTC (rev 738) @@ -21,15 +21,24 @@ $this->tpl->set_file('edit_category', 'EditCategory.tpl'); $this->tpl->set_block('edit_category', 'categories_block', 'categories'); $this->tpl->set_block('edit_category', 'icons_block', 'icons'); + $this->tpl->set_block('edit_category', 'deleteButton_block', 'deleteButton'); $category = new Category(isset($_GET['subAction']) && $_GET['subAction'] == 'addSubCategory'? 0 : $catId); $this->tpl->set_var(array( - 'formAction' => Library::getLink(array('action' => 'SaveCategory')), - 'catId' => $category->getId(), - 'catLabel' => $category->getLabel(), - 'description' => $category->getDescription(), + 'formAction' => Library::getLink(array('action' => 'SaveCategory')), + 'catId' => $category->getId(), + 'catLabel' => $category->getLabel(), + 'catLabelSlashed' => addslashes($category->getLabel()), + 'description' => $category->getDescription(), + 'deleteCatRedirect' => Library::getLink(array('action' => 'DeleteCategory')), )); + if ($catId) { + $this->tpl->parse('deleteButton', 'deleteButton_block'); + } else { + $this->tpl->set_var('deleteButton', ''); + } + $categoryGateway = new CategoryGateway; $categories = $categoryGateway->getCategories(); foreach ($categories[0]->getChildren() as $tempCategory) { Modified: trunk/views/MainView.php =================================================================== --- trunk/views/MainView.php 2008-10-20 14:50:58 UTC (rev 737) +++ trunk/views/MainView.php 2008-10-20 20:43:21 UTC (rev 738) @@ -82,6 +82,11 @@ $this->tpl->set_block('main', 'hideDraftsUnpublishedLink_block', 'hideDraftsUnpublishedLink'); $this->tpl->set_block('main', 'viewExpiredLink_block', 'viewExpiredLink'); $this->tpl->set_block('main', 'hideExpiredLink_block', 'hideExpiredLink'); + $this->tpl->set_block('main', 'showCatAgain_block', 'showCatAgain'); + $this->tpl->set_block('main', 'editCategory_block', 'editCategory'); + $this->tpl->set_block('main', 'hideCategory_block', 'hideCategory'); + $this->tpl->set_block('main', 'showHiddenCategories_block', 'showHiddenCategories'); + $this->tpl->set_block('main', 'addCategoryButton_block', 'addCategoryButton'); $this->tpl->set_block('main', 'requestCat_block', 'requestCat'); $this->tpl->set_block('articles_block', 'status_block', 'status'); $this->tpl->set_block('articles_block', 'question_block', 'question'); @@ -135,6 +140,19 @@ 'view' => 'Rss', 'catId' => $catId, 'items' => 10)), + 'editCategoryLink' => Library::getLink(array( + 'view' => 'EditCategory', + 'catId' => $catId)), + 'linkHideCat' => Library::getLink(array( + 'action' => 'HideCategory', + 'catId' => $catId)), + 'linkShowHiddenCats'=> Library::getLink(array( + 'view' => 'MainView', + 'catId' => $catId, + 'hiddencats' => 1)), + 'showCatAgainLink' => Library::getLink(array( + 'action' => 'ShowCategory', + 'catId' => $catId)), )); if ($catId != 0) { @@ -244,22 +262,63 @@ // don't include current cat in the counter $numCats--; + + if ($this->_isHidden($this->categories[$catId])) { + $this->tpl->parse('showCatAgain', 'showCatAgain_block'); + $this->tpl->set_var('hideCategory', ''); + } else { + $this->tpl->set_var('showCatAgain', ''); + $this->tpl->parse('hideCategory', 'hideCategory_block'); + } + } else { $this->tpl->set_var('path', ''); $this->tpl->parse('totalNumArts', 'totalNumArts_block'); $this->tpl->set_var('totalNumArtsCat', ''); + $this->tpl->set_var('hideCategory', ''); + $this->tpl->set_var('showCatAgain', ''); } $this->tpl->set_var(array( - 'categories' => $this->_getCategoriesHTML($this->categories[$catId]->getChildren(), 'MainView'), + 'categories' => $this->_getCategoriesHTML( + $this->categories[$catId]->getChildren(), + 'MainView', + isset($_GET['hiddencats'])), 'numCats' => $numCats, )); + if (!isset($_GET['hiddencats']) + && $this->_categoryHasHidden($catId)) + { + $this->tpl->parse('showHiddenCategories', 'showHiddenCategories_block'); + } else { + $this->tpl->set_var('showHiddenCategories', ''); + } + if (!$this->user->isAdmin()) { $this->tpl->set_var('requestCatLink', Library::getLink(array('view' => 'RequestCategory', 'catId' => $catId))); $this->tpl->parse('requestCat', 'requestCat_block'); + + $this->tpl->set_var('addCategoryButton', ''); + $this->tpl->set_var('editCategory', ''); } else { $this->tpl->set_var('requestCat', ''); + + if ($catId) { + $this->tpl->set_var('addCategoryLink', Library::getLink(array( + 'view' => 'EditCategory', + 'subAction' => 'addSubCategory', + 'catId' => $catId))); + $this->tpl->set_var('addCategoryLabel', $this->user->lang('Add Subcategory')); + $this->tpl->parse('editCategory', 'editCategory_block'); + } else { + $this->tpl->set_var('addCategoryLink', Library::getLink(array( + 'view' => 'EditCategory', + 'subAction' => 'add'))); + $this->tpl->set_var('addCategoryLabel', $this->user->lang('Add Category')); + $this->tpl->set_var('editCategory', ''); + } + $this->tpl->parse('addCategoryButton', 'addCategoryButton_block'); } // ** ARTICLES LIST ** @@ -442,4 +501,34 @@ $this->tpl->pparse('out', 'main'); } + + private function _categoryHasHidden($catId) + { + $hiddenCategories = $this->user->getPreference('hiddenCategories'); + if (!$hiddenCategories) { + return false; + } + + $hiddenCategories = explode(',', $hiddenCategories); + + foreach ($this->categories[$catId]->getChildren() as $category) { + if (in_array($category->getId(), $hiddenCategories)) { + return true; + } + } + + return false; + } + + private function _isHidden(Category $cat) + { + $hiddenCategories = $this->user->getPreference('hiddenCategories'); + if (!$hiddenCategories) { + return false; + } + + $hiddenCategories = explode(',', $hiddenCategories); + + return in_array($cat->getId(), $hiddenCategories); + } } Modified: trunk/views/View.php =================================================================== --- trunk/views/View.php 2008-10-20 14:50:58 UTC (rev 737) +++ trunk/views/View.php 2008-10-20 20:43:21 UTC (rev 738) @@ -133,10 +133,6 @@ $this->tpl->set_var('addBookmarkLink', ''); } - $this->tpl->set_block('header', 'editCategoriesLink_block', 'editCategoriesLink'); - $this->tpl->set_var('editCategoriesHref', Library::getLink(array('view' => 'EditCategories'))); - $this->tpl->parse('editCategoriesLink', 'editCategoriesLink_block'); - $this->tpl->set_block('header', 'manageUsersLink_block', 'manageUsersLink'); if ($this->user->isAdmin()) { $this->tpl->set_var('manageUsersHref', Library::getLink(array('view' => 'ManageUsers'))); @@ -206,10 +202,11 @@ * Returns HTML string of categories menu * */ - function _getCategoriesHTML($categories, $view) { + function _getCategoriesHTML($categories, $view, $showHidden = false) + { $categories_str = ''; $num_main_cat = 0; - if (!$this->user->getPreference('hiddenCategories')) { + if (!$this->user->getPreference('hiddenCategories') || $showHidden) { $hiddenCategories = array(); } else { $hiddenCategories = explode(',', $this->user->getPreference('hiddenCategories')); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |