Example #1
0
    /**
     * Render the page content.
     *
     * @since 1.9.22
     *
     */
    function controller()
    {
        global $ngg;
        //the directions containing the css files
        if (file_exists(NGG_CONTENT_DIR . "/ngg_styles")) {
            $dir = array(NGGALLERY_ABSPATH . "css", NGG_CONTENT_DIR . "/ngg_styles");
        } else {
            $dir = array(NGGALLERY_ABSPATH . "css");
        }
        //support for legacy location (in theme folder)
        if ($theme_css_exists = file_exists(get_stylesheet_directory() . "/nggallery.css")) {
            $act_cssfile = get_stylesheet_directory() . "/nggallery.css";
        }
        //if someone uses the filter, don't display this page.
        if (!$theme_css_exists && ($set_css_file = nggGallery::get_theme_css_file())) {
            nggGallery::show_error(__('Your CSS file is set by a theme or another plugin.', 'nggallery') . "<br><br>" . __('This CSS file will be applied:', 'nggallery') . "<br>" . $set_css_file);
            return;
        }
        //load all files
        if (!isset($act_cssfile)) {
            $csslist = NGG_Style::ngg_get_cssfiles($dir);
            $act_cssfile = $ngg->options['CSSfile'];
        }
        //get the data from the file
        $act_css_data = NGG_Style::ngg_get_cssfiles_data($act_cssfile);
        $act_css_name = $act_css_data['Name'];
        $act_css_description = $act_css_data['Description'];
        $act_css_author = $act_css_data['Author'];
        $act_css_version = $act_css_data['Version'];
        $act_css_folder = $act_css_data['Folder'];
        // get the content of the file
        $error = !is_file($act_cssfile);
        if (!$error && filesize($act_cssfile) > 0) {
            $f = fopen($act_cssfile, 'r');
            $content = fread($f, filesize($act_cssfile));
            $content = htmlspecialchars($content);
        }
        ?>
		<div class="wrap">
			<div class="bordertitle">
				<?php 
        screen_icon('nextgen-gallery');
        ?>
				<h2><?php 
        _e('Style Editor', 'nggallery');
        ?>
</h2>
				<div class="fileedit-sub">
				<?php 
        if (!$theme_css_exists) {
            //no need if there is a theme css
            ?>
					<div class="alignright">
						<form id="themeselector" name="cssfiles" method="post">
							<?php 
            wp_nonce_field('ngg_style');
            ?>
							<strong><?php 
            _e('Activate and use style sheet:', 'nggallery');
            ?>
</strong>
							<input type="checkbox" name="activateCSS" value="1" <?php 
            checked('1', $ngg->options['activateCSS']);
            ?>
 />							
							<select name="css" id="theme" style="margin: 0pt; padding: 0pt;">
								<?php 
            self::output_css_files_dropdown($csslist, $act_cssfile);
            ?>
							</select>
							<input class="button" type="submit" name="activate" value="<?php 
            _e('Activate', 'nggallery');
            ?>
 &raquo;" class="button" />
						</form>
					</div>
				<?php 
        }
        ?>
				<?php 
        if (!is_multisite() || is_super_admin()) {
            ?>
					<div class="alignleft">
						<?php 
            $title = '<h3>';
            if (is_writeable($act_cssfile)) {
                $title .= sprintf(__('Editing %s', 'nggallery'), $act_css_name);
            } else {
                $title .= sprintf(__('Browsing %s', 'nggallery'), $act_css_name);
            }
            if ($theme_css_exists) {
                $title .= ' ' . __('(from the theme folder)', 'nggallery');
            }
            $title .= '</h3>';
            echo $title;
            ?>
					</div>
					<br class="clear" />
				</div> <!-- fileedit-sub -->
				<div id="templateside">
				<?php 
            if ($theme_css_exists) {
                ?>
					<form id="filemover" name="filemover" method="post" style="background:white; padding: 1px 10px 10px;">
						<p><?php 
                _e('To ensure your css file stays safe during upgrades, please move it to the right folder.', 'nggallery');
                ?>
</p>
						<input type="hidden" name="movecss" value="movecss" />
						<input type="hidden" name="oldpath" value="<?php 
                echo $act_cssfile;
                ?>
" />
						<input class="button-primary action" type="submit" name="submit" value="<?php 
                _e('Move file', 'nggallery');
                ?>
" />
					</form>
					<br class="clear" />
				<?php 
            }
            ?>
					<ul>
						<li><strong><?php 
            _e('Author', 'nggallery');
            ?>
:</strong> <?php 
            echo $act_css_author;
            ?>
</li>
						<li><strong><?php 
            _e('Version', 'nggallery');
            ?>
:</strong> <?php 
            echo $act_css_version;
            ?>
</li>
					</ul>
					<p><strong><?php 
            _e('Description', 'nggallery');
            ?>
:</strong></p>
					<p class="description"><?php 
            echo $act_css_description;
            ?>
</p>
					<p><strong><?php 
            _e('File location', 'nggallery');
            ?>
:</strong></p>
					<p class="description"><?php 
            echo $act_cssfile;
            ?>
</p>
				</div>
				<?php 
            if (!$error) {
                ?>
				<form name="template" id="template" method="post">
					<?php 
                wp_nonce_field('ngg_style');
                ?>
					<div>
						<textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"  class="codepress css"><?php 
                echo $content;
                ?>
</textarea>
						<input type="hidden" name="updatecss" value="updatecss" />
						<input type="hidden" name="folder" value="<?php 
                echo $act_css_folder;
                ?>
" />
						<input type="hidden" name="file" value="<?php 
                echo $act_cssfile;
                ?>
" />
					</div>
					<?php 
                if (is_writeable($act_cssfile)) {
                    ?>
					<p class="submit"><input class="button-primary action" type="submit" name="submit" value="<?php 
                    _e('Update File', 'nggallery');
                    ?>
" tabindex="2" /></p>
					<?php 
                } else {
                    ?>
					<p><em><?php 
                    _e('If this file were writable you could edit it.', 'nggallery');
                    ?>
</em></p>
					<?php 
                }
                ?>
				</form>
				<?php 
            } else {
                echo '<div class="error"><p>' . __('This file does not exist. Double check the name and try again.', 'nggallery') . '</p></div>';
            }
            ?>
				<div class="clear"> &nbsp; </div>
			</div> <!-- wrap-->
			<?php 
        }
        //end if ( !is_multisite() || is_super_admin() )
    }
Example #2
0
function nggallery_wpmu_setup()
{
    //to be sure
    if (!is_super_admin()) {
        die('You are not allowed to call this page.');
    }
    $messagetext = '';
    // get the options
    $ngg_options = get_site_option('ngg_options');
    if (isset($_POST['updateoption'])) {
        check_admin_referer('ngg_wpmu_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 = false;
                if (isset($_POST[$option])) {
                    $value = trim($_POST[$option]);
                    if ($value === "true") {
                        $value = true;
                    }
                    if (is_numeric($value)) {
                        $value = (int) $value;
                    }
                }
                //		$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']);
        update_site_option('ngg_options', $ngg_options);
        var_dump($ngg_options);
        $messagetext = __('Update successfully', 'nggallery');
    }
    global $ngg;
    //the directions containing the css files
    if (file_exists(NGG_CONTENT_DIR . "/ngg_styles")) {
        $dir = array(NGGALLERY_ABSPATH . "css", NGG_CONTENT_DIR . "/ngg_styles");
    } else {
        $dir = array(NGGALLERY_ABSPATH . "css");
    }
    //support for legacy location (in theme folder)
    if ($theme_css_exists = file_exists(get_stylesheet_directory() . "/nggallery.css")) {
        $act_cssfile = get_stylesheet_directory() . "/nggallery.css";
    }
    //if someone uses the filter, don't display this page.
    if (!$theme_css_exists && ($set_css_file = nggGallery::get_theme_css_file())) {
        nggGallery::show_error(__('Your CSS file is set by a theme or another plugin.', 'nggallery') . "<br><br>" . __('This CSS file will be applied:', 'nggallery') . "<br>" . $set_css_file);
        return;
    }
    //load all files
    if (!isset($act_cssfile)) {
        $csslist = NGG_Style::ngg_get_cssfiles($dir);
        $act_cssfile = $ngg->options['CSSfile'];
    }
    // message windows
    if (!empty($messagetext)) {
        echo '<!-- Last Action --><div id="message" class="updated fade"><p>' . $messagetext . '</p></div>';
    }
    ?>

	<div class="wrap">
		<h2><?php 
    _e('Network Options', 'nggallery');
    ?>
</h2>
		<form name="generaloptions" method="post">
			<?php 
    wp_nonce_field('ngg_wpmu_settings');
    ?>
			<input type="hidden" name="page_options" value="silentUpgrade,gallerypath,wpmuQuotaCheck,wpmuZipUpload,wpmuImportFolder,wpmuStyle,wpmuRoles,wpmuCSSfile" />
			<table class="form-table">
				<tr>
					<th><label for="gallerypath"><?php 
    _e('Gallery path', 'nggallery');
    ?>
</label></th>
					<td>
						<input type="text" size="50" name="gallerypath" id="gallerypath" value="<?php 
    echo $ngg_options['gallerypath'];
    ?>
">
						<p class="description">
							<?php 
    _e('This is the default path for all blogs. With the placeholder %BLOG_ID% you can organize the folder structure better.', 'nggallery');
    ?>
							<?php 
    echo sprintf(__('The default setting should be %s.', 'nggallery'), '<code>wp-content/blogs.dir/%BLOG_ID%/files/</code>');
    ?>
						</p>
					</td>
				</tr>
				<tr>
					<th><?php 
    _e('Silent database upgrade', 'nggallery');
    ?>
</th>
					<td>
						<input type="checkbox" name="silentUpgrade" id="silentUpgrade" value="true" <?php 
    checked($ngg_options['silentUpgrade']);
    ?>
>
						<label for="silentUpgrade"><?php 
    _e('Update the database without notice.', 'nggallery');
    ?>
</label>
					</td>
				</tr>
				<tr>
					<th><?php 
    _e('Enable upload quota check', 'nggallery');
    ?>
</th>
					<td>
						<input name="wpmuQuotaCheck" id="wpmuQuotaCheck" type="checkbox" value="true" <?php 
    checked($ngg_options['wpmuQuotaCheck']);
    ?>
>
						<label for="wpmuQuotaCheck"><?php 
    _e('Should work if the gallery is bellow the blog.dir', 'nggallery');
    ?>
</label>
					</td>
				</tr>
				<tr>
					<th><?php 
    _e('Enable zip upload option', 'nggallery');
    ?>
</th>
					<td>
						<input name="wpmuZipUpload" id="wpmuZipUpload" type="checkbox" value="true" <?php 
    checked($ngg_options['wpmuZipUpload']);
    ?>
>
						<label for="wpmuZipUpload"><?php 
    _e('Allow users to upload zip folders.', 'nggallery');
    ?>
</label>
					</td>
				</tr>
				<tr>
					<th><?php 
    _e('Enable import function', 'nggallery');
    ?>
</th>
					<td>
						<input name="wpmuImportFolder" id="wpmuImportFolder" type="checkbox" value="true" <?php 
    checked($ngg_options['wpmuImportFolder']);
    ?>
>
						<label for="wpmuImportFolder"><?php 
    _e('Allow users to import images folders from the server.', 'nggallery');
    ?>
</label>
					</td>
				</tr>
				<tr>
					<th><?php 
    _e('Enable style selection', 'nggallery');
    ?>
</th>
					<td>
						<input name="wpmuStyle" id="wpmuStyle" type="checkbox" value="true" <?php 
    checked($ngg_options['wpmuStyle']);
    ?>
>
						<label for="wpmuStyle"><?php 
    _e('Allow users to choose a style for the gallery.', 'nggallery');
    ?>
</label>
					</td>
				</tr>
				<tr>
					<th><?php 
    _e('Enable roles/capabilities', 'nggallery');
    ?>
</th>
					<td>
						<input name="wpmuRoles" id="wpmuRoles" type="checkbox" value="true" <?php 
    checked($ngg_options['wpmuRoles']);
    ?>
>
						<label for="wpmuRoles"><?php 
    _e('Allow users to change the roles for other blog authors.', 'nggallery');
    ?>
</label>
					</td>
				</tr>
				<tr>
					<th><label for="wpmuCSSfile"><?php 
    _e('Default style', 'nggallery');
    ?>
</label></th>
					<td>
					<select name="wpmuCSSfile" id="wpmuCSSfile">
						<?php 
    NGG_Style::output_css_files_dropdown($csslist, $act_cssfile);
    ?>
					</select>
					<p class="description">
						<?php 
    _e('Choose the default style for the galleries.', 'nggallery');
    ?>
						<?php 
    _e('Note: between brackets is the folder in which the file is.', 'nggallery');
    ?>
					</p>
					</td>
				</tr>
			</table>
			<?php 
    submit_button(__('Save Changes'), 'primary', 'updateoption');
    ?>
		</form>	
	</div>
	<?php 
}