From 0e3fc63390ad8172f6f4ef678567f8eeeafac24f Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Fri, 1 Feb 2019 17:11:58 +0100
Subject: [PATCH] dev #64573 improve rating rendering add missing files

---
 library/Class/ReviewsByRecord.php             |  23 ++++
 .../Library/View/Wrapper/ReviewsByRecord.php  | 115 ++++++++++++++++++
 2 files changed, 138 insertions(+)
 create mode 100644 library/Class/ReviewsByRecord.php
 create mode 100644 library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php

diff --git a/library/Class/ReviewsByRecord.php b/library/Class/ReviewsByRecord.php
new file mode 100644
index 00000000000..c1b34542b35
--- /dev/null
+++ b/library/Class/ReviewsByRecord.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved.
+ *
+ * BOKEH is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
+ * the Free Software Foundation.
+ *
+ * There are special exceptions to the terms and conditions of the AGPL as it
+ * is applied to this software (see README file).
+ *
+ * BOKEH is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * along with BOKEH; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+
+class Class_ReviewsByRecord extends Class_Entity {}
diff --git a/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php b/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php
new file mode 100644
index 00000000000..3bc6efac8d7
--- /dev/null
+++ b/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php
@@ -0,0 +1,115 @@
+<?php
+/**
+ * Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved.
+ *
+ * BOKEH is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
+ * the Free Software Foundation.
+ *
+ * There are special exceptions to the terms and conditions of the AGPL as it
+ * is applied to this software (see README file).
+ *
+ * BOKEH is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * along with BOKEH; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+
+class Intonation_Library_View_Wrapper_ReviewsByRecord extends Intonation_Library_View_Wrapper_Abstract {
+
+  protected $_record,
+    $_reviews = [];
+
+  public function setModel($model) {
+    $this->_record = (new Intonation_Library_View_Wrapper_Record())
+      ->setView($this->_view)
+      ->setModel($model->getRecord());
+
+    foreach ($model->getReviews() as $review)
+      $this->_reviews [] = (new Intonation_Library_View_Wrapper_Review())
+      ->setView($this->_view)
+      ->setModel($review);
+
+    return parent::setModel($model);
+  }
+
+  public function getTitle() {
+    return $this->_record->getTitle();
+  }
+
+
+  public function getAuthor() {
+    return '';
+  }
+
+
+  public function getExplicitTitle() {
+    return $this->_('Avis "%s"',
+                    $this->getTitle());
+  }
+
+
+  public function getDocType() {
+    return $this->_record->getDocType();
+  }
+
+
+  public function getDocTypeLabel() {
+    $type_doc = Class_TypeDoc::find($this->getDocType());
+    return $type_doc ? $type_doc->getLabel() : '';
+  }
+
+
+  public function getMainLink() {
+    return $this->_record->getMainLink();
+  }
+
+
+  protected  function _getMainLinkTitle() {
+    if ($author = $this->getAuthor())
+      return $this->_('Lire l\'avis "%s" écrit par "%s"',
+                      $this->getTitle(),
+                      $this->getAuthor());
+
+    return $this->_('Lire l\'avis: %s',
+                    $this->getTitle());
+  }
+
+
+  public function getPicture() {
+    return $this->_record->getPicture();
+  }
+
+
+  public function getFullDescription() {
+    return $this->_model->getAvis();
+  }
+
+
+  public function getDescription() {
+    $html = [];
+    foreach ($this->_reviews as $review)
+      $html [] = $this->_view->cardifyOnlyDescription($review);
+
+    return $this->_view->renderRecordBadges($this->_record->getModel())
+      . implode($html);
+  }
+
+
+  public function getDescriptionTitle() {
+    return $this->_('Les avis du document : %s', $this->getTitle());
+  }
+
+
+  public function getAuthorIco() {
+    return Class_Template::current()
+      ->getIco($this->_view,
+               'author',
+               'library');
+  }
+}
\ No newline at end of file
-- 
GitLab