mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-08-16 11:54:44 -04:00
Add a weight column to the items model. Change the album ordering to
use this as the default instead of id. This prepares the way for manual reordering in the organize functionality.
This commit is contained in:
@@ -46,7 +46,7 @@ class album_Core {
|
||||
$album->thumb_dirty = 1;
|
||||
$album->resize_dirty = 1;
|
||||
$album->rand_key = ((float)mt_rand()) / (float)mt_getrandmax();
|
||||
$album->sort_column = "id";
|
||||
$album->sort_column = "weight";
|
||||
$album->sort_order = "ASC";
|
||||
|
||||
while (ORM::factory("item")
|
||||
@@ -93,7 +93,7 @@ class album_Core {
|
||||
|
||||
$sort_order->dropdown("column", array("id" => "gAlbumSortColumn"))
|
||||
->label(t("Sort by"))
|
||||
->options(array("id" => t("select a column"),
|
||||
->options(array("weight" => t("Default"),
|
||||
"created" => t("Creation Date"),
|
||||
"title" => t("Title"),
|
||||
"updated" => t("Updated Date"),
|
||||
|
||||
@@ -76,6 +76,7 @@ class core_installer {
|
||||
`rand_key` float default NULL,
|
||||
`sort_column` varchar(64) default NULL,
|
||||
`sort_order` char(4) default 'ASC',
|
||||
`weight` int(9) NOT NULL default 0,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `parent_id` (`parent_id`),
|
||||
KEY `type` (`type`),
|
||||
@@ -201,7 +202,7 @@ class core_installer {
|
||||
$root->level = 1;
|
||||
$root->thumb_dirty = 1;
|
||||
$root->resize_dirty = 1;
|
||||
$root->sort_column = "id";
|
||||
$root->sort_column = "weight";
|
||||
$root->sort_order = "ASC";
|
||||
$root->save();
|
||||
access::add_item($root);
|
||||
|
||||
@@ -63,7 +63,7 @@ class movie_Core {
|
||||
$movie->mime_type = strtolower($pi["extension"]) == "mp4" ? "video/mp4" : "video/x-flv";
|
||||
$movie->thumb_dirty = 1;
|
||||
$movie->resize_dirty = 1;
|
||||
$movie->sort_column = "id";
|
||||
$movie->sort_column = "weight";
|
||||
$movie->rand_key = ((float)mt_rand()) / (float)mt_getrandmax();
|
||||
|
||||
// Randomize the name if there's a conflict
|
||||
|
||||
@@ -63,7 +63,7 @@ class photo_Core {
|
||||
$photo->mime_type = empty($image_info['mime']) ? "application/unknown" : $image_info['mime'];
|
||||
$photo->thumb_dirty = 1;
|
||||
$photo->resize_dirty = 1;
|
||||
$photo->sort_column = "id";
|
||||
$photo->sort_column = "weight";
|
||||
$photo->rand_key = ((float)mt_rand()) / (float)mt_getrandmax();
|
||||
|
||||
// Randomize the name if there's a conflict
|
||||
|
||||
@@ -295,6 +295,11 @@ class Item_Model extends ORM_MPTT {
|
||||
$this->updated = time();
|
||||
if (!$this->loaded) {
|
||||
$this->created = $this->updated;
|
||||
// let albums have a weight of zero so they come first
|
||||
if (!$this->is_album()) {
|
||||
$r = ORM::factory("item")->select("MAX(weight) as max_weight")->find();
|
||||
$this->weight = $r->max_weight + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return parent::save();
|
||||
|
||||
@@ -31,7 +31,7 @@ class Albums_Controller_Test extends Unit_Test_Case {
|
||||
$_POST["name"] = "new name";
|
||||
$_POST["title"] = "new title";
|
||||
$_POST["description"] = "new description";
|
||||
$_POST["column"] = "id";
|
||||
$_POST["column"] = "weight";
|
||||
$_POST["direction"] = "ASC";
|
||||
$_POST["csrf"] = access::csrf_token();
|
||||
$_POST["_method"] = "put";
|
||||
|
||||
@@ -29,7 +29,7 @@ class ORM_MPTT_Test extends Unit_Test_Case {
|
||||
$album = ORM::factory("item");
|
||||
$album->type = "album";
|
||||
$album->rand_key = ((float)mt_rand()) / (float)mt_getrandmax();
|
||||
$album->sort_column = "id";
|
||||
$album->sort_column = "weight";
|
||||
$album->sort_order = "ASC";
|
||||
$album->add_to_parent($root);
|
||||
|
||||
@@ -155,7 +155,7 @@ class ORM_MPTT_Test extends Unit_Test_Case {
|
||||
$parent = ORM::factory("item");
|
||||
$parent->type = "album";
|
||||
$parent->rand_key = ((float)mt_rand()) / (float)mt_getrandmax();
|
||||
$parent->sort_column = "id";
|
||||
$parent->sort_column = "weight";
|
||||
$parent->sort_order = "ASC";
|
||||
$parent->add_to_parent($root);
|
||||
|
||||
@@ -166,7 +166,7 @@ class ORM_MPTT_Test extends Unit_Test_Case {
|
||||
$album1 = ORM::factory("item");
|
||||
$album1->type = "album";
|
||||
$album1->rand_key = ((float)mt_rand()) / (float)mt_getrandmax();
|
||||
$album1->sort_column = "id";
|
||||
$album1->sort_column = "weight";
|
||||
$album1->sort_order = "ASC";
|
||||
$album1->add_to_parent($parent);
|
||||
|
||||
|
||||
@@ -139,6 +139,7 @@ CREATE TABLE {items} (
|
||||
`rand_key` float default NULL,
|
||||
`sort_column` varchar(64) default NULL,
|
||||
`sort_order` char(4) default 'ASC',
|
||||
`weight` int(9) NOT NULL default '0',
|
||||
`view_1` tinyint(2) NOT NULL default '0',
|
||||
`view_2` tinyint(2) NOT NULL default '0',
|
||||
PRIMARY KEY (`id`),
|
||||
@@ -147,7 +148,7 @@ CREATE TABLE {items} (
|
||||
KEY `random` (`rand_key`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
|
||||
SET character_set_client = @saved_cs_client;
|
||||
INSERT INTO {items} VALUES (NULL,UNIX_TIMESTAMP(),'',NULL,1,1,1,NULL,NULL,NULL,0,NULL,NULL,1,2,NULL,NULL,1,'Gallery','album',UNIX_TIMESTAMP(),0,NULL,NULL,'id','ASC',1,1);
|
||||
INSERT INTO {items} VALUES (NULL,UNIX_TIMESTAMP(),'',NULL,1,1,1,NULL,NULL,NULL,0,NULL,NULL,1,2,NULL,NULL,1,'Gallery','album',UNIX_TIMESTAMP(),0,NULL,NULL,'weight','ASC',0,1,1);
|
||||
DROP TABLE IF EXISTS {items_tags};
|
||||
SET @saved_cs_client = @@character_set_client;
|
||||
SET character_set_client = utf8;
|
||||
@@ -325,4 +326,4 @@ CREATE TABLE {vars} (
|
||||
UNIQUE KEY `module_name` (`module_name`,`name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8;
|
||||
SET character_set_client = @saved_cs_client;
|
||||
INSERT INTO {vars} VALUES (1,'core','active_site_theme','default'),(2,'core','active_admin_theme','admin_default'),(3,'core','page_size','9'),(4,'core','thumb_size','200'),(5,'core','resize_size','640'),(6,'core','default_locale','en_US'),(7,'core','graphics_toolkit','imagemagick'),(8,'core','graphics_toolkit_path','/usr/bin'),(9,'core','blocks_dashboard_sidebar','a:4:{i:1804289383;a:2:{i:0;s:4:\"core\";i:1;s:11:\"block_adder\";}i:846930886;a:2:{i:0;s:4:\"core\";i:1;s:5:\"stats\";}i:1681692777;a:2:{i:0;s:4:\"core\";i:1;s:13:\"platform_info\";}i:1714636915;a:2:{i:0;s:4:\"core\";i:1;s:12:\"project_news\";}}'),(10,'core','blocks_dashboard_center','a:4:{i:1957747793;a:2:{i:0;s:4:\"core\";i:1;s:7:\"welcome\";}i:424238335;a:2:{i:0;s:4:\"core\";i:1;s:12:\"photo_stream\";}i:719885386;a:2:{i:0;s:4:\"core\";i:1;s:11:\"log_entries\";}i:1649760492;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'),(11,'core','version','3.0 Alpha 3'),(12,'comment','spam_caught','0');
|
||||
INSERT INTO {vars} VALUES (1,'core','active_site_theme','default'),(2,'core','active_admin_theme','admin_default'),(3,'core','page_size','9'),(4,'core','thumb_size','200'),(5,'core','resize_size','640'),(6,'core','default_locale','en_US'),(7,'core','graphics_toolkit','imagemagick'),(8,'core','graphics_toolkit_path','/usr/bin'),(9,'core','blocks_dashboard_sidebar','a:4:{i:1804289383;a:2:{i:0;s:4:\"core\";i:1;s:11:\"block_adder\";}i:846930886;a:2:{i:0;s:4:\"core\";i:1;s:5:\"stats\";}i:1681692777;a:2:{i:0;s:4:\"core\";i:1;s:13:\"platform_info\";}i:1714636915;a:2:{i:0;s:4:\"core\";i:1;s:12:\"project_news\";}}'),(10,'core','blocks_dashboard_center','a:4:{i:1957747793;a:2:{i:0;s:4:\"core\";i:1;s:7:\"welcome\";}i:424238335;a:2:{i:0;s:4:\"core\";i:1;s:12:\"photo_stream\";}i:719885386;a:2:{i:0;s:4:\"core\";i:1;s:11:\"log_entries\";}i:1649760492;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'),(11,'core','version','3.0 pre-beta svn'),(12,'comment','spam_caught','0');
|
||||
|
||||
@@ -83,8 +83,9 @@
|
||||
</td>
|
||||
<td class="gActions">
|
||||
<a href="<?= url::site("admin/users/edit_user_form/$user->id") ?>"
|
||||
open_text="<?= t("close") ?>"
|
||||
class="gPanelLink gButtonLink ui-state-default ui-corner-all ui-icon-left">
|
||||
<span class="ui-icon ui-icon-pencil"></span><?= t("edit") ?></a>
|
||||
<span class="ui-icon ui-icon-pencil"></span><span class="gButtonText"><?= t("edit") ?></span></a>
|
||||
<? if (user::active()->id != $user->id && !$user->guest): ?>
|
||||
<a href="<?= url::site("admin/users/delete_user_form/$user->id") ?>"
|
||||
class="gDialogLink gButtonLink ui-state-default ui-corner-all ui-icon-left">
|
||||
|
||||
Reference in New Issue
Block a user