forked from hesstobi/herrnhuter-losung-widget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
185 lines (140 loc) · 5.39 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
/*
Plugin Name: Herrnhuter Losung
Plugin URI: https://github.com/hesstobi/herrnhuter-losung-widget
Git URI: https://github.com/hesstobi/herrnhuter-losung-widget
Description: Dieses Plugin erstellt ein Sidebar-Widget, was die heutige Losung der Herrnhuter Brüdergemeine auf der Sidebar ausgibt.
Author: Tobias Heß, Benjamin Pick, Thomas Arend
Version: 1.7.6
Author URI: http://www.tobiashess.de / https://byggvir.de
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
/**
License:
==============================================================================
Copyright 2009 Tobias Heß (email : [email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
The Losungen of the Herrnhuter Brüdergemeine are copyrighted. Owner of
copyright is the Evangelische Brüder-Unität – Herrnhuter Brüdergemeine.
The biblical texts from the Lutheran Bible, revised texts in 2017,
and from the Lutheran Bible, revised texts in 1984, revised
edition with a new spelling, subject to the copyright of the German Bible
Society, Stuttgart.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Requirements:
==============================================================================
This plugin requires WordPress >= 2.8 and tested with PHP Interpreter >= 5.2.10
*/
// Security check: Exit if script is called directly
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
define( "HHL", 'HHL_' );
require_once (dirname(__FILE__) . '/lib/xmlfilereader.php');
require_once (dirname(__FILE__) . '/lib/xml_automatic_updater.php');
class Losung_Widget extends WP_Widget {
function __construct() {
$widget_default_options = array(
'classname' => 'widget_losung',
'description' => 'Die heutige Losung der Herrnhuter Brüdergemeine'
);
parent::__construct('losung', 'Herrnhuter Losung', $widget_default_options);
new HerrnhuterLosungenPlugin_Xml_Automatic_Update();
}
function widget($args, $instance) {
$title = apply_filters('widget_title', $instance['title'] );
$showlink = isset( $instance['showlink'] ) ? $instance['showlink'] : false;
echo $args['before_widget'];
#Titel ausgeben
if ( $title )
echo $args['before_title'] . $title . $args['after_title'];
try {
$this->showLosungen($showlink);
} catch (Exception $e) {
echo $e->getMessage();
}
echo $args['after_widget'];
}
function showLosungen($showlink)
{
echo "<!-- Losung Widget Version 1.7.5 -->";
#Losung einlesen
$losungen = new HerrnhuterLosungenPlugin_Xml();
$verseFuerHeute = $losungen->getVerse();
#Losung ausgeben:
$options = array('showlink' => $showlink);
foreach ($verseFuerHeute as $name => $vers)
{
$options['css'] = 'losung-' . $name;
$text_formatted = $losungen->convertTextToHtml($vers['text']);
$this->showBibleVers($text_formatted, $vers['vers'], $options);
}
#Copyright ausgeben
?>
<p class="losung-copy">
<a href="http://www.herrnhuter.de" target="_blank" title="Evangelische Brüder-Unität">© Evangelische Brüder-Unität – Herrnhuter Brüdergemeine</a> <br>
<a href="https://www.losungen.de" target="_blank" title="www.losungen.de">Weitere Informationen finden Sie hier</a>
</p>
<?php
}
function showBibleVers($text, $vers, $options = array())
{
include(dirname(__FILE__) . '/views/frontend_verse.php');
}
/* Widget options GUI */
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = $new_instance['title'];
$instance['showlink'] = $new_instance['showlink'];
return $instance;
}
function checkIfInstalled($dates) {
$losungReader = new HerrnhuterLosungenPlugin_Xml();
$ret = array();
foreach ($dates as $date)
{
$installed = $losungReader->checkIfLosungenAvailable($date);
$ret[] = array('date' => $date, 'installed' => $installed);
}
return $ret;
}
function form($instance) {
$default = array(
'title' => 'Die heutige Losung',
'showlink' => true
);
$instance = wp_parse_args( (array) $instance, $default);
$_now = getdate();
$_nextYear = getdate(strtotime('next year'));
$installed = $this->checkIfInstalled(array($_now, $_nextYear));
include(dirname(__FILE__) . '/views/widget_options.php');
}
}
/*
* Cascading Style Sheets
*/
function add_herrnhuter_stylesheet( )
{
wp_register_style( HHL . 'StyleSheets', plugins_url( 'css/styles.css', __FILE__ ) );
wp_enqueue_style( HHL . 'StyleSheets' );
}
// Add the EVTStyleSheets
add_action( 'wp_print_styles', 'add_herrnhuter_stylesheet' );
function LosungInit() {
register_widget('Losung_Widget');
}
add_action('widgets_init', 'LosungInit');
function LosungUpdate() {
$updater = new HerrnhuterLosungenPlugin_Xml_Automatic_Update();
$updater->updater_gui();
}
add_action('widgets_admin_page', 'LosungUpdate')
?>