• Main Page
  • Modules
  • Classes
  • Files
  • File List

classes/publicationFormat/PublicationFormat.inc.php

00001 <?php
00002 
00016 import('lib.pkp.classes.core.DataObject');
00017 
00018 class PublicationFormat extends DataObject {
00022    function PublicationFormat() {
00023       // Switch on meta-data adapter support.
00024       $this->setHasLoadableAdapters(true);
00025 
00026       parent::DataObject();
00027    }
00028 
00033    function getIsApproved() {
00034       return $this->getData('approved');
00035    }
00036 
00041    function setIsApproved($approved) {
00042       return $this->setData('approved', $approved);
00043    }
00044 
00049    function getPhysicalFormat() {
00050       return $this->getData('physicalFormat');
00051    }
00052 
00057    function setPhysicalFormat($physicalFormat) {
00058       return $this->setData('physicalFormat', $physicalFormat);
00059    }
00060 
00065    function getEntryKey() {
00066       return $this->getData('entryKey');
00067    }
00068 
00073    function setEntryKey($entryKey) {
00074       $this->setData('entryKey', $entryKey);
00075    }
00076 
00081    function getNameForONIXCode() {
00082       $onixCodelistItemDao =& DAORegistry::getDAO('ONIXCodelistItemDAO');
00083       $codes =& $onixCodelistItemDao->getCodes('List7'); // List7 is for object formats
00084       return $codes[$this->getEntryKey()];
00085    }
00090    function getSeq() {
00091       return $this->getData('seq');
00092    }
00093 
00098    function setSeq($seq) {
00099       return $this->setData('seq', $seq);
00100    }
00101 
00106    function getLocalizedName() {
00107       return $this->getLocalizedData('name');
00108    }
00109 
00114    function getName() {
00115       return $this->getData('name');
00116    }
00117 
00123    function setName($name) {
00124       return $this->setData('name', $name);
00125    }
00126 
00131    function setMonographId($monographId) {
00132       return $this->setData('monographId', $monographId);
00133    }
00134 
00139    function getMonographId() {
00140       return $this->getData('monographId');
00141    }
00142 
00147    function getCountryManufactureCode() {
00148       return $this->getData('countryManufactureCode');
00149    }
00150 
00155    function setCountryManufactureCode($countryManufactureCode) {
00156       return $this->setData('countryManufactureCode', $countryManufactureCode);
00157    }
00158 
00163    function getProductAvailabilityCode() {
00164       return $this->getData('productAvailabilityCode');
00165    }
00166 
00171    function setProductAvailabilityCode($productAvailabilityCode) {
00172       return $this->setData('productAvailabilityCode', $productAvailabilityCode);
00173    }
00174 
00179    function getHeight() {
00180       return $this->getData('height');
00181    }
00182 
00187    function setHeight($height) {
00188       return $this->setData('height', $height);
00189    }
00190 
00195    function getHeightUnitCode() {
00196       return $this->getData('heightUnitCode');
00197    }
00198 
00203    function setHeightUnitCode($heightUnitCode) {
00204       return $this->setData('heightUnitCode', $heightUnitCode);
00205    }
00206 
00211    function getWidth() {
00212       return $this->getData('width');
00213    }
00214 
00219    function setWidth($width) {
00220       return $this->setData('width', $width);
00221    }
00222 
00227    function getWidthUnitCode() {
00228       return $this->getData('widthUnitCode');
00229    }
00230 
00235    function setWidthUnitCode($widthUnitCode) {
00236       return $this->setData('widthUnitCode', $widthUnitCode);
00237    }
00238 
00243    function getThickness() {
00244       return $this->getData('thickness');
00245    }
00246 
00251    function setThickness($thickness) {
00252       return $this->setData('thickness', $thickness);
00253    }
00254 
00259    function getThicknessUnitCode() {
00260       return $this->getData('thicknessUnitCode');
00261    }
00262 
00267    function setThicknessUnitCode($thicknessUnitCode) {
00268       return $this->setData('thicknessUnitCode', $thicknessUnitCode);
00269    }
00270 
00275    function getWeight() {
00276       return $this->getData('weight');
00277    }
00278 
00283    function setWeight($weight) {
00284       return $this->setData('weight', $weight);
00285    }
00286 
00291    function getWeightUnitCode() {
00292       return $this->getData('weightUnitCode');
00293    }
00294 
00299    function setWeightUnitCode($weightUnitCode) {
00300       return $this->setData('weightUnitCode', $weightUnitCode);
00301    }
00302 
00307    function getFileSize() {
00308       return $this->getData('fileSize');
00309    }
00310 
00316    function getCalculatedFileSize() {
00317       $fileSize = 0;
00318       $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
00319       import('classes.monograph.MonographFile'); // File constants
00320       $stageMonographFiles =& $submissionFileDao->getLatestRevisionsByAssocId(
00321             ASSOC_TYPE_PUBLICATION_FORMAT, $this->getId(),
00322             $this->getMonographId(), MONOGRAPH_FILE_PROOF
00323       );
00324 
00325       foreach ($stageMonographFiles as $monographFile) {
00326          if ($monographFile->getViewable()) {
00327             $fileSize += (int) $monographFile->getFileSize();
00328          }
00329       }
00330 
00331       return sprintf('%d.3', $fileSize/(1024*1024)); // bytes to Mb
00332    }
00333 
00338    function setFileSize($fileSize) {
00339       return $this->setData('fileSize', $fileSize);
00340    }
00341 
00346    function getSalesRights() {
00347       $salesRightsDao =& DAORegistry::getDAO('SalesRightsDAO');
00348       $salesRights =& $salesRightsDao->getByPublicationFormatId($this->getId());
00349       return $salesRights;
00350    }
00351 
00356    function getIdentificationCodes() {
00357       $identificationCodeDao =& DAORegistry::getDAO('IdentificationCodeDAO');
00358       $codes =& $identificationCodeDao->getByPublicationFormatId($this->getId());
00359       return $codes;
00360    }
00361 
00366    function getPublicationDates() {
00367       $publicationDateDao =& DAORegistry::getDAO('PublicationDateDAO');
00368       $dates =& $publicationDateDao->getByPublicationFormatId($this->getId());
00369       return $dates;
00370    }
00371 
00376    function getMarkets() {
00377       $marketDao =& DAORegistry::getDAO('MarketDAO');
00378       $markets =& $marketDao->getByPublicationFormatId($this->getId());
00379       return $markets;
00380    }
00385    function getProductFormDetailCode() {
00386       return $this->getData('productFormDetailCode');
00387    }
00388 
00393    function setProductFormDetailCode($productFormDetailCode) {
00394       return $this->setData('productFormDetailCode', $productFormDetailCode);
00395    }
00396 
00401    function getProductCompositionCode() {
00402       return $this->getData('productCompositionCode');
00403    }
00404 
00409    function setProductCompositionCode($productCompositionCode) {
00410       return $this->setData('productCompositionCode', $productCompositionCode);
00411    }
00412 
00417    function getFrontMatter() {
00418       return $this->getData('frontMatter');
00419    }
00420 
00425    function setFrontMatter($frontMatter) {
00426       return $this->setData('frontMatter', $frontMatter);
00427    }
00428 
00433    function getBackMatter() {
00434       return $this->getData('backMatter');
00435    }
00436 
00441    function setBackMatter($backMatter) {
00442       return $this->setData('backMatter', $backMatter);
00443    }
00444 
00449    function getImprint() {
00450       return $this->getData('imprint');
00451    }
00452 
00457    function setImprint($imprint) {
00458       return $this->setData('imprint', $imprint);
00459    }
00460 
00465    function getTechnicalProtectionCode() {
00466       return $this->getData('technicalProtectionCode');
00467    }
00468 
00473    function setTechnicalProtectionCode($technicalProtectionCode) {
00474       return $this->setData('technicalProtectionCode', $technicalProtectionCode);
00475    }
00476 
00481    function getReturnableIndicatorCode() {
00482       return $this->getData('returnableIndicatorCode');
00483    }
00484 
00489    function setReturnableIndicatorCode($returnableIndicatorCode) {
00490       return $this->setData('returnableIndicatorCode', $returnableIndicatorCode);
00491    }
00492 
00497    function getIsAvailable() {
00498       return $this->getData('isAvailable');
00499    }
00500 
00505    function setIsAvailable($isAvailable) {
00506       return $this->setData('isAvailable', $isAvailable);
00507    }
00508 
00516    function hasNeededONIXFields() {
00517       // ONIX requires one identification code and a market region with a defined price.
00518       $assignedIdentificationCodes =& $this->getIdentificationCodes();
00519       $assignedMarkets =& $this->getMarkets();
00520 
00521       $errors = array();
00522       if ($assignedMarkets->wasEmpty()) {
00523          $errors[] = 'monograph.publicationFormat.noMarketsAssigned';
00524       }
00525 
00526       if ($assignedIdentificationCodes->wasEmpty()) {
00527          $errors[] = 'monograph.publicationFormat.noCodesAssigned';
00528       }
00529 
00530       $errors = array_merge($errors, $this->_checkRequiredFieldsAssigned());
00531       return $errors;
00532    }
00533 
00539    function _checkRequiredFieldsAssigned() {
00540       $requiredFields = array('productCompositionCode' => 'grid.catalogEntry.codeRequired', 'productAvailabilityCode' => 'grid.catalogEntry.productAvailabilityRequired');
00541 
00542       $errors = array();
00543 
00544       foreach ($requiredFields as $field => $errorCode) {
00545          if ($this->getData($field) == '') {
00546             $errors[] = $errorCode;
00547          }
00548       }
00549 
00550       if (!$this->getPhysicalFormat()) {
00551          if (!$this->getFileSize() && !$this->getCalculatedFileSize()) {
00552             $errors['fileSize'] = 'grid.catalogEntry.fileSizeRequired';
00553          }
00554       }
00555 
00556       return $errors;
00557    }
00558 }
00559 
00560 ?>

Generated on Mon Sep 17 2012 13:58:55 for Open Monograph Press by  doxygen 1.7.1