* Includes code from the WordPress team - * http://sourceforge.net/project/memberlist.php?group_id=51422 * * b2evolution - {@link http://b2evolution.net/} * Released under GNU GPL License - {@link http://b2evolution.net/about/gnu-gpl-license} * @copyright (c)2003-2019 by Francois Planque - {@link http://fplanque.com/} * * @package plugins */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); /** * @package plugins */ class myhtmltags_plugin extends Plugin { var $code = 'myHtmlTags'; var $name = 'My HTML Tags'; var $priority = 30; var $version = '19.04.09'; var $group = 'editor'; var $number_of_installs = 1; /** * Init */ function PluginInit( & $params ) { $this->short_desc = T_('Easy HTML tags inserting'); $this->long_desc = T_('This plugin will display a toolbar with buttons to quickly insert HTML tags around selected text in a post.'); } /** * Event handler: Called when displaying editor toolbars on post/item form. * * This is for post/item edit forms only. Comments, PMs and emails use different events. * * @todo dh> This seems to be a lot of Javascript. Please try exporting it in a * (dynamically created) .js src file. Then we could use cache headers * to let the browser cache it. * @param array Associative array of parameters * @return boolean did we display a toolbar? */ function AdminDisplayToolbar( & $params ) { $Item = & $params['Item']; if( empty( $Item ) || ! $Item->get_type_setting( 'allow_html' ) ) { // Only when HTML is allowed in post: return false; } $item_Blog = & $Item->get_Blog(); if( ! $this->get_coll_setting( 'coll_use_for_posts', $item_Blog ) ) { // This plugin is disabled to use for posts: return false; } return $this->DisplayCodeToolbar( $params ); } /** * Event handler: Called when displaying editor toolbars on comment form. * * @param array Associative array of parameters * @return boolean did we display a toolbar? */ function DisplayCommentToolbar( & $params ) { $Comment = & $params['Comment']; if( $Comment ) { // Get a post of the comment: $comment_Item = & $Comment->get_Item(); } if( empty( $comment_Item ) || ! $comment_Item->get_type_setting( 'allow_html' ) ) { // Only when HTML is allowed in post: return false; } $item_Blog = & $comment_Item->get_Blog(); if( ! $this->get_coll_setting( 'coll_use_for_comments', $item_Blog ) ) { // This plugin is disabled to use for comments: return false; } global $current_User; // Allow html tags like
, and only when current user has a permission for this: $params['allow_restricted_html'] = ( is_logged_in() && $current_User->check_perm( 'blog_comments', 'edit', false, $item_Blog->ID ) ); return $this->DisplayCodeToolbar( $params ); } /** * Display a code toolbar * * @param array Associative array of parameters * @return boolean did we display a toolbar? */ function DisplayCodeToolbar( & $params ) { global $Hit; if( $Hit->is_lynx() ) { // let's deactivate quicktags on Lynx, because they don't work there. return false; } $params = array_merge( array( 'js_prefix' => '', // Use different prefix if you use several toolbars on one page 'allow_restricted_html' => true, // Set false if html tags like, and must be hidden for current case ), $params ); $simple = ( isset( $params['edit_layout'] ) && $params['edit_layout'] == 'inskin' ); // Load js to work with textarea require_js( 'functions.js', 'blog', true, true ); ?>get_template( 'toolbar_before', array( '$toolbar_class$' => $params['js_prefix'].$this->code.'_toolbar' ) ); echo $this->get_template( 'toolbar_after' ); ?>