Beispiel #1
0
function render()
{
    global $publications;
    echo "<dl>";
    foreach ($publications as $dataId => $dataObject) {
        echo "<dt><h3>{$dataId}</h3></dt>";
        echo "<dd><ul>";
        foreach ($dataObject->rendereddata as $styleName => $renderedText) {
            $style = CiteProc::loadStyleSheet($styleName);
            print_r($style);
            $lang = substr($publications->{$dataId}->locales, 0, 2);
            $citeProc = new CiteProc($style, $lang);
            $actual = preg_replace('!(\\s{2,})!', ' ', strip_tags($citeProc->render($dataObject->rawdata)));
            echo '<li><h4>' . $styleName . ':</h4>' . '<div id="' . $dataId . '-' . $styleName . '" data-pub-ident="' . $dataId . '" data-style="' . $styleName . '">' . '<strong>rendered:</strong><br />' . '<div class="actual">' . $actual . '</div>' . '<strong>expected:</strong><br />' . '<div class="expected"></div>' . '<strong>diff:</strong><br />' . '<div class="diff"></div>' . '</div></li>';
        }
        echo "</ul></dd>";
    }
}
Beispiel #2
0
<?php

/*
 * This file is part of the inlitteris project.
 *
 * (c) Jo Brunner <http://github.com/jobrunner/yii2-inlitteris>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
use yii\helpers\Html;
use jobrunner\inlitteris\widgets\Citation;
/* @var $this yii\web\View */
/* @var $model jobrunner\inlitteris\models\Reference */
/* @var $referenceTypeModel jobrunner\inlitteris\models\ReferenceType */
$citation = Citation::widget(['model' => $model, 'csl' => \AcademicPuma\CiteProc\CiteProc::loadStyleSheet('apa-annotated-bibliography'), 'locale' => 'en-US']);
$breadcrumbCitation = strip_tags($citation);
$breadcrumbCitation = preg_replace('/\\R/u', '', $breadcrumbCitation);
$breadcrumbCitation = trim($breadcrumbCitation, '()');
$this->title = Yii::t('inlitteris', 'Update {modelClass}: ', ['modelClass' => 'Reference']) . ' ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('inlitteris', 'References'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $breadcrumbCitation, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('inlitteris', 'Update');
?>
<div class="reference-update">

    <h1><?php 
echo Html::encode($breadcrumbCitation);
?>
</h1>
             break;
         case JSON_ERROR_CTRL_CHAR:
             echo ' - Unexpected control character found';
             break;
         case JSON_ERROR_SYNTAX:
             echo ' - Syntax error, malformed JSON';
             break;
         case JSON_ERROR_UTF8:
             echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
             break;
         default:
             echo ' - Unknown error';
             break;
     }
     if ($test_data->mode == 'bibliography') {
         $citeproc = new CiteProc($test_data->csl);
         $input_data = (array) $test_data->input;
         $count = count($input_data);
         $output = '';
         foreach ($input_data as $data) {
             $output .= $citeproc->render($data, $test_data->mode);
         }
         //print '<html><body>';
         if ($output != $test_data->result) {
             print TEST_FOLDER . $filename . " FAILED\n";
             print $output . " !=  <br>\n" . $test_data->result . "<br><br>\n\n";
         } else {
             print TEST_FOLDER . $filename . " PASSED\n";
         }
     }
 }
/* @var $model jobrunner\inlitteris\models\CitationStyle */
$this->title = Yii::t('inlitteris', 'Bibliography');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="reference-index">
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
<!--    <p>-->
        <?php 
// = Html::a(Yii::t('inlitteris', 'Create Reference'), ['create'], ['class' => 'btn btn-success'])
?>
<!--    </p>-->

    <?php 
$form = ActiveForm::begin(['method' => 'get']);
?>
    <?php 
echo $form->field($model, 'citationStyle')->dropDownList($model->kvEnabled(), ['onchange' => 'this.form.submit()']);
?>
    <?php 
ActiveForm::end();
?>

    <?php 
echo Bibliography::widget(['dataProvider' => $dataProvider, 'csl' => \AcademicPuma\CiteProc\CiteProc::loadStyleSheet($model->citationStyle), 'locale' => 'en-US']);
?>

</div>
Beispiel #5
0
use jobrunner\inlitteris\widgets\Bibliography;
/* @var $this yii\web\View */
/* @var $model jobrunner\inlitteris\models\Reference */
$citation = Citation::widget(['model' => $model, 'csl' => \AcademicPuma\CiteProc\CiteProc::loadStyleSheet('apa-annotated-bibliography'), 'locale' => 'en-US']);
$breadcrumbCitation = strip_tags($citation);
$breadcrumbCitation = preg_replace('/\\R/u', '', $breadcrumbCitation);
$breadcrumbCitation = trim($breadcrumbCitation, '()');
$this->params['breadcrumbs'][] = ['label' => Yii::t('inlitteris', 'References'), 'url' => ['index']];
$this->params['breadcrumbs'][] = Html::encode($breadcrumbCitation);
?>
<div class="reference-view">

    <h2><?php 
echo Html::encode($breadcrumbCitation);
?>
</h2>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id:ntext', ['label' => 'Citation', 'format' => 'html', 'value' => $citation], ['label' => 'Bibliography', 'format' => 'html', 'value' => Bibliography::widget(['model' => $model, 'csl' => \AcademicPuma\CiteProc\CiteProc::loadStyleSheet('apa-annotated-bibliography'), 'locale' => 'en-US'])], 'referenceType.typeName:ntext', 'authors:ntext', 'title:html', 'secondaryTitle:ntext', 'secondaryAuthors:ntext', 'tertiaryTitle:ntext', 'tertiaryAuthors:ntext', 'year:ntext', 'volume:ntext', 'number:ntext', 'pages:ntext', 'section:ntext', 'edition:ntext', 'place:ntext', 'publisher:ntext', 'isbn:ntext']]);
?>
    <p style="text-align: center">
        <?php 
echo Html::a(Yii::t('inlitteris', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a(Yii::t('inlitteris', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('inlitteris', 'Are you sure you want to delete this item?'), 'method' => 'post']]);
?>
    </p>

</div>