2015-11-30 21:30:54 +00:00
|
|
|
<?php
|
2018-03-19 22:24:44 +00:00
|
|
|
/*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/
|
|
|
|
____ ____ __ __ __
|
|
|
|
/\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__
|
|
|
|
\ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __
|
|
|
|
\/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\
|
|
|
|
/\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/
|
|
|
|
\ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\
|
|
|
|
\/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/
|
|
|
|
|
|
|
|
/------------------------------------------------------------------------------------------------------------------------------------/
|
2015-11-30 21:30:54 +00:00
|
|
|
|
2018-03-03 16:43:27 +00:00
|
|
|
@version 2.0.x
|
2015-11-30 21:30:54 +00:00
|
|
|
@created 22nd October, 2015
|
|
|
|
@package Sermon Distributor
|
|
|
|
@subpackage sermondistributor.php
|
|
|
|
@author Llewellyn van der Merwe <https://www.vdm.io/>
|
|
|
|
@copyright Copyright (C) 2015. All Rights Reserved
|
2015-12-23 12:44:56 +00:00
|
|
|
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
|
|
|
|
A sermon distributor that links to Dropbox.
|
|
|
|
|
2018-03-19 22:24:44 +00:00
|
|
|
/----------------------------------------------------------------------------------------------------------------------------------*/
|
2015-11-30 21:30:54 +00:00
|
|
|
|
|
|
|
// No direct access to this file
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sermondistributor Model
|
|
|
|
*/
|
|
|
|
class SermondistributorModelSermondistributor extends JModelList
|
|
|
|
{
|
|
|
|
public function getIcons()
|
|
|
|
{
|
2018-03-03 16:43:27 +00:00
|
|
|
// load user for access menus
|
|
|
|
$user = JFactory::getUser();
|
|
|
|
// reset icon array
|
2015-11-30 21:30:54 +00:00
|
|
|
$icons = array();
|
2018-03-03 16:43:27 +00:00
|
|
|
// view groups array
|
2015-11-30 21:30:54 +00:00
|
|
|
$viewGroups = array(
|
2016-11-27 04:20:48 +00:00
|
|
|
'main' => array('png.preacher.add', 'png.preachers', 'png.sermon.add', 'png.sermons', 'png.sermons.catid', 'png.series.add', 'png.series_list', 'png.statistics', 'png.external_source.add', 'png.external_sources', 'png.manual_updater', 'png.local_listings', 'png.help_documents')
|
2015-11-30 21:30:54 +00:00
|
|
|
);
|
2016-07-16 12:19:44 +00:00
|
|
|
// view access array
|
2015-11-30 21:30:54 +00:00
|
|
|
$viewAccess = array(
|
2016-11-27 04:20:48 +00:00
|
|
|
'manual_updater.access' => 'manual_updater.access',
|
|
|
|
'manual_updater.submenu' => 'manual_updater.submenu',
|
|
|
|
'manual_updater.dashboard_list' => 'manual_updater.dashboard_list',
|
2015-11-30 21:30:54 +00:00
|
|
|
'preacher.create' => 'preacher.create',
|
|
|
|
'preachers.access' => 'preacher.access',
|
|
|
|
'preacher.access' => 'preacher.access',
|
|
|
|
'preachers.submenu' => 'preacher.submenu',
|
|
|
|
'preachers.dashboard_list' => 'preacher.dashboard_list',
|
|
|
|
'preacher.dashboard_add' => 'preacher.dashboard_add',
|
|
|
|
'sermon.create' => 'sermon.create',
|
|
|
|
'sermons.access' => 'sermon.access',
|
|
|
|
'sermon.access' => 'sermon.access',
|
|
|
|
'sermons.submenu' => 'sermon.submenu',
|
|
|
|
'sermons.dashboard_list' => 'sermon.dashboard_list',
|
|
|
|
'sermon.dashboard_add' => 'sermon.dashboard_add',
|
|
|
|
'series.create' => 'series.create',
|
|
|
|
'series_list.access' => 'series.access',
|
|
|
|
'series.access' => 'series.access',
|
|
|
|
'series_list.submenu' => 'series.submenu',
|
|
|
|
'series_list.dashboard_list' => 'series.dashboard_list',
|
|
|
|
'series.dashboard_add' => 'series.dashboard_add',
|
|
|
|
'statistic.create' => 'statistic.create',
|
|
|
|
'statistics.access' => 'statistic.access',
|
|
|
|
'statistic.access' => 'statistic.access',
|
|
|
|
'statistics.submenu' => 'statistic.submenu',
|
|
|
|
'statistics.dashboard_list' => 'statistic.dashboard_list',
|
2016-11-27 04:20:48 +00:00
|
|
|
'external_source.create' => 'external_source.create',
|
|
|
|
'external_sources.access' => 'external_source.access',
|
|
|
|
'external_source.access' => 'external_source.access',
|
|
|
|
'external_sources.submenu' => 'external_source.submenu',
|
|
|
|
'external_sources.dashboard_list' => 'external_source.dashboard_list',
|
|
|
|
'external_source.dashboard_add' => 'external_source.dashboard_add',
|
|
|
|
'local_listing.create' => 'local_listing.create',
|
|
|
|
'local_listings.access' => 'local_listing.access',
|
|
|
|
'local_listing.access' => 'local_listing.access',
|
|
|
|
'local_listings.submenu' => 'local_listing.submenu',
|
|
|
|
'local_listings.dashboard_list' => 'local_listing.dashboard_list',
|
2015-11-30 21:30:54 +00:00
|
|
|
'help_document.create' => 'help_document.create',
|
|
|
|
'help_documents.access' => 'help_document.access',
|
|
|
|
'help_document.access' => 'help_document.access',
|
|
|
|
'help_documents.submenu' => 'help_document.submenu',
|
|
|
|
'help_documents.dashboard_list' => 'help_document.dashboard_list');
|
2018-03-19 22:24:44 +00:00
|
|
|
// loop over the $views
|
2015-11-30 21:30:54 +00:00
|
|
|
foreach($viewGroups as $group => $views)
|
2018-03-03 16:43:27 +00:00
|
|
|
{
|
2015-11-30 21:30:54 +00:00
|
|
|
$i = 0;
|
|
|
|
if (SermondistributorHelper::checkArray($views))
|
2018-03-03 16:43:27 +00:00
|
|
|
{
|
2015-11-30 21:30:54 +00:00
|
|
|
foreach($views as $view)
|
|
|
|
{
|
|
|
|
$add = false;
|
2018-03-19 22:24:44 +00:00
|
|
|
// external views (links)
|
|
|
|
if (strpos($view,'||') !== false)
|
2018-03-03 16:43:27 +00:00
|
|
|
{
|
2018-03-19 22:24:44 +00:00
|
|
|
$dwd = explode('||', $view);
|
|
|
|
if (count($dwd) == 3)
|
|
|
|
{
|
|
|
|
list($type, $name, $url) = $dwd;
|
|
|
|
$viewName = $name;
|
|
|
|
$alt = $name;
|
|
|
|
$url = $url;
|
|
|
|
$image = $name.'.'.$type;
|
|
|
|
$name = 'COM_SERMONDISTRIBUTOR_DASHBOARD_'.SermondistributorHelper::safeString($name,'U');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// internal views
|
|
|
|
elseif (strpos($view,'.') !== false)
|
|
|
|
{
|
|
|
|
$dwd = explode('.', $view);
|
|
|
|
if (count($dwd) == 3)
|
|
|
|
{
|
|
|
|
list($type, $name, $action) = $dwd;
|
|
|
|
}
|
|
|
|
elseif (count($dwd) == 2)
|
|
|
|
{
|
|
|
|
list($type, $name) = $dwd;
|
|
|
|
$action = false;
|
|
|
|
}
|
|
|
|
if ($action)
|
|
|
|
{
|
|
|
|
$viewName = $name;
|
|
|
|
switch($action)
|
2018-03-03 16:43:27 +00:00
|
|
|
{
|
2018-03-19 22:24:44 +00:00
|
|
|
case 'add':
|
|
|
|
$url = 'index.php?option=com_sermondistributor&view='.$name.'&layout=edit';
|
|
|
|
$image = $name.'_'.$action.'.'.$type;
|
|
|
|
$alt = $name.' '.$action;
|
|
|
|
$name = 'COM_SERMONDISTRIBUTOR_DASHBOARD_'.SermondistributorHelper::safeString($name,'U').'_ADD';
|
|
|
|
$add = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$url = 'index.php?option=com_categories&view=categories&extension=com_sermondistributor.'.$name;
|
|
|
|
$image = $name.'_'.$action.'.'.$type;
|
|
|
|
$alt = $name.' '.$action;
|
|
|
|
$name = 'COM_SERMONDISTRIBUTOR_DASHBOARD_'.SermondistributorHelper::safeString($name,'U').'_'.SermondistributorHelper::safeString($action,'U');
|
|
|
|
break;
|
2018-03-03 16:43:27 +00:00
|
|
|
}
|
2018-03-19 22:24:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$viewName = $name;
|
|
|
|
$alt = $name;
|
|
|
|
$url = 'index.php?option=com_sermondistributor&view='.$name;
|
|
|
|
$image = $name.'.'.$type;
|
|
|
|
$name = 'COM_SERMONDISTRIBUTOR_DASHBOARD_'.SermondistributorHelper::safeString($name,'U');
|
|
|
|
$hover = false;
|
|
|
|
}
|
2018-03-03 16:43:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$viewName = $view;
|
|
|
|
$alt = $view;
|
|
|
|
$url = 'index.php?option=com_sermondistributor&view='.$view;
|
|
|
|
$image = $view.'.png';
|
|
|
|
$name = ucwords($view).'<br /><br />';
|
|
|
|
$hover = false;
|
|
|
|
}
|
|
|
|
// first make sure the view access is set
|
|
|
|
if (SermondistributorHelper::checkArray($viewAccess))
|
|
|
|
{
|
2015-11-30 21:30:54 +00:00
|
|
|
// setup some defaults
|
|
|
|
$dashboard_add = false;
|
|
|
|
$dashboard_list = false;
|
2018-03-03 16:43:27 +00:00
|
|
|
$accessTo = '';
|
|
|
|
$accessAdd = '';
|
|
|
|
// acces checking start
|
|
|
|
$accessCreate = (isset($viewAccess[$viewName.'.create'])) ? SermondistributorHelper::checkString($viewAccess[$viewName.'.create']):false;
|
|
|
|
$accessAccess = (isset($viewAccess[$viewName.'.access'])) ? SermondistributorHelper::checkString($viewAccess[$viewName.'.access']):false;
|
2015-11-30 21:30:54 +00:00
|
|
|
// set main controllers
|
|
|
|
$accessDashboard_add = (isset($viewAccess[$viewName.'.dashboard_add'])) ? SermondistributorHelper::checkString($viewAccess[$viewName.'.dashboard_add']):false;
|
|
|
|
$accessDashboard_list = (isset($viewAccess[$viewName.'.dashboard_list'])) ? SermondistributorHelper::checkString($viewAccess[$viewName.'.dashboard_list']):false;
|
2018-03-03 16:43:27 +00:00
|
|
|
// check for adding access
|
|
|
|
if ($add && $accessCreate)
|
|
|
|
{
|
|
|
|
$accessAdd = $viewAccess[$viewName.'.create'];
|
|
|
|
}
|
|
|
|
elseif ($add)
|
|
|
|
{
|
|
|
|
$accessAdd = 'core.create';
|
|
|
|
}
|
|
|
|
// check if acces to view is set
|
|
|
|
if ($accessAccess)
|
|
|
|
{
|
|
|
|
$accessTo = $viewAccess[$viewName.'.access'];
|
|
|
|
}
|
2015-11-30 21:30:54 +00:00
|
|
|
// set main access controllers
|
|
|
|
if ($accessDashboard_add)
|
|
|
|
{
|
|
|
|
$dashboard_add = $user->authorise($viewAccess[$viewName.'.dashboard_add'], 'com_sermondistributor');
|
|
|
|
}
|
|
|
|
if ($accessDashboard_list)
|
|
|
|
{
|
|
|
|
$dashboard_list = $user->authorise($viewAccess[$viewName.'.dashboard_list'], 'com_sermondistributor');
|
|
|
|
}
|
2018-03-03 16:43:27 +00:00
|
|
|
if (SermondistributorHelper::checkString($accessAdd) && SermondistributorHelper::checkString($accessTo))
|
|
|
|
{
|
|
|
|
// check access
|
|
|
|
if($user->authorise($accessAdd, 'com_sermondistributor') && $user->authorise($accessTo, 'com_sermondistributor') && $dashboard_add)
|
|
|
|
{
|
2018-03-19 22:24:44 +00:00
|
|
|
$icons[$group][$i] = new StdClass;
|
2018-03-03 16:43:27 +00:00
|
|
|
$icons[$group][$i]->url = $url;
|
|
|
|
$icons[$group][$i]->name = $name;
|
|
|
|
$icons[$group][$i]->image = $image;
|
|
|
|
$icons[$group][$i]->alt = $alt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif (SermondistributorHelper::checkString($accessTo))
|
|
|
|
{
|
|
|
|
// check access
|
|
|
|
if($user->authorise($accessTo, 'com_sermondistributor') && $dashboard_list)
|
|
|
|
{
|
2018-03-19 22:24:44 +00:00
|
|
|
$icons[$group][$i] = new StdClass;
|
2018-03-03 16:43:27 +00:00
|
|
|
$icons[$group][$i]->url = $url;
|
|
|
|
$icons[$group][$i]->name = $name;
|
|
|
|
$icons[$group][$i]->image = $image;
|
|
|
|
$icons[$group][$i]->alt = $alt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif (SermondistributorHelper::checkString($accessAdd))
|
|
|
|
{
|
|
|
|
// check access
|
|
|
|
if($user->authorise($accessAdd, 'com_sermondistributor') && $dashboard_add)
|
|
|
|
{
|
2018-03-19 22:24:44 +00:00
|
|
|
$icons[$group][$i] = new StdClass;
|
2018-03-03 16:43:27 +00:00
|
|
|
$icons[$group][$i]->url = $url;
|
|
|
|
$icons[$group][$i]->name = $name;
|
|
|
|
$icons[$group][$i]->image = $image;
|
|
|
|
$icons[$group][$i]->alt = $alt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-19 22:24:44 +00:00
|
|
|
$icons[$group][$i] = new StdClass;
|
2018-03-03 16:43:27 +00:00
|
|
|
$icons[$group][$i]->url = $url;
|
|
|
|
$icons[$group][$i]->name = $name;
|
|
|
|
$icons[$group][$i]->image = $image;
|
|
|
|
$icons[$group][$i]->alt = $alt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-19 22:24:44 +00:00
|
|
|
$icons[$group][$i] = new StdClass;
|
2018-03-03 16:43:27 +00:00
|
|
|
$icons[$group][$i]->url = $url;
|
|
|
|
$icons[$group][$i]->name = $name;
|
|
|
|
$icons[$group][$i]->image = $image;
|
|
|
|
$icons[$group][$i]->alt = $alt;
|
|
|
|
}
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$icons[$group][$i] = false;
|
2015-11-30 21:30:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $icons;
|
2016-11-02 00:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-03-03 16:43:27 +00:00
|
|
|
|
2016-11-02 00:18:26 +00:00
|
|
|
public function getGithub()
|
|
|
|
{
|
2017-08-24 17:34:17 +00:00
|
|
|
// load jquery (not sure why... but else the timeago breaks)
|
|
|
|
JHtml::_('jquery.framework');
|
|
|
|
// get the document to load the scripts
|
2016-11-02 00:18:26 +00:00
|
|
|
$document = JFactory::getDocument();
|
2017-08-24 17:34:17 +00:00
|
|
|
$document->addScript(JURI::root() . "media/com_sermondistributor/js/timeago.js");
|
2016-11-02 00:18:26 +00:00
|
|
|
$document->addScriptDeclaration('
|
|
|
|
var urlToGetAllOpenIssues = "https://api.github.com/repos/SermonDistributor/Joomla-3-Component/issues?state=open&page=1&per_page=5";
|
|
|
|
var urlToGetAllClosedIssues = "https://api.github.com/repos/SermonDistributor/Joomla-3-Component/issues?state=closed&page=1&per_page=5";
|
2017-08-24 17:34:17 +00:00
|
|
|
var urlToGetAllReleases = "https://api.github.com/repos/SermonDistributor/Joomla-3-Component/releases?page=1&per_page=5";
|
2016-11-02 00:18:26 +00:00
|
|
|
jQuery(document).ready(function () {
|
|
|
|
jQuery.getJSON(urlToGetAllOpenIssues, function (openissues) {
|
|
|
|
jQuery("#openissues").html("");
|
|
|
|
jQuery.each(openissues, function (i, issue) {
|
2017-08-24 17:34:17 +00:00
|
|
|
// set time ago
|
|
|
|
var timeago = jQuery.timeago(new Date(issue.created_at));
|
2016-11-02 00:18:26 +00:00
|
|
|
jQuery("#openissues")
|
|
|
|
.append("<h3><a href=\"" + issue.html_url + "\" target=\"_blank\">" + issue.title + "</a></h3>")
|
2017-08-24 17:34:17 +00:00
|
|
|
.append("<img alt=\"@" + issue.user.login + "\" style=\"vertical-align: baseline;\" src=\"" + issue.user.avatar_url +"&s=60\" width=\"30\" height=\"30\"> ")
|
2018-03-03 16:43:27 +00:00
|
|
|
.append("<em><a href=\"" + issue.user.html_url + "\" target=\"_blank\">" + issue.user.login + "</a> '.JText::_('COM_SERMONDISTRIBUTOR_OPENED_THIS').' <a href=\"" + issue.html_url + "\" target=\"_blank\">'.JText::_('COM_SERMONDISTRIBUTOR_ISSUE').'-" + issue.number + "</a> (" + timeago + ")</em> ")
|
2016-11-02 00:18:26 +00:00
|
|
|
.append(marked(issue.body))
|
2017-08-24 17:34:17 +00:00
|
|
|
.append("<a href=\"" + issue.html_url + "\" target=\"_blank\"><span class=\'icon-new-tab\'></span>'.JText::_('COM_SERMONDISTRIBUTOR_RESPOND_TO_THIS_ISSUE_ON_GITHUB').'</a>...<hr />");
|
2016-11-02 00:18:26 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
jQuery.getJSON(urlToGetAllClosedIssues, function (closedissues) {
|
|
|
|
jQuery("#closedissues").html("");
|
|
|
|
jQuery.each(closedissues, function (i, issue) {
|
2017-08-24 17:34:17 +00:00
|
|
|
// set time ago
|
|
|
|
var timeago = jQuery.timeago(new Date(issue.created_at));
|
2016-11-02 00:18:26 +00:00
|
|
|
jQuery("#closedissues")
|
|
|
|
.append("<h3><a href=\"" + issue.html_url + "\" target=\"_blank\">" + issue.title + "</a></h3>")
|
2017-08-24 17:34:17 +00:00
|
|
|
.append("<img alt=\"@" + issue.user.login + "\" style=\"vertical-align: baseline;\" src=\"" + issue.user.avatar_url +"&s=60\" width=\"30\" height=\"30\"> ")
|
|
|
|
.append("<em><a href=\"" + issue.user.html_url + "\" target=\"_blank\">" + issue.user.login + "</a> '.JText::_('COM_SERMONDISTRIBUTOR_OPENED').' <a href=\"" + issue.html_url + "\" target=\"_blank\">'.JText::_('COM_SERMONDISTRIBUTOR_ISSUE').'-" + issue.number + "</a> (" + timeago + ")</em>")
|
2016-11-02 00:18:26 +00:00
|
|
|
.append(marked(issue.body))
|
2017-08-24 17:34:17 +00:00
|
|
|
.append("<a href=\"" + issue.html_url + "\" target=\"_blank\"><span class=\'icon-new-tab\'></span>'.JText::_('COM_SERMONDISTRIBUTOR_REVIEW_THIS_ISSUE_ON_GITHUB').'</a>...<hr />");
|
2016-11-02 00:18:26 +00:00
|
|
|
});
|
|
|
|
});
|
2017-08-24 17:34:17 +00:00
|
|
|
jQuery.getJSON(urlToGetAllReleases, function (tagreleases) {
|
|
|
|
// set the update notice while we are at it
|
|
|
|
var activeVersion = tagreleases[0].tag_name.substring(1);
|
|
|
|
if (activeVersion === manifest.version) {
|
2018-03-03 16:43:27 +00:00
|
|
|
// local version is in sync with latest release
|
2017-08-24 17:34:17 +00:00
|
|
|
jQuery(".update-notice").html("<small><span style=\'color:green;\'><span class=\'icon-shield\'></span>'.JText::_('COM_SERMONDISTRIBUTOR_UP_TO_DATE').'</span></small>");
|
|
|
|
} else {
|
2018-03-03 16:43:27 +00:00
|
|
|
// split versions in to array
|
|
|
|
var activeVersionArray = activeVersion.split(".");
|
|
|
|
var localVersionArray = manifest.version.split(".");
|
|
|
|
if ((+localVersionArray[0] > +activeVersionArray[0]) ||
|
|
|
|
(+localVersionArray[0] == +activeVersionArray[0] && +localVersionArray[1] > +activeVersionArray[1]) ||
|
|
|
|
(+localVersionArray[0] == +activeVersionArray[0] && +localVersionArray[1] == +activeVersionArray[1] && +localVersionArray[2] > +activeVersionArray[2])) {
|
|
|
|
// local version head latest release
|
|
|
|
jQuery(".update-notice").html("<small><span style=\'color:#F7B033;\'><span class=\'icon-wrench\'></span>'.JText::_('COM_SERMONDISTRIBUTOR_BETA_RELEASE').'</span></small>");
|
|
|
|
} else {
|
|
|
|
// local version behind latest release
|
|
|
|
jQuery(".update-notice").html("<small><span style=\'color:red;\'><span class=\'icon-warning-circle\'></span>'.JText::_('COM_SERMONDISTRIBUTOR_OUT_OF_DATE').'</span></small>");
|
|
|
|
}
|
2016-11-02 00:18:26 +00:00
|
|
|
}
|
2017-08-24 17:34:17 +00:00
|
|
|
// set the taged releases
|
|
|
|
jQuery("#tagreleases").html("");
|
|
|
|
jQuery.each(tagreleases, function (i, tagrelease) {
|
|
|
|
// set active release
|
|
|
|
var activeNotice = "";
|
|
|
|
if (i === 0) {
|
|
|
|
var activeNotice = "<a class=\'btn btn-small btn-success\' href=\'https://github.com/SermonDistributor/Joomla-3-Component/releases/latest\'><span class=\'icon-shield icon-white\'></span> '.JText::_('COM_SERMONDISTRIBUTOR_LATEST_RELEASE').'</a><br /><br />";
|
|
|
|
}
|
|
|
|
// set time ago
|
|
|
|
var timeago = jQuery.timeago(new Date(tagrelease.published_at));
|
|
|
|
jQuery("#tagreleases")
|
|
|
|
.append("<h3><a href=\"" + tagrelease.html_url + "\" target=\"_blank\">" + tagrelease.name + "</a></h3>")
|
|
|
|
.append(activeNotice)
|
|
|
|
.append("<img alt=\"@" + tagrelease.author.login + "\" style=\"vertical-align: baseline;\" src=\"" + tagrelease.author.avatar_url +"&s=60\" width=\"30\" height=\"30\"> ")
|
|
|
|
.append("<em><a href=\"" + tagrelease.author.html_url + "\" target=\"_blank\">" + tagrelease.author.login + "</a> '.JText::_('COM_SERMONDISTRIBUTOR_RELEASED_THIS').'<em> <b><span class=\'icon-tag-2\'></span>" + tagrelease.tag_name+ "</b> (" + timeago + ")")
|
|
|
|
.append(marked(tagrelease.body))
|
|
|
|
.append(" <a class=\"hasTooltip\" href=\"" + tagrelease.assets[0].browser_download_url + "\" title=\"'.JText::_('COM_SERMONDISTRIBUTOR_DOWNLOAD').' " + tagrelease.assets[0].name + "\" target=\"_self\"><span class=\'icon-download\'></span>" + tagrelease.assets[0].name + "</a> (<a class=\"hasTooltip\" href=\"" + tagrelease.assets[0].browser_download_url + "\" title=\"'.JText::_('COM_SERMONDISTRIBUTOR_TOTAL_DOWNLOADS').'\"><small>" + tagrelease.assets[0].download_count + "</small></a>) ")
|
|
|
|
.append("| <a href=\"" + tagrelease.html_url + "\" target=\"_blank\" title=\"'.JText::_('COM_SERMONDISTRIBUTOR_OPEN').' " + tagrelease.name + " '.JText::_('COM_SERMONDISTRIBUTOR_ON_GITHUB').'\"><span class=\'icon-new-tab\'></span>'.JText::_('COM_SERMONDISTRIBUTOR_OPEN_ON_GITHUB').'</a>...<hr />");
|
|
|
|
});
|
|
|
|
});
|
2016-11-02 00:18:26 +00:00
|
|
|
});');
|
|
|
|
$create = '<div class="btn-group pull-right">
|
|
|
|
<a href="https://github.com/SermonDistributor/Joomla-3-Component/issues/new" class="btn btn-primary" target="_blank">'.JText::_('COM_SERMONDISTRIBUTOR_NEW_ISSUE').'</a>
|
|
|
|
</div></br >';
|
2017-08-24 17:34:17 +00:00
|
|
|
$moreopen = '<b><a href="https://github.com/SermonDistributor/Joomla-3-Component/issues" target="_blank">'.JText::_('COM_SERMONDISTRIBUTOR_VIEW_MORE_ISSUES_ON_GITHUB').'</a>...</b> ';
|
|
|
|
$moreclosed = '<b><a href="https://github.com/SermonDistributor/Joomla-3-Component/issues?q=is%3Aissue+is%3Aclosed" target="_blank">'.JText::_('COM_SERMONDISTRIBUTOR_VIEW_MORE_ISSUES_ON_GITHUB').'</a>...</b> ';
|
|
|
|
$viewissues = '<b><a href="https://github.com/SermonDistributor/Joomla-3-Component/releases" target="_blank">'.JText::_('COM_SERMONDISTRIBUTOR_VIEW_MORE_RELEASES_ON_GITHUB').'</a>...</b> ';
|
2016-11-02 00:18:26 +00:00
|
|
|
|
|
|
|
return (object) array(
|
|
|
|
'openissues' => $create.'<div id="openissues">'.JText::_('COM_SERMONDISTRIBUTOR_A_FEW_OPEN_ISSUES_FROM_GITHUB_IS_LOADING').'.<span class="loading-dots">.</span></small></div>'.$moreopen,
|
2017-08-24 17:34:17 +00:00
|
|
|
'closedissues' => $create.'<div id="closedissues">'.JText::_('COM_SERMONDISTRIBUTOR_A_FEW_CLOSED_ISSUES_FROM_GITHUB_IS_LOADING').'.<span class="loading-dots">.</span></small></div>'.$moreclosed,
|
|
|
|
'tagreleases' => '<div id="tagreleases">'.JText::_('COM_SERMONDISTRIBUTOR_LAST_FEW_RELEASES_FROM_GITHUB_IS_LOADING').'.<span class="loading-dots">.</span></small></div>'.$viewissues
|
2016-11-02 00:18:26 +00:00
|
|
|
);
|
2018-03-03 16:43:27 +00:00
|
|
|
}
|
|
|
|
|
2016-11-02 00:18:26 +00:00
|
|
|
public function getWiki()
|
|
|
|
{
|
|
|
|
$document = JFactory::getDocument();
|
|
|
|
$document->addScriptDeclaration('
|
|
|
|
var gewiki = "https://raw.githubusercontent.com/wiki/SermonDistributor/Joomla-3-Component/Home.md";
|
|
|
|
jQuery(document).ready(function () {
|
|
|
|
jQuery.get(gewiki)
|
|
|
|
.success(function(wiki) {
|
|
|
|
jQuery("#wiki-md").html(marked(wiki));
|
|
|
|
})
|
|
|
|
.error(function(jqXHR, textStatus, errorThrown) {
|
|
|
|
jQuery("#wiki-md").html("'.JText::_('COM_SERMONDISTRIBUTOR_PLEASE_CHECK_AGAIN_LATTER').'");
|
|
|
|
});
|
|
|
|
});');
|
|
|
|
|
2017-08-24 17:34:17 +00:00
|
|
|
return '<div id="wiki-md"><small>'.JText::_('COM_SERMONDISTRIBUTOR_THE_WIKI_IS_LOADING').'.<span class="loading-dots">.</span></small></div>';
|
2016-11-02 00:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-03-03 16:43:27 +00:00
|
|
|
|
|
|
|
|
2016-11-02 00:18:26 +00:00
|
|
|
public function getNoticeboard()
|
|
|
|
{
|
2017-08-24 17:34:17 +00:00
|
|
|
// get the document to load the scripts
|
2016-11-02 00:18:26 +00:00
|
|
|
$document = JFactory::getDocument();
|
2017-08-24 17:34:17 +00:00
|
|
|
$document->addScript(JURI::root() . "media/com_sermondistributor/js/marked.js");
|
2016-11-02 00:18:26 +00:00
|
|
|
$document->addScriptDeclaration('
|
2017-08-24 17:34:17 +00:00
|
|
|
var token = "'.JSession::getFormToken().'";
|
2020-01-05 22:53:13 +00:00
|
|
|
var noticeboard = "https://vdm.bz/sermondistributor-noticeboard-md";
|
2016-11-02 00:18:26 +00:00
|
|
|
jQuery(document).ready(function () {
|
|
|
|
jQuery.get(noticeboard)
|
|
|
|
.success(function(board) {
|
|
|
|
if (board.length > 5) {
|
|
|
|
jQuery("#noticeboard-md").html(marked(board));
|
|
|
|
getIS(1,board).done(function(result) {
|
|
|
|
if (result){
|
|
|
|
jQuery("#cpanel_tabTabs a").each(function() {
|
2018-03-03 16:43:27 +00:00
|
|
|
if (this.href.indexOf("#vast_development_method") >= 0 || this.href.indexOf("#notice_board") >= 0) {
|
2016-11-02 00:18:26 +00:00
|
|
|
var textVDM = jQuery(this).text();
|
|
|
|
jQuery(this).html("<span class=\"label label-important vdm-new-notice\">1</span> "+textVDM);
|
|
|
|
jQuery(this).attr("id","vdm-new-notice");
|
|
|
|
jQuery("#vdm-new-notice").click(function() {
|
|
|
|
getIS(2,board).done(function(result) {
|
|
|
|
if (result) {
|
|
|
|
jQuery(".vdm-new-notice").fadeOut(500);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
jQuery("#noticeboard-md").html("'.JText::_('COM_SERMONDISTRIBUTOR_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATTER').'");
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.error(function(jqXHR, textStatus, errorThrown) {
|
|
|
|
jQuery("#noticeboard-md").html("'.JText::_('COM_SERMONDISTRIBUTOR_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATTER').'");
|
|
|
|
});
|
2017-08-24 17:34:17 +00:00
|
|
|
});
|
|
|
|
// to check is READ/NEW
|
|
|
|
function getIS(type,notice){
|
|
|
|
if(type == 1){
|
2020-01-05 22:53:13 +00:00
|
|
|
var getUrl = "index.php?option=com_sermondistributor&task=ajax.isNew&format=json&raw=true";
|
2017-08-24 17:34:17 +00:00
|
|
|
} else if (type == 2) {
|
2020-01-05 22:53:13 +00:00
|
|
|
var getUrl = "index.php?option=com_sermondistributor&task=ajax.isRead&format=json&raw=true";
|
2017-08-24 17:34:17 +00:00
|
|
|
}
|
|
|
|
if(token.length > 0 && notice.length){
|
|
|
|
var request = "token="+token+"¬ice="+notice;
|
|
|
|
}
|
|
|
|
return jQuery.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: getUrl,
|
2020-01-05 22:53:13 +00:00
|
|
|
dataType: "json",
|
2017-08-24 17:34:17 +00:00
|
|
|
data: request,
|
2020-01-05 22:53:13 +00:00
|
|
|
jsonp: false
|
2017-08-24 17:34:17 +00:00
|
|
|
});
|
|
|
|
}
|
2020-01-05 22:53:13 +00:00
|
|
|
|
|
|
|
// nice little dot trick :)
|
|
|
|
jQuery(document).ready( function($) {
|
|
|
|
var x=0;
|
|
|
|
setInterval(function() {
|
|
|
|
var dots = "";
|
|
|
|
x++;
|
|
|
|
for (var y=0; y < x%8; y++) {
|
|
|
|
dots+=".";
|
|
|
|
}
|
|
|
|
$(".loading-dots").text(dots);
|
|
|
|
} , 500);
|
|
|
|
});');
|
2016-11-02 00:18:26 +00:00
|
|
|
|
|
|
|
return '<div id="noticeboard-md">'.JText::_('COM_SERMONDISTRIBUTOR_THE_NOTICE_BOARD_IS_LOADING').'.<span class="loading-dots">.</span></small></div>';
|
2018-03-03 16:43:27 +00:00
|
|
|
}
|
|
|
|
|
2017-08-24 17:34:17 +00:00
|
|
|
public function getReadme()
|
|
|
|
{
|
|
|
|
$document = JFactory::getDocument();
|
|
|
|
$document->addScriptDeclaration('
|
|
|
|
var getreadme = "'. JURI::root() . 'administrator/components/com_sermondistributor/README.txt";
|
|
|
|
jQuery(document).ready(function () {
|
|
|
|
jQuery.get(getreadme)
|
|
|
|
.success(function(readme) {
|
|
|
|
jQuery("#readme-md").html(marked(readme));
|
|
|
|
})
|
|
|
|
.error(function(jqXHR, textStatus, errorThrown) {
|
|
|
|
jQuery("#readme-md").html("'.JText::_('COM_SERMONDISTRIBUTOR_PLEASE_CHECK_AGAIN_LATTER').'");
|
|
|
|
});
|
|
|
|
});');
|
|
|
|
|
|
|
|
return '<div id="readme-md"><small>'.JText::_('COM_SERMONDISTRIBUTOR_THE_README_IS_LOADING').'.<span class="loading-dots">.</span></small></div>';
|
2018-03-03 16:43:27 +00:00
|
|
|
}
|
2015-11-30 21:30:54 +00:00
|
|
|
}
|