Beispiel #1
0
 /**
  * Sort the input data by the rules for bibliographies.
  *
  * @return bool
  */
 public function sort()
 {
     if (isset($this->sort) == true && $this->doNotSort == false) {
         $name = 'bibliography';
         if (Container::getContext()->getName() == 'citation') {
             $name = 'citation';
         }
         Container::getContext()->setName('bibliography');
         Container::getContext()->enter('bibliography');
         $return = $this->sort->sort('bibliography');
         Container::getContext()->leave();
         Container::getContext()->setName($name);
         return $return;
     }
     return false;
 }
Beispiel #2
0
 /**
  * Render the citations.
  *
  * @param string $data
  * @return string
  */
 public function render($data)
 {
     Container::getContext()->enter('citation');
     // sort
     if (isset($this->sort) == true) {
         $this->sort->sort('citation');
     }
     // render citation
     $result = $this->layout->render($data);
     // The assignment of the year-suffixes follows the order of the bibliographies entries,
     // so sort if disambiguation by year-suffixes is needed, sort the data by the bibliography
     // and re-render citations
     if (Container::hasBibliography() == true && Container::getContext()->getValue('disambiguateAddYearSuffix', 'citation') === true && Container::getContext()->getLastDisambiguation() == 'Geissler\\CSL\\Options\\Disambiguation\\AddYearSuffix' && Container::getBibliography()->sort() == true) {
         Container::getRendered()->clear();
         // re-render citation
         $result = $this->layout->render($data);
     }
     if (Container::getCitationItem() !== false) {
         // apply additional citation formatting options
         Container::getCitationItem()->moveToFirst();
         if (Container::getCitationItem()->get('noteIndex') !== null || Container::getCitationItem()->get('index') !== null) {
             $citation = array();
             $length = count($result);
             $prefix = '..';
             for ($i = 0; $i < $length; $i++) {
                 if ($i + 1 == $length) {
                     $prefix = '>>';
                 }
                 // Therefore, the first character of a citation should preferably be uppercased
                 $citation[] = $prefix . '[' . $i . '] ' . $this->upperCase($result[$i]);
             }
             $return = implode("\n", $citation);
         } else {
             array_walk($result, array($this, 'upperCase'));
             $return = implode("\n", $result);
         }
     } else {
         array_walk($result, array($this, 'upperCase'));
         $return = implode("\n", $result);
     }
     Container::getContext()->leave();
     return $return;
 }