コード例 #1
0
ファイル: addVideo.act.php プロジェクト: adamfranco/segue
 /**
  * Build the XML content for this action
  * 
  * @return void
  * @access protected
  * @since 1/14/09
  */
 protected function buildXml()
 {
     $upload = RequestContext::value('media_file');
     if ($upload['error']) {
         throw new OperationFailedException("Upload Error: " . $upload['error']);
     }
     if (!$upload['size']) {
         $postMax = ByteSize::fromString(ini_get('post_max_size'));
         $uploadMax = ByteSize::fromString(ini_get('upload_max_filesize'));
         $memoryLimit = ByteSize::fromString(ini_get('memory_limit'));
         $min = $postMax;
         if ($min->isGreaterThan($uploadMax)) {
             $min = $uploadMax;
         }
         if ($min->isGreaterThan($memoryLimit)) {
             $min = $memoryLimit;
         }
         throw new OperationFailedException("No file uploaded or file too big. Max: " . $min->asString());
     }
     $file = $this->addVideo(RequestContext::value('directory'), base64_encode(file_get_contents($upload['tmp_name'])), $upload['name'], $upload['type'], $upload['size']);
     print "\n<file ";
     print "name=\"" . $file['name'] . "\" ";
     print "httpUrl=\"" . $file['httpurl'] . "\" ";
     print "rtmpUrl=\"" . $file['rtmpurl'] . "\" ";
     print "mimeType=\"" . $file['mimetype'] . "\" ";
     print "size=\"" . $file['size'] . "\" ";
     print "date=\"" . $file['date'] . "\" ";
     if (isset($file['creator'])) {
         print "creator=\"" . $file['creator'] . "\" ";
     } else {
         print "creator=\"\" ";
     }
     if (isset($file['fullframeurl'])) {
         print "fullframeUrl=\"" . $file['fullframeurl'] . "\" ";
     } else {
         print "fullframeUrl=\"\" ";
     }
     if (isset($file['thumburl'])) {
         print "thumbUrl=\"" . $file['thumburl'] . "\" ";
     } else {
         print "thumbUrl=\"\" ";
     }
     if (isset($file['splashurl'])) {
         print "splashUrl=\"" . $file['splashurl'] . "\" ";
     } else {
         print "splashUrl=\"\" ";
     }
     print ">";
     print "\n\t<embedCode><![CDATA[";
     print $file['embedcode'];
     print "]]></embedCode>";
     print "</file>";
 }
コード例 #2
0
 /**
  * Update the value for this Part.
  * 
  * @param object mixed $value (original type: java.io.Serializable)
  * 
  * @throws object RepositoryException An exception with one of
  *		   the following messages defined in
  *		   org.osid.repository.RepositoryException may be thrown: {@link
  *		   org.osid.repository.RepositoryException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.repository.RepositoryException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.repository.RepositoryException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.repository.RepositoryException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}
  * 
  * @access public
  */
 function updateValue($value)
 {
     ArgumentValidator::validate($value, StringValidatorRule::getRule());
     // Store the size in the object in case its asked for again.
     try {
         $size = ByteSize::fromString($value);
     } catch (InvalidArgumentException $e) {
         $size = ByteSize::withValue(0);
     }
     $this->_size = $size->value();
     // then write it to the database.
     $dbHandler = Services::getService("DatabaseManager");
     // Check to see if the name is in the database
     $query = new SelectQuery();
     $query->addTable("dr_file");
     $query->addColumn("COUNT(*) as count");
     $query->addWhere("id = '" . $this->_recordId->getIdString() . "'");
     $result = $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
     // If it already exists, use an update query.
     if ($result->field("count") > 0) {
         $query = new UpdateQuery();
         $query->setTable("dr_file");
         $query->setColumns(array("size"));
         $query->setValues(array("'" . addslashes($this->_size) . "'"));
         $query->addWhere("id = '" . $this->_recordId->getIdString() . "'");
     } else {
         $query = new InsertQuery();
         $query->setTable("dr_file");
         $query->setColumns(array("id", "size"));
         $query->setValues(array("'" . $this->_recordId->getIdString() . "'", "'" . addslashes($this->_size) . "'"));
     }
     $result->free();
     // run the query
     $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
     $this->_asset->updateModificationDate();
 }
コード例 #3
0
ファイル: edit.act.php プロジェクト: adamfranco/concerto
 /**
  * Answer a step for all of the the files of the asset
  * 
  * @return object WizardStep
  * @access public
  * @since 10/31/05
  */
 function getRemoteFileRecordsStep()
 {
     $idManager = Services::getService("Id");
     $repository = $this->getRepository();
     $recStructId = $idManager->getId("REMOTE_FILE");
     $recStruct = $repository->getRecordStructure($recStructId);
     $step = new WizardStep();
     $step->setDisplayName($recStruct->getDisplayName());
     ob_start();
     print "\n<h2>" . _("Remote Files") . "</h2>";
     print "\n[[files]]";
     $step->setContent(ob_get_clean());
     $repeatableComponent = $step->addComponent("files", new WRepeatableComponentCollection());
     $repeatableComponent->setStartingNumber(0);
     $repeatableComponent->setAddLabel(_("Add New File"));
     $repeatableComponent->setRemoveLabel(_("Remove File"));
     ob_start();
     $component = $repeatableComponent->addComponent("record_id", new WHiddenField());
     $component = $repeatableComponent->addComponent("file_url", new WTextField());
     $component->setSize(50);
     $vComponent = $repeatableComponent->addComponent("file_name", new WVerifiedChangeInput());
     $vComponent->setChecked(FALSE);
     $component = $vComponent->setInputComponent(new WTextField());
     $vComponent = $repeatableComponent->addComponent("file_size", new WVerifiedChangeInput());
     $vComponent->setChecked(FALSE);
     $component = $vComponent->setInputComponent(new WTextField());
     $vComponent = $repeatableComponent->addComponent("mime_type", new WVerifiedChangeInput());
     $vComponent->setChecked(FALSE);
     $component = $vComponent->setInputComponent(new WTextField());
     // Dimensions
     $dimensionComponent = new WTextField();
     $dimensionComponent->setSize(8);
     $dimensionComponent->setStyle("text-align: right");
     $dimensionComponent->setErrorRule(new WECOptionalRegex("^([0-9]+px)?\$"));
     $dimensionComponent->setErrorText(_("Must be a positive integer followed by 'px'."));
     $dimensionComponent->addOnChange("validateWizard(this.form);");
     $vComponent = $repeatableComponent->addComponent("height", new WVerifiedChangeInput());
     $vComponent->setChecked(FALSE);
     $component = $vComponent->setInputComponent($dimensionComponent->shallowCopy());
     $vComponent = $repeatableComponent->addComponent("width", new WVerifiedChangeInput());
     $vComponent->setChecked(FALSE);
     $component = $vComponent->setInputComponent($dimensionComponent->shallowCopy());
     // Thumnail Upload
     $component = $repeatableComponent->addComponent("thumbnail_upload", new WFileUploadField());
     $vComponent = $repeatableComponent->addComponent("thumbnail_mime_type", new WVerifiedChangeInput());
     $vComponent->setChecked(FALSE);
     $component = $vComponent->setInputComponent(new WTextField());
     // Thumbnail dimensions
     $vComponent = $repeatableComponent->addComponent("thumbnail_height", new WVerifiedChangeInput());
     $vComponent->setChecked(FALSE);
     $component = $vComponent->setInputComponent($dimensionComponent->shallowCopy());
     $vComponent = $repeatableComponent->addComponent("thumbnail_width", new WVerifiedChangeInput());
     $vComponent->setChecked(FALSE);
     $component = $vComponent->setInputComponent($dimensionComponent->shallowCopy());
     print "\n<p>" . _("Url:") . " ";
     print "\n[[file_url]]</p>";
     print "\n<p>";
     print _("By default, the values below will be automatically populated from your uploaded file.");
     print " " . _("If needed, change the properties below to custom values: ");
     print "\n<table border='1'>";
     print "\n<tr>";
     print "\n\t<th>";
     print "\n\t\t" . _("Property") . "";
     print "\n\t</th>";
     print "\n\t<th>";
     print "\n\t\t" . _("Custom Value") . "";
     print "\n\t</th>";
     print "\n</tr>";
     print "\n<tr>";
     print "\n\t<td>";
     print "\n\t\t" . _("File Name") . "";
     print "\n\t</td>";
     print "\n\t<td>";
     print "\n\t\t[[file_name]]";
     print "\n\t</td>";
     print "\n</tr>";
     print "\n<tr>";
     print "\n\t<td>";
     print "\n\t\t" . _("File Size") . "";
     print "\n\t</td>";
     print "\n\t<td>";
     print "\n\t\t[[file_size]]";
     print "\n\t</td>";
     print "\n</tr>";
     print "\n<tr>";
     print "\n\t<td>";
     print "\n\t\t" . _("Mime Type") . "";
     print "\n\t</td>";
     print "\n\t<td>";
     print "\n\t\t[[mime_type]]";
     print "\n\t</td>";
     print "\n</tr>";
     print "\n<tr>";
     print "\n\t<td>";
     print "\n\t\t" . _("Width") . "";
     print "\n\t</td>";
     print "\n\t<td>";
     print "\n\t\t[[width]]";
     print "\n\t</td>";
     print "\n</tr>";
     print "\n<tr>";
     print "\n\t<td>";
     print "\n\t\t" . _("Height") . "";
     print "\n\t</td>";
     print "\n\t<td>";
     print "\n\t\t[[height]]";
     print "\n\t</td>";
     print "\n</tr>";
     print "\n<tr>";
     print "\n\t<td>";
     print "\n\t\t" . _("Thumbnail") . "";
     print "\n\t</td>";
     print "\n\t<td>";
     print "\n[[thumbnail_upload]]";
     print "\n\t</td>";
     print "\n</tr>";
     print "\n<tr>";
     print "\n\t<td>";
     print "\n\t\t" . _("Thumbnail Mime Type") . "";
     print "\n\t</td>";
     print "\n\t<td>";
     print "\n\t\t[[thumbnail_mime_type]]";
     print "\n\t</td>";
     print "\n</tr>";
     print "\n<tr>";
     print "\n\t<td>";
     print "\n\t\t" . _("Thumbnail Width") . "";
     print "\n\t</td>";
     print "\n\t<td>";
     print "\n\t\t[[thumbnail_width]]";
     print "\n\t</td>";
     print "\n</tr>";
     print "\n<tr>";
     print "\n\t<td>";
     print "\n\t\t" . _("Thumbnail Height") . "";
     print "\n\t</td>";
     print "\n\t<td>";
     print "\n\t\t[[thumbnail_height]]";
     print "\n\t</td>";
     print "\n</tr>";
     print "\n</table>";
     print "\n</p>";
     $repeatableComponent->setContent(ob_get_contents());
     ob_end_clean();
     $records = $this->_assets[0]->getRecordsByRecordStructure($recStructId);
     while ($records->hasNext()) {
         $record = $records->next();
         $partIterator = $record->getParts();
         $parts = array();
         while ($partIterator->hasNext()) {
             $part = $partIterator->next();
             $partStructure = $part->getPartStructure();
             $partStructureId = $partStructure->getId();
             $parts[$partStructureId->getIdString()] = $part;
         }
         $collection = array();
         $recordId = $record->getId();
         $collection['record_id'] = $recordId->getIdString();
         $collection['file_url'] = $parts['FILE_URL']->getValue();
         $collection['file_name'] = $parts['FILE_NAME']->getValue();
         $size = ByteSize::withValue($parts['FILE_SIZE']->getValue());
         $collection['file_size'] = $size->asString();
         $collection['mime_type'] = $parts['MIME_TYPE']->getValue();
         $dim = $parts['DIMENSIONS']->getValue();
         if ($dim[1]) {
             $collection['height'] = $dim[1] . 'px';
         }
         if ($dim[0]) {
             $collection['width'] = $dim[0] . 'px';
         }
         $collection['thumbnail_upload'] = array("starting_name" => "thumb.jpg", "starting_size" => strlen($parts['THUMBNAIL_DATA']->getValue()));
         $collection['thumbnail_mime_type'] = $parts['THUMBNAIL_MIME_TYPE']->getValue();
         $thumDim = $parts['THUMBNAIL_DIMENSIONS']->getValue();
         if ($thumDim[1]) {
             $collection['thumbnail_height'] = $thumDim[1] . 'px';
         }
         if ($thumDim[0]) {
             $collection['thumbnail_width'] = $thumDim[0] . 'px';
         }
         $repeatableComponent->addValueCollection($collection);
     }
     return $step;
 }
コード例 #4
0
ファイル: copy_site.act.php プロジェクト: adamfranco/segue
 /**
  * Recursively list a directory
  * 
  * @param string $path
  * @return void
  * @access protected
  * @since 7/28/08
  */
 protected function listDir($path, $tabs = "")
 {
     ob_start();
     if (is_dir($path)) {
         print "\n\t";
     } else {
         print "\n" . ByteSize::withValue(filesize($path))->asString();
     }
     print $tabs . basename($path);
     if (is_dir($path)) {
         $entries = scandir($path);
         foreach ($entries as $entry) {
             if ($entry != '.' && $entry != '..') {
                 print $this->listDir($path . DIRECTORY_SEPARATOR . $entry, $tabs . "\t");
             }
         }
     }
     return ob_get_clean();
 }
コード例 #5
0
 function test_fromString()
 {
     $num = ByteSize::fromString('280 B');
     $this->assertEqual($num->printableString(), '280 B');
     $this->assertEqual(round($num->multipleOfPowerOf2(0), 2), 280);
     $num = ByteSize::fromString('2800 B');
     $this->assertEqual($num->printableString(), '2.73 kB');
     $this->assertEqual(round($num->multipleOfPowerOf2(0), 2), 2800);
     $num = ByteSize::fromString('2.73 kB');
     $this->assertEqual($num->printableString(), '2.73 kB');
     $this->assertEqual(round($num->multipleOfPowerOf2(0), 2), 2796);
     $num = ByteSize::fromString('2.73kB');
     $this->assertEqual($num->printableString(), '2.73 kB');
     $this->assertEqual(round($num->multipleOfPowerOf2(0), 2), 2796);
     $num = ByteSize::fromString('2.73kb');
     $this->assertEqual($num->printableString(), '2.73 kB');
     $this->assertEqual(round($num->multipleOfPowerOf2(0), 2), 2796);
     $num = ByteSize::fromString('2.73 KB');
     $this->assertEqual($num->printableString(), '2.73 kB');
     $this->assertEqual(round($num->multipleOfPowerOf2(0), 2), 2796);
     $num = ByteSize::fromString('2.73KB');
     $this->assertEqual($num->printableString(), '2.73 kB');
     $this->assertEqual(round($num->multipleOfPowerOf2(0), 2), 2796);
     $num = ByteSize::fromString('2.73		kB');
     $this->assertEqual($num->printableString(), '2.73 kB');
     $this->assertEqual(round($num->multipleOfPowerOf2(0), 2), 2796);
     $num = ByteSize::fromString('2.68 MB');
     $this->assertEqual($num->printableString(), '2.68 MB');
     $num = ByteSize::fromString('8.20 GB');
     $this->assertEqual($num->printableString(), '8.20 GB');
     $num = ByteSize::fromString('66.17 YB');
     $this->assertEqual($num->printableString(), '66.17 YB');
     $this->assertEqual(round($this->reallyBigNum->multipleOfPowerOf2(0), 2), 8.000000000000001E+25);
     $num = ByteSize::fromString('80000000000000000000000000 B');
     $this->assertEqual($num->printableString(), '66.17 YB');
     $this->assertEqual(round($this->reallyBigNum->multipleOfPowerOf2(0), 2), 8.000000000000001E+25);
 }
コード例 #6
0
ファイル: MediaFile.class.php プロジェクト: adamfranco/segue
 /**
  * Answer the size of the file as a ByteSize object
  * 
  * @return object ByteSize
  * @access public
  * @since 4/27/07
  */
 function getSize()
 {
     $size = ByteSize::withValue($this->_getPartValue('FILE_SIZE'));
     return $size;
 }
コード例 #7
0
ファイル: import.act.php プロジェクト: adamfranco/segue
 /**
  * Decompress a tar archive of a site.
  * 
  * @param string $archivePath
  * @param string $decompressDir
  * @return void
  * @access public
  * @since 3/14/08
  */
 public function decompressArchive($archivePath, $decompressDir)
 {
     if (!file_exists($archivePath)) {
         throw new Exception("Archive, '" . basename($archivePath) . "' does not exist.");
     }
     if (!is_readable($archivePath)) {
         throw new Exception("Archive, '" . basename($archivePath) . "' is not readable.");
     }
     // Decompress the archive into our temp-dir
     $archive = new Archive_Tar($archivePath);
     // Check for a containing directory and strip it if needed.
     $content = @$archive->listContent();
     if (!is_array($content) || !count($content)) {
         throw new Exception("Invalid Segue archive. '" . basename($archivePath) . "' is not a valid GZIPed Tar archive.");
     }
     $containerName = null;
     // 			printpre($content);
     if ($content[0]['typeflag'] == 5) {
         $containerName = trim($content[0]['filename'], '/') . '/';
         for ($i = 1; $i < count($content); $i++) {
             // if one of the files isn't in the container, then we don't have a container of all
             if (strpos($content[$i]['filename'], $containerName) === false) {
                 $containerName = null;
                 break;
             }
         }
     }
     // 			printpre($containerName);
     $decompressResult = @$archive->extractModify($decompressDir, $containerName);
     if (!$decompressResult) {
         throw new Exception("Could not decompress Segue archive: '" . basename($archivePath) . "' size, " . ByteSize::withValue(filesize($archivePath))->asString() . ".");
     }
     if (!file_exists($decompressDir . "/site.xml")) {
         throw new Exception("Invalid Segue archive. 'site.xml' was not found in '" . implode("', '", scandir($decompressDir)) . "'.");
     }
 }
コード例 #8
0
ファイル: Slot.abstract.php プロジェクト: adamfranco/segue
 /**
  * Answer the media library quota
  * 
  * @return object ByteSize
  * @access public
  * @since 3/20/08
  */
 public function getMediaQuota()
 {
     return ByteSize::withValue($this->mediaQuota);
 }
コード例 #9
0
ファイル: convert.act.php プロジェクト: adamfranco/segue
 /**
  * Convert a Segue1 export into a Segue2 export
  * 
  * @param string $destFilePath The path that Segue2 export file will be placed in.
  * @param string $relativeOutputFilePath The output file path relative to
  * 				encode into the xml output.	 * @return object DOMDocument The Segue2 export document
  * @access protected
  * @since 3/14/08
  */
 protected function convertFrom1To2($destFilePath, $relativeOutputFilePath)
 {
     try {
         $sourcePath = $this->downloadSegue1Export();
         $sourceFilePath = $sourcePath . "/media";
         $sourceDocPath = $sourcePath . "/site.xml";
         $sourceDoc = new Harmoni_DOMDocument();
         $sourceDoc->load($sourceDocPath);
         $converter = new Segue1To2Director($destFilePath, $relativeOutputFilePath);
         $outputDoc = $converter->convert($sourceDoc, $sourceFilePath);
         // Delete the source directory
         $this->cleanUpSourcePath($sourcePath);
     } catch (DOMException $e) {
         $size = ByteSize::withValue(filesize($sourceDocPath));
         $this->cleanUpSourcePath($sourcePath);
         if ($e->getCode() === DOMSTRING_SIZE_ERR) {
             throw new DOMException("The export of '" . $this->getSourceSlotName() . "' is too large to load (" . $size->asString() . ") or contains an element that is too large to load.", DOMSTRING_SIZE_ERR);
         }
         throw $e;
     } catch (Exception $e) {
         if (isset($sourcePath)) {
             $this->cleanUpSourcePath($sourcePath);
         }
         throw $e;
     }
     return $outputDoc;
 }
コード例 #10
0
 /**
  * Executes an SQL query.
  * Executes an SQL query.
  * @access private
  * @param string The SQL query string.
  * @return mixed For a SELECT statement, a resource identifier, if
  * successful; For INSERT, DELETE, UPDATE statements, TRUE if successful;
  * for all: FALSE, if not successful.
  */
 function _query($query)
 {
     // do not attempt to query, if not connected
     if (!$this->isConnected()) {
         throw new ConnectionDatabaseException("Attempted to query but there was no database connection.");
         return false;
     }
     if (is_array($query)) {
         $queries = $query;
     } else {
         if (is_string($query)) {
             $queries = array($query);
         }
     }
     // If we have a persistant connection, it might be shared with other
     // databases, so make sure our database is selected.
     if ($this->_isConnectionPersistant == true) {
         if (!mysql_select_db($this->_dbName, $this->_linkId)) {
             throw new ConnectionDatabaseException("Cannot select database, " . $this->_dbName . " : " . mysql_error($this->_linkId));
         }
     }
     foreach ($queries as $q) {
         // attempt to execute the query
         $resourceId = mysql_query($q, $this->_linkId);
         debug::output("<pre>Query: <div>" . $query . "</div>Result: {$resourceId}</pre>", 1, "DBHandler");
         if ($resourceId === false) {
             $this->_failedQueries++;
             switch (mysql_errno($this->_linkId)) {
                 // No Such Table
                 case 1146:
                 case 1177:
                     throw new NoSuchTableDatabaseException("MySQL Error: " . mysql_error($this->_linkId), mysql_errno($this->_linkId));
                     // Duplicate Key
                 // Duplicate Key
                 case 1022:
                 case 1062:
                     throw new DuplicateKeyDatabaseException("MySQL Error: " . mysql_error($this->_linkId), mysql_errno($this->_linkId));
                     // max_allowed_packet
                 // max_allowed_packet
                 case 1153:
                     // Got a packet bigger than 'max_allowed_packet' bytes
                 // Got a packet bigger than 'max_allowed_packet' bytes
                 case 1162:
                     // Result string is longer than 'max_allowed_packet' bytes
                 // Result string is longer than 'max_allowed_packet' bytes
                 case 1301:
                     // Result of %s() was larger than max_allowed_packet (%ld) - truncated
                     $size = ByteSize::withValue(strlen($query));
                     throw new QuerySizeDatabaseException("MySQL Error: " . mysql_error($this->_linkId) . " (Query Size: " . $size->asString() . ")", mysql_errno($this->_linkId));
                 default:
                     throw new QueryDatabaseException("MySQL Error: " . mysql_error($this->_linkId), mysql_errno($this->_linkId));
             }
         } else {
             $this->_successfulQueries++;
         }
     }
     return $resourceId;
 }
コード例 #11
0
 /**
  * Returns a block of XHTML-valid code that contains markup for this specific
  * component. 
  * @param string $fieldName The field name to use when outputting form data or
  * similar parameters/information.
  * @access public
  * @return string
  */
 function getMarkup($fieldName)
 {
     $name = RequestContext::name($fieldName);
     $m = "";
     if ($this->_filename) {
         $size = ByteSize::withValue($this->_size);
         $m .= "<i>" . $this->_filename . " (" . $size->asString() . ")</i>\n";
     } else {
         if ($this->_startingDisplayFilename && $this->_startingDisplaySize) {
             $size = ByteSize::withValue($this->_startingDisplaySize);
             $m .= "<i>" . $this->_startingDisplayFilename . " (" . $size->asString() . ")</i>\n";
         }
     }
     $m .= "<input type='file' name='{$name}'";
     if (count($this->_accept)) {
         $m .= " accept='" . implode(", ", $this->_accept) . "'";
     }
     if ($this->_style) {
         $m .= " style=\"" . addslashes($this->_style) . "\"";
     }
     $m .= " />";
     if ($this->_errString) {
         $m .= "<span style='color: red; font-weight: 900;'>" . $this->_errString . "</span>";
         $this->_errString = null;
     }
     return $m;
 }
コード例 #12
0
ファイル: edit.act.php プロジェクト: adamfranco/segue
 /**
  * Save our results. Tearing down and unsetting the Wizard is handled by
  * in {@link runWizard()} and does not need to be implemented here.
  * 
  * @param string $cacheName
  * @return boolean TRUE if save was successful and tear-down/cleanup of the
  *		Wizard should ensue.
  * @access public
  * @since 12/7/07
  */
 function saveWizard($cacheName)
 {
     $wizard = $this->getWizard($cacheName);
     $slot = $wizard->slot;
     $values = $wizard->getAllValues();
     $changes = array();
     try {
         if ($slot->getType() != $values['slot']['type']) {
             $changes[] = "Type changed from " . $slot->getType() . " to " . $values['slot']['type'];
             $slotMgr = SlotManager::instance();
             $slot = $slotMgr->convertSlotToType($slot, $values['slot']['type']);
         }
         if ($slot->getLocationCategory() != $values['slot']['category']) {
             $changes[] = "Location Category changed from " . $slot->getLocationCategory() . " to " . $values['slot']['category'];
             $slot->setLocationCategory($values['slot']['category']);
         }
         if (strlen($values['slot']['quota'])) {
             $quota = ByteSize::fromString($values['slot']['quota']);
             if (!$quota->isEqual($slot->getMediaQuota())) {
                 $slot->setMediaQuota($quota);
             }
         } else {
             $slot->useDefaultMediaQuota();
         }
         $idMgr = Services::getService("Id");
         $oldOwners = array();
         foreach ($slot->getOwners() as $ownerId) {
             $oldOwners[] = $ownerId->getIdString();
         }
         $newOwners = $values['slot']['owners'];
         $agentMgr = Services::getService("Agent");
         // Remove any needed existing owners
         foreach ($oldOwners as $idString) {
             if (!in_array($idString, $newOwners)) {
                 $slot->removeOwner($idMgr->getId($idString));
                 try {
                     $agent = $agentMgr->getAgent($idMgr->getId($idString));
                     $agentName = $agent->getDisplayName();
                 } catch (Exception $e) {
                     $agentName = 'Unknown';
                 }
                 $changes[] = "Owner {$agentName} ({$idString}) removed";
             }
         }
         // Add an needed new owners
         foreach ($newOwners as $idString) {
             if (!in_array($idString, $oldOwners)) {
                 $slot->addOwner($idMgr->getId($idString));
                 try {
                     $agent = $agentMgr->getAgent($idMgr->getId($idString));
                     $agentName = $agent->getDisplayName();
                 } catch (Exception $e) {
                     $agentName = 'Unknown';
                 }
                 $changes[] = "Owner {$agentName} ({$idString}) added";
             }
         }
     } catch (Exception $e) {
         print $e->getMessage();
         return false;
     }
     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("Modify Placeholder", "Placeholder changed:  '" . $slot->getShortname() . "'. <br/><br/>Changes: <br/> " . implode(",<br/> ", $changes));
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     return true;
 }
コード例 #13
0
 /**
  * Generate HTML for displaying particular parts of the Record 
  * 
  * @param object $record The record to print.
  * @param array $partStructures An array of particular partStructures to print. 
  * @return string
  * @access public
  * @since 10/19/04
  */
 function generateDisplayForPartStructures(Id $repositoryId, Id $assetId, Record $record, array $partStructures)
 {
     ArgumentValidator::validate($partStructures, new ArrayValidatorRuleWithRule(new ExtendsValidatorRule("PartStructure")));
     $partIterator = $record->getParts();
     $parts = array();
     while ($partIterator->hasNext()) {
         $part = $partIterator->next();
         $partStructure = $part->getPartStructure();
         $partStructureId = $partStructure->getId();
         if (!isset($parts[$partStructureId->getIdString()]) || !is_array($parts[$partStructureId->getIdString()])) {
             $parts[$partStructureId->getIdString()] = array();
         }
         $parts[$partStructureId->getIdString()][] = $part;
     }
     // print out the parts;
     ob_start();
     $partStructuresToSkip = array('FILE_DATA', 'THUMBNAIL_DATA', 'THUMBNAIL_MIME_TYPE', 'THUMBNAIL_DIMENSIONS');
     $printThumbnail = FALSE;
     foreach (array_keys($partStructures) as $key) {
         $partStructure = $partStructures[$key];
         $partStructureId = $partStructure->getId();
         if (!in_array($partStructureId->getIdString(), $partStructuresToSkip)) {
             print "\n<strong>" . $partStructure->getDisplayName() . ":</strong> \n";
             switch ($partStructureId->getIdString()) {
                 case 'FILE_SIZE':
                     $size = ByteSize::withValue($parts[$partStructureId->getIdString()][0]->getValue());
                     print $size->asString();
                     break;
                 case 'DIMENSIONS':
                     $dimensionArray = $parts[$partStructureId->getIdString()][0]->getValue();
                     print "<em>" . _('width: ') . "</em>" . $dimensionArray[0] . 'px<em>;</em> ';
                     print "<em>" . _('height: ') . "</em>" . $dimensionArray[1] . 'px';
                     break;
                 default:
                     print $parts[$partStructureId->getIdString()][0]->getValue();
             }
             print "\n<br />";
         } else {
             $printThumbnail = TRUE;
         }
     }
     $html = ob_get_clean();
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace("polyphony-repository");
     if ($printThumbnail) {
         ob_start();
         $recordId = $record->getId();
         $ns = $harmoni->request->endNamespace();
         // ======= VIEWER LINK ======== //
         $xmlAssetIdString = $harmoni->request->get("asset_id");
         print "<a href='#' onclick='Javascript:window.open(";
         print '"' . VIEWER_URL . "?&amp;source=";
         print urlencode($harmoni->request->quickURL("asset", "browserecordxml", array("collection_id" => $repositoryId->getIdString(), "asset_id" => $xmlAssetIdString, "record_id" => $recordId->getIdString(), RequestContext::name("limit_by") => RequestContext::value("limit_by"), RequestContext::name("type") => RequestContext::value("type"), RequestContext::name("searchtype") => RequestContext::value("searchtype"), RequestContext::name("searchstring") => RequestContext::value("searchstring"))));
         print '&amp;start=0", ';
         print '"' . preg_replace("/[^a-z0-9]/i", '_', $assetId->getIdString()) . '", ';
         print '"toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=500"';
         print ")'>";
         $harmoni->request->startNamespace($ns);
         // If we have a thumbnail with a valid mime type, print a link to that.
         $thumbnailName = preg_replace("/\\.[^\\.]+\$/", "", $parts['FILE_NAME'][0]->getValue());
         if ($thumbnailMimeType = $parts['THUMBNAIL_MIME_TYPE'][0]->getValue()) {
             $mime = Services::getService("MIME");
             $thumbnailName .= "." . $mime->getExtensionForMIMEType($thumbnailMimeType);
         }
         print "\n<img src='";
         print RepositoryInputOutputModuleManager::getThumbnailUrlForRecord($assetId, $record);
         print "'";
         print " style='border: 0px;'";
         print " alt='Thumbnail image.'";
         print " align='left'";
         print " />";
         print "</a> <br />";
         $html2 = ob_get_clean();
         ob_start();
         print "\n<a href='";
         print RepositoryInputOutputModuleManager::getFileUrlForRecord($assetId, $record);
         print "' target='_blank'>";
         print "Download This File</a>\n";
         $downloadlink = ob_get_clean();
         $html = "<table border=0><tr><td>" . $html2 . "</td><td>" . $html . $downloadlink . "</td></tr></table>";
     }
     $harmoni->request->endNamespace();
     return $html;
 }