Skip to content

Commit

Permalink
v1.0.3.8 site book view ok with pv
Browse files Browse the repository at this point in the history
  • Loading branch information
rogercreagh committed Jan 27, 2023
1 parent 57200cc commit f9da54f
Show file tree
Hide file tree
Showing 7 changed files with 355 additions and 180 deletions.
6 changes: 2 additions & 4 deletions src/com_xbbooks/admin/views/book/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*******
* @package xbBooks
* @filesource admin/views/book/view.html.php
* @version 1.0.2.2 6th January 2023
* @version 1.0.3.8 27th January 2023
* @author Roger C-O
* @copyright Copyright (c) Roger Creagh-Osborne, 2021
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
Expand Down Expand Up @@ -90,8 +90,6 @@ protected function addToolBar()
ToolbarHelper::save('book.save');
ToolbarHelper::save2new('book.save2new');
ToolbarHelper::save2copy('book.save2copy');
ToolbarHelper::custom('book.save2NewPer', 'user', '', 'XBCULTURE_BTN_SAVE2PER', false) ;
ToolbarHelper::custom('book.save2NewChar', 'user', '', 'XBCULTURE_BTN_SAVE2CHAR', false) ;
ToolbarHelper::custom('book.save2NewRev', 'comment', '', 'XBCULTURE_BTN_SAVE2REV', false) ;
if ($isNew) {
ToolbarHelper::cancel('book.cancel','JTOOLBAR_CANCEL');
Expand All @@ -104,7 +102,7 @@ protected function addToolBar()
if ($this->item->id > 0) {
$dhtml = '<a href="index.php?option=com_xbbooks&view=book&layout=modalpv&tmpl=component&id='.$this->item->id.'"
data-toggle="modal" data-target="#ajax-pvmodal"
class="btn btn-small btn-primary"><i class="icon-eye"></i> '.Text::_('Preview').'</a>';
class="btn btn-small btn-primary"><i class="far fa-eye"></i> '.Text::_('Preview').'</a>';
$bar->appendButton('Custom', $dhtml);
}
ToolbarHelper::help( '', false,'https://crosborne.uk/xbbooks/doc?tmpl=component#bookedit' );
Expand Down
25 changes: 17 additions & 8 deletions src/com_xbbooks/site/models/book.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*******
* @package xbBooks
* @filesource site/models/book.php
* @version 0.9.11.2 17th November 2022
* @version 1.0.3.8 27th January 2023
* @author Roger C-O
* @copyright Copyright (c) Roger Creagh-Osborne, 2021
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
Expand Down Expand Up @@ -38,6 +38,9 @@ public function getItem($id = null) {
a.state AS published, a.catid AS catid, a.params AS params, a.metadata AS metadata, a.created AS created ');
$query->from('#__xbbooks AS a');
$query->select('(SELECT AVG(br.rating) FROM #__xbbookreviews AS br WHERE br.book_id=a.id) AS averat');
$query->select('(SELECT COUNT(DISTINCT(bp.person_id)) FROM #__xbbookperson AS bp WHERE bp.book_id = a.id) AS pcnt');
$query->select('(SELECT COUNT(DISTINCT(bc.char_id)) FROM #__xbbookcharacter AS bc WHERE bc.book_id = a.id) AS ccnt');
$query->select('(SELECT COUNT(DISTINCT(bg.group_id)) FROM #__xbbookgroup AS bg WHERE bg.book_id = a.id) AS gcnt');
$query->select('c.title AS category_title');
$query->leftJoin('#__categories AS c ON c.id = a.catid');
$query->where('a.id = '.$id);
Expand Down Expand Up @@ -84,15 +87,21 @@ public function getItem($id = null) {
$item->mencnt = count(array_keys($roles, 'mention'));
$item->othcnt = count(array_keys($roles, 'other'));

$item->alist = $item->authcnt==0 ? '' : XbcultureHelper::makeLinkedNameList($item->people,'author','comma');
$item->elist = $item->editcnt==0 ? '' : XbcultureHelper::makeLinkedNameList($item->people,'editor','comma');
$item->mlist = $item->mencnt==0 ? '' : XbcultureHelper::makeLinkedNameList($item->people,'mention','ul',true,1);
$item->olist =$item->othcnt==0 ? '' : XbcultureHelper::makeLinkedNameList($item->people,'other','ul',true,1);
$item->alist = $item->authcnt==0 ? '' : XbcultureHelper::makeItemLists($item->people,'author','tn',5,'ppvmodal');
$item->elist = $item->editcnt==0 ? '' : XbcultureHelper::makeItemLists($item->people,'editor','tn',5,'ppvmodal');
$item->mlist = $item->mencnt==0 ? '' : XbcultureHelper::makeItemLists($item->people,'mention','tn',5,'ppvmodal');
$item->olist =$item->othcnt==0 ? '' : XbcultureHelper::makeItemLists($item->people,'other','rtn',5,'ppvmodal');

$item->chars = XbbooksGeneral::getBookChars($item->id);
$item->charcnt = empty($item->chars) ? 0 : count($item->chars);
$item->clist = $item->charcnt==0 ? '' : XbcultureHelper::makeLinkedNameList($item->chars,'char','ul',true,1);
if ($item->ccnt>0) {
$item->chars = XbbooksGeneral::getBookChars($item->id);
$item->clist = $item->ccnt==0 ? '' : XbcultureHelper::makeItemLists($item->chars,'char','tn',5,'cpvmodal');
}

if ($item->gcnt>0) {
$item->groups = XbbooksGeneral::getBookGroups($item->id);
$item->grouplist = XbcultureHelper::makeItemLists($item->groups,'','rtn',5,'gpvgmodal');
}

//order by review rating or date?
$item->reviews = XbbooksGeneral::getBookReviews($item->id);
$item->revcnt = count($item->reviews);
Expand Down
Loading

0 comments on commit f9da54f

Please sign in to comment.