本文整理汇总了PHP中nggGallery类的典型用法代码示例。如果您正苦于以下问题:PHP nggGallery类的具体用法?PHP nggGallery怎么用?PHP nggGallery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了nggGallery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getData
function getData($number)
{
global $wpdb;
$data = array();
$pictures = $wpdb->get_results("SELECT a.*, b.path FROM " . $wpdb->base_prefix . "ngg_pictures AS a LEFT JOIN " . $wpdb->base_prefix . "ngg_gallery AS b ON a.galleryid = b.gid WHERE a.galleryid = '" . intval($this->_data->get('nggsourcegallery', 0)) . "'");
$i = 0;
if (class_exists('nggGallery') && !class_exists('C_Component_Registry')) {
// legacy
foreach ($pictures as $p) {
$data[$i]['alt_text'] = $p->alttext;
$data[$i]['image'] = nggGallery::get_image_url($p->pid, $p->path, $p->filename);
$data[$i]['thumbnail'] = nggGallery::get_thumbnail_url($p->pid, $p->path, $p->filename);
$i++;
}
} else {
$storage = C_Component_Registry::get_instance()->get_utility('I_Gallery_Storage');
foreach ($pictures as $p) {
$data[$i]['alt_text'] = $p->alttext;
$data[$i]['image'] = $storage->get_image_url($p);
$data[$i]['thumbnail'] = $storage->get_thumbnail_url($p);
$i++;
}
}
return $data;
}
示例2: nextgengallery_showfirstpic
function nextgengallery_showfirstpic($galleryid, $class = '')
{
global $wpdb;
global $ngg_options;
if (!$galleryid) {
return;
}
if (!$wpdb->nggallery) {
return;
}
if (!$ngg_options) {
$ngg_options = get_option('ngg_options');
}
$picturelist = $wpdb->get_results("SELECT t.*, tt.* FROM {$wpdb->nggallery} AS t INNER JOIN {$wpdb->nggpictures} AS tt ON t.gid = tt.galleryid WHERE t.gid = '{$galleryid}' AND tt.exclude != 1 ORDER BY tt.{$ngg_options['galSort']} {$ngg_options['galSortDir']} LIMIT 1");
if ($class) {
$myclass = ' class="' . $class . '" ';
}
if ($picturelist) {
$pid = $picturelist[0]->pid;
if (is_callable(array('nggGallery', 'get_thumbnail_url'))) {
// new NextGen 1.0+
$out = '<img alt="' . __('property photo') . '" src="' . nggGallery::get_thumbnail_url($pid) . '" ' . $myclass . ' />';
} else {
// backwards compatibility - NextGen below 1.0
$out = '<img alt="' . __('property photo') . '" src="' . nggallery::get_thumbnail_url($pid) . '" ' . $myclass . ' />';
}
return $out;
}
}
示例3: processor
/**
* Save/Load options and add a new hook for plugins
*
* @return void
*/
function processor()
{
global $ngg, $nggRewrite;
$old_state = $ngg->options['usePermalinks'];
if (isset($_POST['irDetect'])) {
check_admin_referer('ngg_settings');
$ngg->options['irURL'] = ngg_search_imagerotator();
update_option('ngg_options', $ngg->options);
}
if (isset($_POST['updateoption'])) {
check_admin_referer('ngg_settings');
// get the hidden option fields, taken from WP core
if ($_POST['page_options']) {
$options = explode(',', stripslashes($_POST['page_options']));
}
if ($options) {
foreach ($options as $option) {
$option = trim($option);
$value = isset($_POST[$option]) ? trim($_POST[$option]) : false;
// $value = sanitize_option($option, $value); // This does stripslashes on those that need it
$ngg->options[$option] = $value;
}
// the path should always end with a slash
$ngg->options['gallerypath'] = trailingslashit($ngg->options['gallerypath']);
$ngg->options['imageMagickDir'] = trailingslashit($ngg->options['imageMagickDir']);
// the custom sortorder must be ascending
$ngg->options['galSortDir'] = $ngg->options['galSort'] == 'sortorder' ? 'ASC' : $ngg->options['galSortDir'];
}
// Save options
update_option('ngg_options', $ngg->options);
// Flush Rewrite rules
if ($old_state != $ngg->options['usePermalinks']) {
$nggRewrite->flush();
}
nggGallery::show_message(__('Update Successfully', 'nggallery'));
}
if (isset($_POST['clearcache'])) {
check_admin_referer('ngg_settings');
$path = WINABSPATH . $ngg->options['gallerypath'] . 'cache/';
if (is_dir($path)) {
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
@unlink($path . '/' . $file);
}
}
closedir($handle);
}
}
nggGallery::show_message(__('Cache cleared', 'nggallery'));
}
if (isset($_POST['createslugs'])) {
check_admin_referer('ngg_settings');
include_once dirname(__FILE__) . '/upgrade.php';
ngg_rebuild_unique_slugs::start_rebuild();
}
do_action('ngg_update_options_page');
}
示例4: createNewThumb
function createNewThumb()
{
global $ngg;
// check for correct capability
if (!is_user_logged_in()) {
die('-1');
}
// check for correct NextGEN capability
if (!current_user_can('NextGEN Manage gallery')) {
die('-1');
}
include_once nggGallery::graphic_library();
$id = (int) $_POST['id'];
$picture = nggdb::find_image($id);
$x = round($_POST['x'] * $_POST['rr'], 0);
$y = round($_POST['y'] * $_POST['rr'], 0);
$w = round($_POST['w'] * $_POST['rr'], 0);
$h = round($_POST['h'] * $_POST['rr'], 0);
$thumb = new ngg_Thumbnail($picture->imagePath, TRUE);
$thumb->crop($x, $y, $w, $h);
// Note : the routine is a bit different to create_thumbnail(), due to rounding it's resized in the other way
if ($ngg->options['thumbfix']) {
// check for portrait format
if ($thumb->currentDimensions['height'] > $thumb->currentDimensions['width']) {
// first resize to the wanted height, here changed to create_thumbnail()
$thumb->resize(0, $ngg->options['thumbheight']);
// get optimal y startpos
$ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2;
$thumb->crop(0, $ypos, $ngg->options['thumbwidth'], $ngg->options['thumbheight']);
} else {
// first resize to the wanted width, here changed to create_thumbnail()
$thumb->resize($ngg->options['thumbwidth'], 0);
//
// get optimal x startpos
$xpos = ($thumb->currentDimensions['width'] - $ngg->options['thumbwidth']) / 2;
$thumb->crop($xpos, 0, $ngg->options['thumbwidth'], $ngg->options['thumbheight']);
}
//this create a thumbnail but keep ratio settings
} else {
$thumb->resize($ngg->options['thumbwidth'], $ngg->options['thumbheight']);
}
if ($thumb->save($picture->thumbPath, 100)) {
//read the new sizes
$new_size = @getimagesize($picture->thumbPath);
$size['width'] = $new_size[0];
$size['height'] = $new_size[1];
// add them to the database
nggdb::update_image_meta($picture->pid, array('thumbnail' => $size));
echo "OK";
} else {
header('HTTP/1.1 500 Internal Server Error');
echo "KO";
}
exit;
}
示例5: instantiate
public function instantiate()
{
$this->options = nggGallery::get_option('ngg_options');
$this->overwriteNggConf();
add_filter('ngg_show_gallery_content', array(&$this, "ngg_show_gallery_content"));
add_filter('ngg_show_imagebrowser_content', array(&$this, "ngg_show_imagebrowser_content"));
add_filter('ngg_show_album_content', array(&$this, "ngg_show_album_content"));
add_filter('ngg_show_slideshow_content', array(&$this, "ngg_show_slideshow_content"), 10, 4);
add_filter('ngg_show_slideshow_widget_content', array(&$this, "ngg_show_slideshow_widget_content"), 10, 4);
add_filter('ngg_slideshow_size', array(&$this, "ngg_slideshow_size"));
add_filter('wptouch_user_agents', array(&$this, "wptouch_user_agents"));
}
示例6: check_quota
/**
* Check the Quota under WPMU. Only needed for this case
*
* @class nggWPMU
* @return bool $result
*/
function check_quota()
{
if (get_site_option('upload_space_check_disabled')) {
return false;
}
if (is_multisite() && nggWPMU::wpmu_enable_function('wpmuQuotaCheck')) {
if ($error = upload_is_user_over_quota(false)) {
nggGallery::show_error(__('Sorry, you have used your space allocation. Please delete some files to upload more files.', 'nggallery'));
return true;
}
}
return false;
}
示例7: get_gallery_mrss
/**
* Get the XML <rss> node corresponding to a gallery
*
* @param $gallery (object) The gallery to include in RSS
* @param $prev_gallery (object) The previous gallery to link in RSS (null if none)
* @param $next_gallery (object) The next gallery to link in RSS (null if none)
*/
function get_gallery_mrss($gallery, $prev_gallery = null, $next_gallery = null)
{
$ngg_options = nggGallery::get_option('ngg_options');
//Set sort order value, if not used (upgrade issue)
$ngg_options['galSort'] = $ngg_options['galSort'] ? $ngg_options['galSort'] : 'pid';
$ngg_options['galSortDir'] = $ngg_options['galSortDir'] == 'DESC' ? 'DESC' : 'ASC';
$title = stripslashes(M_I18N::translate($gallery->title));
$description = stripslashes(M_I18N::translate($gallery->galdesc));
$link = nggMediaRss::get_permalink($gallery->pageid);
$prev_link = $prev_gallery != null ? nggMediaRss::get_gallery_mrss_url($prev_gallery->gid, true) : '';
$next_link = $next_gallery != null ? nggMediaRss::get_gallery_mrss_url($next_gallery->gid, true) : '';
$images = nggdb::get_gallery($gallery->gid, $ngg_options['galSort'], $ngg_options['galSortDir']);
return nggMediaRss::get_mrss_root_node($title, $description, $link, $prev_link, $next_link, $images);
}
示例8: createNewThumb
function createNewThumb()
{
// check for correct capability
if (!is_user_logged_in()) {
die('-1');
}
// check for correct NextGEN capability
if (!current_user_can('NextGEN Manage gallery')) {
die('-1');
}
require_once dirname(dirname(__FILE__)) . '/ngg-config.php';
include_once nggGallery::graphic_library();
$ngg_options = get_option('ngg_options');
$id = (int) $_POST['id'];
$picture = nggdb::find_image($id);
$x = round($_POST['x'] * $_POST['rr'], 0);
$y = round($_POST['y'] * $_POST['rr'], 0);
$w = round($_POST['w'] * $_POST['rr'], 0);
$h = round($_POST['h'] * $_POST['rr'], 0);
$thumb = new ngg_Thumbnail($picture->imagePath, TRUE);
$thumb->crop($x, $y, $w, $h);
if ($ngg_options['thumbfix']) {
if ($thumb->currentDimensions['height'] > $thumb->currentDimensions['width']) {
$thumb->resize($ngg_options['thumbwidth'], 0);
} else {
$thumb->resize(0, $ngg_options['thumbheight']);
}
} else {
$thumb->resize($ngg_options['thumbwidth'], $ngg_options['thumbheight'], $ngg_options['thumbResampleMode']);
}
if ($thumb->save($picture->thumbPath, 100)) {
//read the new sizes
$new_size = @getimagesize($picture->thumbPath);
$size['width'] = $new_size[0];
$size['height'] = $new_size[1];
// add them to the database
nggdb::update_image_meta($picture->pid, array('thumbnail' => $size));
echo "OK";
} else {
header('HTTP/1.1 500 Internal Server Error');
echo "KO";
}
exit;
}
示例9: widget
function widget($args, $instance)
{
extract($args);
$ngg_options = nggGallery::get_option('ngg_options');
$title = apply_filters('widget_title', empty($instance['title']) ? ' ' : $instance['title'], $instance, $this->id_base);
$show_global_mrss = $instance['show_global_mrss'];
$show_icon = $instance['show_icon'];
$mrss_text = stripslashes($instance['mrss_text']);
$mrss_title = strip_tags(stripslashes($instance['mrss_title']));
echo $before_widget;
echo $before_title . $title . $after_title;
echo "<ul class='ngg-media-rss-widget'>\n";
if ($show_global_mrss) {
echo " <li>";
echo $this->get_mrss_link(nggMediaRss::get_mrss_url(), $show_icon, stripslashes($mrss_title), stripslashes($mrss_text), $ngg_options['usePicLens']);
echo "</li>\n";
}
echo "</ul>\n";
echo $after_widget;
}
示例10: nggallery_sortorder
/**
* @author Alex Rabe
* @copyright 2008-2011
*/
function nggallery_sortorder($galleryID = 0)
{
global $wpdb, $ngg, $nggdb;
if ($galleryID == 0) {
return;
}
$galleryID = (int) $galleryID;
if (isset($_POST['updateSortorder'])) {
check_admin_referer('ngg_updatesortorder');
// get variable new sortorder
parse_str($_POST['sortorder']);
if (is_array($sortArray)) {
$neworder = array();
foreach ($sortArray as $pid) {
$pid = substr($pid, 4);
// get id from "pid-x"
$neworder[] = (int) $pid;
}
$sortindex = 1;
foreach ($neworder as $pic_id) {
$wpdb->query("UPDATE {$wpdb->nggpictures} SET sortorder = '{$sortindex}' WHERE pid = {$pic_id}");
$sortindex++;
}
do_action('ngg_gallery_sort', $galleryID);
nggGallery::show_message(__('Sort order changed', 'nggallery'));
}
}
// look for presort args
$presort = isset($_GET['presort']) ? $_GET['presort'] : false;
$dir = isset($_GET['dir']) && $_GET['dir'] == 'DESC' ? 'DESC' : 'ASC';
$sortitems = array('pid', 'filename', 'alttext', 'imagedate');
// ensure that nobody added some evil sorting :-)
if (in_array($presort, $sortitems)) {
$picturelist = $nggdb->get_gallery($galleryID, $presort, $dir, false);
} else {
$picturelist = $nggdb->get_gallery($galleryID, 'sortorder', $dir, false);
}
//this is the url without any presort variable
$clean_url = 'admin.php?page=nggallery-manage-gallery&mode=sort&gid=' . $galleryID;
//if we go back , then the mode should be edit
$back_url = 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $galleryID;
// In the case somebody presort, then we take this url
if (isset($_GET['dir']) || isset($_GET['presort'])) {
$base_url = $_SERVER['REQUEST_URI'];
} else {
$base_url = $clean_url;
}
?>
<script type='text/javascript' src='<?php
echo NGGALLERY_URLPATH;
?>
admin/js/sorter.js'></script>
<div class="wrap">
<form id="sortGallery" method="POST" action="<?php
echo $clean_url;
?>
" onsubmit="saveImageOrder()" accept-charset="utf-8">
<h2><?php
_e('Sort Gallery', 'nggallery');
?>
</h2>
<div class="tablenav">
<div class="alignleft actions">
<?php
wp_nonce_field('ngg_updatesortorder');
?>
<input class="button-primary action" type="submit" name="updateSortorder" onclick="saveImageOrder()" value="<?php
_e('Update Sort Order', 'nggallery');
?>
" />
</div>
<div class="alignright actions">
<a href="<?php
echo esc_url($back_url);
?>
" class="button"><?php
_e('Back to gallery', 'nggallery');
?>
</a>
</div>
</div>
<input name="sortorder" type="hidden" />
<ul class="subsubsub">
<li><?php
_e('Presort', 'nggallery');
?>
:</li>
<li><a href="<?php
echo esc_attr(remove_query_arg('presort', $base_url));
?>
" <?php
if ($presort == '') {
echo 'class="current"';
}
?>
><?php
//.........这里部分代码省略.........
示例11: widget
function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? ' ' : $instance['title'], $instance, $this->id_base);
global $wpdb;
$items = $instance['items'];
$exclude = $instance['exclude'];
$list = $instance['list'];
$webslice = $instance['webslice'];
$count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->nggpictures} WHERE exclude != 1 ");
if ($count < $instance['items']) {
$instance['items'] = $count;
}
$exclude_list = '';
// THX to Kay Germer for the idea & addon code
if (!empty($list) && $exclude != 'all') {
$list = explode(',', $list);
// Prepare for SQL
$list = "'" . implode("', '", $list) . "'";
if ($exclude == 'denied') {
$exclude_list = "AND NOT (t.gid IN ({$list}))";
}
if ($exclude == 'allow') {
$exclude_list = "AND t.gid IN ({$list})";
}
// Limit the output to the current author, can be used on author template pages
if ($exclude == 'user_id') {
$exclude_list = "AND t.author IN ({$list})";
}
}
if ($instance['type'] == 'random') {
$imageList = $wpdb->get_results("SELECT t.*, tt.* FROM {$wpdb->nggallery} AS t INNER JOIN {$wpdb->nggpictures} AS tt ON t.gid = tt.galleryid WHERE tt.exclude != 1 {$exclude_list} ORDER by rand() limit {$items}");
} else {
$imageList = $wpdb->get_results("SELECT t.*, tt.* FROM {$wpdb->nggallery} AS t INNER JOIN {$wpdb->nggpictures} AS tt ON t.gid = tt.galleryid WHERE tt.exclude != 1 {$exclude_list} ORDER by pid DESC limit 0,{$items}");
}
// IE8 webslice support if needed
if ($webslice) {
$before_widget .= "\n" . '<div class="hslice" id="ngg-webslice" >' . "\n";
//the headline needs to have the class enty-title
$before_title = str_replace('class="', 'class="entry-title ', $before_title);
$after_widget = '</div>' . "\n" . $after_widget;
}
echo $before_widget . $before_title . $title . $after_title;
echo "\n" . '<div class="ngg-widget entry-content">' . "\n";
if (is_array($imageList)) {
foreach ($imageList as $image) {
// get the URL constructor
$image = new nggImage($image);
// get the effect code
$thumbcode = $image->get_thumbcode($widget_id);
// enable i18n support for alttext and description
$alttext = htmlspecialchars(stripslashes(nggGallery::i18n($image->alttext, 'pic_' . $image->pid . '_alttext')));
$description = htmlspecialchars(stripslashes(nggGallery::i18n($image->description, 'pic_' . $image->pid . '_description')));
//TODO:For mixed portrait/landscape it's better to use only the height setting, if widht is 0 or vice versa
$out = '<a href="' . $image->imageURL . '" title="' . $description . '" ' . $thumbcode . '>';
// Typo fix for the next updates (happend until 1.0.2)
$instance['show'] = $instance['show'] == 'orginal' ? 'original' : $instance['show'];
if ($instance['show'] == 'original') {
$out .= '<img src="' . trailingslashit(home_url()) . 'index.php?callback=image&pid=' . $image->pid . '&width=' . $instance['width'] . '&height=' . $instance['height'] . '" title="' . $alttext . '" alt="' . $alttext . '" />';
} else {
$out .= '<img src="' . $image->thumbURL . '" width="' . $instance['width'] . '" height="' . $instance['height'] . '" title="' . $alttext . '" alt="' . $alttext . '" />';
}
echo $out . '</a>' . "\n";
}
}
echo '</div>' . "\n";
echo $after_widget;
}
示例12: load_styles
function load_styles()
{
// check first the theme folder for a nggallery.css
if (nggGallery::get_theme_css_file()) {
wp_enqueue_style('NextGEN', nggGallery::get_theme_css_file(), false, '1.0.0', 'screen');
} else {
if ($this->options['activateCSS']) {
wp_enqueue_style('NextGEN', NGGALLERY_URLPATH . 'css/' . $this->options['CSSfile'], false, '1.0.0', 'screen');
}
}
// activate Thickbox
if ($this->options['thumbEffect'] == 'thickbox') {
wp_enqueue_style('thickbox');
}
// activate modified Shutter reloaded if not use the Shutter plugin
if ($this->options['thumbEffect'] == 'shutter' && !function_exists('srel_makeshutter')) {
wp_enqueue_style('shutter', NGGALLERY_URLPATH . 'shutter/shutter-reloaded.css', false, '1.3.0', 'screen');
}
}
示例13: publish_post
/**
* Publish a new post with the shortcode from the selected image
*
* @since 1.7.0
* @return void
*/
function publish_post()
{
check_admin_referer('publish-post');
// Create a WP page
global $user_ID, $ngg;
$ngg->options['publish_width'] = (int) $_POST['width'];
$ngg->options['publish_height'] = (int) $_POST['height'];
$ngg->options['publish_align'] = $_POST['align'];
$align = $ngg->options['publish_align'] == 'none' ? '' : 'float=' . $ngg->options['publish_align'];
//save the new values for the next operation
update_option('ngg_options', $ngg->options);
$post['post_type'] = 'post';
$post['post_content'] = '[singlepic id=' . intval($_POST['pid']) . ' w=' . $ngg->options['publish_width'] . ' h=' . $ngg->options['publish_height'] . ' ' . $align . ']';
$post['post_author'] = $user_ID;
$post['post_status'] = isset($_POST['publish']) ? 'publish' : 'draft';
$post['post_title'] = $_POST['post_title'];
$post = apply_filters('ngg_add_new_post', $post, $_POST['pid']);
$post_id = wp_insert_post($post);
if ($post_id != 0) {
nggGallery::show_message(__('Published a new post', 'nggallery'));
}
}
示例14: _wp_post_thumbnail_html
/**
* Output HTML for the post thumbnail meta-box.
*
* @see wp-admin\includes\post.php
* @param int $thumbnail_id ID of the image used for thumbnail
* @return string html output
*/
function _wp_post_thumbnail_html($thumbnail_id = NULL)
{
global $_wp_additional_image_sizes, $post_ID;
$set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__('Set featured image') . '" href="' . esc_url(get_upload_iframe_src('image')) . '" id="set-post-thumbnail" class="thickbox">%s</a></p>';
$content = sprintf($set_thumbnail_link, esc_html__('Set featured image'));
$image = nggdb::find_image($thumbnail_id);
$img_src = false;
// get the options
$ngg_options = nggGallery::get_option('ngg_options');
if ($image) {
if (is_array($_wp_additional_image_sizes) && isset($_wp_additional_image_sizes['post-thumbnail'])) {
// Use post thumbnail settings if defined
$width = absint($_wp_additional_image_sizes['post-thumbnail']['width']);
$height = absint($_wp_additional_image_sizes['post-thumbnail']['height']);
$mode = $_wp_additional_image_sizes['post-thumbnail']['crop'] ? 'crop' : '';
// check fo cached picture
$img_src = $image->cached_singlepic_file($width, $height, $mode);
}
// if we didn't use a cached image then we take the on-the-fly mode
if ($img_src == false) {
$img_src = trailingslashit(home_url()) . 'index.php?callback=image&pid=' . $image->pid . '&width=' . $width . '&height=' . $height . '&mode=crop';
}
$thumbnail_html = '<img width="266" src="' . $img_src . '" alt="' . $image->alttext . '" title="' . $image->alttext . '" />';
if (!empty($thumbnail_html)) {
$ajax_nonce = wp_create_nonce("set_post_thumbnail-{$post_ID}");
$content = sprintf($set_thumbnail_link, $thumbnail_html);
$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__('Remove featured image') . '</a></p>';
}
}
return $content;
}
示例15: convert_shortcode
/**
* NextGEN_shortcodes::convert_shortcode()
* convert old shortcodes to the new WordPress core style
* [gallery=1] ->> [nggallery id=1]
*
* @param string $content Content to search for shortcodes
* @return string Content with new shortcodes.
*/
function convert_shortcode($content)
{
$ngg_options = nggGallery::get_option('ngg_options');
if (stristr($content, '[singlepic')) {
$search = "@\\[singlepic=(\\d+)(|,\\d+|,)(|,\\d+|,)(|,watermark|,web20|,)(|,right|,center|,left|,)\\]@i";
if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
// remove the comma
$match[2] = ltrim($match[2], ',');
$match[3] = ltrim($match[3], ',');
$match[4] = ltrim($match[4], ',');
$match[5] = ltrim($match[5], ',');
$replace = "[singlepic id=\"{$match[1]}\" w=\"{$match[2]}\" h=\"{$match[3]}\" mode=\"{$match[4]}\" float=\"{$match[5]}\" ]";
$content = str_replace($match[0], $replace, $content);
}
}
}
if (stristr($content, '[album')) {
$search = "@(?:<p>)*\\s*\\[album\\s*=\\s*(\\w+|^\\+)(|,extend|,compact)\\]\\s*(?:</p>)*@i";
if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
// remove the comma
$match[2] = ltrim($match[2], ',');
$replace = "[album id=\"{$match[1]}\" template=\"{$match[2]}\"]";
$content = str_replace($match[0], $replace, $content);
}
}
}
if (stristr($content, '[gallery')) {
$search = "@(?:<p>)*\\s*\\[gallery\\s*=\\s*(\\w+|^\\+)\\]\\s*(?:</p>)*@i";
if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
$replace = "[nggallery id=\"{$match[1]}\"]";
$content = str_replace($match[0], $replace, $content);
}
}
}
if (stristr($content, '[imagebrowser')) {
$search = "@(?:<p>)*\\s*\\[imagebrowser\\s*=\\s*(\\w+|^\\+)\\]\\s*(?:</p>)*@i";
if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
$replace = "[imagebrowser id=\"{$match[1]}\"]";
$content = str_replace($match[0], $replace, $content);
}
}
}
if (stristr($content, '[slideshow')) {
$search = "@(?:<p>)*\\s*\\[slideshow\\s*=\\s*(\\w+|^\\+)(|,(\\d+)|,)(|,(\\d+))\\]\\s*(?:</p>)*@i";
if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
// remove the comma
$match[3] = ltrim($match[3], ',');
$match[5] = ltrim($match[5], ',');
$replace = "[slideshow id=\"{$match[1]}\" w=\"{$match[3]}\" h=\"{$match[5]}\"]";
$content = str_replace($match[0], $replace, $content);
}
}
}
if (stristr($content, '[tags')) {
$search = "@(?:<p>)*\\s*\\[tags\\s*=\\s*(.*?)\\s*\\]\\s*(?:</p>)*@i";
if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
$replace = "[nggtags gallery=\"{$match[1]}\"]";
$content = str_replace($match[0], $replace, $content);
}
}
}
if (stristr($content, '[albumtags')) {
$search = "@(?:<p>)*\\s*\\[albumtags\\s*=\\s*(.*?)\\s*\\]\\s*(?:</p>)*@i";
if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
$replace = "[nggtags album=\"{$match[1]}\"]";
$content = str_replace($match[0], $replace, $content);
}
}
}
return $content;
}