Skip to content

Commit

Permalink
v1.0.3.6 detailslist ok, booklist modals not working
Browse files Browse the repository at this point in the history
  • Loading branch information
rogercreagh committed Jan 23, 2023
1 parent d98f9f4 commit 0772847
Show file tree
Hide file tree
Showing 10 changed files with 228 additions and 110 deletions.
41 changes: 0 additions & 41 deletions src/com_xbbooks/admin/models/fields/otherrole.php

This file was deleted.

25 changes: 10 additions & 15 deletions src/com_xbbooks/site/models/booklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function getListQuery() {
$query->join('LEFT', '#__categories AS c ON c.id = a.catid');

// $query->select('(SELECT COUNT(*) FROM #__xbbookreviews AS br WHERE br.book_id=a.id AND br.state=1) AS revcnt');
$query->select('(SELECT AVG(br.rating) FROM #__xbbookreviews AS br WHERE br.book_id=a.id) AS averat');
$query->select('(SELECT AVG(br.rating) FROM #__xbbookreviews AS br JOIN #__xbbookreviews AS r ON r.id = br.id WHERE br.book_id=a.id AND r.state=1) AS averat');
// $query->select('(SELECT MAX(r.rev_date) FROM #__xbbookreviews AS r WHERE r.book_id=a.id) AS lastread');
// $query->select('GREATEST(a.acq_date, COALESCE(a.last_read, 0)) AS sort_date');

Expand Down Expand Up @@ -258,26 +258,21 @@ public function getItems() {
$item->editcnt = array_key_exists('editor', $rolecnts) ? $rolecnts['editor'] :0;
$item->mencnt = array_key_exists('mention', $rolecnts) ? $rolecnts['mention'] :0;
$item->othercnt = count($roles) - $item->authcnt - $item->editcnt - $item->mencnt;
$item->authlist = $item->authcnt==0 ? '' : XbcultureHelper::makeItemLists($item->people,'author','t',1);
$item->editlist = $item->editcnt==0 ? '' : XbcultureHelper::makeItemLists($item->people,'editor','t',2);
$item->menlist = $item->mencnt==0 ? '' : XbcultureHelper::makeItemLists($item->people,'mention','tn',3);
$item->otherlist = $item->othercnt==0 ? '' : XbcultureHelper::makeItemLists($item->people,'other','rt',3);

// $item->authlist = $item->authcnt==0 ? '' : XbcultureHelper::makeLinkedNameList($item->people,'author','ul',2,5);
// $item->editlist = $item->editcnt==0 ? '' : XbcultureHelper::makeLinkedNameList($item->people,'editor','ul',2,5);
// $item->menlist = $item->mencnt==0 ? '' : XbcultureHelper::makeLinkedNameList($item->people,'mention','ul',2,5);
// $item->otherlist = $item->othercnt==0 ? '' : XbcultureHelper::makeLinkedNameList($item->people,'other','ul',2,4);

$item->authlist = $item->authcnt==0 ? '' : XbcultureHelper::makeItemLists($item->people,'author','t',4,'ppvmodal');
$item->editlist = $item->editcnt==0 ? '' : XbcultureHelper::makeItemLists($item->people,'editor','t',4,'ppvmodal');
$item->menlist = $item->mencnt==0 ? '' : XbcultureHelper::makeItemLists($item->people,'mention','tn',4,'ppvmodal');
$item->otherlist = $item->othercnt==0 ? '' : XbcultureHelper::makeItemLists($item->people,'other','rt',4,'ppvmodal');
} else {
$item->authcnt = 0; $item->editcnt = 0; $item->mencnt = 0; $item->othercnt = 0;
}

if ($item->ccnt>0) {
$item->chars = XbbooksGeneral::getBookChars($item->id);
$item->charlist = XbcultureHelper::makeItemLists($item->chars,'','t',1);
// $item->charlist = XbcultureHelper::makeLinkedNameList($item->chars,'','ul',true,5);
$item->charlist = XbcultureHelper::makeItemLists($item->chars,'','t',5,'cpvmodal');
}
if ($item->gcnt>0) {
$item->groups = XbbooksGeneral::getBookGroups($item->id);
$item->grouplist = XbcultureHelper::makeItemLists($item->groups,'','t',3);
// $item->grouplist = XbcultureHelper::makeLinkedNameList($item->groups,'','ul',true,4);
$item->grouplist = XbcultureHelper::makeItemLists($item->groups,'','t',5,'pvgmodal');
}

$item->reviews = XbbooksGeneral::getBookReviews($item->id);
Expand Down
6 changes: 3 additions & 3 deletions src/com_xbbooks/site/views/booklist/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,14 @@
<script>
jQuery(document).ready(function(){
//for preview modal
jQuery('#ajax-pvmodal').on('show', function () {
jQuery('#ajax-ppvmodal').on('show', function () {
// Load view vith AJAX
jQuery(this).find('.modal-content').load('index.php?option=com_xbbooks&view=books&layout=modalpv&tmpl=component');
jQuery(this).find('.modal-content').load('index.php?option=com_xbbooks&view=books&layout=modalppv&tmpl=component');
})
});
</script>
<!-- preview modal window -->
<div class="modal fade xbpvmodal" id="ajax-pvmodal" style="max-width:1100px">
<div class="modal fade xbpvmodal" id="ajax-ppvmodal" style="max-width:800px">
<div class="modal-dialog">
<div class="modal-content">
<!-- Ajax content will be loaded here -->
Expand Down
136 changes: 88 additions & 48 deletions src/com_xbbooks/site/views/booklist/tmpl/detailslist.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
$rlink = 'index.php?option=com_xbbooks&view=bookreview'.$itemid.'&id=';

?>
<style type="text/css" media="screen">
.xbpvmodal .modal-body iframe { max-height:calc(100vh - 190px);}
</style>
<div class="xbculture ">
<?php if(($this->header['showheading']) || ($this->header['title'] != '') || ($this->header['text'] != '')) {
echo XbcultureHelper::sitePageheader($this->header);
Expand Down Expand Up @@ -84,7 +87,7 @@
</div>
<?php else : ?>

<table class="table table-striped table-hover" style="table-layout:fixed;" id="xbbooklist">
<table class="table table-hover" style="table-layout:fixed;width:100%;" id="xbbooklist">
<thead>
<tr>
<th>
Expand All @@ -98,7 +101,7 @@
<tbody>
<?php foreach ($this->items as $i => $item) : ?>
<?php $reviews = ''; ?>
<tr class="row<?php echo $i % 2; ?>">
<tr class="xbrow<?php echo $i % 2; ?>">
<td>
<h3>
<a href="<?php echo Route::_(XbbooksHelperRoute::getBookLink($item->id)) ;?>" >
Expand All @@ -107,8 +110,8 @@
<br /><span class="xb08" style="padding-left:15px;"><?php echo $this->escape($item->subtitle); ?></span>
<?php endif; ?>
</h3>
<table>
<tr class="xbrow<?php echo $i % 2; ?>">
<table style="width:100%;">
<tr>
<?php if($this->show_pic) : ?>
<td style="width:100px;padding-right:20px;">
<?php $src = trim($item->cover_img);
Expand All @@ -123,7 +126,7 @@
</td>
<?php endif; ?>
<td>
<p><span class="<?php echo ($item->authcnt>1) ? 'icon-users' : 'icon-user'; ?>"></span>&nbsp;
<i class="fas fa-user xbpr10"></i>&nbsp;
<?php if ($item->authcnt==0) {
echo '<span class="xbnit">'.Text::_('XBBOOKS_NOAUTHOR').'</span>';
} else { ?>
Expand All @@ -134,30 +137,51 @@
} ?>
<br />
<?php if ($item->editcnt >0 ) : ?>
<span class="icon-checkmark-circle"></span>&nbsp;<span class="xbnit">
<i class="fas fa-user-edit xbpr10"></i>&nbsp;<span class="xbnit">
<?php echo $item->editcnt>1 ? Text::_('XBCULTURE_EDITORS') : Text::_('XBCULTURE_EDITOR' ); ?>
</span>:
<?php echo $item->editlist['commalist']; ?>
<br />
<?php endif; ?>
<?php $othercnt = $item->othercnt + $item->mencnt + $item->gcnt;
if ($othercnt>0) : ?>
<span class="icon-user"></span>&nbsp;
<?php if ($item->othercnt>0) : ?>
<div class="pull-left"><i class="fas fa-user-friends xbpr10"></i>&nbsp;</div>
<div class="pull-left">
<details>
<summary><span class="xbnit"><?php echo $othercnt.' '.Text::_('XBCULTURE_OTHER_PEOPLE_LISTED'); ?></span>
<summary><span class="xbnit"><?php echo $$item->othercnt.' '.Text::_('XBCULTURE_OTHER_PEOPLE_LISTED'); ?></span>
</summary>
<?php echo $item->otherlist['ullist']; ?>
</details>
</div>
<div class="clearfix"></div>
<?php endif; ?>
<?php if ($item->mencnt>0) : ?>
<div class="pull-left"><i class="far fa-user xbpr10"></i>&nbsp;</div>
<div class="pull-left">
<details>
<summary><span class="xbnit"><?php echo $$item->mencnt.' '.Text::_('subjects of book, or mentioned in it'); ?></span>
</summary>
<?php echo $item->menlist['ullist']; ?>
</details>
</div>
<div class="clearfix"></div>
<?php endif; ?>
<?php if ($item->gcnt>0) : ?>
<div class="pull-left"><i class="fas fa-users xbpr10"></i>&nbsp;</div>
<div class="pull-left">
<details>
<summary><span class="xbnit"><?php echo $item->gcnt.' '.Text::_('XBCULTURE_GROUPS'); ?></span>
</summary>
<?php echo ($item->othercnt>0) ? $item->otherlist['ullist'] : ''; ?>
<?php echo ($item->mencnt>0) ? $item->menlist['ullist'] : ''; ?>
<?php echo ($item->gcnt>0) ? $item->grouplist['ullist'] : ''; ?>
</details>
<br />
<?php endif; ?>
<span class="icon-calendar"></span>&nbsp;<span class="xbnit">
</div>
<div class="clearfix"></div>
<?php endif; ?>
<span class="icon-calendar xbpr10"></span>&nbsp;<span class="xbnit">
<?php echo Text::_('XBCULTURE_PUBLISHED'); ?>
</span>
<?php if($item->pubyear > 0) { echo ': '.$item->pubyear; } else { echo '<i>'.Text::_('XBCULTURE_UNKNOWN').'</i>';}?>
<br />
<span class="icon-book"></span>&nbsp;
<i class="fas fa-book xbpr10"></i>&nbsp;
<?php if($this->show_sum) : ?>
<?php if (!empty($item->summary)) : ?>
<?php echo '<i>'.Text::_('XBCULTURE_SUMMARY').'</i>: '.$item->summary; ?>
Expand All @@ -179,36 +203,56 @@
?>
</span>
<?php endif; ?>
<br />
<?php endif; ?>
<br />
<?php if($this->show_revs) : ?>
<span class="icon-pencil-2"></span> &nbsp;
<div class="pull-left"><i class="fas fa-book-reader xbpr10"></i>&nbsp;</div>
<div class="pull-left">
<?php if ($item->revcnt==0) : ?>
<i><?php echo Text::_('XBCULTURE_NO_REVIEWS_AVAILABLE'); ?></i>
<?php else : ?>
<i>
<?php if($item->revcnt==1) {
echo $item->revcnt.' '.Text::_('XBCULTURE_REVIEW_RATING');
} else {
echo $item->revcnt.' '.Text::_('XBCULTURE_REVIEWS_AVE_RATING');
} ?>
</i> &nbsp;
<?php $stars = (round(($item->averat)*2)/2);
if (($this->zero_rating) && ($stars==0)) : ?>
<span class="<?php echo $this->zero_class; ?>" style="color:red;"></span>
<?php else :
echo str_repeat('<i class="'.$this->star_class.'"></i>',intval($item->averat));
if (($item->averat - floor($item->averat))>0) : ?>
<i class="<?php echo $this->halfstar_class; ?>"></i>
<span style="color:darkgray;"> (<?php echo round($item->averat,1); ?>)</span>
<?php endif; ?>
<?php endif; ?>
<!-- TODO add links to modal review details -->
<?php if($item->revcnt==1) : ?>

<?php $stars = (round(($item->averat)*2)/2);
if (($this->zero_rating) && ($stars==0)) : ?>
<span class="<?php echo $this->zero_class; ?>" style="color:red;"></span>
<?php else :
echo str_repeat('<i class="'.$this->star_class.'"></i>',intval($item->averat));
endif;
echo ' on '.HtmlHelper::date($item->reviews[0]->rev_date , 'd M Y');?>
<?php else : ?>
<details><summary><i>
<?php echo $item->revcnt.' '.Text::_('XBCULTURE_REVIEWS_AVE_RATING');?></i>
<?php $stars = (round(($item->averat)*2)/2);
if (($this->zero_rating) && ($stars==0)) : ?>
<span class="<?php echo $this->zero_class; ?>" style="color:red;"></span>
<?php else :
echo str_repeat('<i class="'.$this->star_class.'"></i>',intval($item->averat));
if (($item->averat - floor($item->averat))>0) : ?>
<i class="<?php echo $this->halfstar_class; ?>"></i>
<span style="color:darkgray;"> (<?php echo round($item->averat,1); ?>)</span>
<?php endif; ?>
<?php endif; ?>
</summary>
<?php foreach ($item->reviews as $rev) : ?>
<?php if (($this->zero_rating) && ($rev->rating==0)) : ?>
<span class="<?php echo $this->zero_class; ?>" style="color:red;"></span>
<?php else :
echo str_repeat('<i class="'.$this->star_class.'"></i>',$rev->rating);
endif;
echo ' on '.HtmlHelper::date($item->reviews[0]->rev_date , 'd M Y');?>
<br />
<?php endforeach; ?>
</details>
<?php endif; ?>
<?php endif; ?>
<br />
</div>
<div class="clearfix"></div>
<?php endif; ?>
<?php if(($this->showcat) || ($this->showtags)) : ?>
<?php if($this->showcat) : ?>
<span class="icon-folder"></span> &nbsp;
<i class="fas fa-folder xbpr10"></i>&nbsp;
<?php if($this->showcat==2) : ?>
<a class="label label-success" href="<?php echo $clink.$item->catid; ?>"><?php echo $item->category_title; ?></a>
<?php else: ?>
Expand All @@ -217,16 +261,17 @@
<?php endif; ?>
<?php if($this->showtags) : ?>
<br />
<span class="icon-tags"></span> &nbsp;
<i class="fas fa-tags xbpr10"></i>&nbsp;
<?php $tagLayout = new FileLayout('joomla.content.tagline');
echo $tagLayout->render($item->tags); ?>
<?php endif; ?>
<?php endif; ?>
<?php if ($this->show_bdates) : ?>
<br />
<?php endif; ?>
<?php if ($this->show_bdates) : ?>
<i class="far fa-eye xbpr10"></i>&nbsp;
<?php if($item->first_read) {
$datefmt = xbCultureHelper::getDateFmt($item->first_read, 'D jS M Y');
echo '<span class="icon-eye"></span> &nbsp;<i>'.Text::_('XBBOOKS_FIRST_READ').'</i>: '.HtmlHelper::date($item->first_read , $datefmt);
echo '<i>'.Text::_('XBBOOKS_FIRST_READ').'</i>: '.HtmlHelper::date($item->first_read , $datefmt);
}
if(($item->last_read) && ($item->last_read != $item->first_read)) {
$datefmt = xbCultureHelper::getDateFmt($item->last_read, 'D jS M Y');
Expand All @@ -237,20 +282,15 @@
}
?>
<?php endif; ?>
</p>

</td></tr></table>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>




</table>

<?php echo $this->pagination->getListFooter(); ?>
<?php echo $this->pagination->getListFooter(); ?>
<?php endif; ?>
<?php echo HtmlHelper::_('form.token'); ?>
</div>
Expand Down
31 changes: 31 additions & 0 deletions src/com_xbbooks/site/views/booklist/tmpl/modalbpv.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/*******
* @package xbBooks
* @filesource admin/views/persons/tmpl/modalbpv.php
* @version 1.0.3.6 23rd January 2023
* @author Roger C-O
* @copyright Copyright (c) Roger Creagh-Osborne, 2022
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
******/
defined( '_JEXEC' ) or die( 'Restricted access' );
?>
<script>
jQuery(document).ready(function(){
jQuery('#pv').attr('src',function(i, origValue){return origValue + window.pvid;});
});
jQuery('.iframe-full-height').on('load', function(){
this.style.height=this.contentDocument.body.scrollHeight+20 +'px';
});
</script>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
style="opacity:unset;line-height:unset;border:none;">&times;</button>
<h4 class="modal-title">Preview Book</h4>
</div>
<div class="modal-body">
<div style="margin:0 30px;">
<iframe src="<?php echo JURI::root(); ?>/index.php?option=com_xbbooks&view=book&layout=default&tmpl=component&id="
title="Preview Book" id="pv" class="iframe-full-height"></iframe>
</div>
</div>

Loading

0 comments on commit 0772847

Please sign in to comment.