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


PHP Album::reset_covers方法代码示例

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


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

示例1: index

 function index()
 {
     // TODO: Make sure user is admin over content they trash
     list($params, $id) = $this->parse_params(func_get_args());
     if ($this->method != 'get') {
         $c = new Content();
         $a = new Album();
         $t = new Trash();
         $tag = new Tag();
         $options = array('content' => array(), 'albums' => array());
         $params = array_merge($options, $params);
         if (!empty($params['content'])) {
             $params['content'] = explode(',', $params['content']);
         }
         if (!empty($params['albums'])) {
             $params['albums'] = explode(',', $params['albums']);
         }
         switch ($this->method) {
             case 'post':
                 $q = array();
                 $content_ids = array();
                 $album_ids = array();
                 $now = time();
                 if (!empty($params['content'])) {
                     $content = $c->where_in('id', $params['content'])->get_iterated();
                     foreach ($content as $c) {
                         $q[] = "('content-{$c->id}', '" . $this->db->escape_str(utf8_encode(serialize($c->to_array(array('auth' => $this->auth))))) . "', {$now})";
                     }
                 }
                 if (!empty($params['albums'])) {
                     foreach ($params['albums'] as $album_id) {
                         $al = new Album();
                         $al->get_by_id($album_id);
                         if ($al->exists()) {
                             $q[] = "('album-{$al->id}', '" . $this->db->escape_str(utf8_encode(serialize($al->to_array()))) . "', {$now})";
                             $al->tree_trash();
                             foreach ($al->categories->get_iterated() as $category) {
                                 $category->update_counts('album');
                             }
                             foreach ($al->tags->get_iterated() as $tag) {
                                 $tag->update_counts('album');
                             }
                         }
                     }
                     $a->update_set_counts();
                 }
                 if (!empty($q)) {
                     $q = join(',', $q);
                     $this->db->query("INSERT INTO {$t->table} VALUES {$q} ON DUPLICATE KEY UPDATE data = VALUES(data)");
                 }
                 if (!empty($params['content'])) {
                     $c->where_in('id', $params['content'])->update('deleted', 1);
                     $albums = $a->where_in_related('content', 'id', $params['content'])->get_iterated();
                     foreach ($albums as $a) {
                         $a->update_counts();
                     }
                     $previews = $a->where_in_related('cover', 'id', $params['content'])->distinct()->get_iterated();
                     $prefix = preg_replace('/trash$/', '', $t->table);
                     $this->db->query("DELETE FROM {$prefix}join_albums_covers WHERE cover_id IN(" . join(',', $params['content']) . ")");
                     foreach ($previews as $a) {
                         $a->reset_covers();
                     }
                     foreach ($c->where_in('id', $params['content'])->get_iterated() as $content) {
                         foreach ($content->categories->get_iterated() as $category) {
                             $category->update_counts('content');
                         }
                         foreach ($content->tags->get_iterated() as $tag) {
                             $tag->update_counts('content');
                         }
                     }
                 }
                 $this->redirect('/trash');
                 break;
             case 'delete':
                 $ids = array();
                 foreach ($params['content'] as $id) {
                     $ids[] = "'content-{$id}'";
                 }
                 foreach ($params['albums'] as $id) {
                     $ids[] = "'album-{$id}'";
                 }
                 if (!empty($ids)) {
                     $ids = join(',', $ids);
                     $this->db->query("DELETE FROM {$t->table} WHERE id IN ({$ids})");
                 }
                 if (!empty($params['albums'])) {
                     foreach ($params['albums'] as $album_id) {
                         $al = new Album();
                         $al->get_by_id($album_id);
                         if ($al->exists()) {
                             $al->tree_trash_restore();
                             foreach ($al->categories->get_iterated() as $category) {
                                 $category->update_counts('album');
                             }
                             foreach ($al->tags->get_iterated() as $tag) {
                                 $tag->update_counts('album');
                             }
                         }
                     }
                     $a->update_set_counts();
//.........这里部分代码省略.........
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:101,代码来源:trashes.php

示例2: covers

 function covers()
 {
     list($params, $id) = $this->parse_params(func_get_args());
     $params['auth'] = $this->auth;
     // Standard add/delete cover
     list($id, $content_id) = $id;
     if ($this->method === 'get') {
         $this->redirect("/albums/{$id}");
     }
     $a = new Album($id);
     $c = new Content();
     if (!$a->exists()) {
         $this->error('404', 'Album not found.');
         return;
     }
     $cover_count = $a->covers->count();
     if ($cover_count > 50) {
         $this->error('403', 'Only 50 covers can be added to any one album.');
         return;
     }
     if ($a->album_type == 2 && $cover_count == 0) {
         $subs = new Album();
         $subs->select('id')->where('right_id <', $a->right_id)->where('left_id >', $a->left_id)->where('visibility', $a->visibility)->get_iterated();
         $id_arr = array();
         foreach ($subs as $sub) {
             $id_arr[] = $sub->id;
         }
         if (!empty($id_arr)) {
             $subc = new Content();
             $covers = $subc->query("SELECT DISTINCT cover_id FROM {$a->db_join_prefix}albums_covers WHERE album_id IN (" . join(',', $id_arr) . ") GROUP BY album_id LIMIT " . (3 - $cover_count));
             $f_ids = array();
             foreach ($covers as $f) {
                 $f_ids[] = $f->cover_id;
             }
             if (!empty($f_ids)) {
                 $subc->query("SELECT id FROM {$subc->table} WHERE id IN(" . join(',', $f_ids) . ") ORDER BY FIELD(id, " . join(',', array_reverse($f_ids)) . ")");
                 foreach ($subc as $content) {
                     $a->save_cover($content);
                 }
             }
         }
     }
     if (is_numeric($content_id)) {
         if ($this->method == 'delete') {
             $c->where_related('covers', 'id', $id)->get_by_id($content_id);
         } else {
             if ($a->album_type == 2) {
                 $c->get_by_id($content_id);
             } else {
                 $c->where_related('album', 'id', $id)->get_by_id($content_id);
             }
         }
         if (!$c->exists()) {
             $this->error('404', 'Content not found.');
             return;
         }
         if ($this->method == 'delete') {
             $a->delete_cover($c);
             $a->reset_covers();
         } else {
             $a->delete_cover($c);
             $a->save_cover($c);
         }
     } else {
         $content_id = explode(',', $content_id);
         if ($this->method == 'delete') {
             $c->where_related('covers', 'id', $id)->where_in('id', $content_id)->get_iterated();
         } else {
             if ($a->album_type == 2) {
                 $c->where_in('id', $content_id)->get_iterated();
             } else {
                 $c->where_related('album', 'id', $id)->where_in('id', $content_id)->get_iterated();
             }
         }
         if (!$c->result_count()) {
             $this->error('404', 'Content not found.');
             return;
         }
         if ($this->method == 'delete') {
             foreach ($c as $cover) {
                 $a->delete_cover($cover);
             }
             $a->reset_covers();
         } else {
             foreach ($c as $cover) {
                 $a->delete_cover($cover);
             }
             foreach ($content_id as $cid) {
                 $a->save_cover($c->get_by_id($cid));
             }
         }
     }
     $this->redirect("/albums/{$id}");
 }
开发者ID:Caldis,项目名称:htdocs,代码行数:94,代码来源:albums.php

示例3: Album

 function do_delete()
 {
     $a = new Album();
     $previews = $a->where_related('cover', 'id', $this->id)->get_iterated();
     foreach ($previews as $a) {
         $a->reset_covers();
     }
     $albums = $a->where_related('content', 'id', $this->id)->get_iterated();
     foreach ($albums as $a) {
         $a->update_counts();
     }
     $this->clear_cache();
     if (empty($this->storage_url)) {
         $original = $this->path_to_original();
         $info = pathinfo($original);
         $mid = preg_replace('/\\.' . $info['extension'] . '$/', '.1600.' . $info['extension'], $original);
         unlink($original);
         if (file_exists($mid)) {
             unlink($mid);
         }
         if ($this->file_type > 0 && is_dir($original . '_previews')) {
             delete_files($original . '_previews', true, 1);
         }
         if (@rmdir(dirname($original))) {
             @rmdir(dirname(dirname($original)));
         }
     } else {
         Shutter::delete_original($this->storage_url);
         if (!empty($this->storage_url_midsize)) {
             Shutter::delete_original($this->storage_url_midsize);
         }
     }
     Shutter::hook('content.delete', $this->to_array(array('auth' => true)));
     $s = new Slug();
     $this->db->query("DELETE FROM {$s->table} WHERE id = 'content.{$this->slug}'");
     $this->delete();
 }
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:37,代码来源:content.php


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