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 2017-02-21 +date 2017-11-15 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/syntax/book.php b/syntax/book.php --- a/syntax/book.php +++ b/syntax/book.php @@ -1,323 +1,323 @@ */ // 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_book extends DokuWiki_Syntax_Plugin { protected $hlp = null; // Load the helper plugin public function syntax_plugin_davcard_book() { $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('\{\{davcardbook>[^}]*\}\}',$mode,'plugin_davcard_book'); } /** * Handle the match */ function handle($match, $state, $pos, Doku_Handler $handler){ global $ID; $options = trim(substr($match,14,-2)); $options = explode(',', $options); $data = array('name' => $ID, 'description' => $this->getLang('created_by_davcard'), 'id' => array(), 'filter' => array(), ); foreach($options as $option) { list($key, $val) = explode('=', $option); $key = strtolower(trim($key)); $val = trim($val); switch($key) { case 'filter': list($k, $v) = explode(':', strtolower($val), 2); $data['filter'][$k] = $v; break; case 'id': if(!in_array($val, $data['id'])) $data['id'][] = $val; break; default: $data[$key] = $val; } } // Handle the default case when the user didn't enter a different ID if(empty($data['id'])) { $data['id'] = array($ID); } // Only update the addressbook name/description if the ID matches the page ID. // Otherwise, the addressbook is included in another page and we don't want // to interfere with its data. if(in_array($ID, $data['id'])) { if(isset($_SERVER['REMOTE_USER']) && !is_null($_SERVER['REMOTE_USER'])) $username = $_SERVER['REMOTE_USER']; else $username = uniqid('davcard-'); $this->hlp->setAddressbookNameForPage($data['name'], $data['description'], $ID, $username); } $meta = p_get_metadata($ID, 'plugin_davcard'); if(is_null($meta)) $meta = array(); $meta['addressbooks'] = $data; // Add webdavclient information so that we can disable caching if need be foreach($data['id'] as $addrbkid) { if(strpos($addrbkid, 'webdav://') === 0) { $connectionId = str_replace('webdav://', '', $addrbkid); if(!is_array($meta['webdavclient'])) $meta['webdavclient'] = array(); if(!in_array($addrbkid, $meta['webdavclient'])) $meta['webdavclient'][] = $connectionId; } } p_set_metadata($ID, array('plugin_davcard' => $meta)); return $data; } /** * Create output */ function render($format, Doku_Renderer $R, $data) { global $ID; if($format !== 'xhtml') return false; $addressbooklist = array(); $R->doc .= '
'; $R->doc .= ''.$this->getLang('name').' | '.$this->getLang('address').' | '.$this->getLang('phone').' | '.$this->getLang('email').' |
---|---|---|---|
'.$entry['formattedname'].' | '; + $R->doc .= ' | ||
'.hsc($entry['formattedname']).' | ';
if(count($contactdata['addr']) > 0)
{
$R->doc .= '';
foreach($contactdata['addr'] as $dat)
{
if(isset($dat['type']))
$type = $dat['type'];
else
$type = 'other';
- $R->doc .= ''.$this->getLang('adr'.strtolower($type)).'';
+ $R->doc .= ''.hsc($this->getLang('adr'.strtolower($type))).'';
if($dat['address'][2] != '')
{
- $R->doc .= ''.$dat['address'][2].' '; + $R->doc .= ''.hsc($dat['address'][2]).' '; } if($dat['address'][5] != '') { - $R->doc .= ''.$dat['address'][5].' '; + $R->doc .= ''.hsc($dat['address'][5]).' '; } if($dat['address'][3] != '') { - $R->doc .= ''.$dat['address'][3].' '; + $R->doc .= ''.hsc($dat['address'][3]).' '; } if($dat['address'][6] != '') { - $R->doc .= ''.$dat['address'][6].''; + $R->doc .= ''.hsc($dat['address'][6]).''; } } $R->doc .= ''; } $R->doc .= ' | ';
if(count($contactdata['tel']) > 0)
{
$R->doc .= '';
foreach($contactdata['tel'] as $dat)
{
if(isset($dat['type']))
$type = $dat['type'];
else
$type = 'other';
- $R->doc .= ''.$this->getLang('tel'.strtolower($type)).' ';
- $R->doc .= $dat['number'].' '; + $R->doc .= ''.hsc($this->getLang('tel'.strtolower($type))).' '; + $R->doc .= hsc($dat['number']).' '; } $R->doc .= ''; } $R->doc .= ' | ';
if(count($contactdata['mail']) > 0)
{
foreach($contactdata['mail'] as $dat)
{
- $R->doc .= ''.$dat['mail'].' '; + $R->doc .= ''.hsc($dat['mail']).' '; } } $R->doc .= ' |