/**
  * Accepts AJAX request containing an array matching any allowable params for the [dg] shortcode.
  * Returns the resultant gallery HTML.
  */
 public static function generateGallery()
 {
     if (isset($_REQUEST['atts'])) {
         @header('Content-Type: text/html; charset=' . get_option('blog_charset'));
         echo DocumentGallery::doShortcode($_REQUEST['atts']);
     }
     wp_die();
 }
 /**
  * @param mixed[] $options New value for gallery branch of DG options array.
  * @param int $blog The blog we're retrieving options for (null => current blog).
  */
 public static function setOptions($options, $blog = null)
 {
     $dg_options = DocumentGallery::getOptions($blog);
     $dg_options['gallery'] = $options;
     DocumentGallery::setOptions($dg_options, $blog);
 }
 /**
  * Runs when DG is uninstalled for an individual blog.
  */
 private static function _uninstall($blog)
 {
     $options = DG_Thumber::getOptions($blog);
     if (is_null($options)) {
         return;
     }
     foreach ($options['thumbs'] as $val) {
         if (isset($val['thumber'])) {
             @unlink($val['thumb_path']);
         }
     }
     DocumentGallery::deleteOptions($blog);
 }
 /**
  * Retrieves the supported MIME types from Thumber that are also compatible with WordPress.
  * @return string[] The supported MIME types reported by the Thumber server.
  */
 public function getMimeTypes()
 {
     global $dg_options;
     if (empty($dg_options['thumber-co']['mime_types'])) {
         // avoid values being removed as a result of current user but also include any MIME types
         // that are added outside of the default WP values
         $wp_types = array_merge(wp_get_mime_types(), get_allowed_mime_types());
         $allowed = array_intersect($wp_types, parent::getMimeTypes());
         $dg_options['thumber-co']['mime_types'] = array_keys($allowed);
         DocumentGallery::setOptions($dg_options);
     }
     return $dg_options['thumber-co']['mime_types'];
 }
    /**
     * Render the Logging table.
     */
    public static function renderLoggingSection()
    {
        $log_list = DG_Logger::readLog();
        if ($log_list) {
            $levels = array_map(array(__CLASS__, 'getLogLabelSpan'), array_keys(DG_LogLevel::getLogLevels()));
            $fmt = '<tr>' . '<th scope="col" class="manage-column column-date sorted desc"><a href="javascript:void(0);">' . '<span>%s</span><span class="sorting-indicator"></span></a>' . '</th>' . '<th scope="col" class="manage-column column-level"><span>%s</span></th>' . '<th scope="col" class="manage-column column-message"><span>%s</span></th>' . '</tr>';
            $thead = sprintf($fmt, __('Date', 'document-gallery'), __('Level', 'document-gallery'), __('Message', 'document-gallery'));
            ?>
			<div class="log-list-wrapper">
				<div>
					<div class="tablenav top">
						<div class="alignleft bulkactions">
							<button class="action expandAll">
								<?php 
            echo __('Expand All', 'document-gallery');
            ?>
							</button>
							<button class="action collapseAll">
								<?php 
            echo __('Collapse All', 'document-gallery');
            ?>
							</button>
						</div>
						<div class="levelSelector">
							<input type="checkbox" id="allLevels" name="lswitch" value="all" checked/>
							<label for="allLevels" class="allLevels">ALL</label>
							<?php 
            foreach (array_keys(DG_LogLevel::getLogLevels()) as $k) {
                ?>
								<?php 
                $lower = strtolower($k);
                $upper = strtoupper($k);
                ?>
								<input type="checkbox" id="<?php 
                echo $lower;
                ?>
Level" name="lswitch"
								       value="<?php 
                echo $lower;
                ?>
" checked/>
								<label for="<?php 
                echo $lower;
                ?>
Level"
								       class="<?php 
                echo $lower;
                ?>
Level"><?php 
                echo $upper;
                ?>
</label>
							<?php 
            }
            ?>
						</div>
					</div>
					<table id="LogTable" class="wp-list-table widefat fixed media" cellpadding="0" cellspacing="0">
						<thead>
						<?php 
            echo $thead;
            ?>
						</thead>
						<tfoot>
						<?php 
            echo $thead;
            ?>
						</tfoot>
						<tbody><?php 
            for ($i = count($log_list); $i > 0; $i--) {
                $log_entry = $log_list[$i - 1];
                $date = DocumentGallery::localDateTimeFromTimestamp($log_entry[0]);
                // convert attachment names to links
                $log_entry[2] = preg_replace('/[ ^](attachment #)(\\d+)[.,: ]/i', ' <a href="' . home_url() . '/?attachment_id=\\2" target="_blank">\\1<strong>\\2</strong></a> ', $log_entry[2]);
                // bold the place where log entry was submitted
                $log_entry[2] = preg_replace('/^(\\((?:\\w+(?:::|->))?\\w+\\)) /', '<strong>\\1</strong> ', $log_entry[2]);
                // italicize any function references within log entry
                $log_entry[2] = preg_replace('/(\\(?\\w+(?:::|->)\\w+\\)?)/m', '<i>\\1</i>', $log_entry[2]);
                echo '<tr><td class="date column-date" data-sort-value="' . $log_entry[0] . '"><span class="logLabel date">' . $date . '</span></td>' . '<td class="column-level">' . $levels[$log_entry[1]] . '</td>' . '<td class="column-entry">' . (empty($log_entry[3]) ? '<pre>' . $log_entry[2] . '</pre>' : '<div class="expander" title="Click to Expand"><pre>' . $log_entry[2] . '</pre><div><span class="dashicons dashicons-arrow-down-alt2"></span></div></div><div class="spoiler-body"><pre>' . $log_entry[3] . '</pre></div>') . '</td>' . '</tr>' . PHP_EOL;
            }
            ?>
						</tbody>
					</table>
					<div class="tablenav bottom">
						<div class="alignright bulkactions">
							<button class="button action clearLog" name='<?php 
            echo DG_OPTION_NAME;
            ?>
[clearLog]'
							        value='true'>
								<?php 
            echo __('Clear Log', 'document-gallery');
            ?>
							</button>
						</div>
					</div>
				</div>
			</div>
		<?php 
        } else {
            echo '<div class="noLog">' . __('There are no log entries at this time.', 'document-gallery') . '<br />' . __('For Your information:', 'document-gallery') . ' <strong><i>' . __('Logging', 'document-gallery') . '</i></strong> ' . (DG_Logger::logEnabled() ? '<span class="loggingON">' . __('is turned ON', 'document-gallery') . '!</span>' : '<span class="loggingOFF">' . __('is turned OFF', 'document-gallery') . '!</span>') . '</div>';
        }
    }
示例#6
0
 /**
  * Key: Attachment ID
  * Val: array
  *      + timestamp - When the thumbnail was generated (or generation failed).
  *      + thumb_path - System path to thumbnail image.
  *      + thumb_url - URL pointing to the thumbnail for this document.
  *      + thumber - Generator used to create thumb OR false if failed to gen.
  *
  * @param array $options Thumber options to store in DB
  */
 private static function setOptions($options, $blog = null)
 {
     $dg_options = DocumentGallery::getOptions($blog);
     $dg_options['thumber'] = $options;
     DocumentGallery::setOptions($dg_options, $blog);
 }
示例#7
0
 /**
  * Gets logging options.
  *
  * @param int $blog ID of the blog to be retrieved in multisite env.
  *
  * @return array Logger options for the blog.
  */
 public static function getOptions($blog = null)
 {
     $options = DocumentGallery::getOptions($blog);
     return $options['logging'];
 }
 /**
  * Runs when DG is uninstalled for an individual blog.
  */
 private static function _uninstall($blog)
 {
     DG_Thumb::purgeThumbs(null, $blog);
     DocumentGallery::deleteOptions($blog);
 }
/**
 * @return int The limit, which may or may not be a member of $limit_options.
 */
function dg_get_limit_param()
{
    global $dg_options;
    $limit = isset($_REQUEST['limit']) ? DG_Util::posint($_REQUEST['limit']) : $dg_options['meta']['items_per_page'];
    if ($limit !== $dg_options['meta']['items_per_page']) {
        $dg_options['meta']['items_per_page'] = $limit;
        DocumentGallery::setOptions($dg_options);
    }
    return $limit;
}