示例#1
0
     $data['img_width'] = $s[0];
     $data['img_height'] = $s[1];
     $data['print_RESIZE_BLAHBLAH'] = sprintf(RESIZE_BLAHBLAH, serendipity_specialchars($serendipity['GET']['fname']));
     $data['print_ORIGINAL_SIZE'] = sprintf(ORIGINAL_SIZE, $s[0], $s[1]);
     $data['formtoken'] = serendipity_setFormToken();
     $data['file'] = $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . ($file['extension'] ? '.' . $file['extension'] : "");
     break;
 case 'choose':
     $file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']);
     $media['file'] =& $file;
     if (!is_array($file)) {
         $media['perm_denied'] = true;
         break;
     }
     serendipity_prepareMedia($file);
     $media['file']['props'] =& serendipity_fetchMediaProperties((int) $serendipity['GET']['fid']);
     serendipity_plugin_api::hook_event('media_getproperties_cached', $media['file']['props']['base_metadata'], $media['file']['realfile']);
     if ($file['is_image']) {
         $file['finishJSFunction'] = $file['origfinishJSFunction'] = 'serendipity.serendipity_imageSelector_done(\'' . serendipity_specialchars($serendipity['GET']['textarea']) . '\')';
         if (!empty($serendipity['GET']['filename_only']) && $serendipity['GET']['filename_only'] !== 'true') {
             $file['fast_select'] = true;
         }
     }
     $media = array_merge($serendipity['GET'], $media);
     $serendipity['smarty']->assignByRef('media', $media);
     echo serendipity_smarty_show('admin/media_choose.tpl', $data);
     break;
 default:
     serendipity_restoreVar($serendipity['COOKIE']['serendipity_only_path'], $serendipity['GET']['only_path']);
     $data['case_default'] = true;
     $data['showML'] = showMediaLibrary();
/**
 * Shows the HTML form to add/edit properties of uploaded media items
 *
 * @param  array    Associative array holding an array('image_id', 'target', 'created_thumbnail') that points to the uploaded media
 * @param  int      How many keyword checkboxes to display next to each other?
 * @param  boolean  Can existing data be modified?
 * @return boolean
 *
 */
function serendipity_showPropertyForm(&$new_media, $keywordsPerBlock = 3, $is_edit = true)
{
    global $serendipity;
    if (!is_array($new_media) || count($new_media) < 1) {
        return true;
    }
    $mirror = array();
    serendipity_checkPropertyAccess($new_media, $mirror, 'read');
    $editform_hidden = '';
    if (isset($GLOBALS['image_selector_addvars']) && is_array($GLOBALS['image_selector_addvars'])) {
        // These variables may come from serendipity_admin_image_selector.php to show embedded upload form
        foreach ($GLOBALS['image_selector_addvars'] as $imgsel_key => $imgsel_val) {
            $editform_hidden .= '          <input type="hidden" name="serendipity[' . htmlspecialchars($imgsel_key) . ']" value="' . htmlspecialchars($imgsel_val) . '" />' . "\n";
        }
    }
    $dprops = explode(';', $serendipity['mediaProperties']);
    $keywords = explode(';', $serendipity['mediaKeywords']);
    $now = serendipity_serverOffsetHour();
    $show = array();
    foreach ($new_media as $idx => $media) {
        $props =& serendipity_fetchMediaProperties($media['image_id']);
        $show[$idx] =& $media['internal'];
        $show[$idx]['image_id'] = $media['image_id'];
        serendipity_prepareMedia($show[$idx]);
        if (!is_array($props['base_metadata'])) {
            $show[$idx]['metadata'] =& serendipity_getMetaData($show[$idx]['realfile'], $show[$idx]['header']);
        } else {
            $show[$idx]['metadata'] = $props['base_metadata'];
            serendipity_plugin_api::hook_event('media_getproperties_cached', $show[$idx]['metadata'], $show[$idx]['realfile']);
        }
        serendipity_parseMediaProperties($dprops, $keywords, $show[$idx], $props, $keywordsPerBlock, $is_edit);
    }
    $smarty_vars = array('is_edit' => $is_edit, 'editform_hidden' => $editform_hidden, 'keywordsPerBlock' => $keywordsPerBlock, 'keywords' => $keywords, 'dprops' => $dprops);
    return serendipity_showMedia($show, $mirror, $url, false, 1, false, $smarty_vars);
}
 function displayImage($id, $orderby, $order)
 {
     global $serendipity;
     $extended_data = array();
     $base_directory = $this->get_config('base_directory');
     $file = serendipity_fetchImageFromDatabase($id);
     $file['link'] = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . '.' . $file['extension'];
     $test_string = $serendipity['serendipityPath'] . $serendipity['uploadHTTPPath'] . $base_directory;
     $path_len = strlen($test_string);
     $pic_string = substr($serendipity['serendipityPath'] . $serendipity['uploadHTTPPath'] . $file['path'], 0, $path_len);
     if (isset($file['id'])) {
         $file['size_txt'] = round($file['size'] / 1024);
         $file['is_image'] = serendipity_isImage($file);
         $max_width = $this->get_config('image_width', 480);
         if ($file['dimensions_width'] > $max_width && $max_width != 0) {
             $file['alt_width'] = $max_width;
             $file['alt_height'] = round($max_width / $file['dimensions_width'] * $file['dimensions_height']);
         } else {
             $file['alt_width'] = $file['dimensions_width'];
             $file['alt_height'] = $file['dimensions_height'];
         }
         if ($this->get_config('image_strict') == 'yes') {
             $images = serendipity_fetchImagesFromDatabase($lower_limit, $images_per_page, $total, $orderby, $order, $file['path'], '', '', array(), true);
         } else {
             $images = serendipity_fetchImagesFromDatabase($lower_limit, $images_per_page, $total, $orderby, $order, $file['path']);
         }
         $extended_data = serendipity_fetchMediaProperties($id);
         $base_directory = str_replace('gallery', '', $base_directory);
         $previous_attempt = -1;
         $previous_id = -1;
         $next_id = -1;
         if (is_array($images)) {
             $stop = false;
             $onecount = false;
             while ((list($f, $image) = each($images)) && !$stop) {
                 if ($image['id'] == $file['id']) {
                     $path = $image['path'];
                     $previous_id = $previous_attempt;
                     $onecount = true;
                 } else {
                     if ($onecount == true) {
                         $next_id = $image['id'];
                         $stop = true;
                     } else {
                         $previous_attempt = $image['id'];
                     }
                 }
             }
         }
         $gallery_array = explode('/', $path);
         foreach ($gallery_array as $f => $gallery) {
             $gallery_path = $gallery_path . $gallery . "/";
             if ($gallery_path != $base_directory) {
                 $path_array[$gallery]['path'] = $gallery_path;
                 $path_array[$gallery]['name'] = $gallery;
             }
         }
         // EXIF DATA
         if ($this->get_config('exif_show_data') == 'yes') {
             // If any exif tags that are available.
             $filepath = $serendipity['serendipityPath'] . $serendipity['uploadHTTPPath'] . $file['path'];
             $exif_data = $this->getExifTags($filepath, $file['name'], $file['extension']);
             $exifsettings_one = $this->get_config('exif_data', $this->makeExifSelector());
             // Create array of exif display settings for main information table.
             $exif_arr = explode(',', $exifsettings_one);
             foreach ($exif_arr as $key => $value) {
                 $display = explode('-', $exif_arr[$key]);
                 $exif_display_one[$display[0]] = $display[1];
             }
             $data_written = false;
             $exif_output .= '<div class="all_img_info">';
             $exif_output .= '<div class="exif_info_row"><div class="exif_info_head"><strong>' . PLUGIN_EVENT_USERGALLERY_EXIFDATA_ADDITIONALDATA . '</strong></div></div>';
             foreach ($exif_data as $tag => $value) {
                 if ($value != 'Unknown' && $exif_display_one[$tag] == 'yes') {
                     $data_written = true;
                     $exif_output .= '<div class="exif_info_row"><span class="exif_info_tag">' . $tag . '</span><span class="exif_info">' . $value . '</span></div>';
                 }
             }
             if (!$data_written) {
                 $exif_output .= '<div class="exif_info_row"><strong>' . PLUGIN_EVENT_USERGALLERY_EXIFDATA_NOADDITIONALDATA . '</strong></div>';
             }
             $exif_output .= '</div>';
         }
         // END EXIF DATA
         //Show Media Library Properties
         if ($this->get_config('show_media_properties', 'no') == 'yes') {
             if (is_array($extended_data) && isset($extended_data['base_property'])) {
                 $extended_data = array_merge($extended_data['base_property'], (array) $extended_data['base_metadata']);
             } else {
                 $extended_data = array();
             }
             $extended_data_out = array();
             $extended_output = explode(';', $this->get_config('media_properties', 'COPYRIGHT:Copyright;TITLE:Title;COMMENT2:Comment'));
             foreach ($extended_output as $option) {
                 $option = explode(':', $option);
                 foreach ($extended_data as $ex_name => $ex_data) {
                     if ($ex_name == $option[0] && isset($option[1]) && $ex_data != '') {
                         $extended_data_out[] = array('name' => $option[1], 'value' => $ex_data);
                         if ($ex_name == 'TITLE' && $ex_data != '') {
                             $file['title'] = $ex_data;
                         }
                     }
                 }
             }
         }
         if (!isset($file['title'])) {
             $file['title'] = $file['name'];
         }
         if (serendipity_db_bool($this->get_config('linked_entries'))) {
             $_filename = $file['name'] . '.' . $file['extension'];
             $_thumbname = $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension'];
             $e = $this->fetchLinkedEntries($file['id'], $file['path'] . $_filename, $file['path'] . $_thumbname);
             if (is_array($e)) {
                 $file['entries'] = array();
                 foreach ($e as $_item) {
                     $file['entries'][] = array('href' => serendipity_archiveURL($_item['id'], $_item['title'], 'serendipityHTTPPath', true, array('timestamp' => $_item['timestamp'])), 'title' => $_item['title']);
                 }
             }
             if (class_exists('serendipity_event_staticpage')) {
                 $s = $this->fetchStaticPages($file['id'], $file['path'] . $_filename, $file['path'] . $_thumbname);
                 if (is_array($s)) {
                     $file['staticpage_results'] = array();
                     foreach ($s as $_item) {
                         $staticpage_title = $_item['headline'];
                         if ($staticpage_title == '') {
                             $staticpage_title = $_item['pagetitle'];
                         }
                         if ($serendipity['rewrite'] == 'none') {
                             $staticpage_link = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?serendipity[subpage]=' . $_item['subpage'];
                         } else {
                             $staticpage_link = $_item['permalink'];
                         }
                         $file['staticpage_results'][] = array('href' => $staticpage_link, 'title' => $staticpage_title);
                     }
                 }
             }
         }
         unset($path_array['']);
         $serendipity['smarty']->assign(array('plugin_usergallery_title' => $this->get_config('title'), 'plugin_usergallery_nextid' => $next_id, 'plugin_usergallery_gallery_breadcrumb' => $path_array, 'plugin_usergallery_previousid' => $previous_id, 'plugin_usergallery_xtra_info' => $exif_output, 'plugin_usergallery_extended_info' => $extended_data_out, 'plugin_usergallery_file' => $file));
         $content = $this->parseTemplate('plugin_usergallery_imagedisplay.tpl');
         echo $content;
         return true;
     } else {
         echo "Invalid file.";
         return false;
     }
 }