function enqueue_static_resources($displayed_gallery, $lightbox_library)
 {
     $router = C_Router::get_instance();
     // TODO: (possibly?) find a better solution, This feels too hackish.
     // Remove all currently enqueued CSS & JS. Resources needed by the pro-lightbox incidentally happen
     // to be enqueued after this particular code is run anyway.
     global $wp_styles;
     global $wp_scripts;
     $wp_styles->queue = array();
     $wp_scripts->queue = array();
     wp_enqueue_script('photocrati_ajax');
     // our only necessary script
     wp_enqueue_script('galleria', $this->object->get_static_url('photocrati-galleria#galleria-1.2.9.min.js'), array('jquery'), FALSE, FALSE);
     wp_enqueue_script('pro-lightbox-galleria-init', $this->object->get_static_url('photocrati-nextgen_pro_lightbox#galleria_init.js'), array('galleria'), FALSE, FALSE);
     M_Gallery_Display::enqueue_fontawesome();
     wp_enqueue_script('velocity', $this->object->get_static_url('photocrati-nextgen_pro_lightbox#jquery.velocity.min.js'));
     // retrieve and add some fields to the lightbox settings
     $lightbox = C_Lightbox_Library_Manager::get_instance()->get(NGG_PRO_LIGHTBOX);
     $lightbox_style = $lightbox->values['nplModalSettings']['style'];
     if (!empty($lightbox_style)) {
         wp_enqueue_style('nextgen_pro_lightbox_user_style', $router->get_static_url('photocrati-nextgen_pro_lightbox#styles/' . $lightbox_style));
     }
     // this should come after all other enqueue'ings
     $settings = C_NextGen_Settings::get_instance();
     if ((!is_multisite() || is_multisite() && $settings->wpmuStyle) && $settings->activateCSS) {
         wp_enqueue_style('nggallery', C_NextGen_Style_Manager::get_instance()->get_selected_stylesheet_url());
     }
 }
Example #2
0
 function save_action()
 {
     // Ensure that we have
     if ($settings = $this->object->param('style_settings')) {
         $this->object->get_model()->set($settings)->save();
         // Are we to modify the CSS file?
         if ($contents = $this->object->param('cssfile_contents')) {
             // Find filename
             $css_file = $settings['CSSfile'];
             $styles = C_NextGen_Style_Manager::get_instance();
             $styles->save($contents, $css_file);
         }
     }
 }
 /**
  * Retrieves the contents of the CSS stylesheet specified
  */
 function get_stylesheet_contents_action()
 {
     $retval = array();
     if ($this->object->_authorized_for_stylesheet_action()) {
         $styles = C_NextGen_Style_Manager::get_instance();
         $abspath = $styles->find_selected_stylesheet_abspath($this->object->param('cssfile'));
         $writepath = $styles->get_selected_stylesheet_saved_abspath($this->object->param('cssfile'));
         if (is_readable($abspath)) {
             $retval['contents'] = file_get_contents($abspath);
             $retval['writable'] = is_writable($abspath);
             $retval['abspath'] = $abspath;
             $retval['writepath'] = $writepath;
         } else {
             $retval['error'] = "Could not find stylesheet";
         }
     } else {
         $retval['error'] = 'Unauthorized';
     }
     return $retval;
 }
Example #4
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 = isset($_POST[$option]) ? trim($_POST[$option]) : false;
                //		$value = sanitize_option($option, $value); // This does strip slashes 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);
        $messagetext = __('Update successfully', 'nggallery');
    }
    // Show donation message only one time.
    if (isset($_GET['hideSupportInfo'])) {
        $ngg_options['hideSupportInfo'] = true;
        update_site_option('ngg_options', $ngg_options);
    }
    // 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="gallerypath,wpmuQuotaCheck,wpmuZipUpload,wpmuImportFolder,wpmuStyle,wpmuRoles,wpmuCSSfile" />
			<table class="form-table">
				<tr valign="top">
					<th align="left"><?php 
    _e('Gallery path', 'nggallery');
    ?>
</th>
					<td><input type="text" size="50" name="gallerypath" value="<?php 
    echo $ngg_options['gallerypath'];
    ?>
" /><br />
					<?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 str_replace('%s', '<code>wp-content/blogs.dir/%BLOG_ID%/files/</code>', __('The default setting should be %s', 'nggallery'));
    ?>
                    </td>
				</tr>
				<tr>
					<th valign="top"><?php 
    _e('Enable upload quota check', 'nggallery');
    ?>
:</th>
					<td><input name="wpmuQuotaCheck" type="checkbox" value="1" <?php 
    checked('1', $ngg_options['wpmuQuotaCheck']);
    ?>
 />
					<?php 
    _e('Should work if the gallery is bellow the blog.dir', 'nggallery');
    ?>
					</td>
				</tr>
				<tr>
					<th valign="top"><?php 
    _e('Enable zip upload option', 'nggallery');
    ?>
:</th>
					<td><input name="wpmuZipUpload" type="checkbox" value="1" <?php 
    checked('1', $ngg_options['wpmuZipUpload']);
    ?>
 />
					<?php 
    _e('Allow users to upload zip folders.', 'nggallery');
    ?>
					</td>
				</tr>
				<tr>
					<th valign="top"><?php 
    _e('Enable import function', 'nggallery');
    ?>
:</th>
					<td><input name="wpmuImportFolder" type="checkbox" value="1" <?php 
    checked('1', $ngg_options['wpmuImportFolder']);
    ?>
 />
					<?php 
    _e('Allow users to import images folders from the server.', 'nggallery');
    ?>
					</td>
				</tr>
				<tr>
					<th valign="top"><?php 
    _e('Enable style selection', 'nggallery');
    ?>
:</th>
					<td><input name="wpmuStyle" type="checkbox" value="1" <?php 
    checked('1', $ngg_options['wpmuStyle']);
    ?>
 />
					<?php 
    _e('Allow users to choose a style for the gallery.', 'nggallery');
    ?>
					</td>
				</tr>
				<tr>
					<th valign="top"><?php 
    _e('Enable roles/capabilities', 'nggallery');
    ?>
:</th>
					<td><input name="wpmuRoles" type="checkbox" value="1" <?php 
    checked('1', $ngg_options['wpmuRoles']);
    ?>
 />
					<?php 
    _e('Allow users to change the roles for other blog authors.', 'nggallery');
    ?>
					</td>
				</tr>
				<tr>
					<th valign="top"><?php 
    _e('Default style', 'nggallery');
    ?>
:</th>
					<td>
					<select name="wpmuCSSfile">
					<?php 
    // $csslist = ngg_get_cssfiles();
    $csslist = C_NextGen_Style_Manager::get_instance()->find_all_stylesheets();
    foreach ($csslist as $key => $a_cssfile) {
        $css_name = $a_cssfile['name'];
        if ($key == $ngg_options['wpmuCSSfile']) {
            $selected = " selected='selected'";
        } else {
            $selected = '';
        }
        $css_name = esc_attr($css_name);
        echo "\n\t<option value=\"{$key}\" {$selected}>{$css_name}</option>";
    }
    ?>
					</select><br />
					<?php 
    _e('Choose the default style for the galleries.', 'nggallery');
    ?>
					</td>
				</tr>
			</table> 				
			<div class="submit"><input type="submit" name="updateoption" value="<?php 
    _e('Update');
    ?>
"/></div>
		</form>	
	</div>	

	<?php 
}
 function enqueue_ngg_styles()
 {
     $settings = C_NextGen_Settings::get_instance();
     if ((!is_multisite() || is_multisite() && $settings->wpmuStyle) && $settings->activateCSS) {
         wp_enqueue_style('nggallery', C_NextGen_Style_Manager::get_instance()->get_selected_stylesheet_url());
     }
 }
 /**
  * Gets an instance of the class
  * @return C_NextGen_Style_Manager
  */
 static function get_instance()
 {
     if (is_null(self::$_instance)) {
         $klass = get_class();
         self::$_instance = new $klass();
     }
     return self::$_instance;
 }
 /**
  * Displays a notice to the user that the current stylesheet location is unsafe
  */
 function display_stylesheet_notice()
 {
     if (C_NextGen_Style_Manager::get_instance()->is_directory_unsafe()) {
         $styles = C_NextGen_Style_Manager::get_instance();
         $filename = $styles->get_selected_stylesheet();
         $abspath = $styles->find_selected_stylesheet_abspath();
         $newpath = $styles->new_dir;
         echo "<div class='updated error'>\n                <h3>WARNING: NextGEN Gallery Stylesheet NOT Upgrade-safe</h3>\n                <p>\n                <strong>{$filename}</strong> is currently stored in <strong>{$abspath}</strong>, which isn't upgrade-safe. Please move the stylesheet to\n                <strong>{$newpath}</strong> to ensure that your customizations persist after updates.\n            </p></div>";
     }
 }
 function enqueue_ngg_styles()
 {
     if (defined('NGG_SKIP_LOAD_SCRIPTS') && NGG_SKIP_LOAD_SCRIPTS) {
         return;
     }
     $settings = C_NextGen_Settings::get_instance();
     if ((!is_multisite() || is_multisite() && $settings->wpmuStyle) && $settings->activateCSS) {
         wp_enqueue_style('nggallery', C_NextGen_Style_Manager::get_instance()->get_selected_stylesheet_url());
     }
 }
 function enqueue_ngg_styles()
 {
     wp_enqueue_style('nggallery', C_NextGen_Style_Manager::get_instance()->get_selected_stylesheet_url());
 }
 function index_action()
 {
     $factory = C_Component_Factory::get_instance();
     $router = C_Router::get_instance();
     $gallery_mapper = C_Gallery_Mapper::get_instance();
     $lightbox_mapper = $this->object->get_registry()->get_utility('I_Lightbox_Library_Mapper');
     // retrieve by transient id
     $transient_id = $this->object->param('id');
     // ! denotes a non-nextgen gallery -- skip processing them
     if ($transient_id !== '!') {
         $displayed_gallery = $factory->create('displayed_gallery', array(), $gallery_mapper);
         if (!$displayed_gallery->apply_transient($transient_id)) {
             $response = array();
             // if the transient does not exist we make an HTTP request to the referer to rebuild the transient
             if (!empty($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], home_url()) !== FALSE) {
                 $referrer = $_SERVER['HTTP_REFERER'];
                 if (strpos($referrer, '?') === FALSE) {
                     $referrer .= '?ngg_no_resources=1';
                 } else {
                     $referrer .= '&ngg_no_resources=1';
                 }
                 $response = wp_remote_get($referrer);
             }
             // WP has cached the results of our last get_transient() calls and must be flushed
             global $wp_object_cache;
             $wp_object_cache->flush();
             // and try again to retrieve the transient
             if (!$displayed_gallery->apply_transient($transient_id)) {
                 $displayed_gallery->id($transient_id);
             }
         }
         $displayed_gallery_id = $displayed_gallery->id();
     } else {
         $displayed_gallery_id = '!';
     }
     // TODO: (possibly?) find a better solution, This feels too hackish.
     // Remove all currently enqueued CSS & JS. Resources needed by the pro-lightbox incidentally happen
     // to be enqueued after this particular code is run anyway.
     global $wp_styles;
     global $wp_scripts;
     $wp_styles->queue = array();
     $wp_scripts->queue = array();
     // our only necessary script
     wp_enqueue_script('galleria', $this->object->get_static_url('photocrati-galleria#galleria-1.2.9.min.js'), array('jquery'), FALSE, FALSE);
     wp_enqueue_script('pro-lightbox-galleria-init', $this->object->get_static_url('photocrati-nextgen_pro_lightbox_legacy#galleria_init.js'), array('galleria'), FALSE, FALSE);
     if (!wp_style_is('fontawesome', 'registered')) {
         C_Display_Type_Controller::get_instance()->enqueue_displayed_gallery_trigger_buttons_resources();
     }
     wp_enqueue_style('fontawesome');
     wp_enqueue_script('velocity', $this->object->get_static_url('photocrati-nextgen_pro_lightbox_legacy#jquery.velocity.min.js'));
     // retrieve and add some fields to the lightbox settings
     $library = $lightbox_mapper->find_by_name(NGG_PRO_LIGHTBOX, TRUE);
     $ls =& $library->display_settings;
     $ls['theme'] = $this->object->get_static_url('photocrati-nextgen_pro_lightbox_legacy#theme/galleria.nextgen_pro_lightbox.js');
     $ls['load_images_url'] = $router->get_url('/nextgen-pro-lightbox-load-images/' . $transient_id, TRUE, 'root');
     $ls['gallery_url'] = $router->get_url('/nextgen-pro-lightbox-gallery/{gallery_id}/', TRUE, 'root');
     $ls['share_url'] = $router->get_url('/nextgen-share/{gallery_id}/{image_id}/{named_size}', TRUE, 'root');
     $ls['wp_site_url'] = $router->get_base_url();
     $ls['image_protect'] = !empty(C_NextGen_Settings::get_instance()->protect_images) ? TRUE : FALSE;
     if (!empty($ls['style'])) {
         wp_enqueue_style('nextgen_pro_lightbox_user_style', $router->get_static_url('photocrati-nextgen_pro_lightbox_legacy#styles/' . $ls['style']));
     }
     // this should come after all other enqueue'ings
     $settings = C_NextGen_Settings::get_instance();
     if ((!is_multisite() || is_multisite() && $settings->wpmuStyle) && $settings->activateCSS) {
         wp_enqueue_style('nggallery', C_NextGen_Style_Manager::get_instance()->get_selected_stylesheet_url());
     }
     // The Pro Lightbox can be extended with components that enqueue their own resources
     // and render some markup
     $component_markup = array();
     foreach ($this->object->_components as $name => $handler) {
         $handler = new $handler();
         $handler->name = $name;
         if (!empty($displayed_gallery)) {
             $handler->displayed_gallery = $displayed_gallery;
         }
         $handler->lightbox_library = $library;
         $handler->enqueue_static_resources();
         $component_markup[] = $handler->render();
     }
     $params = array('displayed_gallery_id' => $displayed_gallery_id, 'lightbox_settings' => $library->display_settings, 'component_markup' => implode("\n", $component_markup));
     return $this->object->render_view('photocrati-nextgen_pro_lightbox_legacy#index', $params, FALSE);
 }