[Customisation Database Commits] r964 - in /trunk/titania: includes/functions_display.php includes/functions_posting.php includes/objects/category.php language/en/common.php manage/categories.php styles/default/template/manage/categories.html styles/default/theme/common.css
Tom Catullo
tom at phpbb.com
Thu Apr 1 07:51:03 BST 2010
Author: Tom
Date: Thu Apr 1 07:51:03 2010
New Revision: 964
Log:
Nearly finished the Category Management system at this stage of the game. Creating new categories and editing existing categories works well, except that newly-created categories are not assigned left_id and right_id values in the database yet, which will cause problems! - I will get to that tomorrow.
Delete category function should not be used as of yet, as it is still buggy and has not been worked on since the last commit; it will be worked on last. Like I said, some things are buggy with the system because of the lack of left_id and right_id values for new categories. Everything else checks out OK.
Modified:
trunk/titania/includes/functions_display.php
trunk/titania/includes/functions_posting.php
trunk/titania/includes/objects/category.php
trunk/titania/language/en/common.php
trunk/titania/manage/categories.php
trunk/titania/styles/default/template/manage/categories.html
trunk/titania/styles/default/theme/common.css
Modified: trunk/titania/includes/functions_display.php
==============================================================================
*** trunk/titania/includes/functions_display.php (original)
--- trunk/titania/includes/functions_display.php Thu Apr 1 07:51:03 2010
***************
*** 60,71 ****
* @param int $parent_id The parent id/name (only show categories under this category)
* @param string $blockname The name of the template block to use (categories by default)
*/
! function titania_display_categories($parent_id = 0, $blockname = 'categories')
{
$sql = 'SELECT * FROM ' . TITANIA_CATEGORIES_TABLE . '
! WHERE parent_id = ' . (int) $parent_id . '
! AND category_visible = 1
! ORDER BY left_id ASC';
$result = phpbb::$db->sql_query($sql);
$category = new titania_category();
--- 60,73 ----
* @param int $parent_id The parent id/name (only show categories under this category)
* @param string $blockname The name of the template block to use (categories by default)
*/
! function titania_display_categories($parent_id = 0, $blockname = 'categories', $is_manage = false)
{
+ $only_visible = (!$is_manage) ? 'AND category_visible = 1' : '';
+
$sql = 'SELECT * FROM ' . TITANIA_CATEGORIES_TABLE . '
! WHERE parent_id = ' . (int) $parent_id . "
! $only_visible
! ORDER BY left_id ASC";
$result = phpbb::$db->sql_query($sql);
$category = new titania_category();
Modified: trunk/titania/includes/functions_posting.php
==============================================================================
*** trunk/titania/includes/functions_posting.php (original)
--- trunk/titania/includes/functions_posting.php Thu Apr 1 07:51:03 2010
***************
*** 82,88 ****
'S_IS_SELECTED' => ($selected === false) ? true : false,
'VALUE' => 0,
! 'NAME' => phpbb::$user->lang['SELECT_CONTRIB_TYPE'],
));
foreach (titania_types::$types as $key => $type)
--- 82,88 ----
'S_IS_SELECTED' => ($selected === false) ? true : false,
'VALUE' => 0,
! 'NAME' => (isset(phpbb::$user->lang['SELECT_CONTRIB_TYPE'])) ? phpbb::$user->lang['SELECT_CONTRIB_TYPE'] : '--',
));
foreach (titania_types::$types as $key => $type)
***************
*** 91,97 ****
'S_IS_SELECTED' => ($key == $selected) ? true : false,
'VALUE' => $key,
! 'NAME' => $type->lang,
));
}
}
--- 91,97 ----
'S_IS_SELECTED' => ($key == $selected) ? true : false,
'VALUE' => $key,
! 'NAME' => (isset(phpbb::$user->lang['SELECT_CONTRIB_TYPE'])) ? $type->lang : $type->langs,
));
}
}
Modified: trunk/titania/includes/objects/category.php
==============================================================================
*** trunk/titania/includes/objects/category.php (original)
--- trunk/titania/includes/objects/category.php Thu Apr 1 07:51:03 2010
***************
*** 75,91 ****
}
/**
* Submit data for storing into the database
*
* @return bool
*/
public function submit()
{
- $this->contrib_name_clean = utf8_clean_string($this->contrib_name);
-
- // Destroy category parents cache
- titania::$cache->destroy('_titania_category_parents');
-
return parent::submit();
}
--- 75,98 ----
}
/**
+ * Submit data in the post_data format (from includes/tools/message.php)
+ *
+ * @param object $message The message object
+ */
+ public function post_data($message)
+ {
+ $post_data = $message->request_data();
+
+ parent::post_data($message);
+ }
+
+ /**
* Submit data for storing into the database
*
* @return bool
*/
public function submit()
{
return parent::submit();
}
***************
*** 205,210 ****
--- 212,222 ----
$padding = '';
$category_list = ($return_array) ? array() : '';
+ if(!$select_id)
+ {
+ $selected = (is_array($select_id)) ? ((in_array(0, $select_id)) ? ' selected="selected"' : '') : ((0 == $select_id) ? ' selected="selected"' : '');
+ }
+ $category_list .= '<option value="0"' . (($disabled) ? ' disabled="disabled" class="disabled-option"' : $selected) . '>' . $padding . '- ' . phpbb::$user->lang['ROOT'] . ' -' . '</option>';
while ($row = phpbb::$db->sql_fetchrow($result))
{
$category_name = (isset(phpbb::$user->lang[$row['category_name']])) ? phpbb::$user->lang[$row['category_name']] : $row['category_name'];
***************
*** 569,586 ****
public function assign_display($return = false)
{
$display = array(
! 'CATEGORY_NAME' => (isset(phpbb::$user->lang[$this->category_name])) ? phpbb::$user->lang[$this->category_name] : $this->category_name,
! 'CATEGORY_CONTRIBS' => $this->category_contribs,
! 'CATEGORY_TYPE' => $this->category_type,
! 'U_MOVE_UP' => titania_url::$root_url . $this->get_manage_url() . '-action_move_up',
! 'U_MOVE_DOWN' => titania_url::$root_url . $this->get_manage_url() . '-action_move_down',
! 'U_EDIT' => titania_url::$root_url . $this->get_manage_url() . '-action_edit',
! 'U_DELETE' => titania_url::$root_url . $this->get_manage_url() . '-action_delete',
! 'U_VIEW_CATEGORY' => titania_url::$root_url . $this->get_url(),
'U_VIEW_MANAGE_CATEGORY' => titania_url::$root_url . $this->get_manage_url(),
! 'HAS_CHILDREN' => $this->get_children($this->category_id),
);
if ($return)
--- 581,598 ----
public function assign_display($return = false)
{
$display = array(
! 'CATEGORY_NAME' => (isset(phpbb::$user->lang[$this->category_name])) ? phpbb::$user->lang[$this->category_name] : $this->category_name,
! 'CATEGORY_CONTRIBS' => $this->category_contribs,
! 'CATEGORY_TYPE' => $this->category_type,
! 'U_MOVE_UP' => titania_url::$root_url . $this->get_manage_url() . '-action_move_up',
! 'U_MOVE_DOWN' => titania_url::$root_url . $this->get_manage_url() . '-action_move_down',
! 'U_EDIT' => titania_url::$root_url . $this->get_manage_url() . '-action_edit',
! 'U_DELETE' => titania_url::$root_url . $this->get_manage_url() . '-action_delete',
! 'U_VIEW_CATEGORY' => titania_url::$root_url . $this->get_url(),
'U_VIEW_MANAGE_CATEGORY' => titania_url::$root_url . $this->get_manage_url(),
! 'HAS_CHILDREN' => $this->get_children($this->category_id),
);
if ($return)
Modified: trunk/titania/language/en/common.php
==============================================================================
*** trunk/titania/language/en/common.php (original)
--- trunk/titania/language/en/common.php Thu Apr 1 07:51:03 2010
***************
*** 51,57 ****
--- 51,61 ----
'CACHE_PURGED' => 'Cache has been successfully purged',
'CATEGORY' => 'Category',
'CATEGORY_DELETED' => 'Category Deleted',
+ 'CATEGORY_DESC' => 'Category Description',
+ 'CATEGORY_INFORMATION' => 'Category Information',
'CATEGORY_NAME' => 'Category Name',
+ 'CATEGORY_TYPE' => 'Category Type',
+ 'CATEGORY_TYPE_EXPLAIN' => 'The type of contributions this category will hold. Leave unset to not accept contributions.',
'CAT_ADDONS' => 'Add-ons',
'CAT_ANTI_SPAM' => 'Anti-Spam',
'CAT_AVATARS' => 'Avatars',
***************
*** 102,108 ****
--- 106,114 ----
'LIST' => 'List',
'MANAGE' => 'Manage',
+ 'MAKE_CATEGORY_VISIBLE' => 'Make Category Visible',
'MODIFICATION' => 'Modification',
+ 'MODIFICATIONS' => 'Modifications',
'MOVE_CONTRIBS_TO' => 'Move Contributions to',
'MOVE_DOWN' => 'Move down',
'MOVE_SUBCATS_TO' => 'Move Subcategories to',
***************
*** 113,118 ****
--- 119,125 ----
'NEW_REVISION' => 'New Revision',
'NO_AUTH' => 'You are not authorized to see this page.',
'NO_CATEGORY' => 'The requested category does not exist.',
+ 'NO_CATEGORY_NAME' => 'Enter the category name',
'NO_CONTRIB' => 'The requested contribution does not exist.',
'NO_CONTRIBS' => 'No contributions could be found',
'NO_DESC' => 'You have to enter the description.',
***************
*** 123,128 ****
--- 130,136 ----
'ORDER' => 'Order',
+ 'PARENT_CATEGORY' => 'Parent Category',
'POST_IP' => 'Post IP',
'PURGE_CACHE' => 'Purge Cache',
***************
*** 133,146 ****
--- 141,157 ----
'RATING' => 'Rating',
'REMOVE_RATING' => 'Remove Rating',
'RETURN_LAST_PAGE' => 'Return to the previous page',
+ 'ROOT' => 'Root',
'SELECT_CATEGORY' => '-- Select category --',
+ 'SELECT_CATEGORY_TYPE' => '-- Select category type --',
'SELECT_SORT_METHOD' => 'Sort By',
'SITE_INDEX' => 'Site Index',
'SNIPPET' => 'Snippet',
'SORT_CONTRIB_NAME' => 'Contribution Name',
'STICKIES' => 'Stickies',
'STYLE' => 'Style',
+ 'STYLES' => 'Styles',
'SUBSCRIBE' => 'Subscribe',
'SUBSCRIPTION_NOTIFICATION' => 'Subscription Notification',
Modified: trunk/titania/manage/categories.php
==============================================================================
*** trunk/titania/manage/categories.php (original)
--- trunk/titania/manage/categories.php Thu Apr 1 07:51:03 2010
***************
*** 23,28 ****
--- 23,30 ----
phpbb::$user->add_lang('acp/common');
+ titania::_include('functions_posting', 'generate_type_select');
+
$category_id = request_var('c', 0);
$submit = (isset($_POST['submit'])) ? true : false;
$action = request_var('action', '');
***************
*** 31,43 ****
{
case 'add' :
case 'edit' :
phpbb::$template->assign_vars(array(
'CATEGORY' => $category_id,
! 'SECTION_NAME' => ($action == 'add') ? phpbb::$user->lang['CREATE_CATEGORY'] : phpbb::$user->lang['EDIT_CATEGORY'] . ' - ' . $category_name,
! 'S_EDIT_CATEGORY' => ($action == 'edit') ? true : false,
! 'S_ADD_CATEGORY' => ($action == 'add') ? true : false,
));
break;
case 'move_up' :
--- 33,151 ----
{
case 'add' :
case 'edit' :
+ $category_object = new titania_category;
+
+ if ($action == 'edit' && !$category_id)
+ {
+ trigger_error($user->lang['NO_CATEGORY'], E_USER_WARNING);
+ }
+
+ if ($action == 'add' && $category_id)
+ {
+ $category_data = $category_object->get_category_info($category_id);
+ }
+
+ $subcats_id = array();
+ $subcats = $category_object->get_category_branch($category_id, 'children');
+
+ foreach ($subcats as $row)
+ {
+ $subcats_id[] = $row['category_id'];
+ }
+
+ if ($action == 'add' && !$category_id)
+ {
+ $categories_list = $category_object->make_category_select(0, $subcats_id);
+ }
+ else
+ {
+ $categories_list = $category_object->make_category_select($category_data['parent_id'], $subcats_id);
+ }
+
+ if ($action == 'edit')
+ {
+ $category_object->load($category_id);
+ }
+
+ $sql = 'SELECT category_id
+ FROM ' . TITANIA_CATEGORIES_TABLE . "
+ WHERE category_id <> $category_id";
+ $result = phpbb::$db->sql_query_limit($sql, 1);
+
+ // Setup the display for the parent category dropdown box
+ if (phpbb::$db->sql_fetchrow($result))
+ {
+ phpbb::$template->assign_vars(array(
+ 'S_MOVE_CATEGORY_OPTIONS' => ($submit) ? $category_object->make_category_select(request_var('category_parent', 0), $subcats_id, false, true) : (($action == 'add') ? $category_object->make_category_select($category_id, $subcats_id, false, true) : $category_object->make_category_select($category_object->parent_id, $subcats_id, false, true)) // , false, true, false???
+ ));
+ }
+ phpbb::$db->sql_freeresult($result);
+
+ // Load the message object
+ $message_object = new titania_message($category_object);
+ $message_object->set_auth(array(
+ 'bbcode' => phpbb::$auth->acl_get('u_titania_bbcode'),
+ 'smilies' => phpbb::$auth->acl_get('u_titania_smilies'),
+ ));
+ $message_object->set_settings(array(
+ 'display_error' => false,
+ 'display_subject' => false,
+ ));
+
+ $category_object->post_data($message_object);
+
+ $message_object->display();
+
+ // Define some variables for use later with keeping language-based category names the same in the DB during submit
+ $old_category_name = $category_object->category_name;
+ $old_category_name_clean = $category_object->category_name_clean;
+ $old_category_name_lang = (isset(phpbb::$user->lang[$old_category_name])) ? phpbb::$user->lang[$old_category_name] : $old_category_name;
+
+ if($submit)
+ {
+ // Goodbye to the old category data...
+ unset($category_object->category_name);
+
+ $error = array();
+ $category_object->category_id = ($action == 'edit') ? $category_id : '';
+ $category_name = request_var('category_name', '');
+ $category_object->category_name = ($category_name == $old_category_name_lang) ? $old_category_name : $category_name;
+ $category_object->category_name_clean = (isset(phpbb::$user->lang[$category_object->category_name])) ? $old_category_name_clean : utf8_clean_string($category_object->category_name);
+ $category_object->parent_id = request_var('category_parent', 0);
+ $category_object->category_visible = request_var('category_visible', 1);
+ $category_object->category_type = request_var('category_type', 0);
+
+ // Check for errors
+ if (!$category_object->category_name)
+ {
+ $error[] = phpbb::$user->lang['NO_CATEGORY_NAME'];
+ }
+
+ // We have no errors
+ if (!sizeof($error))
+ {
+ $category_object->submit();
+
+ // Redirect back to previous category to avoid problems
+ redirect(titania_url::build_url('manage/categories', array('c' => $category_object->parent_id)));
+ }
+ }
+
+ // Generate data for category type dropdown box
+ generate_type_select($category_object->category_type);
+
phpbb::$template->assign_vars(array(
+ 'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'CATEGORY' => $category_id,
! 'CATEGORY_NAME' => (isset(phpbb::$user->lang[$category_object->category_name])) ? phpbb::$user->lang[$category_object->category_name] : $category_object->category_name,
! 'CATEGORY_VISIBLE' => $category_object->category_visible,
! 'SECTION_NAME' => ($action == 'add') ? phpbb::$user->lang['CREATE_CATEGORY'] : phpbb::$user->lang['EDIT_CATEGORY'] . ' - ' . ((isset(phpbb::$user->lang[$old_category_name])) ? phpbb::$user->lang[$old_category_name] : $old_category_name),
! 'U_ACTION' => ($action == 'add') ? titania_url::build_url('manage/categories', array('c' => $category_id, 'action' => 'add')) : titania_url::build_url('manage/categories', array('c' => $category_id, 'action' => 'edit')),
! 'U_BACK' => ($action == 'add') ? titania_url::build_url('manage/categories', array('c' => $category_id)) : titania_url::build_url('manage/categories', array('c' => $category_object->parent_id)),
+ 'S_ADD_CATEGORY' => ($action == 'add') ? true : false,
+ 'S_EDIT_CATEGORY' => ($action == 'edit') ? true : false,
));
break;
case 'move_up' :
***************
*** 73,78 ****
--- 181,189 ----
'CATEGORY' => $category_id,
'S_MOVE_CATEGORY' => true,
+ 'S_CATEGORIES_LIST' => $categories_list,
+ 'S_ERROR' => (sizeof($errors)) ? true : false,
+ 'ERROR_MSG' => (sizeof($errors)) ? implode('<br />', $errors) : '',
));
// Redirect back to previous category to avoid problems
***************
*** 150,156 ****
default :
titania::_include('functions_display', 'titania_display_categories');
! titania_display_categories($category_id);
if ($category_id != 0)
{
--- 261,267 ----
default :
titania::_include('functions_display', 'titania_display_categories');
! titania_display_categories($category_id, 'categories', true);
if ($category_id != 0)
{
***************
*** 185,191 ****
'ICON_DELETE' => '<img src="' . titania::$absolute_board . 'adm/images/icon_delete.gif" alt="' . phpbb::$user->lang['DELETE'] . '" title="' . phpbb::$user->lang['DELETE'] . '" />',
'ICON_DELETE_DISABLED' => '<img src="' . titania::$absolute_board . 'adm/images/icon_delete_disabled.gif" alt="' . phpbb::$user->lang['DELETE'] . '" title="' . phpbb::$user->lang['DELETE'] . '" />',
! 'U_CREATE_CATEGORY' => ($category_id) ? titania_url::build_url('manage/categories', array('c' => $category_id, 'action' => 'add')) : titania_url::build_url('manage/categories', array('action' => 'add')),
'S_MANAGE' => true,
));
--- 296,302 ----
'ICON_DELETE' => '<img src="' . titania::$absolute_board . 'adm/images/icon_delete.gif" alt="' . phpbb::$user->lang['DELETE'] . '" title="' . phpbb::$user->lang['DELETE'] . '" />',
'ICON_DELETE_DISABLED' => '<img src="' . titania::$absolute_board . 'adm/images/icon_delete_disabled.gif" alt="' . phpbb::$user->lang['DELETE'] . '" title="' . phpbb::$user->lang['DELETE'] . '" />',
! 'U_CREATE_CATEGORY' => titania_url::build_url('manage/categories', array('c' => $category_id, 'action' => 'add')),
'S_MANAGE' => true,
));
Modified: trunk/titania/styles/default/template/manage/categories.html
==============================================================================
*** trunk/titania/styles/default/template/manage/categories.html (original)
--- trunk/titania/styles/default/template/manage/categories.html Thu Apr 1 07:51:03 2010
***************
*** 1,22 ****
<!-- INCLUDE manage/manage_header.html -->
<!-- IF S_ADD_CATEGORY or S_EDIT_CATEGORY -->
! <h3 class="section-name">{SECTION_NAME}</h3>
! Add or Edit
<!-- ELSEIF S_DELETE_CATEGORY -->
! <h3 class="section-name">{SECTION_NAME}</h3>
<div class="panel">
<div class="inner"><span class="corners-top"><span></span></span>
- <!-- IF S_ERROR -->
- <div class="errorbox">
- <h3>{L_WARNING}</h3>
- <p>{ERROR_MSG}</p>
- </div>
- <!-- ENDIF -->
-
<form method="post" action="{U_ACTION}">
-
<fieldset>
<dl>
<dt><label>{L_CATEGORY_NAME}:</label></dt>
--- 1,64 ----
<!-- INCLUDE manage/manage_header.html -->
+ <!-- IF SECTION_NAME --><h3 class="section-name">{SECTION_NAME}</h3><!-- ENDIF -->
<!-- IF S_ADD_CATEGORY or S_EDIT_CATEGORY -->
! <!-- IF ERROR_MSG --><p class="error">{ERROR_MSG}</p><!-- ENDIF -->
! <form name="postform" method="post" action="{U_ACTION}">
! <div class="panel" id="addcategory">
! <div class="inner"><span class="corners-top"><span></span></span>
!
! <h3>{L_CATEGORY_INFORMATION}</h3>
!
! <fieldset>
! <dl>
! <dt><label for="category_name">{L_CATEGORY_NAME}:</label></dt>
! <dd><input type="text" name="category_name" id="category_name" size="45" maxlength="60" value="{CATEGORY_NAME}" class="inputbox autowidth" /></dd>
! </dl>
! <dl>
! <dt><label for="category_parent">{L_PARENT_CATEGORY}:</label></dt>
! <!-- IF S_MOVE_CATEGORY_OPTIONS -->
! <dd><label><select name="category_parent" id="category_parent">{S_MOVE_CATEGORY_OPTIONS}</select></dd>
! <!-- ENDIF -->
! </dl>
! <dl>
! <dt><label for="category_visible">{L_MAKE_CATEGORY_VISIBLE}:</label></dt>
! <dd><label><input type="radio" class="radio" id="category_visible" name="category_visible" value="1"<!-- IF CATEGORY_VISIBLE --> checked<!-- ENDIF --> />{L_YES}</label> <label><input type="radio" class="radio" name="category_visible" value="0"<!-- IF not CATEGORY_VISIBLE --> checked<!-- ENDIF --> />{L_NO}</label></dd>
! </dl>
! <dl>
! <dt><label for="category_type">{L_CATEGORY_TYPE}:</label><br /><span>{L_CATEGORY_TYPE_EXPLAIN}</span></dt>
! <dd>
! <select name="category_type" id="category_type">
! <!-- BEGIN type_select -->
! <option value="{type_select.VALUE}"<!-- IF type_select.S_IS_SELECTED --> selected="selected"<!-- ENDIF -->>{type_select.NAME}</option>
! <!-- END type_select -->
! </select>
! </dd>
! </dl>
! <dl>
! <dt><label for="message">{L_CATEGORY_DESC}:</label></dt>
! </dl>
! </fieldset>
! <!-- INCLUDE posting/posting_basic_editor.html -->
!
! <span class="corners-bottom"><span></span></span></div>
! </div>
! <div class="panel bg2">
! <div class="inner"><span class="corners-top"><span></span></span>
! <fieldset class="submit-buttons">
! <input type="reset" name="reset" value="{L_RESET}" class="button2" />
! <input type="submit" name="submit" value="{L_SUBMIT}" class="button1" />
! {S_FORM_TOKEN}
! </fieldset>
! <span class="corners-bottom"><span></span></span></div>
! </div>
! </form>
!
<!-- ELSEIF S_DELETE_CATEGORY -->
! <!-- IF ERROR_MSG --><p class="error">{ERROR_MSG}</p><!-- ENDIF -->
<div class="panel">
<div class="inner"><span class="corners-top"><span></span></span>
<form method="post" action="{U_ACTION}">
<fieldset>
<dl>
<dt><label>{L_CATEGORY_NAME}:</label></dt>
Modified: trunk/titania/styles/default/theme/common.css
==============================================================================
*** trunk/titania/styles/default/theme/common.css (original)
--- trunk/titania/styles/default/theme/common.css Thu Apr 1 07:51:03 2010
***************
*** 478,483 ****
--- 478,487 ----
color: #BC2A4D;
}
+ #addcategory textarea {
+ height: 185px;
+ }
+
/* Attention Details Page
--------------------------------------------- */
#attention {
More information about the customisationdb-commits
mailing list