Documentation is available at FileUrlPart.class.php
- <?php
- /**
- * @since 12/5/06
- * @package harmoni.osid_v2.repository
- *
- * @copyright Copyright © 2005, Middlebury College
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
- *
- * @version $Id: FileUrlPart.class.php,v 1.3 2007/09/11 17:40:57 adamfranco Exp $
- */
- /**
- * A Part for storing the file's URL
- *
- * @since 12/5/06
- * @package harmoni.osid_v2.repository
- *
- * @copyright Copyright © 2005, Middlebury College
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
- *
- * @version $Id: FileUrlPart.class.php,v 1.3 2007/09/11 17:40:57 adamfranco Exp $
- */
- class FileUrlPart
- extends Part
- {
- var $_recordId;
- var $_partStructure;
- var $_value;
- function FileUrlPart( $partStructure, $recordId, $configuration, $asset ) {
- $this->_recordId =$recordId;
- $this->_partStructure =$partStructure;
- $this->_configuration =$configuration;
- $this->_asset =$asset;
- // Set our data to NULL, so that we can know if it has not been checked
- // for yet. If we search for data, but don't have any, or the data is
- // an empty string, it will have value "" instead of NULL
- $this->_value = NULL;
- }
- /**
- * Get the unique Id for this Part.
- *
- * @return object Id
- *
- * @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}
- *
- * @access public
- */
- function getId() {
- $idManager = Services::getService("Id");
- return $idManager->getId($this->_recordId->getIdString()."-FILE_URL");
- }
- /**
- * Create a Part. Records are composed of Parts. Parts can also contain
- * other Parts. Each Record is associated with a specific RecordStructure
- * and each Part is associated with a specific PartStructure.
- *
- * @param object Id $partStructureId
- * @param object mixed $value (original type: java.io.Serializable)
- *
- * @return object Part
- *
- * @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}, {@link }
- * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
- *
- * @access public
- */
- function createPart($partStructureId, $value) {
- throwError(
- new Error(RepositoryException::UNIMPLEMENTED(), "HarmoniPart", true));
- }
- /**
- * Delete a Part and all its Parts.
- *
- * @param object Id $partId
- *
- * @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}, {@link }
- * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
- *
- * @access public
- */
- function deletePart($partId) {
- throwError(
- new Error(RepositoryException::UNIMPLEMENTED(), "HarmoniPart", true));
- }
- /**
- * Get all the Parts in this Part. Iterators return a set, one at a time.
- *
- * @return object PartIterator
- *
- * @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}
- *
- * @access public
- */
- function getParts() {
- throwError(
- new Error(RepositoryException::UNIMPLEMENTED(), "HarmoniPart", true));
- }
- /**
- * Get the value for this Part.
- *
- * @return object mixed (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}
- *
- * @access public
- */
- function getValue() {
- // If we don't have the name, load it from the database.
- if ($this->_value === NULL) {
- $dbHandler = Services::getService("DatabaseManager");
- // Get the data from the database,
- $query = new SelectQuery;
- $query->addTable("dr_file");
- $query->addTable("dr_file_url", LEFT_JOIN, "dr_file.id = dr_file_url.fk_file");
- $query->addColumn("url");
- $query->addWhere("dr_file.id = '".$this->_recordId->getIdString()."'");
- $result =$dbHandler->query($query, $this->_configuration->getProperty("database_index"));
- // If no name was found, return an empty string.
- if ($result->getNumberOfRows() == 0)
- $this->_value = "";
- else
- $this->_value = $result->field("url");
- $result->free();
- }
- return $this->_value;
- }
- /**
- * 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 name in the object in case its asked for again.
- $this->_value = $value;
- // then write it to the database.
- $dbHandler = Services::getService("DatabaseManager");
- // Check to see if the name is in the database
- // Check to see if the data is in the database
- $query = new SelectQuery;
- $query->addTable("dr_file_url");
- $query->addColumn("COUNT(*) as count");
- $query->addWhere("fk_file = '".$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_url");
- $query->setColumns(array("url"));
- $query->setValues(array("'".addslashes($value)."'"));
- $query->addWhere("fk_file = '".$this->_recordId->getIdString()."'");
- }
- // If it doesn't exist, use an insert query.
- else {
- $query = new InsertQuery;
- $query->setTable("dr_file_url");
- $query->setColumns(array("fk_file","url"));
- $query->setValues(array("'".$this->_recordId->getIdString()."'",
- "'".addslashes($value)."'"));
- }
- $result->free();
- // run the query
- $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
- $this->_asset->updateModificationDate();
- }
- /**
- * Get the PartStructure associated with this Part.
- *
- * @return object PartStructure
- *
- * @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}
- *
- * @access public
- */
- function getPartStructure() {
- return $this->_partStructure;
- }
- /**
- * Allow the file record to update the fetch from its own queries
- *
- * @param string $value
- * @return void
- * @access private
- * @since 11/17/05
- */
- function _updateValue ( $value ) {
- $this->_value = $value;
- }
- }
- ?>
Documentation generated on Wed, 19 Sep 2007 10:23:16 -0400 by phpDocumentor 1.3.0RC3