Пример #1
0
 /**
  * Constructor
  * 
  * @return void
  * @access public
  * @since 1/29/07
  */
 function __construct()
 {
     $this->mediaFileType = MediaAsset::getMediaFileType();
     if (method_exists($this, 'XmlAction')) {
         $this->XmlAction();
     }
 }
Пример #2
0
 /**
  * Answer a new MediaAsset that wraps the Asset identified with the passed Ids.
  * 
  * @param string $repositoryId
  * @param string $assetId
  * @return object MediaAsset
  * @access public
  * @since 4/27/07
  * @static
  */
 public static function withIdStrings($repositoryId, $assetId)
 {
     ArgumentValidator::validate($repositoryId, NonZeroLengthStringValidatorRule::getRule());
     ArgumentValidator::validate($assetId, NonZeroLengthStringValidatorRule::getRule());
     $idManager = Services::getService("Id");
     $mediaAsset = MediaAsset::withIds($idManager->getId($repositoryId), $idManager->getId($assetId));
     return $mediaAsset;
 }
Пример #3
0
 /**
  * Answer a new MediaAsset that wraps the Asset identified with the passed Ids.
  * 
  * @param object Id $repositoryId
  * @param object Id $assetId
  * @return object MediaAsset
  * @access public
  * @since 4/27/07
  * @static
  */
 public static function withIds($repositoryId, $assetId, $recordId)
 {
     ArgumentValidator::validate($repositoryId, ExtendsValidatorRule::getRule("Id"));
     ArgumentValidator::validate($assetId, ExtendsValidatorRule::getRule("Id"));
     ArgumentValidator::validate($recordId, ExtendsValidatorRule::getRule("Id"));
     $repositoryManager = Services::getService("Repository");
     $repository = $repositoryManager->getRepository($repositoryId);
     $asset = $repository->getAsset($assetId);
     $mediaFile = new MediaFile(MediaAsset::withAsset($asset), $asset->getRecord($recordId));
     return $mediaFile;
 }
Пример #4
0
 /**
  * Create a new file asset
  * 
  * @return object Asset
  * @access public
  * @since 1/26/07
  */
 function createFileAsset()
 {
     $contentAsset = $this->getContentAsset();
     $asset = MediaAsset::createForContentAsset($contentAsset);
     if (!($displayName = RequestContext::value('displayName'))) {
         $displayName = $_FILES['media_file']['name'];
     }
     if (!($description = RequestContext::value('description'))) {
         $description = '';
     }
     // Check the quota
     $slot = $this->getSlot();
     if ($this->getQuotaUsed() + $_FILES['media_file']['size'] > $slot->getMediaQuota()->value()) {
         throw new Exception("Cannot add File, {$displayName}, quota of " . $slot->getMediaQuota()->asString() . " exceeded.");
     }
     // Create the asset
     $asset->updateDisplayName($displayName);
     $asset->updateDescription($description);
     try {
         $this->addFileRecord($asset);
     } catch (Exception $e) {
         HarmoniErrorHandler::logException($e, 'Segue');
         $this->nonFatalError($e->getMessage(), get_class($e));
     }
     try {
         $this->addDublinCoreRecord($asset);
     } catch (Exception $e) {
         HarmoniErrorHandler::logException($e, 'Segue');
         $this->nonFatalError($e->getMessage(), get_class($e));
     }
     // Log the success or failure
     if (Services::serviceRunning("Logging")) {
         $loggingManager = Services::getService("Logging");
         $log = $loggingManager->getLogForWriting("Segue");
         $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified.");
         $priorityType = new Type("logging", "edu.middlebury", "Event_Notice", "Normal events.");
         $item = new AgentNodeEntryItem("Media Library", "File uploaded with id '" . $asset->getId()->getIdString() . "' and filename '" . $_FILES['media_file']['name'] . "'");
         $item->addNodeId($asset->getId());
         $item->addNodeId($contentAsset->getId());
         $idManager = Services::getService("Id");
         $director = AssetSiteDirector::forAsset($contentAsset);
         $site = $director->getRootSiteComponent($contentAsset->getId()->getIdString());
         $item->addNodeId($idManager->getId($site->getId()));
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     return $asset;
 }
Пример #5
0
    /**
     * Provide requested media panels for this plugin
     *
     * @param string $panel The HTML content of the panel to be output in the media bar
     * @param MediaSilo $silo The silo for which the panel was requested
     * @param string $path The path within the silo (silo root omitted) for which the panel was requested
     * @param string $panelname The name of the requested panel
     * @return string The modified $panel to contain the HTML output for the requested panel
     *
     * @todo Move the uploaded file from the temporary location to the location indicated by the path field.
     */
    public function filter_media_panels($panel, $silo, $path, $panelname)
    {
        $class = __CLASS__;
        if ($silo instanceof $class) {
            switch ($panelname) {
                case 'record':
                    $user = User::identify()->info->viddler__username;
                    $pass = User::identify()->info->viddler__password;
                    $auth = $this->viddler->user_authenticate(array('user' => $user, 'password' => $pass, 'get_record_token' => 1, 'record_token' => 1));
                    $sid = new SimpleXMLElement($auth);
                    $rt = $sid->record_token;
                    $panel .= "<div class=\"span-18\" style=\"padding-top:30px;color: #e0e0e0;margin: 0px auto;\">";
                    $panel .= $this->viddler->video_getrecordembed($rt);
                    $panel .= '</div>';
                    break;
                case 'upload':
                    if (isset($_FILES['file'])) {
                        $size = Utils::human_size($_FILES['file']['size']);
                        $panel .= "<div class=\"span-18\" style=\"padding-top:30px;color: #e0e0e0;margin: 0px auto;\"><p>File Uploaded: {$_FILES['file']['name']} ({$size})</p>";
                        $path = self::SILO_NAME . '/' . preg_replace('%\\.{2,}%', '.', $path) . '/' . $_FILES['file']['name'];
                        $asset = new MediaAsset($path, false);
                        $asset->upload($_FILES['file']);
                        if ($asset->put()) {
                            $panel .= '<p>File added successfully.</p>';
                        } else {
                            $panel .= '<p>File could not be added to the silo.</p>';
                        }
                        $panel .= '<p><a href="#" onclick="habari.media.forceReload();habari.media.showdir(\'' . dirname($path) . '\');">Browse the current silo path.</a></p></div>';
                    } else {
                        $fullpath = self::SILO_NAME . '/' . $path;
                        $form_action = URL::get('admin_ajax', array('context' => 'media_panel'));
                        $panel .= <<<UPLOAD_FORM
<form enctype="multipart/form-data" method="post" id="simple_upload" target="simple_upload_frame" action="{$form_action}" class="span-10" style="margin:0px auto;text-align: center">
\t<p style="padding-top:30px;">Upload to: <b style="font-weight:normal;color: #e0e0e0;font-size: 1.2em;">/{$path}</b></p>
\t<p><input type="file" name="file"><input type="submit" name="upload" value="Upload">
\t<input type="hidden" name="path" value="{$fullpath}">
\t<input type="hidden" name="panel" value="{$panelname}">
\t</p>
</form>
<iframe id="simple_upload_frame" name="simple_upload_frame" style="width:1px;height:1px;" onload="simple_uploaded();"></iframe>
<script type="text/javascript">
var responsedata;
function simple_uploaded() {
\tif(!\$('#simple_upload_frame')[0].contentWindow) return;
\tvar response = \$(\$('#simple_upload_frame')[0].contentWindow.document.body).text();
\tif(response) {
\t\teval('responsedata = ' + response);
\t\twindow.setTimeout(simple_uploaded_complete, 500);
\t}
}
function simple_uploaded_complete() {
\thabari.media.jsonpanel(responsedata);
}
</script>
UPLOAD_FORM;
                    }
            }
        }
        return $panel;
    }
	/**
	 * Provide requested media panels for this plugin
	 *
	 * Regarding Uploading:
	 * A panel is returned to the media bar that contains a form, an iframe, and a javascript function.
	 * The form allows the user to select a file, and is submitted back to the same URL that produced this panel in the first place.
	 * This has the result of submitting the uploaded file to here when the form is submitted.
	 * To prevent the panel form from reloading the whole publishing page, the form is submitted into the iframe.
	 * An onload event attached to the iframe calls the function.
	 * The function accesses the content of the iframe when it loads, which should contain the results of the request to obtain this panel, which are in JSON format.
	 * The JSON data is passed to the habari.media.jsonpanel() function in media.js to process the data and display the results, just like when displaying a panel normally.
	 *
	 * @param string $panel The HTML content of the panel to be output in the media bar
	 * @param MediaSilo $silo The silo for which the panel was requested
	 * @param string $path The path within the silo (silo root omitted) for which the panel was requested
	 * @param string $panelname The name of the requested panel
	 * @return string The modified $panel to contain the HTML output for the requested panel
	 *
	 * @todo Move the uploaded file from the temporary location to the location indicated by the path field.
	 */
	public function filter_media_panels( $panel, $silo, $path, $panelname)
	{
		$class = __CLASS__;
		if ( $silo instanceof $class ) {
			switch ( $panelname ) {
				case 'mkdir':

					$fullpath = self::SILO_NAME . '/' . $path;

					$form = new FormUI( 'habarisilomkdir' );
					$form->append( 'static', 'ParentDirectory', '<div style="margin: 10px auto;">' . _t('Parent Directory:') . " <strong>/{$path}</strong></div>" );

					// add the parent directory as a hidden input for later validation
					$form->append( 'hidden', 'path', 'null:unused' )->value = $path;
					$form->append( 'hidden', 'action', 'null:unused')->value = $panelname;
					$dir_text_control = $form->append( 'text', 'directory', 'null:unused', _t('What would you like to call the new directory?') );
					$dir_text_control->add_validator( array( $this, 'mkdir_validator' ) );
					$form->append( 'submit', 'submit', _t('Submit') );
					$form->media_panel($fullpath, $panelname, 'habari.media.forceReload();');
					$form->on_success( array( $this, 'dir_success' ) );
					$panel = $form->get(); /* form submission magicallly happens here */

					return $panel;

					break;
				case 'rmdir':
					$fullpath = self::SILO_NAME . '/' . $path;

					$form = new FormUI( 'habarisilormdir' );
					$form->append( 'static', 'RmDirectory', '<div style="margin: 10px auto;">' . _t('Directory:') . " <strong>/{$path}</strong></div>" );

					// add the parent directory as a hidden input for later validation
					$form->append( 'hidden', 'path', 'null:unused' )->value = $path;
					$form->append( 'hidden', 'action', 'null:unused')->value = $panelname;
					$dir_text_control = $form->append( 'static', 'directory', _t('Are you sure you want to delete this directory?') );
					$form->append( 'submit', 'submit', _t('Delete') );
					$form->media_panel($fullpath, $panelname, 'habari.media.forceReload();');
					$form->on_success( array( $this, 'dir_success' ) );
					$panel = $form->get(); /* form submission magicallly happens here */

					return $panel;

					break;
				case 'delete':
					$fullpath = self::SILO_NAME . '/' . $path;

					$form = new FormUI( 'habarisilodelete' );
					$form->append( 'static', 'RmFile', '<div style="margin: 10px auto;">' . _t('File:') . " <strong>/{$path}</strong></div>" );

					// add the parent directory as a hidden input for later validation
					$form->append( 'hidden', 'path', 'null:unused' )->value = $path;
					$dir_text_control = $form->append( 'static', 'directory', '<p>' . _t('Are you sure you want to delete this file?') . '</p>');
					$form->append( 'submit', 'submit', _t('Delete') );
					$form->media_panel($fullpath, $panelname, 'habari.media.forceReload();');
					$form->on_success( array( $this, 'do_delete' ) );
					$panel = $form->get();

					return $panel;
					break;
				case 'upload':
					if ( isset( $_FILES['file'] ) ) {
						$size = Utils::human_size($_FILES['file']['size']);
						$panel .= "<div class=\"span-18\" style=\"padding-top:30px;color: #e0e0e0;margin: 0px auto;\"><p>" . _t( "File Uploaded: " ) . "{$_FILES['file']['name']} ($size)</p>";

						$path = self::SILO_NAME . '/' . preg_replace('%\.{2,}%', '.', $path). '/' . $_FILES['file']['name'];
						$asset = new MediaAsset($path, false);
						$asset->upload( $_FILES['file'] );

						if ( $asset->put() ) {
							$panel .= '<p>' . _t( 'File added successfully.' ) . '</p>';
						}
						else {
							$panel .= '<p>' . _t( 'File could not be added to the silo.' ) . '</p>';
						}

						$panel .= '<p><a href="#" onclick="habari.media.forceReload();habari.media.showdir(\'' . dirname($path) . '\');">' . _t( 'Browse the current silo path.' ) . '</a></p></div>';
					}
					else {

						$fullpath = self::SILO_NAME . '/' . $path;
						$form_action = URL::get('admin_ajax', array('context' => 'media_panel'));
						$panel .= <<< UPLOAD_FORM
<form enctype="multipart/form-data" method="post" id="simple_upload" target="simple_upload_frame" action="{$form_action}" class="span-10" style="margin:0px auto;text-align: center">
	<p style="padding-top:30px;">%s <b style="font-weight:normal;color: #e0e0e0;font-size: 1.2em;">/{$path}</b></p>
	<p><input type="file" name="file"><input type="submit" name="upload" value="%s">
	<input type="hidden" name="path" value="{$fullpath}">
	<input type="hidden" name="panel" value="{$panelname}">
	</p>
</form>
<iframe id="simple_upload_frame" name="simple_upload_frame" style="width:1px;height:1px;" onload="simple_uploaded();"></iframe>
<script type="text/javascript">
var responsedata;
function simple_uploaded() {
	if (!$('#simple_upload_frame')[0].contentWindow) return;
	var response = $($('#simple_upload_frame')[0].contentWindow.document.body).text();
	if (response) {
		eval('responsedata = ' + response);
		window.setTimeout(simple_uploaded_complete, 500);
	}
}
function simple_uploaded_complete() {
	habari.media.jsonpanel(responsedata);
}
</script>
UPLOAD_FORM;

					$panel = sprintf( $panel, _t( "Upload to:" ), _t( "Upload" ) );
				}
			}
		}
		return $panel;
	}
Пример #7
0
 /**
  * Constructor
  * 
  * @return void
  * @access public
  * @since 8/5/08
  */
 public function __construct()
 {
     $this->mediaFileType = MediaAsset::getMediaFileType();
 }
Пример #8
0
    /**
     * Provide requested media panels for this plugin
     *
     * Regarding Uploading:
     * A panel is returned to the media bar that contains a form, an iframe, and a javascript function.
     * The form allows the user to select a file, and is submitted back to the same URL that produced this panel in the first place.
     * This has the result of submitting the uploaded file to here when the form is submitted.
     * To prevent the panel form from reloading the whole publishing page, the form is submitted into the iframe.
     * An onload event attached to the iframe calls the function.
     * The function accesses the content of the iframe when it loads, which should contain the results of the request to obtain this panel, which are in JSON format.
     * The JSON data is passed to the habari.media.jsonpanel() function in media.js to process the data and display the results, just like when displaying a panel normally.
     *
     * @param string $panel The HTML content of the panel to be output in the media bar
     * @param MediaSilo $silo The silo for which the panel was requested
     * @param string $path The path within the silo (silo root omitted) for which the panel was requested
     * @param string $panelname The name of the requested panel
     * @return string The modified $panel to contain the HTML output for the requested panel
     *
     * @todo Move the uploaded file from the temporary location to the location indicated by the path field.
     */
    public function filter_media_panels($panel, $silo, $path, $panelname)
    {
        $class = __CLASS__;
        if ($silo instanceof $class) {
            switch ($panelname) {
                case 'mkdir':
                    $fullpath = self::SILO_NAME . '/' . $path;
                    $form = new FormUI('habarisilomkdir');
                    $form->append('static', 'ParentDirectory', '<div style="margin: 10px auto;">' . _t('Parent Directory:') . " <strong>/{$path}</strong></div>");
                    // add the parent directory as a hidden input for later validation
                    $form->append('hidden', 'path', 'null:unused')->value = $path;
                    $form->append('hidden', 'action', 'null:unused')->value = $panelname;
                    $dir_text_control = $form->append('text', 'directory', 'null:unused', _t('What would you like to call the new directory?'));
                    $dir_text_control->add_validator(array($this, 'mkdir_validator'));
                    $form->append('submit', 'submit', _t('Submit'));
                    $form->media_panel($fullpath, $panelname, 'habari.media.forceReload();');
                    $form->on_success(array($this, 'dir_success'));
                    $panel = $form->get();
                    /* form submission magicallly happens here */
                    return $panel;
                    break;
                case 'rmdir':
                    $fullpath = self::SILO_NAME . '/' . $path;
                    $form = new FormUI('habarisilormdir');
                    $form->append('static', 'RmDirectory', '<div style="margin: 10px auto;">' . _t('Directory:') . " <strong>/{$path}</strong></div>");
                    // add the parent directory as a hidden input for later validation
                    $form->append('hidden', 'path', 'null:unused')->value = $path;
                    $form->append('hidden', 'action', 'null:unused')->value = $panelname;
                    $dir_text_control = $form->append('static', 'directory', _t('Are you sure you want to delete this directory?'));
                    $form->append('submit', 'submit', _t('Delete'));
                    $form->media_panel($fullpath, $panelname, 'habari.media.forceReload();');
                    $form->on_success(array($this, 'dir_success'));
                    $panel = $form->get();
                    /* form submission magicallly happens here */
                    return $panel;
                    break;
                case 'delete':
                    $fullpath = self::SILO_NAME . '/' . $path;
                    $form = new FormUI('habarisilodelete');
                    $form->append('static', 'RmFile', '<div style="margin: 10px auto;">' . _t('File:') . " <strong>/{$path}</strong></div>");
                    // add the parent directory as a hidden input for later validation
                    $form->append('hidden', 'path', 'null:unused')->value = $path;
                    $dir_text_control = $form->append('static', 'directory', '<p>' . _t('Are you sure you want to delete this file?') . '</p>');
                    $form->append('submit', 'submit', _t('Delete'));
                    $form->media_panel($fullpath, $panelname, 'habari.media.forceReload();');
                    $form->on_success(array($this, 'do_delete'));
                    $panel = $form->get();
                    return $panel;
                    break;
                case 'upload':
                    if (isset($_FILES['file'])) {
                        if (isset($_POST['token']) && isset($_POST['token_ts']) && self::verify_token($_POST['token'], $_POST['token_ts'])) {
                            $size = Utils::human_size($_FILES['file']['size']);
                            $panel .= '<div class="span-18" style="padding-top:30px;color: #e0e0e0;margin: 0px auto;"><p>' . _t('File: ') . $_FILES['file']['name'];
                            $panel .= $_FILES['file']['size'] > 0 ? "({$size})" : '';
                            $panel .= '</p>';
                            $path = self::SILO_NAME . '/' . preg_replace('%\\.{2,}%', '.', $path) . '/' . $_FILES['file']['name'];
                            $asset = new MediaAsset($path, false);
                            $asset->upload($_FILES['file']);
                            if ($asset->put()) {
                                $msg = _t('File uploaded: %s', array($_FILES['file']['name']));
                                $panel .= '<p>' . $msg . '</p>';
                                EventLog::log($msg, 'info');
                            } else {
                                $upload_errors = array(1 => _t('The uploaded file exceeds the upload_max_filesize directive in php.ini.'), 2 => _t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'), 3 => _t('The uploaded file was only partially uploaded.'), 4 => _t('No file was uploaded.'), 6 => _t('Missing a temporary folder.'), 7 => _t('Failed to write file to disk.'), 8 => _t('A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help.'));
                                $msg = _t('File upload failed: %s', array($_FILES['file']['name']));
                                $panel .= '<p>' . $msg . '</p>';
                                $panel .= '<p><strong>' . $upload_errors[$_FILES['file']['error']] . '</strong></p>';
                                EventLog::log($msg . ' ' . $upload_errors[$_FILES['file']['error']], 'err');
                            }
                            $panel .= '<p><a href="#" onclick="habari.media.forceReload();habari.media.showdir(\'' . dirname($path) . '\');">' . _t('Browse the current silo path.') . '</a></p></div>';
                        } else {
                            $panel .= '<p><strong>' . _t('Suspicious behaviour or too much time has elapsed.  Please upload your file again.') . '</strong></p>';
                        }
                    } else {
                        $token_ts = time();
                        $token = self::create_token($token_ts);
                        $fullpath = self::SILO_NAME . '/' . $path;
                        $form_action = URL::get('admin_ajax', array('context' => 'media_upload'));
                        $panel .= <<<UPLOAD_FORM
<form enctype="multipart/form-data" method="post" id="simple_upload" target="simple_upload_frame" action="{$form_action}" class="span-10" style="margin:0px auto;text-align: center">
\t<p style="padding-top:30px;">%s <b style="font-weight:normal;color: #e0e0e0;font-size: 1.2em;">/{$path}</b></p>
\t<p><input type="file" name="file"><input type="submit" name="upload" value="%s">
\t<input type="hidden" name="path" value="{$fullpath}">
\t<input type="hidden" name="panel" value="{$panelname}">
\t<input type="hidden" name="token" value="{$token}">
\t<input type="hidden" name="token_ts" value="{$token_ts}">
\t</p>
</form>
<iframe id="simple_upload_frame" name="simple_upload_frame" style="width:1px;height:1px;" onload="simple_uploaded();"></iframe>
<script type="text/javascript">
var responsedata;
function simple_uploaded() {
\tif (!\$('#simple_upload_frame')[0].contentWindow) return;
\tvar response = \$(\$('#simple_upload_frame')[0].contentWindow.document.body).text();
\tif (response) {
\t\teval('responsedata = ' + response);
\t\twindow.setTimeout(simple_uploaded_complete, 500);
\t}
}
function simple_uploaded_complete() {
\thabari.media.jsonpanel(responsedata.data);
}
</script>
UPLOAD_FORM;
                        $panel = sprintf($panel, _t("Upload to:"), _t("Upload"));
                    }
            }
        }
        return $panel;
    }
 /**
  * Answer an XML representation of a media file.
  * 
  * @param object Asset $asset
  * @param string $parentId
  * @access protected
  */
 protected function recordMediaAsset(Asset $asset, $parentId)
 {
     $mediaAsset = MediaAsset::withAsset($asset);
     if (!$mediaAsset->getFiles()->hasNext()) {
         return;
     }
     $file = $mediaAsset->getFiles()->next();
     $element = $this->channel->insertBefore($this->doc->createElement('item'), $this->endFiles);
     $element->appendChild($this->getElement('title', $mediaAsset->getDisplayName()));
     $element->appendChild($this->getElement('link', $file->getUrl()));
     $element->appendChild($this->getElement('guid', $file->getUrl()))->setAttribute('isPermaLink', 'false');
     $element->appendChild($this->getElement('description', $mediaAsset->getDescription()));
     $element->appendChild($this->getCDATAElementNS("http://wordpress.org/export/1.1/excerpt/", 'excerpt:encoded', $mediaAsset->getDescription()));
     $element->appendChild($this->getElement('pubDate', $mediaAsset->getModificationDate()->format('r')));
     $agentUID = $this->recordAgent($asset->getCreator());
     $element->appendChild($this->getElementNS("http://purl.org/dc/elements/1.1/", 'dc:creator', $agentUID));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:post_id', $mediaAsset->getId()));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:post_date', $mediaAsset->getModificationDate()->format('Y-m-d H:i:s')));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:post_date_gmt', $mediaAsset->getModificationDate()->asUTC()->format('Y-m-d H:i:s')));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:comment_status', 'closed'));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:ping_status', 'closed'));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:status', 'publish'));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:post_parent', $parentId));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:menu_order', '0'));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:post_type', 'attachment'));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:post_password', ''));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:is_sticky', '0'));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:attachment_url', $file->getUrl()));
     // Thumbnail
     $element = $this->channel->insertBefore($this->doc->createElement('item'), $this->endFiles);
     if ($file->getThumbnailMimeType()) {
         $mime = Services::getService("MIME");
         $thumbExtension = $mime->getExtensionForMIMEType($file->getThumbnailMimeType());
     } else {
         $thumbExtension = 'png';
     }
     $element->appendChild($this->getElement('title', $mediaAsset->getDisplayName() . ' - thumbnail'));
     $element->appendChild($this->getElement('link', $file->getThumbnailUrl()));
     $element->appendChild($this->getElement('guid', $file->getThumbnailUrl()))->setAttribute('isPermaLink', 'false');
     $element->appendChild($this->getElement('description', $mediaAsset->getDescription()));
     $element->appendChild($this->getElement('pubDate', $mediaAsset->getModificationDate()->format('r')));
     $agentUID = $this->recordAgent($asset->getCreator());
     $element->appendChild($this->getElementNS("http://purl.org/dc/elements/1.1/", 'dc:creator', $agentUID));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:post_id', intval($mediaAsset->getId()->getIdString()) + 200000000000));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:post_date', $mediaAsset->getModificationDate()->format('Y-m-d H:i:s')));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:post_date_gmt', $mediaAsset->getModificationDate()->asUTC()->format('Y-m-d H:i:s')));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:comment_status', 'closed'));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:ping_status', 'closed'));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:status', 'publish'));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:post_parent', $parentId));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:menu_order', '0'));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:post_type', 'attachment'));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:post_password', ''));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:is_sticky', '0'));
     $element->appendChild($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:attachment_url', $file->getThumbnailUrl()));
 }
 /**
  * Add a Media File
  * 
  * @param Asset $contentAsset
  * @param object DOMElement $element
  * @return void
  * @access protected
  * @since 1/24/08
  */
 protected function addMedia(Asset $contentAsset, DOMElement $element)
 {
     $asset = MediaAsset::createForContentAsset($contentAsset);
     $element->setAttribute('new_id', $asset->getId()->getIdString());
     $asset->updateDisplayName($this->getStringValue($this->getSingleChild('displayName', $element)));
     $asset->updateDescription($this->getStringValue($this->getSingleChild('description', $element)));
     $fileElements = $this->xpath->query("./file", $element);
     foreach ($fileElements as $fileElement) {
         $this->addFileRecord($asset, $fileElement);
     }
     $dcElements = $this->xpath->query("./dublinCore", $element);
     foreach ($dcElements as $dcElement) {
         $this->addDublinCoreRecord($asset, $dcElement);
     }
     $this->setAssetAuthorship($asset, $element);
     $this->setAssetDates($asset, $element);
 }