setDescription() публичный Метод

set description
public setDescription ( $description, $locale )
$description string
$locale string
 function importIssue(&$journal, &$issueNode, &$issue, &$errors, &$user, $isCommandLine, &$dependentItems, $cleanupErrors = true)
 {
     $errors = array();
     $issue = null;
     $hasErrors = false;
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     $issue = new Issue();
     $issue->setJournalId($journal->getId());
     $journalSupportedLocales = array_keys($journal->getSupportedLocaleNames());
     // => journal locales must be set up before
     $journalPrimaryLocale = $journal->getPrimaryLocale();
     /* --- Set title, description, volume, number, and year --- */
     $titleExists = false;
     for ($index = 0; $node = $issueNode->getChildByName('title', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $journalPrimaryLocale;
         } elseif (!in_array($locale, $journalSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.issueTitleLocaleUnsupported', array('issueTitle' => $node->getValue(), 'locale' => $locale));
             $hasErrors = true;
             continue;
         }
         $issue->setTitle($node->getValue(), $locale);
         $titleExists = true;
     }
     for ($index = 0; $node = $issueNode->getChildByName('description', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $journalPrimaryLocale;
         } elseif (!in_array($locale, $journalSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.issueDescriptionLocaleUnsupported', array('issueTitle' => $issue->getLocalizedTitle(), 'locale' => $locale));
             $hasErrors = true;
             continue;
         }
         $issue->setDescription($node->getValue(), $locale);
     }
     if ($node = $issueNode->getChildByName('volume')) {
         $issue->setVolume($node->getValue());
     }
     if ($node = $issueNode->getChildByName('number')) {
         $issue->setNumber($node->getValue());
     }
     if ($node = $issueNode->getChildByName('year')) {
         $issue->setYear($node->getValue());
     }
     /* --- Set date published --- */
     if ($node = $issueNode->getChildByName('date_published')) {
         $publishedDate = strtotime($node->getValue());
         if ($publishedDate === -1) {
             $errors[] = array('plugins.importexport.native.import.error.invalidDate', array('value' => $node->getValue()));
             if ($cleanupErrors) {
                 NativeImportDom::cleanupFailure($dependentItems);
             }
             return false;
         } else {
             $issue->setDatePublished($publishedDate);
         }
     }
     /* --- Set attributes: Identification type, published, current, public ID --- */
     switch ($value = $issueNode->getAttribute('identification')) {
         case 'num_vol_year':
             $issue->setShowVolume(1);
             $issue->setShowNumber(1);
             $issue->setShowYear(1);
             $issue->setShowTitle(0);
             break;
         case 'vol_year':
             $issue->setShowVolume(1);
             $issue->setShowNumber(0);
             $issue->setShowYear(1);
             $issue->setShowTitle(0);
             break;
         case 'vol':
             $issue->setShowVolume(1);
             $issue->setShowNumber(0);
             $issue->setShowYear(0);
             $issue->setShowTitle(0);
             break;
         case 'year':
             $issue->setShowVolume(0);
             $issue->setShowNumber(0);
             $issue->setShowYear(1);
             $issue->setShowTitle(0);
             break;
         case 'title':
         case '':
         case null:
             $issue->setShowVolume(0);
             $issue->setShowNumber(0);
             $issue->setShowYear(0);
             $issue->setShowTitle(1);
             break;
         default:
             $errors[] = array('plugins.importexport.native.import.error.unknownIdentificationType', array('identificationType' => $value, 'issueTitle' => $issue->getLocalizedTitle()));
             $hasErrors = true;
             break;
     }
     if (($issueNode->getAttribute('identification') == 'title' || $issueNode->getAttribute('identification') == '') && !$titleExists) {
         $errors[] = array('plugins.importexport.native.import.error.titleMissing', array());
         // Set a placeholder title so that further errors are
         // somewhat meaningful; this placeholder will not be
         // inserted into the database.
         $issue->setTitle(__('plugins.importexport.native.import.error.defaultTitle'), $journalPrimaryLocale);
         $hasErrors = true;
     }
     switch ($value = $issueNode->getAttribute('published')) {
         case 'true':
             $issue->setPublished(1);
             break;
         case 'false':
         case '':
         case null:
             $issue->setPublished(0);
             break;
         default:
             $errors[] = array('plugins.importexport.native.import.error.invalidBooleanValue', array('value' => $value));
             $hasErrors = true;
             break;
     }
     switch ($value = $issueNode->getAttribute('current')) {
         case 'true':
             $issue->setCurrent(1);
             break;
         case 'false':
         case '':
         case null:
             $issue->setCurrent(0);
             break;
         default:
             $errors[] = array('plugins.importexport.native.import.error.invalidBooleanValue', array('value' => $value));
             $hasErrors = true;
             break;
     }
     if (($value = $issueNode->getAttribute('public_id')) != '') {
         $anotherIssue = $issueDao->getIssueByPublicIssueId($value, $journal->getId());
         if ($anotherIssue) {
             $errors[] = array('plugins.importexport.native.import.error.duplicatePublicId', array('issueTitle' => $issue->getIssueIdentification(), 'otherIssueTitle' => $anotherIssue->getIssueIdentification()));
             $hasErrors = true;
         } else {
             $issue->setPublicIssueId($value);
         }
     }
     /* --- Access Status --- */
     $node = $issueNode->getChildByName('open_access');
     $issue->setAccessStatus($node ? ISSUE_ACCESS_OPEN : ISSUE_ACCESS_SUBSCRIPTION);
     if ($node = $issueNode->getChildByName('access_date')) {
         $accessDate = strtotime($node->getValue());
         if ($accessDate === -1) {
             $errors[] = array('plugins.importexport.native.import.error.invalidDate', array('value' => $node->getValue()));
             $hasErrors = true;
         } else {
             $issue->setOpenAccessDate($accessDate);
         }
     }
     /* --- All processing that does not require an inserted issue ID
        --- has been performed by this point. If there were no errors
        --- then insert the issue and carry on. If there were errors,
        --- then abort without performing the insertion. */
     if ($hasErrors) {
         $issue = null;
         if ($cleanupErrors) {
             NativeImportDom::cleanupFailure($dependentItems);
         }
         return false;
     } else {
         if ($issue->getCurrent()) {
             $issueDao->updateCurrentIssue($journal->getId());
         }
         $issue->setIssueId($issueDao->insertIssue($issue));
         $dependentItems[] = array('issue', $issue);
     }
     /* --- Handle cover --- */
     for ($index = 0; $node = $issueNode->getChildByName('cover', $index); $index++) {
         if (!NativeImportDom::handleCoverNode($journal, $node, $issue, $coverErrors, $isCommandLine)) {
             $errors = array_merge($errors, $coverErrors);
             $hasErrors = true;
         }
     }
     /* --- Handle sections --- */
     for ($index = 0; $node = $issueNode->getChildByName('section', $index); $index++) {
         if (!NativeImportDom::handleSectionNode($journal, $node, $issue, $sectionErrors, $user, $isCommandLine, $dependentItems, $index)) {
             $errors = array_merge($errors, $sectionErrors);
             $hasErrors = true;
         }
     }
     /* --- See if any errors occurred since last time we checked.
        --- If so, delete the created issue and return failure.
        --- Otherwise, the whole process was successful. */
     if ($hasErrors) {
         $issue = null;
         // Don't pass back a reference to a dead issue
         if ($cleanupErrors) {
             NativeImportDom::cleanupFailure($dependentItems);
         }
         return false;
     }
     $issueDao->updateIssue($issue);
     return true;
 }
Пример #2
0
             $ticket->setLocation($location);
         } else {
             $ticket->setLocation($row['street_num']);
         }
     }
 } else {
     $location = "{$row['street_dir']} {$row['street_name']} {$row['street_type']} {$row['sud_type']} {$row['sud_num']}";
     $location = preg_replace('/\\s+/', ' ', $location);
     $ticket->setLocation($location);
 }
 echo $ticket->getLocation() . "\n";
 // Create the issue on this ticket
 $issue = new Issue();
 $issue->setDate($ticket->getEnteredDate());
 if ($row['comments']) {
     $issue->setDescription($row['comments']);
 }
 $ticket->updateIssues($issue);
 $issue = $ticket->getIssue();
 $location = $ticket->getLocation();
 $date = $issue->getDate();
 $description = $issue->getDescription();
 echo "Query: {$location}, {$description}, {$date}\n";
 $ticketList = new TicketList();
 $ticketList->findByMongoQuery(array('location' => $location, 'issues.description' => $description, 'issues.date' => $date));
 if (count($ticketList) == 1) {
     // Update the Mongo case Number with what's in reqpro
     foreach ($ticketList as $t) {
         $data = $t->getData();
         $data['number'] = (int) $row['c_num'];
         echo "Saving new number {$data['number']}\n";
Пример #3
0
 /**
  * Save issue settings.
  */
 function execute($issueId = 0)
 {
     $journal =& Request::getJournal();
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     if ($issueId) {
         $issue = $issueDao->getIssueById($issueId);
         $isNewIssue = false;
     } else {
         $issue = new Issue();
         $isNewIssue = true;
     }
     $volume = $this->getData('volume');
     $number = $this->getData('number');
     $year = $this->getData('year');
     $showVolume = $this->getData('showVolume');
     $showNumber = $this->getData('showNumber');
     $showYear = $this->getData('showYear');
     $showTitle = $this->getData('showTitle');
     $issue->setJournalId($journal->getId());
     $issue->setTitle($this->getData('title'), null);
     // Localized
     $issue->setVolume(empty($volume) ? 0 : $volume);
     $issue->setNumber(empty($number) ? 0 : $number);
     $issue->setYear(empty($year) ? 0 : $year);
     if (!$isNewIssue) {
         $issue->setDatePublished($this->getData('datePublished'));
     }
     $issue->setDescription($this->getData('description'), null);
     // Localized
     $issue->setPublicIssueId($this->getData('publicIssueId'));
     $issue->setShowVolume(empty($showVolume) ? 0 : $showVolume);
     $issue->setShowNumber(empty($showNumber) ? 0 : $showNumber);
     $issue->setShowYear(empty($showYear) ? 0 : $showYear);
     $issue->setShowTitle(empty($showTitle) ? 0 : $showTitle);
     $issue->setCoverPageDescription($this->getData('coverPageDescription'), null);
     // Localized
     $issue->setCoverPageAltText($this->getData('coverPageAltText'), null);
     // Localized
     $showCoverPage = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('showCoverPage'));
     foreach (array_keys($this->getData('coverPageDescription')) as $locale) {
         if (!array_key_exists($locale, $showCoverPage)) {
             $showCoverPage[$locale] = 0;
         }
     }
     $issue->setShowCoverPage($showCoverPage, null);
     // Localized
     $hideCoverPageArchives = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageArchives'));
     foreach (array_keys($this->getData('coverPageDescription')) as $locale) {
         if (!array_key_exists($locale, $hideCoverPageArchives)) {
             $hideCoverPageArchives[$locale] = 0;
         }
     }
     $issue->setHideCoverPageArchives($hideCoverPageArchives, null);
     // Localized
     $hideCoverPageCover = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageCover'));
     foreach (array_keys($this->getData('coverPageDescription')) as $locale) {
         if (!array_key_exists($locale, $hideCoverPageCover)) {
             $hideCoverPageCover[$locale] = 0;
         }
     }
     $issue->setHideCoverPageCover($hideCoverPageCover, null);
     // Localized
     $issue->setAccessStatus($this->getData('accessStatus'));
     if ($this->getData('enableOpenAccessDate')) {
         $issue->setOpenAccessDate($this->getData('openAccessDate'));
     } else {
         $issue->setOpenAccessDate(null);
     }
     // if issueId is supplied, then update issue otherwise insert a new one
     if ($issueId) {
         $issue->setIssueId($issueId);
         $issueDao->updateIssue($issue);
     } else {
         $issue->setPublished(0);
         $issue->setCurrent(0);
         $issueId = $issueDao->insertIssue($issue);
         $issue->setIssueId($issueId);
     }
     import('classes.file.PublicFileManager');
     $publicFileManager = new PublicFileManager();
     if ($publicFileManager->uploadedFileExists('coverPage')) {
         $journal = Request::getJournal();
         $originalFileName = $publicFileManager->getUploadedFileName('coverPage');
         $newFileName = 'cover_issue_' . $issueId . '_' . $this->getFormLocale() . '.' . $publicFileManager->getExtension($originalFileName);
         $publicFileManager->uploadJournalFile($journal->getId(), 'coverPage', $newFileName);
         $issue->setOriginalFileName($publicFileManager->truncateFileName($originalFileName, 127), $this->getFormLocale());
         $issue->setFileName($newFileName, $this->getFormLocale());
         // Store the image dimensions.
         list($width, $height) = getimagesize($publicFileManager->getJournalFilesPath($journal->getId()) . '/' . $newFileName);
         $issue->setWidth($width, $this->getFormLocale());
         $issue->setHeight($height, $this->getFormLocale());
         $issueDao->updateIssue($issue);
     }
     if ($publicFileManager->uploadedFileExists('styleFile')) {
         $journal = Request::getJournal();
         $originalFileName = $publicFileManager->getUploadedFileName('styleFile');
         $newFileName = 'style_' . $issueId . '.css';
         $publicFileManager->uploadJournalFile($journal->getId(), 'styleFile', $newFileName);
         $issue->setStyleFileName($newFileName);
         $issue->setOriginalStyleFileName($publicFileManager->truncateFileName($originalFileName, 127));
         $issueDao->updateIssue($issue);
     }
     return $issueId;
 }
Пример #4
0
 /**
  * Save issue settings.
  */
 function execute($issueId = 0)
 {
     $journal =& Request::getJournal();
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     if ($issueId) {
         $issue = $issueDao->getIssueById($issueId);
         $isNewIssue = false;
     } else {
         $issue = new Issue();
         $isNewIssue = true;
     }
     $volume = $this->getData('volume');
     $number = $this->getData('number');
     $year = $this->getData('year');
     $showVolume = $this->getData('showVolume');
     $showNumber = $this->getData('showNumber');
     $showYear = $this->getData('showYear');
     $showTitle = $this->getData('showTitle');
     $issue->setJournalId($journal->getId());
     $issue->setTitle($this->getData('title'), null);
     // Localized
     $issue->setVolume(empty($volume) ? 0 : $volume);
     $issue->setNumber(empty($number) ? 0 : $number);
     $issue->setYear(empty($year) ? 0 : $year);
     if (!$isNewIssue) {
         $issue->setDatePublished($this->getData('datePublished'));
         // If the Editor has asked to reset article publication dates for content
         // in this issue, set them all to the specified issue publication date.
         if ($this->getData('resetArticlePublicationDates')) {
             $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
             $publishedArticles =& $publishedArticleDao->getPublishedArticles($issue->getId());
             foreach ($publishedArticles as $publishedArticle) {
                 $publishedArticle->setDatePublished($this->getData('datePublished'));
                 $publishedArticleDao->updatePublishedArticle($publishedArticle);
             }
         }
     }
     $issue->setDescription($this->getData('description'), null);
     // Localized
     $issue->setStoredPubId('publisher-id', $this->getData('publicIssueId'));
     $issue->setShowVolume(empty($showVolume) ? 0 : $showVolume);
     $issue->setShowNumber(empty($showNumber) ? 0 : $showNumber);
     $issue->setShowYear(empty($showYear) ? 0 : $showYear);
     $issue->setShowTitle(empty($showTitle) ? 0 : $showTitle);
     $issue->setCoverPageDescription($this->getData('coverPageDescription'), null);
     // Localized
     $issue->setCoverPageAltText($this->getData('coverPageAltText'), null);
     // Localized
     $showCoverPage = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('showCoverPage'));
     foreach (array_keys($this->getData('coverPageDescription')) as $locale) {
         if (!array_key_exists($locale, $showCoverPage)) {
             $showCoverPage[$locale] = 0;
         }
     }
     $issue->setShowCoverPage($showCoverPage, null);
     // Localized
     $hideCoverPageArchives = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageArchives'));
     foreach (array_keys($this->getData('coverPageDescription')) as $locale) {
         if (!array_key_exists($locale, $hideCoverPageArchives)) {
             $hideCoverPageArchives[$locale] = 0;
         }
     }
     $issue->setHideCoverPageArchives($hideCoverPageArchives, null);
     // Localized
     $hideCoverPageCover = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageCover'));
     foreach (array_keys($this->getData('coverPageDescription')) as $locale) {
         if (!array_key_exists($locale, $hideCoverPageCover)) {
             $hideCoverPageCover[$locale] = 0;
         }
     }
     $issue->setHideCoverPageCover($hideCoverPageCover, null);
     // Localized
     $issue->setAccessStatus($this->getData('accessStatus') ? $this->getData('accessStatus') : ISSUE_ACCESS_OPEN);
     // See bug #6324
     if ($this->getData('enableOpenAccessDate')) {
         $issue->setOpenAccessDate($this->getData('openAccessDate'));
     } else {
         $issue->setOpenAccessDate(null);
     }
     // consider the additional field names from the public identifer plugins
     import('classes.plugins.PubIdPluginHelper');
     $pubIdPluginHelper = new PubIdPluginHelper();
     $pubIdPluginHelper->execute($this, $issue);
     // if issueId is supplied, then update issue otherwise insert a new one
     if ($issueId) {
         $issue->setId($issueId);
         $this->issue =& $issue;
         parent::execute();
         $issueDao->updateIssue($issue);
     } else {
         $issue->setPublished(0);
         $issue->setCurrent(0);
         $issueId = $issueDao->insertIssue($issue);
         $issue->setId($issueId);
     }
     import('classes.file.PublicFileManager');
     $publicFileManager = new PublicFileManager();
     if ($publicFileManager->uploadedFileExists('coverPage')) {
         $journal = Request::getJournal();
         $originalFileName = $publicFileManager->getUploadedFileName('coverPage');
         $type = $publicFileManager->getUploadedFileType('coverPage');
         $newFileName = 'cover_issue_' . $issueId . '_' . $this->getFormLocale() . $publicFileManager->getImageExtension($type);
         $publicFileManager->uploadJournalFile($journal->getId(), 'coverPage', $newFileName);
         $issue->setOriginalFileName($publicFileManager->truncateFileName($originalFileName, 127), $this->getFormLocale());
         $issue->setFileName($newFileName, $this->getFormLocale());
         // Store the image dimensions.
         list($width, $height) = getimagesize($publicFileManager->getJournalFilesPath($journal->getId()) . '/' . $newFileName);
         $issue->setWidth($width, $this->getFormLocale());
         $issue->setHeight($height, $this->getFormLocale());
         $issueDao->updateIssue($issue);
     }
     if ($publicFileManager->uploadedFileExists('styleFile')) {
         $journal = Request::getJournal();
         $originalFileName = $publicFileManager->getUploadedFileName('styleFile');
         $newFileName = 'style_' . $issueId . '.css';
         $publicFileManager->uploadJournalFile($journal->getId(), 'styleFile', $newFileName);
         $issue->setStyleFileName($newFileName);
         $issue->setOriginalStyleFileName($publicFileManager->truncateFileName($originalFileName, 127));
         $issueDao->updateIssue($issue);
     }
     return $issueId;
 }