Skip to content

Commit

Permalink
BackwardsCompatibilityBreak - fCRUD::createSortableColumn() was renam…
Browse files Browse the repository at this point in the history
…ed to fCRUD::printSortableColumn()
  • Loading branch information
wbond committed Apr 12, 2012
1 parent 5b552d4 commit f58475f
Showing 1 changed file with 32 additions and 27 deletions.
59 changes: 32 additions & 27 deletions classes/fCRUD.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,6 @@ class fCRUD
static private $sort_direction = NULL;


/**
* Prints a sortable column header
*
* @param string $column The column to create the sortable header for
* @param string $column_name This will override the humanized version of the column
* @return void
*/
static public function createSortableColumn($column, $column_name=NULL)
{
if ($column_name === NULL) {
$column_name = fGrammar::humanize($column);
}

if (self::$sort_column == $column) {
$sort = $column;
$direction = (self::$sort_direction == 'asc') ? 'desc' : 'asc';
} else {
$sort = $column;
$direction = 'asc';
}

$columns = array_merge(array('sort', 'dir'), array_keys(self::$search_values));
$values = array_merge(array($sort, $direction), array_values(self::$search_values));
?><a href="<?= fHTML::encode(fURL::get() . fURL::replaceInQueryString($columns, $values)) ?>" class="sortable_column<?= (self::$sort_column == $column) ? ' ' . self::$sort_direction : '' ?>"><?= fHTML::prepare($column_name) ?></a><?
}


/**
* Return the string 'sorted' if $column is the column that is currently being sorted by, otherwise returns ''
*
Expand Down Expand Up @@ -262,6 +235,38 @@ static public function printOption($text, $value, $selected_value=NULL)
}
echo '>' . fHTML::prepare($text) . '</option>';
}


/**
* Prints a sortable column header
*
* @param string $column The column to create the sortable header for
* @param string $column_name This will override the humanized version of the column
* @return void
*/
static public function printSortableColumn($column, $column_name=NULL)
{
if ($column_name === NULL) {
$column_name = fGrammar::humanize($column);
}

if (self::$sort_column == $column) {
$sort = $column;
$direction = (self::$sort_direction == 'asc') ? 'desc' : 'asc';
} else {
$sort = $column;
$direction = 'asc';
}

$columns = array_merge(array('sort', 'dir'), array_keys(self::$search_values));
$values = array_merge(array($sort, $direction), array_values(self::$search_values));

$url = fHTML::encode(fURL::get() . fURL::replaceInQueryString($columns, $values));
$css_class = (self::$sort_column == $column) ? ' ' . self::$sort_direction : '';
$column_name = fHTML::prepare($column_name);

echo '<a href="' . $url . '" class="sortable_column' . $css_class . '">' . $column_name . '</a>';
}


/**
Expand Down

0 comments on commit f58475f

Please sign in to comment.