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


PHP item::remove_album_cover方法代码示例

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


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

示例1: move

 static function move($source, $target)
 {
     access::required("view", $source);
     access::required("view", $target);
     access::required("edit", $source);
     access::required("edit", $target);
     $parent = $source->parent();
     if ($parent->album_cover_item_id == $source->id) {
         if ($parent->children_count() > 1) {
             foreach ($parent->children(2) as $child) {
                 if ($child->id != $source->id) {
                     $new_cover_item = $child;
                     break;
                 }
             }
             item::make_album_cover($new_cover_item);
         } else {
             item::remove_album_cover($parent);
         }
     }
     $source->move_to($target);
     // If the target has no cover item, make this it.
     if ($target->album_cover_item_id == null) {
         item::make_album_cover($source);
     }
 }
开发者ID:krgeek,项目名称:gallery3,代码行数:26,代码来源:item.php

示例2: delete

 public function delete()
 {
     if ($this->id == 1) {
         $v = new Validation(array("id"));
         $v->add_error("id", "cant_delete_root_album");
         ORM_Validation_Exception::handle_validation($this->table_name, $v);
     }
     $old = clone $this;
     module::event("item_before_delete", $this);
     $parent = $this->parent();
     if ($parent->album_cover_item_id == $this->id) {
         item::remove_album_cover($parent);
     }
     $path = $this->file_path();
     $resize_path = $this->resize_path();
     $thumb_path = $this->thumb_path();
     parent::delete();
     if (is_dir($path)) {
         // Take some precautions against accidentally deleting way too much
         $delete_resize_path = dirname($resize_path);
         $delete_thumb_path = dirname($thumb_path);
         if ($delete_resize_path == VARPATH . "resizes" || $delete_thumb_path == VARPATH . "thumbs" || $path == VARPATH . "albums") {
             throw new Exception("@todo DELETING_TOO_MUCH ({$delete_resize_path}, {$delete_thumb_path}, {$path})");
         }
         @dir::unlink($path);
         @dir::unlink($delete_resize_path);
         @dir::unlink($delete_thumb_path);
     } else {
         @unlink($path);
         @unlink($resize_path);
         @unlink($thumb_path);
     }
     module::event("item_deleted", $old);
 }
开发者ID:joericochuyt,项目名称:gallery3,代码行数:34,代码来源:item.php

示例3: item_deleted

 static function item_deleted($item)
 {
     access::delete_item($item);
     // Find any other albums that had the deleted item as the album cover and null it out.
     // In some cases this may leave us with a missing album cover up in this item's parent
     // hierarchy, but in most cases it'll work out fine.
     foreach (ORM::factory("item")->where("album_cover_item_id", "=", $item->id)->find_all() as $parent) {
         item::remove_album_cover($parent);
     }
     $parent = $item->parent();
     if (!$parent->album_cover_item_id) {
         // Assume that we deleted the album cover
         if (batch::in_progress()) {
             // Remember that this parent is missing an album cover, for later.
             $batch_missing_album_cover = Session::instance()->get("batch_missing_album_cover", array());
             $batch_missing_album_cover[$parent->id] = 1;
             Session::instance()->set("batch_missing_album_cover", $batch_missing_album_cover);
         } else {
             // Choose the first viewable child as the new cover.
             if ($child = $parent->viewable()->children(1)->current()) {
                 item::make_album_cover($child);
             }
         }
     }
 }
开发者ID:kandsten,项目名称:gallery3,代码行数:25,代码来源:gallery_event.php

示例4: move

 static function move($source, $target)
 {
     access::required("view", $source);
     access::required("view", $target);
     access::required("edit", $source);
     access::required("edit", $target);
     $parent = $source->parent();
     if ($parent->album_cover_item_id == $source->id) {
         if ($parent->children_count() > 1) {
             foreach ($parent->children(2) as $child) {
                 if ($child->id != $source->id) {
                     $new_cover_item = $child;
                     break;
                 }
             }
             item::make_album_cover($new_cover_item);
         } else {
             item::remove_album_cover($parent);
         }
     }
     $orig_name = $source->name;
     $source->parent_id = $target->id;
     $source->save();
     if ($orig_name != $source->name) {
         switch ($source->type) {
             case "album":
                 message::info(t("Album <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", array("old_name" => $orig_name, "new_name" => $source->name)));
                 break;
             case "photo":
                 message::info(t("Photo <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", array("old_name" => $orig_name, "new_name" => $source->name)));
                 break;
             case "movie":
                 message::info(t("Movie <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", array("old_name" => $orig_name, "new_name" => $source->name)));
                 break;
         }
     }
     // If the target has no cover item, make this it.
     if ($target->album_cover_item_id == null) {
         item::make_album_cover($source);
     }
 }
开发者ID:qboy1987,项目名称:mooiyou,代码行数:41,代码来源:item.php

示例5: delete

 public function delete()
 {
     $old = clone $this;
     module::event("item_before_delete", $this);
     $parent = $this->parent();
     if ($parent->album_cover_item_id == $this->id) {
         item::remove_album_cover($parent);
     }
     $path = $this->file_path();
     $resize_path = $this->resize_path();
     $thumb_path = $this->thumb_path();
     parent::delete();
     if (is_dir($path)) {
         @dir::unlink($path);
         @dir::unlink(dirname($resize_path));
         @dir::unlink(dirname($thumb_path));
     } else {
         @unlink($path);
         @unlink($resize_path);
         @unlink($thumb_path);
     }
     module::event("item_deleted", $old);
 }
开发者ID:ChrisRut,项目名称:gallery3,代码行数:23,代码来源:item.php

示例6: move

 static function move($source, $target)
 {
     access::required("view", $source);
     access::required("view", $target);
     access::required("edit", $source);
     access::required("edit", $target);
     $parent = $source->parent();
     if ($parent->album_cover_item_id == $source->id) {
         if ($parent->children_count() > 1) {
             foreach ($parent->children(2) as $child) {
                 if ($child->id != $source->id) {
                     $new_cover_item = $child;
                     break;
                 }
             }
             item::make_album_cover($new_cover_item);
         } else {
             item::remove_album_cover($parent);
         }
     }
     $source->parent_id = $target->id;
     // Moving may result in name or slug conflicts.  If that happens, try up to 5 times to pick a
     // random name (or slug) to avoid the conflict.
     $orig_name = $source->name;
     $orig_name_filename = pathinfo($source->name, PATHINFO_FILENAME);
     $orig_name_extension = pathinfo($source->name, PATHINFO_EXTENSION);
     $orig_slug = $source->slug;
     for ($i = 0; $i < 5; $i++) {
         try {
             $source->save();
             if ($orig_name != $source->name) {
                 switch ($source->type) {
                     case "album":
                         message::info(t("Album <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", array("old_name" => $orig_name, "new_name" => $source->name)));
                         break;
                     case "photo":
                         message::info(t("Photo <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", array("old_name" => $orig_name, "new_name" => $source->name)));
                         break;
                     case "movie":
                         message::info(t("Movie <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", array("old_name" => $orig_name, "new_name" => $source->name)));
                         break;
                 }
             }
             break;
         } catch (ORM_Validation_Exception $e) {
             $rand = rand(10, 99);
             $errors = $e->validation->errors();
             if (isset($errors["name"])) {
                 $source->name = $orig_name_filename . "-{$rand}." . $orig_name_extension;
                 unset($errors["name"]);
             }
             if (isset($errors["slug"])) {
                 $source->slug = $orig_slug . "-{$rand}";
                 unset($errors["slug"]);
             }
             if ($errors) {
                 // There were other validation issues-- we don't know how to handle those
                 throw $e;
             }
         }
     }
     // If the target has no cover item, make this it.
     if ($target->album_cover_item_id == null) {
         item::make_album_cover($source);
     }
 }
开发者ID:kandsten,项目名称:gallery3,代码行数:66,代码来源:item.php


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