Commit 4bfb50a2 authored by Dries's avatar Dries

- Patch #1019928 by xjm, aspilicious: purge the term 'vancode'.

parent 107f67e7
...@@ -147,7 +147,7 @@ function comment_schema() { ...@@ -147,7 +147,7 @@ function comment_schema() {
'type' => 'varchar', 'type' => 'varchar',
'length' => 255, 'length' => 255,
'not null' => TRUE, 'not null' => TRUE,
'description' => "The vancode representation of the comment's place in a thread.", 'description' => "The alphadecimal representation of the comment's place in a thread, consisting of a base 36 string prefixed by an integer indicating its length.",
), ),
'name' => array( 'name' => array(
'type' => 'varchar', 'type' => 'varchar',
......
...@@ -1436,6 +1436,8 @@ function comment_access($op, $comment) { ...@@ -1436,6 +1436,8 @@ function comment_access($op, $comment) {
* *
* @param $comment * @param $comment
* A comment object. * A comment object.
*
* @see comment_int_to_alphadecimal()
*/ */
function comment_save($comment) { function comment_save($comment) {
global $user; global $user;
...@@ -1500,7 +1502,7 @@ function comment_save($comment) { ...@@ -1500,7 +1502,7 @@ function comment_save($comment) {
// Strip the "/" from the end of the thread. // Strip the "/" from the end of the thread.
$max = rtrim($max, '/'); $max = rtrim($max, '/');
// Finally, build the thread field for this new comment. // Finally, build the thread field for this new comment.
$thread = int2vancode(vancode2int($max) + 1) . '/'; $thread = comment_increment_alphadecimal($max) . '/';
} }
else { else {
// This is a comment with a parent comment, so increase the part of the // This is a comment with a parent comment, so increase the part of the
...@@ -1518,7 +1520,7 @@ function comment_save($comment) { ...@@ -1518,7 +1520,7 @@ function comment_save($comment) {
if ($max == '') { if ($max == '') {
// First child of this parent. // First child of this parent.
$thread = $parent->thread . '.' . int2vancode(0) . '/'; $thread = $parent->thread . '.' . comment_int_to_alphadecimal(0) . '/';
} }
else { else {
// Strip the "/" at the end of the thread. // Strip the "/" at the end of the thread.
...@@ -1528,7 +1530,7 @@ function comment_save($comment) { ...@@ -1528,7 +1530,7 @@ function comment_save($comment) {
$parent_depth = count(explode('.', $parent->thread)); $parent_depth = count(explode('.', $parent->thread));
$last = $parts[$parent_depth]; $last = $parts[$parent_depth];
// Finally, build the thread field for this new comment. // Finally, build the thread field for this new comment.
$thread = $parent->thread . '.' . int2vancode(vancode2int($last) + 1) . '/'; $thread = $parent->thread . '.' . comment_increment_alphadecimal($last) . '/';
} }
} }
...@@ -1767,7 +1769,7 @@ function comment_get_display_ordinal($cid, $node_type) { ...@@ -1767,7 +1769,7 @@ function comment_get_display_ordinal($cid, $node_type) {
} }
else { else {
// For threaded comments, the c.thread column is used for ordering. We can // For threaded comments, the c.thread column is used for ordering. We can
// use the vancode for comparison, but must remove the trailing slash. // use the sorting code for comparison, but must remove the trailing slash.
// See comment_view_multiple(). // See comment_view_multiple().
$query->where('SUBSTRING(c1.thread, 1, (LENGTH(c1.thread) -1)) < SUBSTRING(c2.thread, 1, (LENGTH(c2.thread) -1))'); $query->where('SUBSTRING(c1.thread, 1, (LENGTH(c1.thread) -1)) < SUBSTRING(c2.thread, 1, (LENGTH(c2.thread) -1))');
} }
...@@ -2453,11 +2455,11 @@ function _comment_update_node_statistics($nid) { ...@@ -2453,11 +2455,11 @@ function _comment_update_node_statistics($nid) {
} }
/** /**
* Generate vancode. * Generate sorting code.
* *
* Consists of a leading character indicating length, followed by N digits * Consists of a leading character indicating length, followed by N digits
* with a numerical value in base 36. Vancodes can be sorted as strings * with a numerical value in base 36 (alphadecimal). These codes can be sorted
* without messing up numerical order. * as strings without altering numerical order.
* *
* It goes: * It goes:
* 00, 01, 02, ..., 0y, 0z, * 00, 01, 02, ..., 0y, 0z,
...@@ -2465,7 +2467,7 @@ function _comment_update_node_statistics($nid) { ...@@ -2465,7 +2467,7 @@ function _comment_update_node_statistics($nid) {
* 2100, 2101, ..., 2zzy, 2zzz, * 2100, 2101, ..., 2zzy, 2zzz,
* 31000, 31001, ... * 31000, 31001, ...
*/ */
function int2vancode($i = 0) { function comment_int_to_alphadecimal($i = 0) {
$num = base_convert((int) $i, 10, 36); $num = base_convert((int) $i, 10, 36);
$length = strlen($num); $length = strlen($num);
...@@ -2473,12 +2475,23 @@ function int2vancode($i = 0) { ...@@ -2473,12 +2475,23 @@ function int2vancode($i = 0) {
} }
/** /**
* Decode vancode back to an integer. * Decode sorting code back to an integer.
*
* @see comment_int_to_alphadecimal()
*/ */
function vancode2int($c = '00') { function comment_alphadecimal_to_int($c = '00') {
return base_convert(substr($c, 1), 36, 10); return base_convert(substr($c, 1), 36, 10);
} }
/**
* Increment a sorting code to the next value.
*
* @see comment_int_to_alphadecimal()
*/
function comment_increment_alphadecimal($c = '00') {
return comment_int_to_alphadecimal(comment_alphadecimal_to_int($c) + 1);
}
/** /**
* Implements hook_action_info(). * Implements hook_action_info().
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment