2016-11-27 04:20:48 +00:00
< ? php
2021-08-16 17:11:22 +00:00
/*-------------------------------------------------------------------------------------------------------------| www . vdm . io |------/
____ ____ __ __ __
/ \ _ `\ /\ _` \ __ / \ \__ __ / \ \ / \ \__
\ \ , \L\_\ __ _ __ ___ ___ ___ ___ \ \ \ / \ \ / \_\ ____\ \ , _\ _ __ / \_\ \ \____ __ __\ \ , _\ ___ _ __
\ / _\__ \ / '__`\/\`' __\ / ' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__` \ / \ \ / \ \\ \ \ / / __ ` \ / \ ` ' __\
/ \ \L\ \ / \ __ / \ \ \ / / \ \ / \ \ / \ \ / \ \L\ \ / \ \ / \ \ \ \ \_\ \ \ \ / \__ , ` \\ \ \_\ \ \ / \ \ \ \ \L\ \ \ \_\ \\ \ \_ / \ \L\ \ \ \ /
\ ` \____\ \____\\ \_\ \ \_\ \_\ \_\ \____ / \ \_\ \_\ \ \____ / \ \_\ / \____ / \ \__\\ \_\ \ \_\ \_ , __ / \ \____ / \ \__\ \____ / \ \_\
\ / _____ / \ / ____ / \ / _ / \ / _ / \ / _ / \ / _ / \ / ___ / \ / _ / \ / _ / \ / ___ / \ / _ / \ / ___ / \ / __ / \ / _ / \ / _ / \ / ___ / \ / ___ / \ / __ / \ / ___ / \ / _ /
/------------------------------------------------------------------------------------------------------------------------------------/
2024-02-10 09:13:31 +00:00
@ version 3.0 . x
2021-08-16 17:11:22 +00:00
@ created 22 nd October , 2015
@ package Sermon Distributor
@ subpackage default . php
@ author Llewellyn van der Merwe < https :// www . vdm . io />
@ copyright Copyright ( C ) 2015. All Rights Reserved
@ license GNU / GPL Version 2 or later - http :// www . gnu . org / licenses / gpl - 2.0 . html
A sermon distributor that links to Dropbox .
/----------------------------------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined ( '_JEXEC' ) or die ( 'Restricted access' );
2024-02-10 09:13:31 +00:00
use Joomla\CMS\Factory ;
use Joomla\CMS\Language\Text ;
use Joomla\CMS\HTML\HTMLHelper as Html ;
use Joomla\CMS\Layout\LayoutHelper ;
use Joomla\CMS\Router\Route ;
use VDM\Joomla\Utilities\ArrayHelper ;
use VDM\Joomla\Utilities\StringHelper ;
Html :: addIncludePath ( JPATH_COMPONENT . '/helpers/html' );
Html :: _ ( 'behavior.formvalidator' );
Html :: _ ( 'formbehavior.chosen' , 'select' );
Html :: _ ( 'behavior.keepalive' );
2016-11-27 04:20:48 +00:00
// get the needed module for translation
2021-08-16 17:11:22 +00:00
$model = SermondistributorHelper :: getModel ( 'external_sources' );
?>
2016-11-27 04:20:48 +00:00
< ? php if ( $this -> canDo -> get ( 'manual_updater.access' )) : ?>
< script type = " text/javascript " >
Joomla . submitbutton = function ( task ) {
2017-02-17 20:21:37 +00:00
if ( task === 'manual_updater.back' ) {
2016-11-27 04:20:48 +00:00
parent . history . back ();
return false ;
} else {
var form = document . getElementById ( 'adminForm' );
form . task . value = task ;
form . submit ();
}
}
2021-08-16 17:11:22 +00:00
</ script >
2024-02-10 09:13:31 +00:00
< form action = " <?php echo Route::_('index.php?option=com_sermondistributor&view=manual_updater'); ?> " method = " post " name = " adminForm " id = " adminForm " class = " form-validate " enctype = " multipart/form-data " >
2020-05-30 21:39:43 +00:00
2024-02-10 09:13:31 +00:00
< ? php if ( isset ( $this -> items ) && ArrayHelper :: check ( $this -> items )) : ?>
2016-11-27 04:20:48 +00:00
< script type = " text/javascript " >
// Add spindle-wheel for update:
jQuery ( document ) . ready ( function ( $ ) {
// waiting spinner
var outerDiv = jQuery ( 'body' );
jQuery ( '<div id="loading"></div>' )
. css ( " background " , " rgba(255, 255, 255, .8) url('components/com_sermondistributor/assets/images/import.gif') 50% 15% no-repeat " )
. css ( " top " , outerDiv . position () . top - jQuery ( window ) . scrollTop ())
. css ( " left " , outerDiv . position () . left - jQuery ( window ) . scrollLeft ())
. css ( " width " , outerDiv . width ())
. css ( " height " , outerDiv . height ())
. css ( " position " , " fixed " )
. css ( " opacity " , " 0.80 " )
. css ( " -ms-filter " , " progid:DXImageTransform.Microsoft.Alpha(Opacity = 80) " )
. css ( " filter " , " alpha(opacity = 80) " )
. css ( " display " , " none " )
. appendTo ( outerDiv );
jQuery ( '#loading' ) . show ();
// when page is ready remove and show
jQuery ( window ) . load ( function () {
jQuery ( '#sermondistributor_loader' ) . fadeIn ( 'fast' );
jQuery ( '#loading' ) . hide ();
});
});
</ script >
< div id = " sermondistributor_loader " >
2024-02-10 09:13:31 +00:00
< ? php echo Html :: _ ( 'bootstrap.startAccordion' , 'dashboard' ); ?>
2016-11-27 04:20:48 +00:00
< ? php foreach ( $this -> items as $item ) : ?>
2024-02-10 09:13:31 +00:00
< ? php $key = StringHelper :: safe ( $item -> description ) . $item -> id ; ?>
< ? php $name = '<div id="heading_' . $key . '">' . $item -> description . ' <small>(' . Text :: _ ( $model -> selectionTranslation ( $item -> build , 'build' )) . ')</small></div>' ; ?>
< ? php echo Html :: _ ( 'bootstrap.addSlide' , 'dashboard' , $name , $key ); ?>
2016-11-27 04:20:48 +00:00
< div class = " uk-form-row " >
< label class = " uk-form-label " >
2024-02-10 09:13:31 +00:00
< ? php echo Text :: _ ( 'COM_SERMONDISTRIBUTOR_ADD_THE_STRONGAPP_GENERATED_ACCESS_TOKENSTRONG_HERE' ); ?>
2016-11-27 04:20:48 +00:00
</ label >
< input
class = " span12 "
type = " text "
id = " sleutel-<?php echo $item->id ; ?> "
2024-02-10 09:13:31 +00:00
placeholder = " <?php echo Text::_('COM_SERMONDISTRIBUTOR_ADD_TOKEN_HERE'); ?> "
2016-11-27 04:20:48 +00:00
>
</ div >
< div class = " alert alert-info " >
2024-02-10 09:13:31 +00:00
< p >< ? php echo Text :: _ ( 'COM_SERMONDISTRIBUTOR_BY_USING_AN_ACCESS_TOKEN_YOU_WILL_BE_ABLE_TO_MAKE_API_CALLS_FOR_YOUR_OWN_ACCOUNT_WITHOUT_GOING_THROUGH_THE_AUTHORIZATION_FLOW_DURING_THIS_MANUAL_UPDATE_OF_THE_LOCAL_LISTINGBR_THE_TOKEN_WILL_NOT_BE_STORED_AND_FOR_SAFETY_THE_TOKEN_WILL_BE_REVOKED_ONCE_THE_UPDATE_IS_COMPLETED_SUCCESSFULLYBR_BTHIS_WILL_MEAN_IT_CAN_ONLY_BE_USED_THIS_ONCEB_YOU_WOULD_NEED_A_NEW_TOKEN_EACH_TIME_YOU_RUN_THIS_UPDATE_MANUALLY_BR_SMALLMAKE_SURE_TO_HAVE_SSL_INPLACE_ON_THIS_PAGE_WHEN_DOING_THIS_UPDATE_AS_AN_EXTRA_SECURITY_MEASURESMALL' ); ?> </p>
2016-11-27 04:20:48 +00:00
</ div >
< ? php $targets = SermondistributorHelper :: getExternalListingUpdateKeys ( $item -> id , 1 , 2 ); ?>
2024-02-10 09:13:31 +00:00
< ? php if ( ArrayHelper :: check ( $targets )) : ?>
2016-11-27 04:20:48 +00:00
< ? php foreach ( $targets as $target ) : ?>
2016-12-05 07:40:19 +00:00
< ? php $error = SermondistributorHelper :: getUpdateError ( 0 , $item -> id . $target . $item -> build ); ?>
2024-02-10 09:13:31 +00:00
< ? php if ( StringHelper :: check ( $error )) : ?>
< ? php $errorKey = StringHelper :: safe ( $item -> id . $target . $item -> build ); ?>
< a class = " btn btn-danger " href = " #<?php echo 'error'. $errorKey ; ?> " data - toggle = " modal " >< ? php echo Text :: _ ( 'COM_SERMONDISTRIBUTOR_VIEW_ERROR' ); ?> </a>
< ? php echo Html :: _ ( 'bootstrap.renderModal' , 'error' . $errorKey , array ( 'title' => Text :: _ ( 'COM_SERMONDISTRIBUTOR_THERE_WAS_AN_ERROR_DURING_THE_LAST_UPDATE_ATTEMPT' )), $error ); ?>
2016-11-27 04:20:48 +00:00
< ? php endif ; ?>
< button onclick = " updateLocalLinks('sleutel-<?php echo $item->id ; ?>', <?php echo $target ; ?>, <?php echo $item->id ; ?>, <?php echo $item->build ; ?>) " class = " btn btn-big " >
< span class = " icon-cog " ></ span >
2024-02-10 09:13:31 +00:00
< ? php echo Text :: sprintf ( 'COM_SERMONDISTRIBUTOR_UPDATE_LOCAL_LINKS_OF_TARGET_S_EXTERNAL_SOURCE' , $target ); ?>
2016-11-27 04:20:48 +00:00
</ button >
< ? php endforeach ; ?>
< ? php else : ?>
2024-02-10 09:13:31 +00:00
< ? php echo Text :: _ ( 'COM_SERMONDISTRIBUTOR_THERE_HAS_NO_TARGETS_BEEN_SET_PLEASE_MAKE_SURE_TO_ADD_TARGETS_TO_THIS_EXTERNAL_SOURCE' ); ?>
2016-11-27 04:20:48 +00:00
< ? php endif ; ?>
2024-02-10 09:13:31 +00:00
< ? php echo Html :: _ ( 'bootstrap.endSlide' ); ?>
2016-11-27 04:20:48 +00:00
< ? php endforeach ; ?>
2024-02-10 09:13:31 +00:00
< ? php echo Html :: _ ( 'bootstrap.endAccordion' ); ?>
2016-11-27 04:20:48 +00:00
</ div >
< div id = " uploader " style = " display:none; " >
2024-02-10 09:13:31 +00:00
< center >< h1 >< ? php echo Text :: _ ( 'COM_SERMONDISTRIBUTOR_THE_UPDATE_IS_RUNNING' ); ?> <span class="loading-dots">.</span></h1><p><b>You can close the browser window!</b><br />This update will continue to run in the background on the server (and can take hours).<br />Check again latter since time of completion, or any errors will be logged and displayed here.</p></center>
2016-11-27 04:20:48 +00:00
</ div >
< script >
// token
var token = '<?php echo JSession::getFormToken(); ?>' ;
// 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 );
});
function updateLocalLinks ( fieldId , target , id , type )
{
var sleutel = jQuery ( '#' + fieldId ) . val ();
jQuery ( '#error-key' ) . remove ();
if ( sleutel === '' ) {
jQuery ( '#' + fieldId ) . closest ( 'div' ) . prepend ( '<span id="error-key" style="color:red;"><b>No token was added, please add the token and try again.</b></span>' );
} else {
jQuery ( '#sermondistributor_loader' ) . hide ();
jQuery ( '#loading' ) . css ( 'display' , 'block' );
jQuery ( '#uploader' ) . show ();
server_updateLocalLinks ( target , type , id , sleutel ) . done ( function ( result ) {
jQuery ( '#sermondistributor_loader' ) . show ();
jQuery ( '#loading' ) . css ( 'display' , 'none' );
jQuery ( '#uploader' ) . hide ();
if ( result . success ) {
var message = [ '<h3>The update was successfully completed.</h3>' ];
Joomla . renderMessages ({ 'success' : message });
} else {
var message = [];
if ( result . error ) {
message . push ( result . error );
message . push ( '<h3>The update is unable to run, this could be because of the following reasons:</h3>' );
} else {
message . push ( '<h3>An unknown error has occurred.</h3>' );
}
Joomla . renderMessages ({ 'error' : message });
}
});
}
2017-08-18 11:20:01 +00:00
return false ;
2016-11-27 04:20:48 +00:00
}
function server_updateLocalLinks ( target , type , id , sleutel )
{
var getUrl = 'index.php?option=com_sermondistributor&task=ajax.updateLocalListingExternal&format=json' ;
if ( id > 0 && token . length == 32 && type > 0 && target > 0 ){
var request = 'token=' + token + '&target=' + target + '&type=' + type + '&id=' + id + '&sleutel=' + sleutel ;
}
return jQuery . ajax ({
type : 'GET' ,
url : getUrl ,
dataType : 'jsonp' ,
data : request ,
jsonp : 'callback'
});
}
</ script >
< ? php else : ?>
< div class = " uk-alert uk-alert-success " data - uk - alert >
2024-02-10 09:13:31 +00:00
< p >< ? php echo Text :: _ ( 'COM_SERMONDISTRIBUTOR_NO_MANUAL_UPDATES_AVAILABLE' ); ?> </p>
2016-11-27 04:20:48 +00:00
</ div >
2020-05-30 21:39:43 +00:00
< ? php endif ; ?>
< input type = " hidden " name = " task " value = " " />
2024-02-10 09:13:31 +00:00
< ? php echo Html :: _ ( 'form.token' ); ?>
2021-08-16 17:11:22 +00:00
</ form >
< ? php else : ?>
2024-02-10 09:13:31 +00:00
< h1 >< ? php echo Text :: _ ( 'COM_SERMONDISTRIBUTOR_NO_ACCESS_GRANTED' ); ?> </h1>
2021-08-16 17:11:22 +00:00
< ? php endif ; ?>