Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1880325
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Size
12 KB
Subscribers
None
View Options
diff --git a/action/ajax.php b/action/ajax.php
deleted file mode 100644
--- a/action/ajax.php
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-
-/**
- * DokuWiki DAVCard PlugIn - Ajax component
- */
-
-if(!defined('DOKU_INC')) die();
-
-class action_plugin_davcard_ajax extends DokuWiki_Action_Plugin {
-
- /**
- * @var helper_plugin_davcal
- */
- private $hlp = null;
-
- function __construct() {
- $this->hlp =& plugin_load('helper','davcard');
- }
-
- function register(Doku_Event_Handler $controller) {
- $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handle_ajax_call_unknown');
- }
-
- function handle_ajax_call_unknown(Doku_Event $event, $param) {
- if($event->data != 'plugin_davcard') return;
-
- $event->preventDefault();
- $event->stopPropagation();
- global $INPUT;
-
- $action = trim($INPUT->post->str('action'));
- $id = trim($INPUT->post->str('id'));
- $name = trim($INPUT->post->str('name'));
-
- if(!checkSecurityToken())
- {
- echo "CSRF Attack.";
- return;
- }
-
- $data = array();
-
- $data['result'] = false;
- $data['html'] = $this->getLang('unknown_error');
-
- // Parse the requested action
- switch($action)
- {
- case 'getContact':
- if($name !== '')
- {
- $info = $this->hlp->getContactByName($id, $name);
- if($info === false)
- {
- $data['html'] = $this->getLang('contact_not_found');
- break;
- }
- $data['result'] = true;
- if($info['formattedname'] !== '')
- $data['html'] = 'Name: '.$info['formattedname'].'<br>';
- if(count($info['tel']) > 0)
- {
- foreach($info['tel'] as $type => $nr)
- {
- $data['html'] .= $type.': '.$nr.'<br>';
- }
- }
- if(count($info['addr']) > 0)
- {
- foreach($info['addr'] as $type => $addr)
- {
- $data['html'] .= $type.': '.join('<br>', $addr);
- $data['html'] .= '<br>';
- }
- }
- if(count($info['mail']) > 0)
- {
- foreach($info['mail'] as $type => $mail)
- {
- $data['html'] .= $type.': '.$mail.'<br>';
- }
- }
-
- }
- else
- {
- $data['html'] = $this->hlp-->getContactByUri($id);
- }
- break;
- }
-
- // If we are still here, JSON output is requested
-
- //json library of DokuWiki
- require_once DOKU_INC . 'inc/JSON.php';
- $json = new JSON();
-
- //set content type
- header('Content-Type: application/json');
- echo $json->encode($data);
- }
-
-}
diff --git a/action/cache.php b/action/cache.php
new file mode 100644
--- /dev/null
+++ b/action/cache.php
@@ -0,0 +1,44 @@
+<?php
+
+/**
+ * DokuWiki DAVCal PlugIn - Ajax component
+ */
+
+if(!defined('DOKU_INC')) die();
+
+class action_plugin_davcal_cache extends DokuWiki_Action_Plugin {
+
+ function __construct() {
+
+ }
+
+ function register(Doku_Event_Handler $controller) {
+ $controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this, 'handle_parser_cache_use');
+ }
+
+ function handle_parser_cache_use(Doku_Event $event, $param)
+ {
+ $cache = &$event->data;
+ if(!isset($cache->page)) return;
+ //purge only xhtml cache
+ if($cache->mode != "xhtml") return;
+
+ $meta = p_get_metadata($cache->page, 'plugin_davcard');
+ if($meta === null)
+ return;
+ // Force re-caching if the webdavclient has synced
+ if(isset($meta['webdavclient']))
+ {
+ $wdc =& plugin_load('helper', 'webdavclient');
+ if(is_null($wdc))
+ return;
+ foreach($meta['webdavclient'] as $connectionId)
+ {
+ $cache->depends['files'][] = $wdc->getLastSyncChangeFileForConnection($connectionId);
+ }
+ }
+ }
+
+}
+
+
diff --git a/lang/en/lang.php b/lang/en/lang.php
--- a/lang/en/lang.php
+++ b/lang/en/lang.php
@@ -1,13 +1,34 @@
<?php
/**
* English language file for DAVCard
*
* @author Andreas Böhler <dev@aboehler.at>
*/
$lang['unknown_error'] = 'Unknown Error';
$lang['id_name_not_set'] = 'Either ID or Name must be set';
$lang['loading_via_ajax'] = 'Loadig Contact Data...';
-$lang['wdc'] = 'Loading webdavclient PlugIn failed.';
+$lang['no_wdc'] = 'Loading webdavclient PlugIn failed.';
$lang['settings_not_found'] = 'The requested WebDAV connection was not found';
$lang['wrong_type'] = 'The requested WebDAV connection is not of type contact';
$lang['contact_not_found'] = 'The requested contact was not found';
+$lang['telvoice'] = 'Voice';
+$lang['telhome'] = 'Home';
+$lang['telmsg'] = 'Message';
+$lang['telwork'] = 'Work';
+$lang['telpref'] = 'preferred';
+$lang['telfax'] = 'Fax';
+$lang['telcell'] = 'Cell';
+$lang['telvideo'] = 'Video';
+$lang['telpager'] = 'Pager';
+$lang['telbbs'] = 'BBS';
+$lang['telmodem'] = 'Modem';
+$lang['telcar'] = 'Car';
+$lang['telisdn'] = 'ISDN';
+$lang['telpcs'] = 'PCS';
+$lang['adrintl'] = 'International';
+$lang['adrpostal'] = 'Postal';
+$lang['adrparcel'] = 'Parcel';
+$lang['adrwork'] = 'Work';
+$lang['adrdom'] = 'Domestic';
+$lang['adrhome'] = 'Home';
+$lang['adrpref'] = 'preferred';
diff --git a/plugin.info.txt b/plugin.info.txt
--- a/plugin.info.txt
+++ b/plugin.info.txt
@@ -1,7 +1,7 @@
base davcard
author Andreas Boehler
email dev@aboehler.at
-date 2016-05-12
+date 2016-05-13
name Addressbook PlugIn with CardDAV client support
desc Show contact information from a CardDAV address book (needs webdavclient)
url http://www.dokuwiki.org/plugin:davcard
diff --git a/script.js b/script.js
deleted file mode 100644
--- a/script.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Initialize the DAVCard script, attaching some event handlers and triggering
- * the initial load of the fullcalendar JS
- */
-
-jQuery(function() {
- jQuery('div.plugin_davcard').each(function() {
- var $div = jQuery(this);
- var id = $div.data('cardid');
- var name = $div.data('name');
- if (!id && !name) return;
-
- jQuery.post(
- DOKU_BASE + 'lib/exe/ajax.php',
- {
- call: 'plugin_davcard',
- id: id,
- action: 'getContact',
- name: name,
- sectok: JSINFO.plugin.davcard['sectok']
- },
- function(data)
- {
- $div.html(data['html']);
- });
-
- });
-});
diff --git a/style.css b/style.css
new file mode 100644
--- /dev/null
+++ b/style.css
@@ -0,0 +1,34 @@
+div.dokuwiki a.plugin_davcard_url:link,
+div.dokuwiki a.plugin_davcard_url:active,
+div.dokuwiki a.plugin_davcard_url:hover,
+div.dokuwiki a.plugin_davcard_url:visited {
+ position: relative;
+ padding-left: 18px;
+ z-index: 10;
+}
+
+div.dokuwiki a.plugin_davcard_url:link span.plugin_davcard_popup,
+div.dokuwiki a.plugin_davcard_url:active span.plugin_davcard_popup,
+div.dokuwiki a.plugin_davcard_url:visited span.plugin_davcard_popup {
+ display: none;
+}
+
+div.dokuwiki a.plugin_davcard_url:hover {
+ text-decoration: none !important;
+ z-index: 15;
+}
+
+div.dokuwiki a.plugin_davcard_url:hover span.plugin_davcard_popup {
+ display: block;
+ position: absolute;
+ top: 1.2em;
+ left: 18px;
+ width: 20em;
+ height: 64px;
+ min-height: 64px;
+ height: auto;
+ background-color: __background__;
+ border: 1px solid __border__;
+ padding: 0.5em;
+ font-size: 90%;
+}
\ No newline at end of file
diff --git a/syntax/card.php b/syntax/card.php
--- a/syntax/card.php
+++ b/syntax/card.php
@@ -1,97 +1,164 @@
<?php
/**
* DokuWiki Plugin DAVCard (Contact Syntax Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Andreas Böhler <dev@aboehler.at>
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
class syntax_plugin_davcard_card extends DokuWiki_Syntax_Plugin {
protected $hlp = null;
// Load the helper plugin
public function syntax_plugin_davcard_card() {
$this->hlp =& plugin_load('helper', 'davcard');
}
/**
* What kind of syntax are we?
*/
function getType(){
return 'substition';
}
/**
* What about paragraphs?
*/
function getPType(){
return 'normal';
}
/**
* Where to sort in?
*/
function getSort(){
return 165;
}
/**
* Connect pattern to lexer
*/
function connectTo($mode) {
$this->Lexer->addSpecialPattern('\{\{davcard>[^}]*\}\}',$mode,'plugin_davcard_card');
}
/**
* Handle the match
*/
function handle($match, $state, $pos, Doku_Handler $handler){
global $ID;
$options = trim(substr($match,10,-2));
$options = explode(',', $options);
$data = array('name' => '',
'id' => '',
);
foreach($options as $option)
{
list($key, $val) = explode('=', $option);
$key = strtolower(trim($key));
$val = trim($val);
switch($key)
{
default:
$data[$key] = $val;
}
}
if($data['id'] === '' && $data['name'] === '')
{
msg($this->getLang('id_name_not_set'), -1);
}
return $data;
}
/**
* Create output
*/
function render($format, Doku_Renderer $R, $data) {
- if($format != 'xhtml') return false;
+ if($format == 'metadata')
+ {
+ if(strpos($data['id'], 'webdav://') === 0)
+ {
+ $connectionId = str_replace('webdav://', '', $data['id']);
+ $R->meta['plugin_davcard']['webdavclient'][] = $connectionId;
+ return true;
+ }
+ }
+ if($format != 'xhtml')
+ return false;
+
+
+ $contactdata = array();
+ if(strpos($data['id'], 'webdav://') === 0)
+ {
+ if($data['name'] !== '')
+ {
+ $contactdata = $this->hlp->getContactByName($data['id'], $data['name']);
+ }
+ }
- $R->doc .= '<div class="plugin_davcard" data-cardid="'.hsc($data['id']).'" data-name="'.hsc($data['name']).'">';
- $R->doc .= '<img src="' . DOKU_BASE . 'lib/images/throbber.gif" alt="" width="16" height="16" />';
- $R->doc .= $this->getLang('loading_via_ajax').'</div>';
+ $R->doc .= '<a class="url fn plugin_davcard_url" href="#">'.$contactdata['formattedname'];
+ $R->doc .= '<span class="plugin_davcard_popup vcard">';
+ if(count($contactdata['addr']) > 0)
+ {
+ $R->doc .= '<span class="adr">';
+ foreach($contactdata['addr'] as $type => $addr)
+ {
+ $R->doc .= '<span class="type">'.$this->getLang('adr'.strtolower($type)).'</span>';
+ if($addr[2] != '')
+ {
+ $R->doc .= '<span class="street-address">'.$addr[2].'</span><br>';
+ }
+ if($addr[5] != '')
+ {
+ $R->doc .= '<span class="postal-code">'.$addr[5].' </span>';
+ }
+ if($addr[3] != '')
+ {
+ $R->doc .= '<span class="locality">'.$addr[3].'</span><br>';
+ }
+
+ if($addr[6] != '')
+ {
+ $R->doc .= '<span class="country-name">'.$addr[6].'</span>';
+ }
+ }
+ $R->doc .= '</span><br>';
+ }
+ if(count($contactdata['tel']) > 0)
+ {
+ $R->doc .= '<span class="tel">';
+ foreach($contactdata['tel'] as $type => $number)
+ {
+ $R->doc .= '<span class="type">'.$this->getLang('tel'.strtolower($type)).' </span>';
+ $R->doc .= $number.'<br>';
+ }
+ $R->doc .= '</span>';
+ }
+ if(count($contactdata['mail']) > 0)
+ {
+ $R->doc .= '<span>EMail:<br>';
+ foreach($contactdata['mail'] as $type => $mail)
+ {
+ $R->doc .= '<span class="email">'.$mail.'</span><br>';
+ }
+ $R->doc .= '</span><br>';
+ }
+
+ $R->doc .= '</span>';
+ $R->doc .= '</a>';
}
}
// vim:ts=4:sw=4:et:enc=utf-8:
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Jan 24, 3:49 AM (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
528319
Default Alt Text
(12 KB)
Attached To
rDAVCARD DokuWiki davcard PlugIn
Event Timeline
Log In to Comment