Exemplo n.º 1
0
 /**
  * 
  * @global type $wpdb
  * @param WPFB_File $file
  * @param type $info
  * @return type
  */
 static function StoreFileInfo($file, $info)
 {
     global $wpdb;
     if (empty($file->file_thumbnail)) {
         if (!empty($info['comments']['picture'][0]['data'])) {
             $cover_img =& $info['comments']['picture'][0]['data'];
         } elseif (!empty($info['id3v2']['APIC'][0]['data'])) {
             $cover_img =& $info['id3v2']['APIC'][0]['data'];
         } else {
             $cover_img = null;
         }
         // TODO unset pic in info?
         if (!empty($cover_img)) {
             $cover = $file->GetLocalPath();
             $cover = substr($cover, 0, strrpos($cover, '.')) . '.jpg';
             file_put_contents($cover, $cover_img);
             $file->CreateThumbnail($cover, true);
             @unlink($cover);
             $cf_changed = true;
         }
     }
     self::cleanInfoByRef($info);
     // set encoding to utf8 (required for getKeywords)
     if (function_exists('mb_internal_encoding')) {
         $cur_enc = mb_internal_encoding();
         mb_internal_encoding('UTF-8');
     }
     $keywords = array();
     self::getKeywords($info, $keywords);
     $keywords = strip_tags(join(' ', $keywords));
     $keywords = str_replace(array('\\n', '
'), '', $keywords);
     $keywords = preg_replace('/\\s\\s+/', ' ', $keywords);
     if (!function_exists('mb_detect_encoding') || mb_detect_encoding($keywords, "UTF-8") != "UTF-8") {
         $keywords = utf8_encode($keywords);
     }
     // restore prev encoding
     if (function_exists('mb_internal_encoding')) {
         mb_internal_encoding($cur_enc);
     }
     // don't store keywords 2 times:
     unset($info['keywords']);
     self::removeLongData($info, 8000);
     $data = empty($info) ? '0' : base64_encode(serialize($info));
     $res = $wpdb->replace($wpdb->wpfilebase_files_id3, array('file_id' => (int) $file->GetId(), 'analyzetime' => time(), 'value' => &$data, 'keywords' => &$keywords));
     unset($data, $keywords);
     $cf_changed = false;
     // TODO: move this cleanup into a callback / should NOT be HERE!
     if ($file->file_rescan_pending) {
         $file->file_rescan_pending = 0;
         $cf_changed = true;
     }
     // delete local temp file
     if ($file->IsRemote() && file_exists($file->GetLocalPath())) {
         @unlink($file->GetLocalPath());
     }
     // TODO END;
     if ($cf_changed && !$file->IsLocked()) {
         $file->DbSave(true);
     }
     return $res;
 }
Exemplo n.º 2
0
<input type="hidden" name="file_id" id="file_id" value="<?php 
echo $update ? $multi_edit ? $item_ids : $file->file_id : "";
?>
" />
<?php 
wp_nonce_field($nonce_action, 'wpfb-file-nonce');
?>
<table class="form-table">
<?php 
if (!$multi_edit) {
    ?>
	<tr id="wpfilebase-form-upload-row">
		<td colspan="4">			
			<div id="wpfilebase-upload-menu">
				<a href="#" <?php 
    echo $file->IsRemote() ? '' : 'class="current"';
    ?>
 onclick="return WPFB_switchFileUpload(0)"><?php 
    _e('Upload');
    ?>
</a>
				<a href="#" <?php 
    echo $file->IsRemote() ? 'class="current"' : '';
    ?>
 onclick="return WPFB_switchFileUpload(1)"><?php 
    _e('File URL');
    ?>
</a>
				<input type="hidden" name="file_is_remote" id="file_is_remote" value="<?php 
    echo $file->IsRemote() ? 1 : 0;
    ?>
Exemplo n.º 3
0
			<div class="overlay-locked"><?php 
    echo WPFB_Admin::Icon('lock', 70);
    ?>
				<span><?php 
    $file->IsScanLocked() && printf(__('This file is locked for %s or until the scan process completes.', 'wp-filebase'), human_time_diff(time(), $file->file_scan_lock));
    echo ' ' . __('You can edit meta data only.', 'wp-filebase');
    ?>
</span>
			</div>
		<?php 
}
?>

		<div id="wpfilebase-upload-menu" class="admin-scheme-bgcolor-0">
			<a href="#" <?php 
echo $file->IsRemote() ? '' : 'class="admin-scheme-bgcolor-2 current"';
?>
 onclick="return WPFB_switchFileUpload(0)"><?php 
$update ? _e('Upload Update', 'wp-filebase') : _e('Upload');
?>
</a>
			<a href="#" <?php 
echo $file->IsRemote() ? 'class="admin-scheme-bgcolor-2 current"' : '';
?>
 onclick="return WPFB_switchFileUpload(1)"><?php 
_e('File URL');
?>
</a>
			<input type="hidden" name="file_is_remote" id="file_is_remote" value="<?php 
echo $file->IsRemote() ? 1 : 0;
?>