Example #1
0
 /**
  * Returns the number of a document in a series.
  * @param Opus_Document $document
  * @param Opus_Series $series
  * @return string
  */
 public function seriesNumber($document, $series)
 {
     foreach ($document->getSeries() as $linkedSeries) {
         if ($linkedSeries->getModel()->getId() === $series->getId()) {
             return htmlspecialchars($linkedSeries->getNumber());
         }
     }
     return '';
 }
Example #2
0
 public function testGetModel()
 {
     $form = new Admin_Form_Document_Series();
     $doc = new Opus_Document(146);
     $series = $doc->getSeries();
     $form->getElement('Id')->setValue($doc->getId());
     $form->getElement('SeriesId')->setValue($series[0]->getModel()->getId());
     $form->getElement('Number')->setValue('b');
     $form->getElement('SortOrder')->setValue(7);
     $model = $form->getModel();
     $modelId = $model->getId();
     $this->assertEquals(146, $modelId[0]);
     $this->assertEquals($series[0]->getModel()->getId(), $modelId[1]);
     $this->assertEquals('b', $model->getNumber());
     $this->assertEquals(7, $model->getDocSortOrder());
 }
        echo "sorting documents in series #" . $series->getId() . " numerically\n";
        if (!asort($seriesNumbers, SORT_NUMERIC)) {
            echo "Error while sorting docs -- skip series #" . $series->getId() . "\n";
            break;
        }
    } else {
        echo "sorting documents in series #" . $series->getId() . " lexicographically\n";
        if (!asort($seriesNumbers, SORT_STRING)) {
            echo "Error while sorting docs -- skip series #" . $series->getId() . "\n";
            break;
        }
    }
    $seriesCounter = 0;
    foreach ($seriesNumbers as $docId => $seriesNumber) {
        $doc = new Opus_Document($docId);
        $allSeries = $doc->getSeries();
        $doc->setSeries(array());
        $doc->store();
        foreach ($allSeries as $docSeries) {
            $seriesInstance = $docSeries->getModel();
            if ($seriesInstance->getId() === $series->getId()) {
                echo "reassign doc_sort_order for doc #" . $doc->getId() . " (series number: " . $docSeries->getNumber() . ") -- old / new doc_sort_order: " . $docSeries->getDocSortOrder() . " / " . $seriesCounter . "\n";
                $doc->addSeries($seriesInstance)->setNumber($docSeries->getNumber())->setDocSortOrder($seriesCounter++);
            } else {
                $doc->addSeries($seriesInstance)->setNumber($docSeries->getNumber())->setDocSortOrder($docSeries->getDocSortOrder());
            }
        }
        $doc->store();
    }
}
exit;
 public function testXMetaDissPlusDctermsispartofContainsSeriesTitleAndNumber()
 {
     $doc = new Opus_Document(146);
     $series = $doc->getSeries();
     $this->dispatch('/oai?verb=GetRecord&metadataPrefix=XMetaDissPlus&identifier=oai::146');
     $response = $this->getResponse();
     $xpath = $this->prepareXpathFromResultString($response->getBody());
     $dctermsIspartof = $xpath->query('//xMetaDiss:xMetaDiss/dcterms:isPartOf');
     $this->assertEquals(1, $dctermsIspartof->length);
     $this->assertEquals($series[0]->getTitle() . ' ; ' . $series[0]->getNumber(), $dctermsIspartof->item(0)->nodeValue);
 }
 /**
  * Regression test for OPUSVIER-2232
  */
 public function testSeries149InVisible()
 {
     $d = new Opus_Document(149);
     $seriesIds = array();
     $seriesNumbers = array();
     foreach ($d->getSeries() as $series) {
         $seriesIds[] = $series->getModel()->getId();
         $seriesNumbers[] = $series->getNumber();
     }
     $this->assertContains('3', $seriesIds);
     $this->assertContains('4', $seriesIds);
     $this->assertContains('id-3-is-invisible', $seriesNumbers);
     $this->assertContains('id-4-is-visible', $seriesNumbers);
     $this->dispatch('/frontdoor/index/index/docId/149');
     $this->assertResponseCode(200);
     $responseBody = $this->getResponse()->getBody();
     // series 3 is NOT visible
     $this->assertNotContains('id-3-is-invisible', $responseBody);
     $this->assertNotRegExp('/href="\\/solrsearch\\/index\\/search\\/searchtype\\/series\\/id\\/3"/', $responseBody);
     // series 4 is visible
     $this->assertContains('id-4-is-visible', $responseBody);
     $this->assertRegExp('/href="\\/solrsearch\\/index\\/search\\/searchtype\\/series\\/id\\/4"/', $responseBody);
 }