Exemplo n.º 1
0
 /**
  * nggAdmin::get_MetaData()
  * 
  * @class nggAdmin
  * @require NextGEN Meta class
  * @param int $id image ID
  * @return array metadata
  */
 function get_MetaData($id)
 {
     require_once NGGALLERY_ABSPATH . '/lib/meta.php';
     $meta = array();
     $pdata = new nggMeta($id);
     $meta['title'] = trim($pdata->get_META('title'));
     $meta['caption'] = trim($pdata->get_META('caption'));
     $meta['keywords'] = trim($pdata->get_META('keywords'));
     $meta['timestamp'] = $pdata->get_date_time();
     // this contain other useful meta information
     $meta['common'] = $pdata->get_common_meta();
     // hook for addon plugin to add more meta fields
     $meta = apply_filters('ngg_get_image_metadata', $meta, $pdata);
     return $meta;
 }
Exemplo n.º 2
0
/**
 * ngg_import_date_time() - Read the timestamp from exif and insert it into the database
 * 
 * @return void
 */
function ngg_import_date_time()
{
    global $wpdb;
    $imagelist = $wpdb->get_results("SELECT t.*, tt.* FROM {$wpdb->nggallery} AS t INNER JOIN {$wpdb->nggpictures} AS tt ON t.gid = tt.galleryid ORDER BY tt.pid ASC");
    if (is_array($imagelist)) {
        foreach ($imagelist as $image) {
            $picture = new nggImage($image);
            $meta = new nggMeta($picture->imagePath, true);
            $date = $meta->get_date_time();
            $wpdb->query("UPDATE {$wpdb->nggpictures} SET imagedate = '{$date}' WHERE pid = '{$picture->pid}'");
        }
    }
}
Exemplo n.º 3
0
 public function handleUpload_widget()
 {
     global $wpdb;
     require_once dirname(__FILE__) . '/class.npu_uploader.php';
     require_once NGGALLERY_ABSPATH . '/lib/meta.php';
     $ngg->options['swfupload'] = false;
     //Where is this being instantiated?
     if (isset($_POST['uploadimage_widget'])) {
         check_admin_referer('ngg_addgallery');
         if (!isset($_FILES['MF__F_0_0']['error']) || $_FILES['MF__F_0_0']['error'] == 0) {
             $objUploaderNggAdmin = new UploaderNggAdmin();
             $messagetext = $objUploaderNggAdmin->upload_images_widget();
             $this->arrImageIds = $objUploaderNggAdmin->arrImageIds;
             $this->strGalleryPath = $objUploaderNggAdmin->strGalleryPath;
             $this->arrImageNames = $objUploaderNggAdmin->arrImageNames;
             if (is_array($objUploaderNggAdmin->arrThumbReturn) && count($objUploaderNggAdmin->arrThumbReturn) > 0) {
                 foreach ($objUploaderNggAdmin->arrThumbReturn as $strReturnMsg) {
                     if ($strReturnMsg != '1') {
                         $this->arrErrorMsg_widg[] = $strReturnMsg;
                     }
                 }
                 $this->arrImageMsg_widg[] = get_option('npu_upload_success') ? get_option('npu_upload_success') : __('Thank you! Your image has been submitted and is pending review.', 'nextgen-public-uploader');
                 $this->sendEmail();
             }
             //Used in update_details method.
             if (is_array($this->arrImageIds) && count($this->arrImageIds) > 0) {
                 foreach ($this->arrImageIds as $imageId) {
                     $pic = nggdb::find_image($imageId);
                     $objEXIF = new nggMeta($pic->imagePath);
                     $this->strTitle = $objEXIF->get_META('title');
                     $this->strDescription = $objEXIF->get_META('caption');
                     $this->strKeywords = $objEXIF->get_META('keywords');
                     $this->strTimeStamp = $objEXIF->get_date_time();
                 }
             } else {
                 $this->arrErrorMsg_widg[] = get_option('npu_no_file') ? get_option('npu_no_file') : __('You must select a file to upload', 'nextgen-public-uploader');
             }
             $this->update_details();
         } else {
             $this->arrErrorMsg_widg[] = get_option('npu_upload_failed') ? get_option('npu_upload_failed') : __('Upload failed!', 'nextgen-public-uploader');
         }
         //If we've encountered any errors, delete?
         if (count($this->arrErrorMsg_widg) > 0 && (is_array($this->arrImageIds) && count($this->arrImageIds) > 0)) {
             $gal_id = !empty($_POST['galleryselect']) ? absint($_POST['galleryselect']) : 1;
             foreach ($this->arrImageIds as $intImageId) {
                 $filename = $wpdb->get_var("SELECT filename FROM {$wpdb->nggpictures} WHERE pid = '{$intImageId}' ");
                 if ($filename) {
                     $gallerypath = $wpdb->get_var($wpdb->prepare("SELECT path FROM {$wpdb->nggallery} WHERE gid = %d", $gal_id));
                     if ($gallerypath) {
                         @unlink(WINABSPATH . $gallerypath . '/thumbs/thumbs_' . $filename);
                         @unlink(WINABSPATH . $gallerypath . '/' . $filename);
                     }
                     $delete_pic = $wpdb->delete($wpdb->nggpictures, array('pid' => $intImageId), array('%d'));
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 public function handleUpload_widget()
 {
     global $wpdb;
     require_once dirname(__FILE__) . '/class.npu_uploader.php';
     require_once NGGALLERY_ABSPATH . '/lib/meta.php';
     $ngg->options['swfupload'] = false;
     if ($_POST['uploadimage_widget']) {
         check_admin_referer('ngg_addgallery');
         if ($_FILES['MF__F_0_0']['error'] == 0) {
             $objUploaderNggAdmin = new UploaderNggAdmin();
             $messagetext = $objUploaderNggAdmin->upload_images_widget();
             $this->arrImageIds = $objUploaderNggAdmin->arrImageIds;
             $this->strGalleryPath = $objUploaderNggAdmin->strGalleryPath;
             $this->arrImageNames = $objUploaderNggAdmin->arrImageNames;
             if (is_array($objUploaderNggAdmin->arrThumbReturn) && count($objUploaderNggAdmin->arrThumbReturn) > 0) {
                 foreach ($objUploaderNggAdmin->arrThumbReturn as $strReturnMsg) {
                     if ($strReturnMsg != '1') {
                         $this->arrErrorMsg_widg[] = $strReturnMsg;
                     }
                 }
                 if (get_option('npu_upload_success')) {
                     $this->arrImageMsg_widg[] = get_option('npu_upload_success');
                 } else {
                     $this->arrImageMsg_widg[] = "Thank you! Your image has been submitted and is pending review.";
                 }
                 $this->sendEmail();
             }
             if (is_array($this->arrImageIds) && count($this->arrImageIds) > 0) {
                 foreach ($this->arrImageIds as $imageId) {
                     $pic = nggdb::find_image($imageId);
                     $objEXIF = new nggMeta($pic->imagePath);
                     $this->strTitle = $objEXIF->get_META('title');
                     $this->strDescription = $objEXIF->get_META('caption');
                     $this->strKeywords = $objEXIF->get_META('keywords');
                     $this->strTimeStamp = $objEXIF->get_date_time();
                 }
             } else {
                 if (get_option('npu_no_file')) {
                     $this->arrErrorMsg_widg[] = get_option('npu_no_file');
                 } else {
                     $this->arrErrorMsg_widg[] = "You must select a file to upload";
                 }
             }
             $this->update_details();
         } else {
             if (get_option('npu_upload_failed')) {
                 $this->arrErrorMsg_widg[] = get_option('npu_upload_failed');
             } else {
                 $this->arrErrorMsg_widg[] = "Upload failed!";
             }
         }
         if (count($this->arrErrorMsg_widg) > 0 && (is_array($this->arrImageIds) && count($this->arrImageIds) > 0)) {
             $gal_id = $_POST['galleryselect'];
             foreach ($this->arrImageIds as $intImageId) {
                 $filename = $wpdb->get_var("SELECT filename FROM {$wpdb->nggpictures} WHERE pid = '{$intImageId}' ");
                 if ($filename) {
                     $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$gal_id}' ");
                     if ($gallerypath) {
                         @unlink(WINABSPATH . $gallerypath . '/thumbs/thumbs_' . $filename);
                         @unlink(WINABSPATH . $gallerypath . '/' . $filename);
                     }
                     $delete_pic = $wpdb->query("DELETE FROM {$wpdb->nggpictures} WHERE pid = {$intImageId}");
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
 function get_MetaData($picPath)
 {
     // must be Gallery absPath + filename
     require_once NGGALLERY_ABSPATH . '/lib/meta.php';
     $meta = array();
     $pdata = new nggMeta($picPath);
     $meta['title'] = $pdata->get_META('title');
     $meta['caption'] = $pdata->get_META('caption');
     $meta['keywords'] = $pdata->get_META('keywords');
     $meta['timestamp'] = $pdata->get_date_time();
     return $meta;
 }
Exemplo n.º 6
0
 /**
  * nggAdmin::get_MetaData()
  * 
  * @class nggAdmin
  * @require NextGEN Meta class
  * @param int $id image ID
  * @return array metadata
  */
 function get_MetaData($id)
 {
     require_once NGGALLERY_ABSPATH . '/lib/meta.php';
     $meta = array();
     $pdata = new nggMeta($id);
     $meta['title'] = trim($pdata->get_META('title'));
     $meta['caption'] = trim($pdata->get_META('caption'));
     $meta['keywords'] = trim($pdata->get_META('keywords'));
     $meta['timestamp'] = $pdata->get_date_time();
     // this contain other useful meta information
     $meta['common'] = $pdata->get_common_meta();
     return $meta;
 }