/** * Get the XML <rss> node corresponding to the last pictures registered * * @param page The current page (defaults to 0) * @param show The number of pictures to include in one field (default 30) */ function get_last_pictures_mrss($page = 0, $show = 30) { $images = nggdb::find_last_images($page, $show); $title = stripslashes(get_option('blogname')); $description = stripslashes(get_option('blogdescription')); $link = site_url(); $prev_link = $page > 0 ? nggMediaRss::get_last_pictures_mrss_url($page - 1, $show) : ''; $next_link = count($images) != 0 ? nggMediaRss::get_last_pictures_mrss_url($page + 1, $show) : ''; return nggMediaRss::get_mrss_root_node($title, $description, $link, $prev_link, $next_link, $images); }
/** * nggShowRandomRecent($type, $maxImages, $template, $galleryId) - return recent or random images * * @access public * @param string $type 'id' (for latest addition to DB), 'date' (for image with the latest date), 'sort' (for image sorted by user order) or 'random' * @param integer $maxImages of images * @param string $template (optional) name for a template file, look for gallery-$template * @param int $galleryId Limit to a specific gallery * @return the content */ function nggShowRandomRecent($type, $maxImages, $template = '', $galleryId = 0) { // $_GET from wp_query $pid = get_query_var('pid'); $pageid = get_query_var('pageid'); // get now the recent or random images switch ($type) { case 'random': $picturelist = nggdb::get_random_images($maxImages, $galleryId); break; case 'id': $picturelist = nggdb::find_last_images(0, $maxImages, true, $galleryId, 'id'); break; case 'date': $picturelist = nggdb::find_last_images(0, $maxImages, true, $galleryId, 'date'); break; case 'sort': $picturelist = nggdb::find_last_images(0, $maxImages, true, $galleryId, 'sort'); break; default: // default is by pid $picturelist = nggdb::find_last_images(0, $maxImages, true, $galleryId, 'id'); } // look for ImageBrowser if we have a $_GET('pid') if ($pageid == get_the_ID() || !is_home()) { if (!empty($pid)) { $out = nggCreateImageBrowser($picturelist); return $out; } } // go on if not empty if (empty($picturelist)) { return; } // show gallery if (is_array($picturelist)) { $out = nggCreateGallery($picturelist, false, $template); } $out = apply_filters('ngg_show_images_content', $out, $picturelist); return $out; }
function start_process() { global $ngg; if (!$this->valid_access()) { return; } switch ($this->method) { case 'search': //search for some images $this->result['images'] = array_merge((array) nggdb::search_for_images($this->term), (array) nggTags::find_images_for_tags($this->term, 'ASC')); break; case 'album': //search for some album //TODO : Get images for each gallery, could end in a big db query $this->result['album'] = nggdb::find_album($this->id); break; case 'gallery': //search for some gallery $this->result['images'] = $this->id == 0 ? nggdb::find_last_images(0, 100) : nggdb::get_gallery($this->id, $ngg->options['galSort'], $ngg->options['galSortDir'], true, 0, 0, true); break; case 'image': //search for some image $this->result['images'] = nggdb::find_image($this->id); break; case 'tag': //search for images based on tags $this->result['images'] = nggTags::find_images_for_tags($this->term, 'ASC'); break; case 'recent': //search for images based on tags $this->result['images'] = nggdb::find_last_images(0, $this->limit); break; case 'autocomplete': //return images, galleries or albums for autocomplete drop down list return $this->autocomplete(); break; case 'version': $this->result = array('stat' => 'ok', 'version' => $ngg->version); return; break; default: $this->result = array('stat' => 'fail', 'code' => '98', 'message' => 'Method not known.'); return false; break; } // result should be fine $this->result['stat'] = 'ok'; }
<?php //引入图片插件入口文件 require_once './wp-content/plugins/nextgen-gallery/ngg-config.php'; require_once './inc/php/cfg.php'; $fotos = nggdb::find_last_images(0, 50); //var_dump($fotos); //取图片tags $foto_ids = array(); foreach ($fotos as $foto) { $foto_ids[] = $foto->pid; } $args = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'all_with_object_id'); $tags = wp_get_object_terms($foto_ids, 'ngg_tag', $args); $tags_arr = array(); foreach ($tags as $tag) { $tags_arr[$tag->object_id][] = array('term_id' => $tag->term_id, 'name' => $tag->name, 'slug' => $tag->slug); } header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>'; ?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" > <channel>
/** * Show watermark related settings. */ private function tab_watermark() { global $ngg; // take the first image as sample $image_array = nggdb::find_last_images(0, 1); $ngg_image = $image_array[0]; $imageID = $ngg_image->pid; ?> <h3><?php _e('Watermark', 'nggallery'); ?> </h3> <p><?php _e('Please note : you can only activate the watermark under -> Manage Galleries. This action cannot be undone.', 'nggallery'); ?> </p> <form name="watermarkform" method="POST" action="<?php echo $this->filepath . '#watermark'; ?> "> <?php wp_nonce_field('ngg_settings'); ?> <input type="hidden" name="page_options" value="wmPos,wmXpos,wmYpos,wmType,wmPath,wmFont,wmSize,wmColor,wmText,wmOpaque" /> <div id="wm-preview"> <h3><?php esc_html_e('Preview', 'nggallery'); ?> </h3> <label for="wm-preview-select"><?php _e('Select an image', 'nggallery'); ?> </label> <select id="wm-preview-select" name="wm-preview-img" style="width: 200px"> <?php echo '<option value="' . $ngg_image->pid . '">' . $ngg_image->pid . ' - ' . $ngg_image->alttext . '</option>'; ?> </select> <div id="wm-preview-container"> <a id="wm-preview-image-url" href="<?php echo home_url('index.php'); ?> ?callback=image&pid=<?php echo intval($imageID); ?> &mode=watermark" target="_blank" title="<?php _e("View full image", 'nggallery'); ?> "> <img id="wm-preview-image" src="<?php echo home_url('index.php'); ?> ?callback=image&pid=<?php echo intval($imageID); ?> &mode=watermark" /> </a> </div> <h3><?php _e('Position', 'nggallery'); ?> </h3> <table id="wm-position"> <tr> <td> <strong><?php _e('Position', 'nggallery'); ?> </strong> <table> <tr> <td><input type="radio" name="wmPos" value="topLeft" <?php checked('topLeft', $ngg->options['wmPos']); ?> /></td> <td><input type="radio" name="wmPos" value="topCenter" <?php checked('topCenter', $ngg->options['wmPos']); ?> /></td> <td><input type="radio" name="wmPos" value="topRight" <?php checked('topRight', $ngg->options['wmPos']); ?> /></td> </tr> <tr> <td><input type="radio" name="wmPos" value="midLeft" <?php checked('midLeft', $ngg->options['wmPos']); ?> /></td> <td><input type="radio" name="wmPos" value="midCenter" <?php checked('midCenter', $ngg->options['wmPos']); ?> /></td> <td><input type="radio" name="wmPos" value="midRight" <?php checked('midRight', $ngg->options['wmPos']); ?> /></td> </tr> <tr> <td><input type="radio" name="wmPos" value="botLeft" <?php checked('botLeft', $ngg->options['wmPos']); ?> /></td> <td><input type="radio" name="wmPos" value="botCenter" <?php checked('botCenter', $ngg->options['wmPos']); ?> /></td> <td><input type="radio" name="wmPos" value="botRight" <?php checked('botRight', $ngg->options['wmPos']); ?> /></td> </tr> </table> </td> <td> <strong><?php _e('Offset', 'nggallery'); ?> </strong> <table border="0"> <tr> <td><label for="wmXpos">x:</label></td> <td><input type="number" step="1" min="0" class="small-text" name="wmXpos" id="wmXpos" value="<?php echo $ngg->options['wmXpos']; ?> ">px</td> </tr> <tr> <td><label for="wmYpos">y:</label></td> <td><input type="number" step="1" min="0" class="small-text" name="wmYpos" id="wmYpos" value="<?php echo $ngg->options['wmYpos']; ?> " />px</td> </tr> </table> </td> </tr> </table> </div> <h3><label><input type="radio" name="wmType" value="image" <?php checked('image', $ngg->options['wmType']); ?> ><?php _e('Use image as watermark', 'nggallery'); ?> </label></h3> <table class="wm-table form-table"> <tr> <th><label for="wmPath"><?php _e('URL to file', 'nggallery'); ?> </label></th> <td><input type="text" class="regular-text code" name="wmPath" id="wmPath" value="<?php echo $ngg->options['wmPath']; ?> "><br> </tr> </table> <h3><label><input type="radio" name="wmType" value="text" <?php checked('text', $ngg->options['wmType']); ?> ><?php _e('Use text as watermark', 'nggallery'); ?> </label></h3> <table class="wm-table form-table"> <tr> <th><?php _e('Font', 'nggallery'); ?> </th> <td> <select name="wmFont" size="1"> <?php $fontlist = $this->get_fonts(); foreach ($fontlist as $fontfile) { echo "\n" . '<option value="' . $fontfile . '" ' . selected($fontfile, $ngg->options['wmFont']) . ' >' . $fontfile . '</option>'; } ?> </select><br> <span> <?php if (!function_exists('ImageTTFBBox')) { _e('This function will not work, cause you need the FreeType library', 'nggallery'); } else { _e('You can upload more fonts in the folder <strong>nggallery/fonts</strong>', 'nggallery'); } ?> </span> </td> </tr> <tr> <th><label for="wmSize"><?php _e('Size', 'nggallery'); ?> </label></th> <td><input type="number" step="1" min="0" class="small-text" name="wmSize" id="wmSize" value="<?php echo $ngg->options['wmSize']; ?> ">px</td> </tr> <tr> <th><label for="wmColor"><?php _e('Color', 'nggallery'); ?> </label></th> <td><input class="picker" type="text" id="wmColor" name="wmColor" value="<?php echo $ngg->options['wmColor']; ?> "> </tr> <tr> <th><label for="wmText"><?php _e('Text', 'nggallery'); ?> </label></th> <td><textarea name="wmText" id="wmText" cols="50" rows="5" class="normal-text"><?php echo $ngg->options['wmText']; ?> </textarea></td> </tr> <tr> <th><label for="wmOpaque"><?php _e('Opaque', 'nggallery'); ?> </label></th> <td><input type="number" step="1" min="0" max="100" class="small-text" name="wmOpaque" id="wmOpaque" value="<?php echo $ngg->options['wmOpaque']; ?> ">%</td> </tr> </table> <div class="clear"></div> <?php submit_button(__('Save Changes'), 'primary', 'updateoption'); ?> </form> <?php }