Hooks/en

From EQdkp Plus
Jump to navigation Jump to search


Hooks can be used to extend EQdkp Plus. They are executed in defined points of EQdkp Plus.

Existing Hooks

Hook Parameter Description
portal none Will be executed if portal is displayed. Good for extending the header or other areas.
search none Extends the search enginge, requires a PDH modules (For example, take a look at the shoutbox plugin)
wrapper id: String, link: String Extends the Wrapper. For example, take a look at the latestposts module.
bbcodes text: String, state: String Adds own BBCodes.

Since EQdkp Plus 2.0

Since EQdkp Plus 2.0, additional hooks are available.

Hook Parameters Recursive Description
menu Multidimension-Array with menu entries No Hook contains all menu entries as multidimensional array. Each dimension is one menu level.
menu_onelevel Array with menu entries Yes Hook gets all menu entries as single array, without levels.
game_chartooltip tooltip: string; char_id: integer; Yes tooltip containes parsed character tooltip
article_parse content: string; view: string, article_id: integer; specific_id: string Yes content contains parsed article
tinymce_bbcode_setup js: string; env: object; Yes Setup method of BBCode-Editor, e.g. for adding own buttons
tinymce_normal_setup js: string; env: object; Yes Setup method of normal WYSIWYG Editor, e.g. for adding own buttons
tinymce_inline_simple_setup js: string; selector: string; env: object; Yes Setup method of simple inline Editor, e.g. for adding own buttons
tinymce_inline_setup js: string; selector: string; env: object; Yes Setup method of normal inline Editor, e.g. for adding own buttons
comments_save user_id; attach_id; comment; page; reply_tp; permission; Yes Triggered before saving comments
admin_tasks - No Expecting an array like this:
$arrTasks = array(
	//Confirm new Chars
	'confirmChars' => array(
			'name'		=> 'uc_confirm_list',
			'icon'		=> 'fa fa-check',
			'notify_func'	=> array($this, 'ntfyConfirmChars'),
			'content_func'	=> array($this, 'contentConfirmChars'),
			'action_func'	=> array($this, 'actionHandleChars'),
			'actions'	=> array(
					'confirm' => array('icon' => 'fa fa-check', 'title' => 'uc_confirm_char', 'permissions' => array('a_members_man')),
					'delete'  => array('icon' => 'fa-trash-o', 'title' => 'delete_member', 'permissions' => array('a_members_man')),
			),
	),
);
massmail_content - No Expecting an array like this:
$data = array(
	'latest_news'	=> array(
		'name'	=> $this->user->lang('news'),
		'list'	=> $arrNewsList,
	),
);
calendar start: integer; end: integer; No Expecting an array like this:
$events[] = array(
	'className'				=> 'cal_birthday',
	'title'					=> $this->pdh->get('user', 'name', array($birthday_uid)),
	'start'					=> $birthday_y.'-'.$this->time->date('m-d', $birthday_ts),
	'end'					=> $birthday_y.'-'.$this->time->date('m-d', $birthday_ts),
	'allDay'				=> true,
	'textColor'				=> '#000000',
	'backgroundColor'			=> '#E8E8E8',
	'borderColor'				=> '#7F7F7F',
	'author'				=> 'Authorname',
	'note'					=> 'Note',
);
main_menu_items - No Adding of links. Expecting an array like this:
$main_menu[] = array(
	'link'  		=> $this->pdh->get('mediacenter_categories', 'path', array($intCategoryID)),
	'text'  		=> $strCategoryName,
	'check' 		=> 'u_mediacenter_view',
	'default_hide'		=> 1,
	'link_category' 	=> 'mc_mediacenter',
);
calendarevent_chartooltip member_id: integer No Expects an array with the content of the tooltip. Each array entry is a new line of the tooltip.
$membertooltip[] = "This is row 1";
$membertooltip[] = "This is row 2";
return $membertooltip;
userprofile_customtabs user_id: integer No Creates a new tab at the userprofile page. Expects an array with the content, like this:
$out = array(
'title' => "Title of the Tab",
'content' => "Content of the Tab", 
);
return $out;


Since EQdkp Plus 2.3

Hook Parameters Recursive Description
user_avatarimg user_id:interger; fullsize:boolean; avatarimg:string; avatartype:int; default:boolean; Yes Triggered when user avatar is shown.
avatar_provider for_usersettings:boolean; No
return array('discord' => array('name' => 'Discord'));
user_inserted user_id:interger; username:string; data: Array; Yes Triggered when new user created. Read-only.
user_updated user_id:integer; data: Array; No Triggered when a user is updated. Read-only.
user_delete user_id:integer No Triggered when a user is deleted. Read-only.
user_reset own_userid:integer No Triggered when all user are deleted. Read-only.
viewraid raid_id:integer No Triggered when showing a raid at the frontend. Read-only. You can use template-listener like "viewraid_beforetables" to show content.

If you need more hooks, please contact us in our board.

Create new hook

Filename

The Filename of your new hook must contain the name of the hook before ".class.php". Example: myhook_wrapper.class.php or anotherhook_portal.class.php

Classname

The Classname must be the same as the filename before ".class.php", means "myhook_wrapper" or "anotherhook_portal".

Methodname

The name of the method that will be executed must be the hookname, means "wrapper" or "portal".

Folder

Your new hook must be put into the folder "core/hooks".

Example-Hook

This hook is a example for displaying the realmstatus in the personal area on top of a EQdkp Plus page. Filename: realmstatus_portal_hook.class.php

<?php
/*
 * Project:     EQdkp Shoutbox
 * License:     Creative Commons - Attribution-Noncommercial-Share Alike 3.0 Unported
 * Link:        http://creativecommons.org/licenses/by-nc-sa/3.0/
 * -----------------------------------------------------------------------
 * Began:       2008
 * Date:        $Date: 2012-11-11 18:36:16 +0100 (So, 11. Nov 2012) $
 * -----------------------------------------------------------------------
 * @author      $Author: godmod $
 * @copyright   2008-2011 Aderyn
 * @link        http://eqdkp-plus.com
 * @package     shoutbox
 * @version     $Rev: 12434 $
 *
 * $Id: realmstatus_portal_hook.class.php 12434 2012-11-11 17:36:16Z godmod $
 */

if (!defined('EQDKP_INC'))
{
  header('HTTP/1.0 404 Not Found');exit;
}


/*+----------------------------------------------------------------------------
  | realmstatus_portal_hook
  +--------------------------------------------------------------------------*/
if (!class_exists('realmstatus_portal_hook'))
{
  class realmstatus_portal_hook extends gen_class
  {
    /* List of dependencies */
    public static $shortcuts = array('user', 'tpl', 'game', 'config');

	/**
    * portal
    * Do the hook 'portal'
    *
    * @return array
    */
	public function portal()
	{
		 // try to load the status file for this game
		$game_name = strtolower($this->game->get_game());
		$status_file = $this->root_path.'portal/realmstatus/'.$game_name.'/status.class.php';
		if (file_exists($status_file))
		{
		  include_once($status_file);

		  $class_name = $game_name.'_realmstatus';
		  $status = registry::register($class_name);
		  if ($status){
			$strServerStatus = $status->checkServer($this->config->get('servername'));
			$text = $this->config->get('servername');
			if ($strServerStatus = 'up') $text .= ' <span class="positive">online</span>';
			if ($strServerStatus != 'up') $text .= ' <span class="negative">offline</span>';
			
			$this->tpl->assign_block_vars('personal_area_addition', array(
				'TEXT' => $text,
			));
		  }

		}
	}
  }
}
if(version_compare(PHP_VERSION, '5.3.0', '<')) {
	registry::add_const('short_realmstatus_portal_hook', realmstatus_portal_hook::$shortcuts);
}
?>