tra('Author'), 'documentation' => 'PluginAuthor', 'description' => tra('Add popups and color coding that identifies authors'), 'prefs' => ['wikiplugin_author'], 'body' => tra('text'), 'iconname' => 'pencil', 'introduced' => 6, 'params' => [ 'author' => [ 'required' => true, 'name' => tra('Username'), 'description' => tra('Username of the author of the text.'), 'since' => '6.0', 'default' => '', 'filter' => 'username', ], 'deleted_by' => [ 'required' => false, 'name' => tra('Deleted by User'), 'description' => tra('Username of the person who deleted the text.'), 'since' => '6.0', 'default' => '', 'filter' => 'username', ], 'visible' => [ 'required' => false, 'name' => tra('Make Visible'), 'description' => tra("Should this author's contribution be visible (default: no)."), 'since' => '6.0', 'filter' => 'text', 'default' => 0, 'options' => [ ['text' => '', 'value' => ''], ['text' => tra('Yes'), 'value' => '1'], ['text' => tra('No'), 'value' => '0'], ], ], 'popup' => [ 'required' => false, 'name' => tra('Show popup with author/deleted by'), 'description' => tra('Generate a popup with names of author(s) (default: no).'), 'since' => '6.0', 'filter' => 'text', 'default' => 0, 'options' => [ ['text' => '', 'value' => ''], ['text' => tra('Yes'), 'value' => '1'], ['text' => tra('No'), 'value' => '0'], ], ], ], // params ]; } function wikiplugin_author($data, $params) { $headerlib = TikiLib::lib('header'); $tikilib = TikiLib::lib('tiki'); $smarty = TikiLib::lib('smarty'); global $authors; static $style = 0; static $id = 0; $blocktags = '/(<+\/?address.*?>|<+\/?blockcode.*?>|<+\/?blockquote.*?>|<+\/?div.*?>|<+\/?h1.*?>|<+\/?h2.*?>|<+\/?h3.*?>|<+\/?h4.*?>|<+\/?h5.*?>|<+\/?h6.*?>|<+\/?hr.*?>|<+\/?h.*?>|<+\/?li.*?>|<+\/?ol.*?>|<+\/?pre.*?>|<+\/?p.*?>|<+\/?section.*?>|<+\/?table.*?>|<+\/?td.*?>|<+\/?th.*?>|<+\/?tr.*?>|<+\/?ul.*?>)/'; $default = ['popup' => 0]; $params = array_merge($default, $params); if (! is_array($authors)) { $authors = []; } $author = $params['author']; if (! isset($authors[$author])) { $authors[$author] = []; } if (! isset($authors[$author]['style'])) { $authors[$author]['style'] = "author$style"; $style++; if ($style > 15) { $style = 0; // so far only 16 colors defined } } $content = preg_split($blocktags, $data, -1, PREG_SPLIT_DELIM_CAPTURE); $html = ''; foreach ($content as $data) { if ($data != '') { if (preg_match($blocktags, $data) > 0) { $html .= $data; } else { if ($params['visible'] == 1 or $params['popup'] == 1) { $html .= 'add_jq_onready($js); $html .= "" . tra('Author') . ": $author" . (isset($params['deleted_by']) ? "
" . tra('deleted by') . ': ' . $params['deleted_by'] : '') . "
"; } $id++; } // content is not a block tag } // content <>"" } // foreach return $html; }