当前位置: 首页>>代码示例>>PHP>>正文


PHP item::resequence_child_weights方法代码示例

本文整理汇总了PHP中item::resequence_child_weights方法的典型用法代码示例。如果您正苦于以下问题:PHP item::resequence_child_weights方法的具体用法?PHP item::resequence_child_weights怎么用?PHP item::resequence_child_weights使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在item的用法示例。


在下文中一共展示了item::resequence_child_weights方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: rearrange

 function rearrange()
 {
     access::verify_csrf();
     $input = Input::instance();
     $target = ORM::factory("item", $input->post("target_id"));
     if (!$target->loaded()) {
         json::reply(null);
         return;
     }
     $album = $target->parent();
     access::required("edit", $album);
     if ($album->sort_column != "weight") {
         // Force all the weights into the current order before changing the order to manual
         // @todo: consider making this a trigger in the Item_Model.
         item::resequence_child_weights($album);
         $album->sort_column = "weight";
         $album->sort_order = "ASC";
         $album->save();
     }
     $source_ids = explode(",", $input->post("source_ids"));
     $base_weight = $target->weight;
     if ($input->post("relative") == "after") {
         $base_weight++;
     }
     if ($source_ids) {
         // Make a hole the right size
         db::build()->update("items")->set("weight", db::expr("`weight` + " . count($source_ids)))->where("parent_id", "=", $album->id)->where("weight", ">=", $base_weight)->execute();
         // Move all the source items to the right spots.
         for ($i = 0; $i < count($source_ids); $i++) {
             $source = ORM::factory("item", $source_ids[$i]);
             if ($source->parent_id == $album->id) {
                 $source->weight = $base_weight + $i;
                 $source->save();
             }
         }
     }
     json::reply(null);
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:38,代码来源:organize.php

示例2: resequence_child_weights_test

 public function resequence_child_weights_test()
 {
     $album = test::random_album_unsaved();
     $album->sort_column = "id";
     $album->save();
     $photo1 = test::random_photo($album);
     $photo2 = test::random_photo($album);
     $this->assert_true($photo2->weight > $photo1->weight);
     $album->reload();
     $album->sort_order = "DESC";
     $album->save();
     item::resequence_child_weights($album);
     $this->assert_equal(2, $photo1->reload()->weight);
     $this->assert_equal(1, $photo2->reload()->weight);
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:15,代码来源:Item_Helper_Test.php


注:本文中的item::resequence_child_weights方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。