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


PHP nggAdmin::old_import_gallery方法代码示例

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


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

示例1: post_processor_images


//.........这里部分代码省略.........
         $pic_ids = explode(',', $_POST['TB_imagelist']);
         $taglist = explode(',', $_POST['taglist']);
         $taglist = array_map('trim', $taglist);
         if (is_array($pic_ids)) {
             foreach ($pic_ids as $pic_id) {
                 // which action should be performed ?
                 switch ($_POST['TB_bulkaction']) {
                     case 'no_action':
                         // No action
                         break;
                     case 'overwrite_tags':
                         // Overwrite tags
                         wp_set_object_terms($pic_id, $taglist, 'ngg_tag');
                         break;
                     case 'add_tags':
                         // Add / append tags
                         wp_set_object_terms($pic_id, $taglist, 'ngg_tag', TRUE);
                         break;
                     case 'delete_tags':
                         // Delete tags
                         $oldtags = wp_get_object_terms($pic_id, 'ngg_tag', 'fields=names');
                         // get the slugs, to vaoid  case sensitive problems
                         $slugarray = array_map('sanitize_title', $taglist);
                         $oldtags = array_map('sanitize_title', $oldtags);
                         // compare them and return the diff
                         $newtags = array_diff($oldtags, $slugarray);
                         wp_set_object_terms($pic_id, $newtags, 'ngg_tag');
                         break;
                 }
             }
             nggGallery::show_message(__('Tags changed', 'nggallery'));
         }
     }
     if (isset($_POST['updatepictures'])) {
         // Update pictures
         check_admin_referer('ngg_updategallery');
         if (nggGallery::current_user_can('NextGEN Edit gallery options') && !isset($_GET['s'])) {
             if (nggGallery::current_user_can('NextGEN Edit gallery title')) {
                 // don't forget to update the slug
                 $slug = nggdb::get_unique_slug(sanitize_title($_POST['title']), 'gallery', $this->gid);
                 $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggallery} SET title= '%s', slug= '%s' WHERE gid = %d", esc_attr($_POST['title']), $slug, $this->gid));
             }
             if (nggGallery::current_user_can('NextGEN Edit gallery path')) {
                 $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggallery} SET path= '%s' WHERE gid = %d", untrailingslashit(str_replace('\\', '/', trim(stripslashes($_POST['path'])))), $this->gid));
             }
             if (nggGallery::current_user_can('NextGEN Edit gallery description')) {
                 $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggallery} SET galdesc= '%s' WHERE gid = %d", esc_attr($_POST['gallerydesc']), $this->gid));
             }
             if (nggGallery::current_user_can('NextGEN Edit gallery page id')) {
                 $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggallery} SET pageid= '%d' WHERE gid = %d", (int) $_POST['pageid'], $this->gid));
             }
             if (nggGallery::current_user_can('NextGEN Edit gallery preview pic')) {
                 $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggallery} SET previewpic= '%d' WHERE gid = %d", (int) $_POST['previewpic'], $this->gid));
             }
             if (isset($_POST['author']) && nggGallery::current_user_can('NextGEN Edit gallery author')) {
                 $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggallery} SET author= '%d' WHERE gid = %d", (int) $_POST['author'], $this->gid));
             }
             wp_cache_delete($this->gid, 'ngg_gallery');
         }
         $this->update_pictures();
         //hook for other plugin to update the fields
         do_action('ngg_update_gallery', $this->gid, $_POST);
         nggGallery::show_message(__('Update successful', "nggallery"));
     }
     if (isset($_POST['scanfolder'])) {
         // Rescan folder
         check_admin_referer('ngg_updategallery');
         $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
         nggAdmin::import_gallery($gallerypath);
     }
     if (isset($_POST['oldscanfolder'])) {
         // old rescan folder
         check_admin_referer('ngg_updategallery');
         $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
         nggAdmin::old_import_gallery($gallerypath);
     }
     if (isset($_POST['addnewpage'])) {
         // Add a new page
         check_admin_referer('ngg_updategallery');
         $parent_id = esc_attr($_POST['parent_id']);
         $gallery_title = esc_attr($_POST['title']);
         $gallery_name = $wpdb->get_var("SELECT name FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
         // Create a WP page
         global $user_ID;
         $page['post_type'] = 'page';
         $page['post_content'] = '[nggallery id=' . $this->gid . ']';
         $page['post_parent'] = $parent_id;
         $page['post_author'] = $user_ID;
         $page['post_status'] = 'publish';
         $page['post_title'] = $gallery_title == '' ? $gallery_name : $gallery_title;
         $page = apply_filters('ngg_add_new_page', $page, $this->gid);
         $gallery_pageid = wp_insert_post($page);
         if ($gallery_pageid != 0) {
             $result = $wpdb->query("UPDATE {$wpdb->nggallery} SET title= '{$gallery_title}', pageid = '{$gallery_pageid}' WHERE gid = '{$this->gid}'");
             wp_cache_delete($this->gid, 'ngg_gallery');
             nggGallery::show_message(__('New gallery page ID', 'nggallery') . ' ' . $gallery_pageid . ' -> <strong>' . $gallery_title . '</strong> ' . __('created', 'nggallery'));
         }
         do_action('ngg_gallery_addnewpage', $this->gid);
     }
 }
开发者ID:valerol,项目名称:korpus,代码行数:101,代码来源:manage.php


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