forked from friendica/deprecated-addons
Moved widgets and remote permissions to the deprecated addons
This commit is contained in:
parent
46ef41508e
commit
6d2a6408e8
55 changed files with 1762 additions and 0 deletions
57
widgets/lang/C/messages.po
Normal file
57
widgets/lang/C/messages.po
Normal file
|
@ -0,0 +1,57 @@
|
|||
# ADDON widgets
|
||||
# Copyright (C)
|
||||
# This file is distributed under the same license as the Friendica widgets addon package.
|
||||
#
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2021-02-01 18:16+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
|
||||
#: widget_friendheader.php:50
|
||||
msgid "Get added to this list!"
|
||||
msgstr ""
|
||||
|
||||
#: widget_friends.php:53
|
||||
msgid "Connect on Friendica!"
|
||||
msgstr ""
|
||||
|
||||
#: widget_like.php:56
|
||||
#, php-format
|
||||
msgid "%d person doesn't like this"
|
||||
msgid_plural "%d people don't like this"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
#: widget_like.php:66
|
||||
#, php-format
|
||||
msgid "%d person likes this"
|
||||
msgid_plural "%d people like this"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
#: widgets.php:59
|
||||
msgid "Generate new key"
|
||||
msgstr ""
|
||||
|
||||
#: widgets.php:61
|
||||
msgid "Widgets key"
|
||||
msgstr ""
|
||||
|
||||
#: widgets.php:63
|
||||
msgid "Widgets available"
|
||||
msgstr ""
|
||||
|
||||
#: widgets.php:124
|
||||
msgid "Addon Settings"
|
||||
msgstr ""
|
10
widgets/lang/ca/strings.php
Normal file
10
widgets/lang/ca/strings.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
$a->strings["%d person likes this"] = "Array";
|
||||
$a->strings["%d person doesn't like this"] = "Array";
|
||||
$a->strings["Connect on Friendica!"] = "Connectar en Friendica";
|
||||
$a->strings["Generate new key"] = "Generar nova clau";
|
||||
$a->strings["Widgets key"] = "Ginys clau";
|
||||
$a->strings["Widgets available"] = "Ginys disponibles";
|
||||
$a->strings["Addon Settings"] = "Ajustos de Addon";
|
||||
$a->strings["Get added to this list!"] = "S'afegeixen a aquesta llista!";
|
10
widgets/lang/cs/strings.php
Normal file
10
widgets/lang/cs/strings.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
$a->strings["%d person likes this"] = "Array";
|
||||
$a->strings["%d person doesn't like this"] = "Array";
|
||||
$a->strings["Connect on Friendica!"] = "Připojit na Friendica!";
|
||||
$a->strings["Generate new key"] = "Generovat nové klíče";
|
||||
$a->strings["Widgets key"] = "Widgety klíč";
|
||||
$a->strings["Widgets available"] = "Widgety k dispozici";
|
||||
$a->strings["Addon Settings"] = "Nastavení doplňku";
|
||||
$a->strings["Get added to this list!"] = "Nechte se přidat do tohoto listu!";
|
10
widgets/lang/de/strings.php
Normal file
10
widgets/lang/de/strings.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
$a->strings["%d person likes this"] = "Array";
|
||||
$a->strings["%d person doesn't like this"] = "Array";
|
||||
$a->strings["Connect on Friendica!"] = "In Friendica verbinden!";
|
||||
$a->strings["Generate new key"] = "Neuen Schlüssel erstellen";
|
||||
$a->strings["Widgets key"] = "Widgets Schlüssel";
|
||||
$a->strings["Widgets available"] = "Verfügbare Widgets";
|
||||
$a->strings["Addon Settings"] = "Addon-Einstellungen";
|
||||
$a->strings["Get added to this list!"] = "Werde Mitglied dieser Liste";
|
10
widgets/lang/eo/strings.php
Normal file
10
widgets/lang/eo/strings.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
$a->strings["%d person likes this"] = "Array";
|
||||
$a->strings["%d person doesn't like this"] = "Array";
|
||||
$a->strings["Connect on Friendica!"] = "Konekti ĉe Friendica!";
|
||||
$a->strings["Generate new key"] = "Generi novan ĉifroŝlosilon";
|
||||
$a->strings["Widgets key"] = "Ŝlosilo por fenestraĵoj";
|
||||
$a->strings["Widgets available"] = "Disponeblaj fenestraĵoj";
|
||||
$a->strings["Addon Settings"] = "Kromprogramoagordoj";
|
||||
$a->strings["Get added to this list!"] = "Iĝu membro de ĉi tiu listo!";
|
10
widgets/lang/es/strings.php
Normal file
10
widgets/lang/es/strings.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
$a->strings["%d person likes this"] = "Array";
|
||||
$a->strings["%d person doesn't like this"] = "Array";
|
||||
$a->strings["Connect on Friendica!"] = "¡Conéctate en Friendica!";
|
||||
$a->strings["Generate new key"] = "Generar clave nueva";
|
||||
$a->strings["Widgets key"] = "Clave de aplicaciones";
|
||||
$a->strings["Widgets available"] = "Aplicaciones disponibles";
|
||||
$a->strings["Addon Settings"] = "Configuración de los módulos";
|
||||
$a->strings["Get added to this list!"] = "¡Añadido a la lista!";
|
10
widgets/lang/fr/strings.php
Normal file
10
widgets/lang/fr/strings.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
$a->strings["%d person likes this"] = "Array";
|
||||
$a->strings["%d person doesn't like this"] = "Array";
|
||||
$a->strings["Connect on Friendica!"] = "Se connecter sur Friendica!";
|
||||
$a->strings["Generate new key"] = "Générer une nouvelle clé";
|
||||
$a->strings["Widgets key"] = "Clé des widgets";
|
||||
$a->strings["Widgets available"] = "Widgets disponibles";
|
||||
$a->strings["Addon Settings"] = "Extensions";
|
||||
$a->strings["Get added to this list!"] = "Ajoutez-vous à cette liste!";
|
10
widgets/lang/is/strings.php
Normal file
10
widgets/lang/is/strings.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
$a->strings["%d person likes this"] = "Array";
|
||||
$a->strings["%d person doesn't like this"] = "Array";
|
||||
$a->strings["Connect on Friendica!"] = "Tengist á Friendica!";
|
||||
$a->strings["Generate new key"] = "Búa til nýjan lykil";
|
||||
$a->strings["Widgets key"] = "Lykill smáforrits ";
|
||||
$a->strings["Widgets available"] = "Smáforrit til";
|
||||
$a->strings["Addon Settings"] = "Eininga stillingar";
|
||||
$a->strings["Get added to this list!"] = "Láta bæta þér við þennan lista!";
|
10
widgets/lang/it/strings.php
Normal file
10
widgets/lang/it/strings.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
$a->strings["%d person likes this"] = "Array";
|
||||
$a->strings["%d person doesn't like this"] = "Array";
|
||||
$a->strings["Connect on Friendica!"] = "Connettiti su Friendica!";
|
||||
$a->strings["Generate new key"] = "Genera una nuova chiave";
|
||||
$a->strings["Widgets key"] = "Chiave Widget";
|
||||
$a->strings["Widgets available"] = "Widget disponibili";
|
||||
$a->strings["Addon Settings"] = "Impostazioni addon";
|
||||
$a->strings["Get added to this list!"] = "Aggiungiti a questa lista!";
|
10
widgets/lang/nb-no/strings.php
Normal file
10
widgets/lang/nb-no/strings.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
$a->strings["%d person likes this"] = "Array";
|
||||
$a->strings["%d person doesn't like this"] = "Array";
|
||||
$a->strings["Connect on Friendica!"] = "";
|
||||
$a->strings["Generate new key"] = "Lag ny nøkkel";
|
||||
$a->strings["Widgets key"] = "Nøkkel til småprogrammer";
|
||||
$a->strings["Widgets available"] = "Småprogrammer er tilgjengelige";
|
||||
$a->strings["Addon Settings"] = "Tilleggsinnstillinger";
|
||||
$a->strings["Get added to this list!"] = "";
|
10
widgets/lang/pl/strings.php
Normal file
10
widgets/lang/pl/strings.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
$a->strings["%d person likes this"] = "Array";
|
||||
$a->strings["%d person doesn't like this"] = "Array";
|
||||
$a->strings["Connect on Friendica!"] = "Połączono z Friendica!";
|
||||
$a->strings["Generate new key"] = "Stwórz nowy klucz";
|
||||
$a->strings["Widgets key"] = "";
|
||||
$a->strings["Widgets available"] = "Widgety są dostępne";
|
||||
$a->strings["Addon Settings"] = "Ustawienia wtyczki";
|
||||
$a->strings["Get added to this list!"] = "Zostań dodany do listy!";
|
10
widgets/lang/pt-br/strings.php
Normal file
10
widgets/lang/pt-br/strings.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
$a->strings["%d person likes this"] = "Array";
|
||||
$a->strings["%d person doesn't like this"] = "Array";
|
||||
$a->strings["Connect on Friendica!"] = "Conecte no Friendica!";
|
||||
$a->strings["Generate new key"] = "Gerar nova chave";
|
||||
$a->strings["Widgets key"] = "Chave de widgets";
|
||||
$a->strings["Widgets available"] = "Widgets disponíveis";
|
||||
$a->strings["Addon Settings"] = "Configurações do addon";
|
||||
$a->strings["Get added to this list!"] = "";
|
10
widgets/lang/ru/strings.php
Normal file
10
widgets/lang/ru/strings.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
$a->strings["%d person likes this"] = "Array";
|
||||
$a->strings["%d person doesn't like this"] = "Array";
|
||||
$a->strings["Connect on Friendica!"] = "Подключены к Friendica!";
|
||||
$a->strings["Generate new key"] = "Сгенерировать новый ключ";
|
||||
$a->strings["Widgets key"] = "Ключ виджетов";
|
||||
$a->strings["Widgets available"] = "Виджеты доступны";
|
||||
$a->strings["Addon Settings"] = "Настройки плагина";
|
||||
$a->strings["Get added to this list!"] = "";
|
3
widgets/lang/sv/strings.php
Normal file
3
widgets/lang/sv/strings.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
$a->strings["Addon Settings"] = "Inställningar för insticksprogram";
|
10
widgets/lang/zh-cn/strings.php
Normal file
10
widgets/lang/zh-cn/strings.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
$a->strings["%d person likes this"] = "Array";
|
||||
$a->strings["%d person doesn't like this"] = "Array";
|
||||
$a->strings["Connect on Friendica!"] = "连接在Friendica!";
|
||||
$a->strings["Generate new key"] = "造成新钥匙";
|
||||
$a->strings["Widgets key"] = "小窗口钥匙";
|
||||
$a->strings["Widgets available"] = "可用的小窗口";
|
||||
$a->strings["Addon Settings"] = "插件设置";
|
||||
$a->strings["Get added to this list!"] = "被在这个单子加入!";
|
19
widgets/templates/settings.tpl
Normal file
19
widgets/templates/settings.tpl
Normal file
|
@ -0,0 +1,19 @@
|
|||
<div class="settings-block">
|
||||
<h3 class="settings-heading">{{$title}}</h3>
|
||||
<div class='field noedit'>
|
||||
<label>{{$label}}</label>
|
||||
<tt>{{$key}}</tt>
|
||||
</div>
|
||||
|
||||
<div class="settings-submit-wrapper">
|
||||
<input type="submit" value="{{$submit}}" class="settings-submit" name="widgets-submit" />
|
||||
</div>
|
||||
|
||||
<h4>{{$widgets_h}}</h4>
|
||||
<ul>
|
||||
{{foreach $widgets as $w}}
|
||||
<li><a href="{{$baseurl}}/widgets/{{$w.0}}/?k={{$key}}&p=1">{{$w.1}}</a></li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
|
||||
</div>
|
5
widgets/templates/widget_like.tpl
Normal file
5
widgets/templates/widget_like.tpl
Normal file
|
@ -0,0 +1,5 @@
|
|||
<style>body {font-size: 0.8em; margin: 0px; padding: 0px;}</style>
|
||||
<span class='f9k_like' title="{{$strlike}}">{{$like}} <img src="{{$baseurl}}/images/like.gif" alt="like"/></span>
|
||||
{{if $dislike}}
|
||||
<span class='f9k_dislike' title="{{$strdislike}}">{{$dislike}} <img src="{{$baseurl}}/images/dislike.gif" alt="dislike"/></span>
|
||||
{{/if}}
|
49
widgets/widget_friendheader.php
Normal file
49
widgets/widget_friendheader.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Content\Widget\ContactBlock;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User;
|
||||
|
||||
function friendheader_widget_name()
|
||||
{
|
||||
return "Shows friends as a bar";
|
||||
}
|
||||
function friendheader_widget_help()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
function friendheader_widget_args()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
function friendheader_widget_size()
|
||||
{
|
||||
return ['780px','140px'];
|
||||
}
|
||||
|
||||
|
||||
function friendheader_widget_content(&$a, $conf)
|
||||
{
|
||||
$owner = User::getOwnerDataById($conf['uid']);
|
||||
if (empty($owner)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$o = "";
|
||||
$o .= "<style>
|
||||
body {font-size: 0.8em; margin: 0px; padding: 0px;}
|
||||
#contact-block { overflow: hidden; height: auto; }
|
||||
.contact-block-h4 { float: left; margin: 0px; }
|
||||
.allcontact-link { float: right; margin: 0px; }
|
||||
.contact-block-content { clear:both; }
|
||||
.contact-block-div { display: block !important; float: left!important; width: 50px!important; height: 50px!important; margin: 2px!important;}
|
||||
|
||||
</style>";
|
||||
$o .= _abs_url(ContactBlock::getHTML($owner));
|
||||
$o .= "<a href='".DI::baseUrl()->get().'/profile/'.$owner['nickname']."' target=new>". DI::l10n()->t('Get added to this list!') ."</a>";
|
||||
|
||||
return $o;
|
||||
}
|
48
widgets/widget_friends.php
Normal file
48
widgets/widget_friends.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
use Friendica\Content\Widget\ContactBlock;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User;
|
||||
|
||||
function friends_widget_name()
|
||||
{
|
||||
return "Shows profile contacts";
|
||||
}
|
||||
|
||||
function friends_widget_help()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
function friends_widget_args()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
function friends_widget_size()
|
||||
{
|
||||
return ['100%', '200px'];
|
||||
}
|
||||
|
||||
|
||||
function friends_widget_content(&$a, $conf)
|
||||
{
|
||||
$owner = User::getOwnerDataById($conf['uid']);
|
||||
if (empty($owner)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$o = "";
|
||||
$o .= "<style>
|
||||
body {font-size: 0.8em; margin: 0px; padding: 0px;}
|
||||
#contact-block { overflow: hidden; height: auto; }
|
||||
.contact-block-h4 { float: left; margin: 0px; }
|
||||
.allcontact-link { float: right; margin: 0px; }
|
||||
.contact-block-content { clear:both; }
|
||||
.contact-block-div { display: block !important; float: left!important; width: 50px!important; height: 50px!important; margin: 2px!important;}
|
||||
|
||||
</style>";
|
||||
$o .= _abs_url(ContactBlock::getHTML($owner));
|
||||
$o .= "<a href='".DI::baseUrl()->get().'/profile/'.$owner['nickname']."'>". DI::l10n()->t('Connect on Friendica!') ."</a>";
|
||||
return $o;
|
||||
}
|
73
widgets/widget_like.php
Normal file
73
widgets/widget_like.php
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
||||
function like_widget_name() {
|
||||
return "Shows likes";
|
||||
}
|
||||
function like_widget_help() {
|
||||
return "Search first item which contains <em>KEY</em> and print like/dislike count";
|
||||
}
|
||||
|
||||
function like_widget_args(){
|
||||
return ["KEY"];
|
||||
}
|
||||
|
||||
function like_widget_size(){
|
||||
return ['60px','20px'];
|
||||
}
|
||||
|
||||
|
||||
function like_widget_content(&$a, $conf){
|
||||
$args = explode(",",$_GET['a']);
|
||||
|
||||
|
||||
$baseq="SELECT COUNT(`post-view`.`id`) as `c`, `p`.`id`
|
||||
FROM `post-view`,
|
||||
(SELECT `i`.`id` FROM `post-view` as `i` WHERE
|
||||
`i`.`visible` = 1 AND `i`.`deleted` = 0
|
||||
AND (( `i`.`wall` = 1 AND `i`.`allow_cid` = ''
|
||||
AND `i`.`allow_gid` = ''
|
||||
AND `i`.`deny_cid` = ''
|
||||
AND `i`.`deny_gid` = '' )
|
||||
OR `i`.`uid` = %d )
|
||||
AND `i`.`body` LIKE '%%%s%%' LIMIT 1) as `p`
|
||||
WHERE `post-view`.`parent` = `p`.`id` ";
|
||||
|
||||
// count likes
|
||||
$r = q( $baseq . "AND `post-view`.`verb` = 'http://activitystrea.ms/schema/1.0/like'",
|
||||
intval($conf['uid']),
|
||||
DBA::escape($args[0])
|
||||
);
|
||||
$likes = $r[0]['c'];
|
||||
|
||||
$dislikes = 0;
|
||||
$strdislike = '';
|
||||
if (!DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) {
|
||||
// count dislikes
|
||||
$r = q( $baseq . "AND `post-view`.`verb` = 'http://purl.org/macgirvin/dfrn/1.0/dislike'",
|
||||
intval($conf['uid']),
|
||||
DBA::escape($args[0])
|
||||
);
|
||||
$dislikes = $r[0]['c'];
|
||||
$strdislike = DI::l10n()->tt("%d person doesn't like this", "%d people don't like this", $dislikes);
|
||||
}
|
||||
|
||||
|
||||
$o = "";
|
||||
|
||||
# $t = file_get_contents( dirname(__file__). "/widget_like.tpl" );
|
||||
$t = Renderer::getMarkupTemplate("widget_like.tpl", "addon/widgets/");
|
||||
$o .= Renderer::replaceMacros($t, [
|
||||
'$like' => $likes,
|
||||
'$strlike' => DI::l10n()->tt("%d person likes this", "%d people like this", $likes),
|
||||
|
||||
'$dislike' => $dislikes,
|
||||
'$strdislike'=> $strdislike,
|
||||
]);
|
||||
|
||||
return $o;
|
||||
}
|
37
widgets/widgets.js
Normal file
37
widgets/widgets.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* @author Fabio Comuni
|
||||
*/
|
||||
var f9a_widget_$widget_id = {
|
||||
width: "$width",
|
||||
height: "$height",
|
||||
entrypoint : "$entrypoint",
|
||||
key : "$key",
|
||||
widgetid: "$widget_id",
|
||||
argstr: "$args",
|
||||
|
||||
load : function() {
|
||||
var args = new Array();
|
||||
args['k']=this.key;
|
||||
args['s']=window.location.href;
|
||||
args['a']=this.argstr;
|
||||
var urlencodedargs = new Array();
|
||||
for(k in args){
|
||||
if (typeof args[k] != 'function')
|
||||
urlencodedargs.push( encodeURIComponent(k)+"="+encodeURIComponent(args[k]) );
|
||||
}
|
||||
var url = this.entrypoint + "?"+ urlencodedargs.join("&");
|
||||
|
||||
console.log(this.widgetid);
|
||||
console.log(document.getElementById(this.widgetid));
|
||||
document.getElementById(this.widgetid).innerHTML = '<iframe style="border:0px; width: '+this.width+'; height:'+this.height+'" src="'+url+'"></iframe>';
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
document.writeln("<div id='$widget_id' class='f9k_widget $type'>");
|
||||
document.writeln("<img id='$widget_id_ld' src='$loader'>");
|
||||
document.writeln("</div>");
|
||||
(function() {
|
||||
f9a_widget_$widget_id.load();
|
||||
})();
|
||||
|
172
widgets/widgets.php
Normal file
172
widgets/widgets.php
Normal file
|
@ -0,0 +1,172 @@
|
|||
<?php
|
||||
/**
|
||||
* Name: Widgets
|
||||
* Description: Allow to embed info from friendica into another site
|
||||
* Version: 1.0
|
||||
* Author: Fabio Comuni <http://kirgroup.com/profile/fabrix/>
|
||||
* Status: Unsupported
|
||||
*/
|
||||
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
||||
function widgets_install() {
|
||||
Hook::register('addon_settings', 'addon/widgets/widgets.php', 'widgets_settings');
|
||||
Hook::register('addon_settings_post', 'addon/widgets/widgets.php', 'widgets_settings_post');
|
||||
Logger::notice("installed widgets");
|
||||
}
|
||||
|
||||
function widgets_settings_post(){
|
||||
if(! local_user())
|
||||
return;
|
||||
if (isset($_POST['widgets-submit'])){
|
||||
DI::pConfig()->delete(local_user(), 'widgets', 'key');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function widgets_settings(&$a,&$o) {
|
||||
if(! local_user())
|
||||
return;
|
||||
|
||||
|
||||
$key = DI::pConfig()->get(local_user(), 'widgets', 'key' );
|
||||
if ($key=='') { $key = mt_rand(); DI::pConfig()->set(local_user(), 'widgets', 'key', $key); }
|
||||
|
||||
$widgets = [];
|
||||
$d = dir(dirname(__file__));
|
||||
while(false !== ($f = $d->read())) {
|
||||
if(substr($f,0,7)=="widget_") {
|
||||
preg_match("|widget_([^.]+).php|", $f, $m);
|
||||
$w=$m[1];
|
||||
if ($w!=""){
|
||||
require_once($f);
|
||||
$widgets[] = [$w, call_user_func($w."_widget_name")];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
# $t = file_get_contents( dirname(__file__). "/settings.tpl" );
|
||||
$t = Renderer::getMarkupTemplate("settings.tpl", "addon/widgets/");
|
||||
$o .= Renderer::replaceMacros($t, [
|
||||
'$submit' => DI::l10n()->t('Generate new key'),
|
||||
'$title' => "Widgets",
|
||||
'$label' => DI::l10n()->t('Widgets key'),
|
||||
'$key' => $key,
|
||||
'$widgets_h' => DI::l10n()->t('Widgets available'),
|
||||
'$widgets' => $widgets,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
function widgets_module() {
|
||||
return;
|
||||
}
|
||||
|
||||
function _abs_url($s){
|
||||
return preg_replace("|href=(['\"])([^h][^t][^t][^p])|", "href=\$1" . DI::baseUrl()->get() . "/\$2", $s);
|
||||
}
|
||||
|
||||
function _randomAlphaNum($length){
|
||||
return substr(str_shuffle(str_repeat('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',$length)),0,$length);
|
||||
}
|
||||
|
||||
|
||||
function widgets_content(&$a) {
|
||||
|
||||
if (!isset($_GET['k'])) {
|
||||
if(DI::args()->get(2)=="cb"){header('HTTP/1.0 400 Bad Request'); exit();}
|
||||
return;
|
||||
}
|
||||
|
||||
$r = q("SELECT * FROM pconfig WHERE uid IN (SELECT uid FROM pconfig WHERE v='%s')AND cat='widgets'",
|
||||
DBA::escape($_GET['k'])
|
||||
);
|
||||
if (!count($r)){
|
||||
if(DI::args()->get(2)=="cb"){header('HTTP/1.0 400 Bad Request'); exit();}
|
||||
return;
|
||||
}
|
||||
$conf = [];
|
||||
$conf['uid'] = $r[0]['uid'];
|
||||
foreach($r as $e) { $conf[$e['k']]=$e['v']; }
|
||||
|
||||
$o = "";
|
||||
|
||||
$widgetfile =dirname(__file__)."/widget_".DI::args()->get(1).".php";
|
||||
if (file_exists($widgetfile)){
|
||||
require_once($widgetfile);
|
||||
} else {
|
||||
if(DI::args()->get(2)=="cb"){header('HTTP/1.0 400 Bad Request'); exit();}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//echo "<pre>"; var_dump($a->argv); die();
|
||||
if (DI::args()->get(2)=="cb"){
|
||||
/*header('Access-Control-Allow-Origin: *');*/
|
||||
$o .= call_user_func(DI::args()->get(1).'_widget_content',$a, $conf);
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
if (isset($_GET['p']) && local_user()==$conf['uid'] ) {
|
||||
$o .= "<style>.f9k_widget { float: left;border:1px solid black; }</style>";
|
||||
$o .= "<h1>Preview Widget</h1>";
|
||||
$o .= '<a href="'.DI::baseUrl()->get().'/settings/addon">'. DI::l10n()->t("Addon Settings") .'</a>';
|
||||
|
||||
$o .= "<h4>".call_user_func(DI::args()->get(1).'_widget_name')."</h4>";
|
||||
$o .= call_user_func(DI::args()->get(1).'_widget_help');
|
||||
$o .= "<br style='clear:left'/><br/>";
|
||||
$o .= "<script>";
|
||||
} else {
|
||||
header("content-type: application/x-javascript");
|
||||
}
|
||||
|
||||
|
||||
|
||||
$widget_size = call_user_func(DI::args()->get(1).'_widget_size');
|
||||
|
||||
$script = file_get_contents(dirname(__file__)."/widgets.js");
|
||||
$o .= Renderer::replaceMacros($script, [
|
||||
'$entrypoint' => DI::baseUrl()->get()."/widgets/".DI::args()->get(1)."/cb/",
|
||||
'$key' => $conf['key'],
|
||||
'$widget_id' => 'f9a_'.DI::args()->get(1)."_"._randomAlphaNum(6),
|
||||
'$loader' => DI::baseUrl()->get()."/images/rotator.gif",
|
||||
'$args' => (isset($_GET['a'])?$_GET['a']:''),
|
||||
'$width' => $widget_size[0],
|
||||
'$height' => $widget_size[1],
|
||||
'$type' => DI::args()->get(1),
|
||||
]);
|
||||
|
||||
|
||||
if (isset($_GET['p'])) {
|
||||
$wargs = call_user_func(DI::args()->get(1).'_widget_args');
|
||||
$jsargs = implode("</em>,<em>", $wargs);
|
||||
if ($jsargs!='') $jsargs = "&a=<em>".$jsargs."</em>";
|
||||
|
||||
$o .= "</script>
|
||||
<br style='clear:left'/><br/>
|
||||
<h4>Copy and paste this code</h4>
|
||||
<code>"
|
||||
|
||||
.htmlspecialchars('<script src="'.DI::baseUrl()->get().'/widgets/'.DI::args()->get(1).'?k='.$conf['key'])
|
||||
.$jsargs
|
||||
.htmlspecialchars('"></script>')
|
||||
."</code>";
|
||||
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
|
||||
echo $o;
|
||||
exit();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue