Changes for upcoming version 1.3.0

- Bugfix: Changed tooltip class to be unique
- Bugfix: Changed superscript styling to not manipulate the line height
- Bugfix: Changed styling of the footnotes text in the reference container to avoid line breaks
- Updated: Reformatted code
- Added: new settings tab for custom CSS settings

git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@957947 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
Aricura 2014-07-31 10:17:38 +00:00
parent 0f3996338b
commit 3802249ec4
26 changed files with 2137 additions and 1651 deletions

396
classes/admin.php Normal file
View file

@ -0,0 +1,396 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0.7
* Since: 1.0
*/
// define class only once
if (!class_exists("MCI_Footnotes_Admin")) :
/**
* Class MCI_Footnotes_Admin
* @since 1.0
*/
class MCI_Footnotes_Admin {
// page hook for adding a new sub menu page to the settings
// @since 1.0
private $a_str_Pagehook = null;
// collection of settings values for this plugin
// @since 1.0
private $a_arr_Options = array();
// collection of tabs for the settings page of this plugin
// @since 1.0
private $a_arr_SettingsTabs = array();
// current active tab
public static $a_str_ActiveTab = null;
/**
* @constructor
* @since 1.0
*/
public function __construct() {
// include script and stylesheet functions
require_once(dirname(__FILE__) . "/../includes/wysiwyg-editor.php");
// load setting tabs
add_action('admin_init', array($this, 'Register'));
// register plugin in settings menu
add_action('admin_menu', array($this, 'RegisterMenu'));
}
/**
* register the settings field in the database for the "save" function
* called in class constructor @ admin_init
* @since 1.0
*/
public function Register() {
// register settings
register_setting(FOOTNOTES_SETTINGS_TAB_GENERAL, FOOTNOTES_SETTINGS_CONTAINER);
register_setting(FOOTNOTES_SETTINGS_TAB_CUSTOM, FOOTNOTES_SETTINGS_CONTAINER_CUSTOM);
// load tab 'general'
require_once(dirname( __FILE__ ) . "/tab_general.php");
new MCI_Footnotes_Tab_General($this->a_arr_SettingsTabs);
// load tab 'custom'
require_once(dirname( __FILE__ ) . "/tab_custom.php");
new MCI_Footnotes_Tab_Custom($this->a_arr_SettingsTabs);
// load tab 'how to'
require_once(dirname( __FILE__ ) . "/tab_howto.php");
new MCI_Footnotes_Tab_HowTo($this->a_arr_SettingsTabs);
}
/**
* sets the plugin's title for the admins settings menu
* called in class constructor @ admin_menu
* @since 1.0
*/
public function RegisterMenu() {
// current user needs the permission to update plugins for further access
if (!current_user_can('update_plugins')) {
return;
}
// Add a new sub menu to the standard Settings panel
$this->a_str_Pagehook = add_options_page(
FOOTNOTES_PLUGIN_PUBLIC_NAME,
FOOTNOTES_PLUGIN_PUBLIC_NAME,
'administrator',
FOOTNOTES_SETTINGS_PAGE_ID,
array($this, 'DisplaySettings')
);
}
/**
* Plugin Options page rendering goes here, checks
* for active tab and replaces key with the related
* settings key. Uses the plugin_options_tabs method
* to render the tabs.
* @since 1.0
*/
public function DisplaySettings() {
// load stylesheets and scripts
$this->LoadScriptsAndStylesheets();
// gets active tab, or if nothing set the "general" tab will be set to active
self::$a_str_ActiveTab = isset($_GET['tab']) ? $_GET['tab'] : FOOTNOTES_SETTINGS_TAB_GENERAL;
// outputs all tabs
echo '<div class="wrap">';
echo '<h2 class="nav-tab-wrapper">';
// iterate through all register tabs
foreach ($this->a_arr_SettingsTabs as $l_str_TabKey => $l_str_TabCaption) {
$l_str_Active = self::$a_str_ActiveTab == $l_str_TabKey ? 'nav-tab-active' : '';
echo '<a class="nav-tab ' . $l_str_Active . '" href="?page=' . FOOTNOTES_SETTINGS_PAGE_ID . '&tab=' . $l_str_TabKey . '">' . $l_str_TabCaption . '</a>';
}
echo '</h2>';
// outputs a form with the content of the current active tab
echo '<form method="post" action="options.php">';
wp_nonce_field('update-options');
settings_fields(self::$a_str_ActiveTab);
// outputs the settings field of the current active tab
do_settings_sections(self::$a_str_ActiveTab);
do_meta_boxes(self::$a_str_ActiveTab, 'main', NULL);
// adds a submit button to the current page
if (self::$a_str_ActiveTab != FOOTNOTES_SETTINGS_TAB_HOWTO) {
submit_button();
}
echo '</form>';
echo '</div>';
// output settings page specific javascript code
$this->OutputJavascript();
}
/**
* register and loads css and javascript files for settings
* @since 1.3
*/
private function LoadScriptsAndStylesheets() {
// register settings stylesheet
wp_register_style('footnote_settings_style', plugins_url('../css/settings.css', __FILE__));
// add settings stylesheet
wp_enqueue_style('footnote_settings_style');
// Needed to allow meta box layout and close functionality
wp_enqueue_script('postbox');
}
/**
* outputs page specific javascript code
* @since 1.0.7
*/
private function OutputJavascript() {
?>
<!-- Needed to allow meta box layout and close functionality. -->
<script type="text/javascript">
jQuery(document).ready(function ($) {
// close postboxes that should be closed
$('.if-js-closed').removeClass('if-js-closed').addClass('closed');
// postboxes setup
postboxes.add_postbox_toggles('<?php echo $this->a_str_Pagehook; ?>');
jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_START); ?>').on('change', function() {
var l_int_SelectedIndex = jQuery(this).prop("selectedIndex");
jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_END); ?> option:eq(' + l_int_SelectedIndex + ')').prop('selected', true);
footnotes_Display_UserDefined_Placeholders();
});
jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_END); ?>').on('change', function() {
var l_int_SelectedIndex = jQuery(this).prop("selectedIndex");
jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_START); ?> option:eq(' + l_int_SelectedIndex + ')').prop('selected', true);
footnotes_Display_UserDefined_Placeholders();
});
footnotes_Display_UserDefined_Placeholders();
});
function footnotes_Display_UserDefined_Placeholders() {
if (jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_START); ?>').val() == "userdefined") {
jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED); ?>').show();
jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED); ?>').show();
} else {
jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED); ?>').hide();
jQuery('#<?php echo $this->getFieldID(FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED); ?>').hide();
}
}
</script>
<?php
}
/**
* loads specific setting and returns an array with the keys [id, name, value]
* @since 1.0
* @param $p_str_FieldID
* @return array
*/
protected function LoadSetting($p_str_FieldID) {
// loads and filters the settings for this plugin
if (empty($this->a_arr_Options)) {
$this->a_arr_Options = MCI_Footnotes_getOptions(true);
}
$p_arr_Return = array();
$p_arr_Return["id"] = $this->getFieldID($p_str_FieldID);
$p_arr_Return["name"] = $this->getFieldName($p_str_FieldID);
$p_arr_Return["value"] = esc_attr($this->getFieldValue($p_str_FieldID));
return $p_arr_Return;
}
/**
* access settings field by name
* @since 1.0
* @param string $p_str_FieldName
* @return string
*/
protected function getFieldName($p_str_FieldName) {
// general setting
if (MCI_Footnotes_Admin::$a_str_ActiveTab == FOOTNOTES_SETTINGS_TAB_GENERAL) {
return sprintf('%s[%s]', FOOTNOTES_SETTINGS_CONTAINER, $p_str_FieldName);
// custom setting
} else if (MCI_Footnotes_Admin::$a_str_ActiveTab == FOOTNOTES_SETTINGS_TAB_CUSTOM) {
return sprintf('%s[%s]', FOOTNOTES_SETTINGS_CONTAINER_CUSTOM, $p_str_FieldName);
}
// undefined
return sprintf('%s[%s]', FOOTNOTES_SETTINGS_CONTAINER, $p_str_FieldName);
}
/**
* access settings field by id
* @since 1.0
* @param string $p_str_FieldID
* @return string
*/
protected function getFieldID($p_str_FieldID) {
return sprintf( '%s', $p_str_FieldID );
}
/**
* get settings field value
* @since 1.0
* @param string $p_str_Key
* @return string
*/
protected function getFieldValue($p_str_Key) {
return $this->a_arr_Options[$p_str_Key];
}
/**
* outputs a break to have a new line
* @since 1.0.7
*/
public function AddNewline() {
echo '<br/><br/>';
}
/**
* outputs a simple text
* @param string $p_str_Text
* @since 1.1.1
*/
public function AddText($p_str_Text) {
echo '<span>' . $p_str_Text . '</span>';
}
/**
* outputs a simple text with some highlight
* @param string $p_str_Text+
* @return string
* @since 1.1.1
*/
public function Highlight($p_str_Text) {
return '<b>' . $p_str_Text . '</b>';
}
/**
* outputs a label for a specific input/select box
* @param string $p_str_SettingsID
* @param string $p_str_Caption
* @param string $p_str_Styling
* @since 1.0.7
*/
public function AddLabel($p_str_SettingsID, $p_str_Caption, $p_str_Styling = "") {
// add styling tag if styling is set
if (!empty($p_str_Styling)) {
$p_str_Styling = ' style="' . $p_str_Styling . '"';
}
echo '<label for="' . $p_str_SettingsID . '"' . $p_str_Styling . '>' . $p_str_Caption . '</label>';
}
/**
* outputs a input type=text
* @param string $p_str_SettingsID [id of the settings field]
* @param string $p_str_ClassName [css class name]
* @param int $p_str_MaxLength [max length for the input value]
* @param bool $p_bool_Readonly [input is readonly] in version 1.1.1
* @param bool $p_bool_Hidden [input is hidden by default] in version 1.1.2
* @since 1.0-beta
* removed optional parameter for a label in version 1.0.7
*/
public function AddTextbox($p_str_SettingsID, $p_str_ClassName = "", $p_str_MaxLength = 0, $p_bool_Readonly = false, $p_bool_Hidden = false) {
// collect data for given settings field
$l_arr_Data = $this->LoadSetting($p_str_SettingsID);
// if input shall have a css class, add the style tag for it
if (!empty($p_str_ClassName)) {
$p_str_ClassName = 'class="' . $p_str_ClassName . '"';
}
// optional add a max length to the input field
if (!empty($p_str_MaxLength)) {
$p_str_MaxLength = ' maxlength="' . $p_str_MaxLength . '"';
}
if ($p_bool_Readonly) {
$p_bool_Readonly = ' readonly="readonly"';
}
if ($p_bool_Hidden) {
$p_bool_Hidden = ' style="display:none;"';
}
// outputs an input field type TEXT
echo '<input type="text" ' . $p_str_ClassName . $p_str_MaxLength . $p_bool_Readonly . $p_bool_Hidden . ' name="' . $l_arr_Data["name"] . '" id="' . $l_arr_Data["id"] . '" value="' . $l_arr_Data["value"] . '"/>';
}
/**
* outputs a input type=checkbox
* @param string $p_str_SettingsID [id of the settings field]
* @param string $p_str_ClassName [optional css class name]
* @since 1.0-beta
*/
public function AddCheckbox($p_str_SettingsID, $p_str_ClassName = "") {
require_once(dirname(__FILE__) . "/convert.php");
// collect data for given settings field
$l_arr_Data = $this->LoadSetting($p_str_SettingsID);
// if input shall have a css class, add the style tag for it
if (!empty($p_str_ClassName)) {
$p_str_ClassName = 'class="' . $p_str_ClassName . '"';
}
// lookup if the checkbox shall be pre-checked
$l_str_Checked = "";
if (MCI_Footnotes_Convert::toBool($l_arr_Data["value"])) {
$l_str_Checked = 'checked="checked"';
}
// outputs an input field type CHECKBOX
echo sprintf('<input type="checkbox" ' . $p_str_ClassName . ' name="' . $l_arr_Data["name"] . '" id="' . $l_arr_Data["id"] . '" %s/>', $l_str_Checked);
}
/**
* outputs a select box
* @param string $p_str_SettingsID [id of the settings field]
* @param array $p_arr_Options [array with options]
* @param string $p_str_ClassName [optional css class name]
* @since 1.0-beta
*/
public function AddSelect($p_str_SettingsID, $p_arr_Options, $p_str_ClassName = "") {
// collect data for given settings field
$l_arr_Data = $this->LoadSetting($p_str_SettingsID);
// if input shall have a css class, add the style tag for it
if (!empty($p_str_ClassName)) {
$p_str_ClassName = 'class="' . $p_str_ClassName . '"';
}
// select starting tag
$l_str_Output = '<select ' . $p_str_ClassName . ' name="' . $l_arr_Data["name"] . '" id="' . $l_arr_Data["id"] . '">';
// loop through all array keys
foreach ($p_arr_Options as $l_str_Value => $l_str_Caption) {
// add key as option value
$l_str_Output .= '<option value="' . $l_str_Value . '"';
// check if option value is set and has to be pre-selected
if ($l_arr_Data["value"] == $l_str_Value) {
$l_str_Output .= ' selected';
}
// write option caption and close option tag
$l_str_Output .= '>' . $l_str_Caption . '</option>';
}
// close select
$l_str_Output .= '</select>';
// outputs the SELECT field
echo $l_str_Output;
}
/**
* outputs a textarea
* @param string $p_str_SettingsID [id of the settings field]
* @param int $p_int_Rows [amount of rows]
* @param string $p_str_ClassName [css class name]
* @since 1.3
*/
public function AddTextarea($p_str_SettingsID, $p_int_Rows, $p_str_ClassName = "") {
// collect data for given settings field
$l_arr_Data = $this->LoadSetting($p_str_SettingsID);
// if input shall have a css class, add the style tag for it
if (!empty($p_str_ClassName)) {
$p_str_ClassName = 'class="' . $p_str_ClassName . '"';
}
// outputs an input field type TEXT
echo '<textarea ' . $p_str_ClassName . ' name="' . $l_arr_Data["name"] . '" id="' . $l_arr_Data["id"] . '" rows="'.$p_int_Rows.'">' . $l_arr_Data["value"] . '</textarea>';
}
}// class MCI_Footnotes_Admin
endif;

152
classes/convert.php Normal file
View file

@ -0,0 +1,152 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 30.07.14 11:45
* Version: 1.0
* Since: 1.3
*/
// define class only once
if (!class_exists("MCI_Footnotes_Convert")) :
/**
* Class MCI_Footnotes_Convert
* @since 1.3
*/
class MCI_Footnotes_Convert {
/**
* converts a integer into the user-defined counter style for the footnotes
* @since 1.0-gamma
* @param int $p_int_Index
* @param string $p_str_ConvertStyle [counter style]
* @return string
*/
public static function Index($p_int_Index, $p_str_ConvertStyle = "arabic_plain") {
switch ($p_str_ConvertStyle) {
case "romanic":
return self::toRomanic($p_int_Index);
case "latin_high":
return self::toLatin($p_int_Index, true);
case "latin_low":
return self::toLatin($p_int_Index, false);
case "arabic_leading":
return self::toArabicLeading($p_int_Index);
case "arabic_plain":
default:
return $p_int_Index;
}
}
/**
* converts a integer into latin ascii characters, either lower or upper-case
* function available from A to ZZ ( means 676 footnotes at 1 page possible)
* @since 1.0-gamma
* @param int $p_int_Value
* @param bool $p_bool_UpperCase
* @return string
*/
private static function toLatin($p_int_Value, $p_bool_UpperCase) {
// decimal value of the starting ascii character
$l_int_StartingASCII = 65 - 1; // = A
// if lower-case, change decimal to lower-case "a"
if (!$p_bool_UpperCase) {
$l_int_StartingASCII = 97 - 1; // = a
}
// output string
$l_str_Return = "";
$l_int_Offset = 0;
// check if the value is higher then 26 = Z
while ($p_int_Value > 26) {
// increase offset and reduce counter
$l_int_Offset++;
$p_int_Value -= 26;
}
// if offset set (more then Z), then add a new letter in front
if ($l_int_Offset > 0) {
$l_str_Return = chr($l_int_Offset + $l_int_StartingASCII);
}
// add the origin letter
$l_str_Return .= chr($p_int_Value + $l_int_StartingASCII);
// return the latin character representing the integer
return $l_str_Return;
}
/**
* converts a integer to a leading-0 integer
* @since 1.0-gamma
* @param int $p_int_Value
* @return string
*/
private static function toArabicLeading($p_int_Value) {
// add a leading 0 if number lower then 10
if ($p_int_Value < 10) {
return "0" . $p_int_Value;
}
return $p_int_Value;
}
/**
* converts a arabic integer value into a romanic letter value
* @since 1.0-gamma
* @param int $p_int_Value
* @return string
*/
private static function toRomanic($p_int_Value) {
// table containing all necessary romanic letters
$l_arr_RomanicLetters = array(
'M' => 1000,
'CM' => 900,
'D' => 500,
'CD' => 400,
'C' => 100,
'XC' => 90,
'L' => 50,
'XL' => 40,
'X' => 10,
'IX' => 9,
'V' => 5,
'IV' => 4,
'I' => 1
);
// return value
$l_str_Return = '';
// iterate through integer value until it is reduced to 0
while ($p_int_Value > 0) {
foreach ($l_arr_RomanicLetters as $l_str_Romanic => $l_int_Arabic) {
if ($p_int_Value >= $l_int_Arabic) {
$p_int_Value -= $l_int_Arabic;
$l_str_Return .= $l_str_Romanic;
break;
}
}
}
// return romanic letters as string
return $l_str_Return;
}
/**
* converts a string depending on its value to a boolean
* @since 1.0-beta
* @param string $p_str_Value
* @return bool
*/
public static function toBool($p_str_Value) {
// convert string to lower-case to make it easier */
$p_str_Value = strtolower($p_str_Value);
// check if string seems to contain a "true" value */
switch ($p_str_Value) {
case "checked":
case "yes":
case "true":
case "on":
case "1":
return true;
}
// nothing found that says "true", so we return false */
return false;
}
} // class MCI_Footnotes_Convert
endif;

View file

@ -8,52 +8,64 @@
* Since: 1.0
*/
// define class only once
if (!class_exists( "MCI_Footnotes" )) :
/**
* Class Class_Footnotes
* Class MCI_Footnotes
* @since 1.0
*/
class Class_Footnotes
{
/*
* object to the plugin's settings
* @since 1.0
*/
var $a_obj_Settings;
class MCI_Footnotes {
// object to the plugin settings
// @since 1.0
// @var MCI_Footnotes_Admin $a_obj_Settings
private $a_obj_Admin;
// replace task object
/** @var \MCI_Footnotes_Task $a_obj_Task */
public $a_obj_Task;
/**
* @constructor
* @since 1.0
*/
function __construct()
{
/* load settings only if current wordpress user is admin */
public function __construct() {
// load settings only if current WordPress user is admin
if (is_admin()) {
/* create a new instance of the class settings */
$this->a_obj_Settings = new Class_FootnotesSettings();
// load plugin settings
require_once(dirname( __FILE__ ) . "/admin.php");
$this->a_obj_Admin = new MCI_Footnotes_Admin();
}
// load plugin widget
require_once(dirname( __FILE__ ) . "/widget.php");
// register footnotes widget
add_action('widgets_init', create_function('', 'return register_widget("MCI_Footnotes_Widget");'));
// load public css and javascript files
add_action('init', array($this, 'LoadScriptsAndStylesheets'));
// adds javascript and stylesheets to the public page
add_action('wp_enqueue_scripts', array($this, 'LoadScriptsAndStylesheets'));
/* execute class function: init, admin_init and admin_menu */
add_action('init', array($this, 'init'));
add_action('admin_init', array($this, 'admin_init'));
add_action('admin_menu', array($this, 'admin_menu'));
// load plugin widget
require_once(dirname( __FILE__ ) . "/task.php");
$this->a_obj_Task = new MCI_Footnotes_Task();
$this->a_obj_Task->Register();
}
/**
* activates the plugin
* @since 1.0
*/
static function activate()
{
// unused
public static function activate() {
// unused
}
/**
* deactivates the plugin
* @since 1.0
*/
static function deactivate()
{
// unused
public static function deactivate() {
// unused
}
/**
@ -61,53 +73,44 @@ class Class_Footnotes
* updated file path in version 1.0.6
* @since 1.0
*/
static function uninstall()
{
/* uninstalling the plugin is only allowed for logged in users */
public static function uninstall() {
// uninstalling the plugin is only allowed for logged in users
if (!is_user_logged_in()) {
wp_die(__('You must be logged in to run this script.', FOOTNOTES_PLUGIN_NAME));
}
/* current user needs the permission to (un)install plugins */
// current user needs the permission to (un)install plugins
if (!current_user_can('install_plugins')) {
wp_die(__('You do not have permission to run this script.', FOOTNOTES_PLUGIN_NAME));
}
/*
* delete the settings container in the database
* @since 1.0.6
*/
delete_option(FOOTNOTE_SETTINGS_CONTAINER);
// delete the settings container in the database
// @since 1.0.6
delete_option(FOOTNOTES_SETTINGS_CONTAINER);
delete_option(FOOTNOTES_SETTINGS_CONTAINER_CUSTOM);
}
/**
* initialize function
* called in the class constructor
* @since 1.0
*/
function init()
{
// unused
}
/**
* load public styling and client function
* called in class constructor @ init
* @since 1.0
*/
public function LoadScriptsAndStylesheets() {
// register public stylesheets
wp_register_style('MCI_Footnotes_public_style_General', plugins_url('../css/footnotes.css', __FILE__));
wp_register_style('MCI_Footnotes_public_style_Tooltip', plugins_url('../css/tooltip.css', __FILE__));
wp_register_style('MCI_Footnotes_public_style_ReferenceContainer', plugins_url('../css/reference_container.css', __FILE__));
// add public stylesheets
wp_enqueue_style('MCI_Footnotes_public_style_General');
wp_enqueue_style('MCI_Footnotes_public_style_Tooltip');
wp_enqueue_style('MCI_Footnotes_public_style_ReferenceContainer');
/**
* do admin init stuff
* called in the class constructor
* @since 1.0
*/
function admin_init()
{
// unused
}
// add the jQuery plugin (already registered by WP)
wp_enqueue_script('jquery');
// add jquery tools to public page
wp_enqueue_script('footnotes_public_script', plugins_url('../js/jquery.tools.min.js', __FILE__), array());
}
/**
* do admin menu stuff
* called in the class constructor
* @since 1.0
*/
function admin_menu()
{
// unused
}
} // class MCI_Footnotes
} /* class Class_Footnotes */
endif;

View file

@ -1,626 +0,0 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0.7
* Since: 1.0
*/
/**
* Class Class_FootnotesSettings
* @since 1.0
*/
class Class_FootnotesSettings
{
/*
* attribute for default settings value
* updated default value for 'FOOTNOTE_INPUTFIELD_LOVE' to default: 'no' in version 1.0.6
* @since 1.0
*/
public static $a_arr_Default_Settings = array(
FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL => 'yes',
FOOTNOTE_INPUTFIELD_REFERENCES_LABEL => 'References',
FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES => '',
FOOTNOTE_INPUTFIELD_PLACEHOLDER_START => '((',
FOOTNOTE_INPUTFIELD_PLACEHOLDER_END => '))',
FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT => 'yes',
FOOTNOTE_INPUTFIELD_LOVE => 'no',
FOOTNOTE_INPUTFIELD_COUNTER_STYLE => 'arabic_plain',
FOOTNOTE_INPUTFIELD_REFERENCE_CONTAINER_PLACE => 'post_end',
FOOTNOTE_INPUTFIELD_PLACEHOLDER_START_USERDEFINED => '',
FOOTNOTE_INPUTFIELD_PLACEHOLDER_END_USERDEFINED => ''
);
/*
* resulting pagehook for adding a new sub menu page to the settings
* @since 1.0
*/
var $a_str_Pagehook;
/*
* collection of settings values for this plugin
* @since 1.0
*/
var $a_arr_Options;
/*
* collection of tabs for the settings page of this plugin
* @since 1.0
*/
private $a_arr_SettingsTabs = array();
/**
* @constructor
* @since 1.0
*/
function __construct()
{
/* loads and filters the settings for this plugin */
$this->a_arr_Options = footnotes_filter_options(FOOTNOTE_SETTINGS_CONTAINER, self::$a_arr_Default_Settings, true);
/* execute class includes on action-even: init, admin_init and admin_menu */
add_action('init', array($this, 'LoadScriptsAndStylesheets'));
add_action('admin_init', array($this, 'RegisterSettings'));
add_action('admin_init', array($this, 'RegisterTab_General'));
add_action('admin_init', array($this, 'RegisterTab_HowTo'));
add_action('admin_menu', array($this, 'AddSettingsMenuPanel'));
}
/**
* initialize settings page, loads scripts and stylesheets needed for the layout
* called in class constructor @ init
* @since 1.0
*/
function LoadScriptsAndStylesheets()
{
/* register public stylesheet */
wp_register_style('footnote_public_style', plugins_url('../css/footnote.css', __FILE__));
/* add public stylesheet */
wp_enqueue_style('footnote_public_style');
}
/**
* register the settings field in the database for the "save" function
* called in class constructor @ admin_init
* @since 1.0
*/
function RegisterSettings()
{
register_setting(FOOTNOTE_SETTINGS_LABEL_GENERAL, FOOTNOTE_SETTINGS_CONTAINER);
}
/**
* sets the plugin's title for the admins settings menu
* called in class constructor @ admin_menu
* @since 1.0
*/
function AddSettingsMenuPanel()
{
/* current user needs the permission to update plugins for further access */
if (!current_user_can('update_plugins')) {
return;
}
/* submenu page title */
$l_str_PageTitle = FOOTNOTES_PLUGIN_PUBLIC_NAME;
/* submenu title */
$l_str_MenuTitle = FOOTNOTES_PLUGIN_PUBLIC_NAME;
/* Add a new submenu to the standard Settings panel */
$this->a_str_Pagehook = add_options_page($l_str_PageTitle, $l_str_MenuTitle, 'administrator', FOOTNOTES_SETTINGS_PAGE_ID, array($this, 'OutputSettingsPage'));
}
/**
* Plugin Options page rendering goes here, checks
* for active tab and replaces key with the related
* settings key. Uses the plugin_options_tabs method
* to render the tabs.
* @since 1.0
*/
function OutputSettingsPage()
{
/* add the jQuery plugin (already registered by WP) */
wp_enqueue_script('jquery');
/* register settings stylesheet */
wp_register_style('footnote_settings_style', plugins_url('../css/settings.css', __FILE__));
/* add settings stylesheet */
wp_enqueue_style('footnote_settings_style');
/* Needed to allow metabox layout and close functionality */
wp_enqueue_script('postbox');
/* add jquery tools to public page */
wp_enqueue_script('footnotes_public_script', plugins_url('../js/jquery.tools.min.js', __FILE__), array());
/* gets active tag, or if nothing set the "general" tab will be set to active */
$l_str_tab = isset($_GET['tab']) ? $_GET['tab'] : FOOTNOTE_SETTINGS_LABEL_GENERAL;
/* outputs all tabs */
echo '<div class="wrap">';
$this->OutputSettingsPageTabs();
/* outputs a form with the content of the current active tab */
echo '<form method="post" action="options.php">';
wp_nonce_field('update-options');
settings_fields($l_str_tab);
/* outputs the settings field of the current active tab */
do_settings_sections($l_str_tab);
do_meta_boxes($l_str_tab, 'main', NULL);
/* adds a submit button to the current page */
/*
* add submit button only if there are some settings on the current page
* @since version 1.0.7
*/
if ($l_str_tab == FOOTNOTE_SETTINGS_LABEL_GENERAL) {
submit_button();
}
echo '</form>';
echo '</div>';
/*
* output settings page specific javascript code
* @since 1.0.7
*/
$this->OutputJavascript();
}
/**
* Renders our tabs in the plugin options page,
* walks through the object's tabs array and prints
* them one by one. Provides the heading for the
* plugin_options_page method.
* @since 1.0
*/
function OutputSettingsPageTabs()
{
/* gets active tag, or if nothing set the "general" tab will be set to active */
$l_str_CurrentTab = isset($_GET['tab']) ? $_GET['tab'] : FOOTNOTE_SETTINGS_LABEL_GENERAL;
screen_icon();
echo '<h2 class="nav-tab-wrapper">';
foreach ($this->a_arr_SettingsTabs as $l_str_TabKey => $l_str_TabCaption) {
$active = $l_str_CurrentTab == $l_str_TabKey ? 'nav-tab-active' : '';
echo '<a class="nav-tab ' . $active . '" href="?page=' . FOOTNOTES_SETTINGS_PAGE_ID . '&tab=' . $l_str_TabKey . '">' . $l_str_TabCaption . '</a>';
}
echo '</h2>';
}
/**
* outputs page specific javascript code
* @since 1.0.7
*/
function OutputJavascript()
{
?>
<!-- Needed to allow metabox layout and close functionality. -->
<script type="text/javascript">
jQuery(document).ready(function ($) {
// close postboxes that should be closed
$('.if-js-closed').removeClass('if-js-closed').addClass('closed');
// postboxes setup
postboxes.add_postbox_toggles('<?php echo $this->a_str_Pagehook; ?>');
jQuery('#<?php echo $this->getFieldID(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START); ?>').on('change', function() {
var l_int_SelectedIndex = jQuery(this).prop("selectedIndex");
jQuery('#<?php echo $this->getFieldID(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END); ?> option:eq(' + l_int_SelectedIndex + ')').prop('selected', true);
footnotes_Display_UserDefined_Placeholders();
});
jQuery('#<?php echo $this->getFieldID(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END); ?>').on('change', function() {
var l_int_SelectedIndex = jQuery(this).prop("selectedIndex");
jQuery('#<?php echo $this->getFieldID(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START); ?> option:eq(' + l_int_SelectedIndex + ')').prop('selected', true);
footnotes_Display_UserDefined_Placeholders();
});
footnotes_Display_UserDefined_Placeholders();
});
function footnotes_Display_UserDefined_Placeholders() {
if (jQuery('#<?php echo $this->getFieldID(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START); ?>').val() == "userdefined") {
jQuery('#<?php echo $this->getFieldID(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START_USERDEFINED); ?>').show();
jQuery('#<?php echo $this->getFieldID(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END_USERDEFINED); ?>').show();
} else {
jQuery('#<?php echo $this->getFieldID(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START_USERDEFINED); ?>').hide();
jQuery('#<?php echo $this->getFieldID(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END_USERDEFINED); ?>').hide();
}
}
</script>
<?php
}
/**
* loads specific setting and returns an array with the keys [id, name, value]
* @since 1.0
* @param $p_str_FieldID
* @return array
*/
protected function LoadSetting($p_str_FieldID)
{
$p_arr_Return = array();
$p_arr_Return["id"] = $this->getFieldID($p_str_FieldID);
$p_arr_Return["name"] = $this->getFieldName($p_str_FieldID);
$p_arr_Return["value"] = esc_attr($this->getFieldValue($p_str_FieldID));
return $p_arr_Return;
}
/**
* access settings field by name
* @since 1.0
* @param string $p_str_FieldName
* @return string
*/
protected function getFieldName($p_str_FieldName)
{
return sprintf('%s[%s]', FOOTNOTE_SETTINGS_CONTAINER, $p_str_FieldName);
//return sprintf( '%s', $p_str_FieldName );
}
/**
* access settings field by id
* @since 1.0
* @param string $p_str_FieldID
* @return string
*/
protected function getFieldID($p_str_FieldID)
{
//return sprintf('%s[%s]', FOOTNOTE_SETTINGS_CONTAINER, $p_str_FieldID);
return sprintf( '%s', $p_str_FieldID );
}
/**
* get settings field value
* @since 1.0
* @param string $p_str_Key
* @return string
*/
protected function getFieldValue($p_str_Key)
{
return $this->a_arr_Options[$p_str_Key];
}
/**
* outputs a break to have a new line
* @since 1.0.7
*/
function AddNewline()
{
echo '<br/><br/>';
}
/**
* outputs a simple text
* @param string $p_str_Text
* @since 1.1.1
*/
function AddText($p_str_Text)
{
echo '<span>' . $p_str_Text . '</span>';
}
/**
* outputs a label for a specific input/select box
* @param string $p_str_SettingsID
* @param string $p_str_Caption
* @param string $p_str_Styling
* @since 1.0.7
*/
function AddLabel($p_str_SettingsID, $p_str_Caption, $p_str_Styling = "")
{
/* add styling tag if styling is set */
if (!empty($p_str_Styling)) {
$p_str_Styling = ' style="' . $p_str_Styling . '"';
}
echo '<label for="' . $p_str_SettingsID . '"' . $p_str_Styling . '>' . $p_str_Caption . '</label>';
}
/**
* outputs a input type=text
* @param string $p_str_SettingsID [id of the settings field]
* @param string $p_str_ClassName [css class name]
* @param int $p_str_MaxLength [max length for the input value]
* @param bool $p_bool_Readonly [input is readonly] in version 1.1.1
* @param bool $p_bool_Hidden [input is hidden by default] in version 1.1.2
* @since 1.0-beta
* removed optional paremter for a label in version 1.0.7
*/
function AddTextbox($p_str_SettingsID, $p_str_ClassName = "", $p_str_MaxLength = 0, $p_bool_Readonly = false, $p_bool_Hidden = false)
{
/* collect data for given settings field */
$l_arr_Data = $this->LoadSetting($p_str_SettingsID);
/* if input shall have a css class, add the style tag for it */
if (!empty($p_str_ClassName)) {
$p_str_ClassName = 'class="' . $p_str_ClassName . '"';
}
/* optional add a maxlength to the input field */
if (!empty($p_str_MaxLength)) {
$p_str_MaxLength = ' maxlength="' . $p_str_MaxLength . '"';
}
if ($p_bool_Readonly) {
$p_bool_Readonly = ' readonly="readonly"';
}
if ($p_bool_Hidden) {
$p_bool_Hidden = ' style="display:none;"';
}
/* outputs an input field type TEXT */
echo '<input type="text" ' . $p_str_ClassName . $p_str_MaxLength . $p_bool_Readonly . $p_bool_Hidden . ' name="' . $l_arr_Data["name"] . '" id="' . $l_arr_Data["id"] . '" value="' . $l_arr_Data["value"] . '"/>';
}
/**
* outputs a input type=checkbox
* @param string $p_str_SettingsID [id of the settings field]
* @param string $p_str_ClassName [optional css class name]
* @since 1.0-beta
*/
function AddCheckbox($p_str_SettingsID, $p_str_ClassName = "")
{
/* collect data for given settings field */
$l_arr_Data = $this->LoadSetting($p_str_SettingsID);
/* if input shall have a css class, add the style tag for it */
if (!empty($p_str_ClassName)) {
$p_str_ClassName = 'class="' . $p_str_ClassName . '"';
}
/* lookup if the checkbox shall be pre-checked */
$l_str_Checked = "";
if (footnotes_ConvertToBool($l_arr_Data["value"])) {
$l_str_Checked = 'checked="checked"';
}
/* outputs an input field type CHECKBOX */
echo sprintf('<input type="checkbox" ' . $p_str_ClassName . ' name="' . $l_arr_Data["name"] . '" id="' . $l_arr_Data["id"] . '" %s/>', $l_str_Checked);
}
/**
* outputs a select box
* @param string $p_str_SettingsID [id of the settings field]
* @param array $p_arr_Options [array with options]
* @param string $p_str_ClassName [optional css class name]
* @since 1.0-beta
*/
function AddSelectbox($p_str_SettingsID, $p_arr_Options, $p_str_ClassName = "")
{
/* collect data for given settings field */
$l_arr_Data = $this->LoadSetting($p_str_SettingsID);
/* if input shall have a css class, add the style tag for it */
if (!empty($p_str_ClassName)) {
$p_str_ClassName = 'class="' . $p_str_ClassName . '"';
}
/* select starting tag */
$l_str_Output = '<select ' . $p_str_ClassName . ' name="' . $l_arr_Data["name"] . '" id="' . $l_arr_Data["id"] . '">';
/* loop through all array keys */
foreach ($p_arr_Options as $l_str_Value => $l_str_Caption) {
/* add key as option value */
$l_str_Output .= '<option value="' . $l_str_Value . '"';
/* check if option value is set and has to be pre-selected */
if ($l_arr_Data["value"] == $l_str_Value) {
$l_str_Output .= ' selected';
}
/* write option caption and close option tag */
$l_str_Output .= '>' . $l_str_Caption . '</option>';
}
/* close select */
$l_str_Output .= '</select>';
/* outputs the SELECT field */
echo $l_str_Output;
}
/**
* initialize general settings tab
* called in class constructor @ admin_init
* @since 1.0
* changed layout of settings form settings fields to meta boxes in version 1.0.7
*/
function RegisterTab_General()
{
/* add tab to the tab array */
$this->a_arr_SettingsTabs[FOOTNOTE_SETTINGS_LABEL_GENERAL] = __("General", FOOTNOTES_PLUGIN_NAME);
/* register settings tab */
add_settings_section("Footnote_Secion_Settings_General", sprintf(__("%s Settings", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME), array($this, 'RegisterTab_General_Description'), FOOTNOTE_SETTINGS_LABEL_GENERAL);
add_meta_box('Register_MetaBox_ReferenceContainer', __("References Container", FOOTNOTES_PLUGIN_NAME), array($this, 'Register_MetaBox_ReferenceContainer'), FOOTNOTE_SETTINGS_LABEL_GENERAL, 'main');
add_meta_box('Register_MetaBox_FootnoteStyling', sprintf(__("%s styling", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME), array($this, 'Register_MetaBox_FootnoteStyling'), FOOTNOTE_SETTINGS_LABEL_GENERAL, 'main');
add_meta_box('Register_MetaBox_Love', FOOTNOTES_PLUGIN_PUBLIC_NAME . '&nbsp;' . FOOTNOTES_LOVE_SYMBOL, array($this, 'Register_MetaBox_Love'), FOOTNOTE_SETTINGS_LABEL_GENERAL, 'main');
add_meta_box('Register_MetaBox_Other', __("Other", FOOTNOTES_PLUGIN_NAME), array($this, 'Register_MetaBox_Other'), FOOTNOTE_SETTINGS_LABEL_GENERAL, 'main');
}
/**
* adds a desciption to the general settings tab
* called in RegisterTab_General
* @since 1.0
*/
function RegisterTab_General_Description()
{
// unused description
}
/**
* outputs a container for the reference container settings
* @since 1.0.7
*/
function Register_MetaBox_ReferenceContainer()
{
/* setting for 'reference label' */
$this->AddLabel(FOOTNOTE_INPUTFIELD_REFERENCES_LABEL, __("References label:", FOOTNOTES_PLUGIN_NAME));
$this->AddTextbox(FOOTNOTE_INPUTFIELD_REFERENCES_LABEL, "footnote_plugin_50");
$this->AddNewline();
/* setting for 'collapse reference container by default' */
$this->AddLabel(FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES, __("Collapse references by default:", FOOTNOTES_PLUGIN_NAME));
$this->AddCheckbox(FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES);
$this->AddNewline();
/*
* setting for 'placement of the reference container'
* @since 1.0.7
*/
$l_arr_Options = array(
"footer" => __("in the footer", FOOTNOTES_PLUGIN_NAME),
"post_end" => __("at the end of the post", FOOTNOTES_PLUGIN_NAME),
"widget" => __("in the widget area", FOOTNOTES_PLUGIN_NAME)
);
$this->AddLabel(FOOTNOTE_INPUTFIELD_REFERENCE_CONTAINER_PLACE, __("Where shall the reference container appear:", FOOTNOTES_PLUGIN_NAME));
$this->AddSelectbox(FOOTNOTE_INPUTFIELD_REFERENCE_CONTAINER_PLACE, $l_arr_Options, "footnote_plugin_50");
}
/**
* outputs a container for the styling of footnotes
* @since 1.0.7
*/
function Register_MetaBox_FootnoteStyling()
{
/* setting for 'combine identical footnotes' */
$l_arr_Options = array(
"yes" => __("Yes", FOOTNOTES_PLUGIN_NAME),
"no" => __("No", FOOTNOTES_PLUGIN_NAME)
);
$this->AddLabel(FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL, __("Combine identical footnotes:", FOOTNOTES_PLUGIN_NAME));
$this->AddSelectbox(FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL, $l_arr_Options, "footnote_plugin_50");
$this->AddNewline();
/* setting for 'footnote tag starts with' */
$l_arr_Options = array(
"((" => "((",
"<fn>" => htmlspecialchars("<fn>"),
"[ref]" => "[ref]",
"userdefined" => __('user defined', FOOTNOTES_PLUGIN_NAME)
);
$this->AddLabel(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START, __("Footnote tag starts with:", FOOTNOTES_PLUGIN_NAME));
$this->AddSelectbox(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START, $l_arr_Options, "footnote_plugin_15");
/* setting for 'footnote tag ends with' */
$l_arr_Options = array(
"))" => "))",
"</fn>" => htmlspecialchars("</fn>"),
"[/ref]" => "[/ref]",
"userdefined" => __('user defined', FOOTNOTES_PLUGIN_NAME)
);
$this->AddLabel(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END, __("and ends with:", FOOTNOTES_PLUGIN_NAME) . '&nbsp;&nbsp;&nbsp;', 'text-align: right;');
$this->AddSelectbox(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END, $l_arr_Options, "footnote_plugin_15");
$this->AddNewline();
/* user defined setting for 'footnote start and end tag' */
$this->AddLabel(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START_USERDEFINED, "");
$this->AddTextbox(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START_USERDEFINED, "footnote_plugin_15", 14, false, true);
$this->AddLabel(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END_USERDEFINED, "");
$this->AddTextbox(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END_USERDEFINED, "footnote_plugin_15", 14, false, true);
$this->AddNewline();
/* setting for 'footnotes counter style' */
$l_str_Space = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$l_arr_Options = array(
"arabic_plain" => __("Arabic Numbers - Plain", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "1, 2, 3, 4, 5, ...",
"arabic_leading" => __("Arabic Numbers - Leading 0", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "01, 02, 03, 04, 05, ...",
"latin_low" => __("Latin Character - lower case", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "a, b, c, d, e, ...",
"latin_high" => __("Latin Character - upper case", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "A, B, C, D, E, ...",
"romanic" => __("Roman Numerals", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "I, II, III, IV, V, ..."
);
$this->AddLabel(FOOTNOTE_INPUTFIELD_COUNTER_STYLE, __('Counter style:', FOOTNOTES_PLUGIN_NAME));
$this->AddSelectbox(FOOTNOTE_INPUTFIELD_COUNTER_STYLE, $l_arr_Options, "footnote_plugin_50");
}
/**
* outputs other footnotes settings that doesn't match a special category
* @since 1.0.7
*/
function Register_MetaBox_Love()
{
/* setting for 'love and share this plugin in my footer' */
$l_arr_Options = array(
"text-1" => sprintf(__('I %s %s', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_LOVE_SYMBOL, FOOTNOTES_PLUGIN_PUBLIC_NAME),
"text-2" => sprintf(__('this site uses the awesome %s Plugin', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME),
"text-3" => sprintf(__('extra smooth %s', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME),
"random" => __('random text', FOOTNOTES_PLUGIN_NAME),
"no" => sprintf(__("Don't display a %s %s text in my footer.", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME, FOOTNOTES_LOVE_SYMBOL)
);
$this->AddLabel(FOOTNOTE_INPUTFIELD_LOVE, sprintf(__("Tell the world you're using %s:", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME));
$this->AddSelectbox(FOOTNOTE_INPUTFIELD_LOVE, $l_arr_Options, "footnote_plugin_50");
$this->AddNewline();
/* no 'love me' on specific pages */
$this->AddText(sprintf(__("Don't tell the world you're using %s on specific pages by adding the following short code:", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME));
$this->AddText("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
$this->AddText(FOOTNOTES_NO_SLUGME_PLUG);
}
/**
* outputs other footnotes settings that doesn't match a special category
* @since 1.0.7
*/
function Register_MetaBox_Other()
{
/* setting for 'search footnotes tag in excerpt' */
$l_arr_Options = array(
"yes" => __("Yes", FOOTNOTES_PLUGIN_NAME),
"no" => __("No", FOOTNOTES_PLUGIN_NAME)
);
$this->AddLabel(FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT, __('Allow footnotes on Summarized Posts:', FOOTNOTES_PLUGIN_NAME));
$this->AddSelectbox(FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT, $l_arr_Options, "footnote_plugin_50");
}
/**
* initialize howto settings tab
* called in class constructor @ admin_init
* @since 1.0
* changed layout of settings form settings fields to meta boxes in version 1.0.7
*/
function RegisterTab_HowTo()
{
/* add tab to the tab array */
$this->a_arr_SettingsTabs[FOOTNOTE_SETTINGS_LABEL_HOWTO] = __("HowTo", FOOTNOTES_PLUGIN_NAME);
/* register settings tab */
add_settings_section("Footnote_Secion_Settings_Howto", "&nbsp;", array($this, 'RegisterTab_HowTo_Description'), FOOTNOTE_SETTINGS_LABEL_HOWTO);
add_meta_box('Register_MetaBox_HowTo', __("Brief introduction in how to use the plugin", FOOTNOTES_PLUGIN_NAME), array($this, 'Register_MetaBox_HowTo'), FOOTNOTE_SETTINGS_LABEL_HOWTO, 'main');
}
/**
* adds a descrption to the HowTo settings tab
* called int RegisterTab_HowTo
* @since 1.0
* removed output of description in version 1.0.7
*/
function RegisterTab_HowTo_Description()
{
// unused
}
/**
* outputs the content of the HowTo settings tab
* @since 1.0
*/
function Register_MetaBox_HowTo()
{
$l_arr_Footnote_StartingTag = $this->LoadSetting(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START);
$l_arr_Footnote_EndingTag = $this->LoadSetting(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END);
if ($l_arr_Footnote_StartingTag["value"] == "userdefined" || $l_arr_Footnote_EndingTag["value"] == "userdefined") {
$l_arr_Footnote_StartingTag = $this->LoadSetting(FOOTNOTE_INPUTFIELD_PLACEHOLDER_START_USERDEFINED);
$l_arr_Footnote_EndingTag = $this->LoadSetting(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END_USERDEFINED);
}
?>
<div style="text-align:center;">
<div class="footnote_placeholder_box_container">
<p>
<?php echo __("Start your footnote with the following shortcode:", FOOTNOTES_PLUGIN_NAME); ?>
<span
class="footnote_highlight_placeholder"><?php echo $l_arr_Footnote_StartingTag["value"]; ?></span>
</p>
<p>
<?php echo __("...and end your footnote with this shortcode:", FOOTNOTES_PLUGIN_NAME); ?>
<span
class="footnote_highlight_placeholder"><?php echo $l_arr_Footnote_EndingTag["value"]; ?></span>
</p>
<div class="footnote_placeholder_box_example">
<p>
<span
class="footnote_highlight_placeholder"><?php echo $l_arr_Footnote_StartingTag["value"] . __("example string", FOOTNOTES_PLUGIN_NAME) . $l_arr_Footnote_EndingTag["value"]; ?></span>
<?php echo __("will be displayed as:", FOOTNOTES_PLUGIN_NAME); ?>
&nbsp;&nbsp;&nbsp;&nbsp;
<?php echo footnotes_replaceFootnotes($l_arr_Footnote_StartingTag["value"] . __("example string", FOOTNOTES_PLUGIN_NAME) . $l_arr_Footnote_EndingTag["value"], true, true); ?>
</p>
</div>
<p>
<?php echo sprintf(__("If you have any questions, please don't hesitate to %se-mail%s us.", FOOTNOTES_PLUGIN_NAME), '<a href="mailto:mci@cheret.co.uk" class="footnote_plugin">', '</a>'); ?>
</p>
</div>
</div>
<?php
}
} /* Class Class_FootnotesSettings */

View file

@ -1,51 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: Stefan
* Date: 24.05.14
* Time: 13:57
*/
class Class_FootnotesWidget extends WP_Widget {
/**
* @constructor
*/
function Class_FootnotesWidget() {
$widget_ops = array( 'classname' => 'Class_FootnotesWidget', 'description' => __('The widget defines the position of the reference container if set to "widget area".', FOOTNOTES_PLUGIN_NAME) );
$control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'footnotes_widget' );
$this->WP_Widget( 'footnotes_widget', FOOTNOTES_PLUGIN_NAME, $widget_ops, $control_ops );
}
/**
* widget form creation
* @param $instance
*/
function form($instance) {
echo __('The widget defines the position of the reference container if set to "widget area".', FOOTNOTES_PLUGIN_NAME);
}
/**
* widget update
* @param $new_instance
* @param $old_instance
*/
function update($new_instance, $old_instance) {
return $new_instance;
}
/**
* widget display
* @param $args
* @param $instance
*/
function widget($args, $instance) {
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* get setting for 'display reference container position' */
$l_str_ReferenceContainerPosition = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_REFERENCE_CONTAINER_PLACE];
if ($l_str_ReferenceContainerPosition == "widget") {
echo footnotes_OutputReferenceContainer();
}
}
}

77
classes/tab_custom.php Normal file
View file

@ -0,0 +1,77 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 30.07.14 10:53
* Version: 1.0
* Since: 1.3
*/
// define class only once
if (!class_exists("MCI_Footnotes_Tab_Custom")) :
/**
* Class MCI_Footnotes_Tab_Custom
* @since 1.3
*/
class MCI_Footnotes_Tab_Custom extends MCI_Footnotes_Admin {
/**
* register the meta boxes for the tab
* @constructor
* @since 1.3
* @param array $p_arr_Tabs
*/
public function __construct(&$p_arr_Tabs) {
// add tab to the tab array
$p_arr_Tabs[FOOTNOTES_SETTINGS_TAB_CUSTOM] = __("Custom CSS", FOOTNOTES_PLUGIN_NAME);
// register settings tab
add_settings_section(
"MCI_Footnotes_Settings_Section_Custom",
"&nbsp;",
array($this, 'Description'),
FOOTNOTES_SETTINGS_TAB_CUSTOM
);
// help
add_meta_box(
'MCI_Footnotes_Tab_HowTo_Custom',
__("Add custom CSS to the public page", FOOTNOTES_PLUGIN_NAME),
array($this, 'CSS'),
FOOTNOTES_SETTINGS_TAB_CUSTOM,
'main'
);
}
/**
* output a description for the tab
* @since 1.3
*/
public function Description() {
// unused
}
/**
* @since 1.3
*/
public function CSS() {
$l_str_Separator = " &rArr; ";
// setting for 'reference label'
$this->AddLabel(FOOTNOTES_INPUT_CUSTOM_CSS, __("Add custom CSS:", FOOTNOTES_PLUGIN_NAME));
$this->AddTextarea(FOOTNOTES_INPUT_CUSTOM_CSS, 12, "footnote_plugin_100");
$this->AddNewline();
$this->AddText($this->Highlight(gettext("Available CSS classes to customize the footnotes and the reference container:")) . "<br/>");
echo "<blockquote>";
$this->AddText($this->Highlight(".footnote_plugin_tooltip_text") . $l_str_Separator . gettext("inline footnotes") . "<br/>");
$this->AddText($this->Highlight(".footnote_tooltip") . $l_str_Separator . gettext("inline footnotes, mouse over highlight box") . "<br/><br/>");
$this->AddText($this->Highlight(".footnote_plugin_index") . $l_str_Separator . gettext("reference container footnotes index") . "<br/>");
$this->AddText($this->Highlight(".footnote_plugin_link") . $l_str_Separator . gettext("reference container footnotes linked arrow") . "<br/>");
$this->AddText($this->Highlight(".footnote_plugin_text") . $l_str_Separator . gettext("reference container footnotes text"));
echo "</blockquote>";
}
} // class MCI_Footnotes_Tab_Custom
endif;

190
classes/tab_general.php Normal file
View file

@ -0,0 +1,190 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 30.07.14 10:37
* Version: 1.0
* Since: 1.3
*/
// define class only once
if (!class_exists("MCI_Footnotes_Tab_General")) :
/**
* Class MCI_Footnotes_Tab_General
* @since 1.3
*/
class MCI_Footnotes_Tab_General extends MCI_Footnotes_Admin {
/**
* register the meta boxes for the tab
* @constructor
* @since 1.3
* @param array $p_arr_Tabs
*/
public function __construct(&$p_arr_Tabs) {
// add tab to the tab array
$p_arr_Tabs[FOOTNOTES_SETTINGS_TAB_GENERAL] = __("General", FOOTNOTES_PLUGIN_NAME);
// register settings tab
add_settings_section(
"MCI_Footnotes_Settings_Section_General",
sprintf(__("%s Settings", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME),
array($this, 'Description'),
FOOTNOTES_SETTINGS_TAB_GENERAL
);
// reference container
add_meta_box(
'MCI_Footnotes_Tab_General_ReferenceContainer',
__("References Container", FOOTNOTES_PLUGIN_NAME),
array($this, 'ReferenceContainer'),
FOOTNOTES_SETTINGS_TAB_GENERAL,
'main'
);
// styling
add_meta_box(
'MCI_Footnotes_Tab_General_Styling',
sprintf(__("%s styling", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME),
array($this, 'Styling'),
FOOTNOTES_SETTINGS_TAB_GENERAL,
'main'
);
// love
add_meta_box(
'MCI_Footnotes_Tab_General_Love',
FOOTNOTES_PLUGIN_PUBLIC_NAME . '&nbsp;' . FOOTNOTES_LOVE_SYMBOL,
array($this, 'Love'),
FOOTNOTES_SETTINGS_TAB_GENERAL,
'main'
);
// other
add_meta_box(
'MCI_Footnotes_Tab_General_Other',
__("Other", FOOTNOTES_PLUGIN_NAME),
array($this, 'Other'),
FOOTNOTES_SETTINGS_TAB_GENERAL,
'main'
);
}
/**
* output a description for the tab
* @since 1.3
*/
public function Description() {
// unused
}
/**
* output the setting fields for the reference container
* @since 1.3
*/
public function ReferenceContainer() {
// setting for 'reference label'
$this->AddLabel(FOOTNOTES_INPUT_REFERENCES_LABEL, __("References label:", FOOTNOTES_PLUGIN_NAME));
$this->AddTextbox(FOOTNOTES_INPUT_REFERENCES_LABEL, "footnote_plugin_50");
$this->AddNewline();
// setting for 'collapse reference container by default'
$this->AddLabel(FOOTNOTES_INPUT_COLLAPSE_REFERENCES, __("Collapse references by default:", FOOTNOTES_PLUGIN_NAME));
$this->AddCheckbox(FOOTNOTES_INPUT_COLLAPSE_REFERENCES);
$this->AddNewline();
// setting for 'placement of the reference container'
// @since 1.0.7
$l_arr_Options = array(
"footer" => __("in the footer", FOOTNOTES_PLUGIN_NAME),
"post_end" => __("at the end of the post", FOOTNOTES_PLUGIN_NAME),
"widget" => __("in the widget area", FOOTNOTES_PLUGIN_NAME)
);
$this->AddLabel(FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE, __("Where shall the reference container appear:", FOOTNOTES_PLUGIN_NAME));
$this->AddSelect(FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE, $l_arr_Options, "footnote_plugin_50");
}
/**
* output the setting fields for the footnotes styling
* @since 1.3
*/
public function Styling() {
// setting for 'combine identical footnotes'
$l_arr_Options = array(
"yes" => __("Yes", FOOTNOTES_PLUGIN_NAME),
"no" => __("No", FOOTNOTES_PLUGIN_NAME)
);
$this->AddLabel(FOOTNOTES_INPUT_COMBINE_IDENTICAL, __("Combine identical footnotes:", FOOTNOTES_PLUGIN_NAME));
$this->AddSelect(FOOTNOTES_INPUT_COMBINE_IDENTICAL, $l_arr_Options, "footnote_plugin_50");
$this->AddNewline();
// setting for 'footnote tag starts with'
$l_arr_Options = array(
"((" => "((",
"<fn>" => htmlspecialchars("<fn>"),
"[ref]" => "[ref]",
"userdefined" => __('user defined', FOOTNOTES_PLUGIN_NAME)
);
$this->AddLabel(FOOTNOTES_INPUT_PLACEHOLDER_START, __("Footnote tag starts with:", FOOTNOTES_PLUGIN_NAME));
$this->AddSelect(FOOTNOTES_INPUT_PLACEHOLDER_START, $l_arr_Options, "footnote_plugin_15");
// setting for 'footnote tag ends with'
$l_arr_Options = array(
"))" => "))",
"</fn>" => htmlspecialchars("</fn>"),
"[/ref]" => "[/ref]",
"userdefined" => __('user defined', FOOTNOTES_PLUGIN_NAME)
);
$this->AddLabel(FOOTNOTES_INPUT_PLACEHOLDER_END, __("and ends with:", FOOTNOTES_PLUGIN_NAME) . '&nbsp;&nbsp;&nbsp;', 'text-align: right;');
$this->AddSelect(FOOTNOTES_INPUT_PLACEHOLDER_END, $l_arr_Options, "footnote_plugin_15");
$this->AddNewline();
// user defined setting for 'footnote start and end tag'
$this->AddLabel(FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED, "");
$this->AddTextbox(FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED, "footnote_plugin_15", 14, false, true);
$this->AddLabel(FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED, "");
$this->AddTextbox(FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED, "footnote_plugin_15", 14, false, true);
$this->AddNewline();
// setting for 'footnotes counter style'
$l_str_Space = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$l_arr_Options = array(
"arabic_plain" => __("Arabic Numbers - Plain", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "1, 2, 3, 4, 5, ...",
"arabic_leading" => __("Arabic Numbers - Leading 0", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "01, 02, 03, 04, 05, ...",
"latin_low" => __("Latin Character - lower case", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "a, b, c, d, e, ...",
"latin_high" => __("Latin Character - upper case", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "A, B, C, D, E, ...",
"romanic" => __("Roman Numerals", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "I, II, III, IV, V, ..."
);
$this->AddLabel(FOOTNOTES_INPUT_COUNTER_STYLE, __('Counter style:', FOOTNOTES_PLUGIN_NAME));
$this->AddSelect(FOOTNOTES_INPUT_COUNTER_STYLE, $l_arr_Options, "footnote_plugin_50");
}
/**
* output the setting fields to love and share the footnotes plugin
* @since 1.3
*/
public function Love() {
// setting for 'love and share this plugin in my footer'
$l_arr_Options = array(
"text-1" => sprintf(__('I %s %s', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_LOVE_SYMBOL, FOOTNOTES_PLUGIN_PUBLIC_NAME),
"text-2" => sprintf(__('this site uses the awesome %s Plugin', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME),
"text-3" => sprintf(__('extra smooth %s', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME),
"random" => __('random text', FOOTNOTES_PLUGIN_NAME),
"no" => sprintf(__("Don't display a %s %s text in my footer.", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME, FOOTNOTES_LOVE_SYMBOL)
);
$this->AddLabel(FOOTNOTES_INPUT_LOVE, sprintf(__("Tell the world you're using %s:", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME));
$this->AddSelect(FOOTNOTES_INPUT_LOVE, $l_arr_Options, "footnote_plugin_50");
$this->AddNewline();
// no 'love me' on specific pages
$this->AddText(sprintf(__("Don't tell the world you're using %s on specific pages by adding the following short code:", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME));
$this->AddText("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
$this->AddText(FOOTNOTES_NO_SLUGME_PLUG);
}
/**
* output settings fields with no specific topic
* @since 1.3
*/
public function Other() {
// setting for 'search footnotes tag in excerpt'
$l_arr_Options = array(
"yes" => __("Yes", FOOTNOTES_PLUGIN_NAME),
"no" => __("No", FOOTNOTES_PLUGIN_NAME)
);
$this->AddLabel(FOOTNOTES_INPUT_SEARCH_IN_EXCERPT, __('Allow footnotes on Summarized Posts:', FOOTNOTES_PLUGIN_NAME));
$this->AddSelect(FOOTNOTES_INPUT_SEARCH_IN_EXCERPT, $l_arr_Options, "footnote_plugin_50");
}
} // class MCI_Footnotes_Tab_General
endif;

102
classes/tab_howto.php Normal file
View file

@ -0,0 +1,102 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 30.07.14 10:53
* Version: 1.0
* Since: 1.3
*/
// define class only once
if (!class_exists("MCI_Footnotes_Tab_HowTo")) :
/**
* Class MCI_Footnotes_Tab_HowTo
* @since 1.3
*/
class MCI_Footnotes_Tab_HowTo extends MCI_Footnotes_Admin {
/**
* register the meta boxes for the tab
* @constructor
* @since 1.3
* @param array $p_arr_Tabs
*/
public function __construct(&$p_arr_Tabs) {
// add tab to the tab array
$p_arr_Tabs[FOOTNOTES_SETTINGS_TAB_HOWTO] = __("How to", FOOTNOTES_PLUGIN_NAME);
// register settings tab
add_settings_section(
"MCI_Footnotes_Settings_Section_HowTo",
"&nbsp;",
array($this, 'Description'),
FOOTNOTES_SETTINGS_TAB_HOWTO
);
// help
add_meta_box(
'MCI_Footnotes_Tab_HowTo_Help',
__("Brief introduction in how to use the plugin", FOOTNOTES_PLUGIN_NAME),
array($this, 'Help'),
FOOTNOTES_SETTINGS_TAB_HOWTO,
'main'
);
}
/**
* output a description for the tab
* @since 1.3
*/
public function Description() {
// unused
}
/**
* outputs the help box
* @since 1.3
*/
public function Help() {
global $g_obj_MCI_Footnotes;
// load footnotes starting and end tag
$l_arr_Footnote_StartingTag = $this->LoadSetting(FOOTNOTES_INPUT_PLACEHOLDER_START);
$l_arr_Footnote_EndingTag = $this->LoadSetting(FOOTNOTES_INPUT_PLACEHOLDER_END);
if ($l_arr_Footnote_StartingTag["value"] == "userdefined" || $l_arr_Footnote_EndingTag["value"] == "userdefined") {
// load user defined starting and end tag
$l_arr_Footnote_StartingTag = $this->LoadSetting(FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED);
$l_arr_Footnote_EndingTag = $this->LoadSetting(FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED);
}
$l_str_Example = $l_arr_Footnote_StartingTag["value"] . __("example string", FOOTNOTES_PLUGIN_NAME) . $l_arr_Footnote_EndingTag["value"];
?>
<div style="text-align:center;">
<div class="footnote_placeholder_box_container">
<p>
<?php echo __("Start your footnote with the following shortcode:", FOOTNOTES_PLUGIN_NAME); ?>
<span class="footnote_highlight_placeholder">
<?php echo $l_arr_Footnote_StartingTag["value"]; ?>
</span>
</p>
<p>
<?php echo __("...and end your footnote with this shortcode:", FOOTNOTES_PLUGIN_NAME); ?>
<span class="footnote_highlight_placeholder">
<?php echo $l_arr_Footnote_EndingTag["value"]; ?>
</span>
</p>
<div class="footnote_placeholder_box_example">
<p>
<span class="footnote_highlight_placeholder"><?php echo $l_str_Example; ?></span>
<?php echo __("will be displayed as:", FOOTNOTES_PLUGIN_NAME); ?>
&nbsp;&nbsp;&nbsp;&nbsp;
<?php echo $g_obj_MCI_Footnotes->a_obj_Task->exec($l_str_Example, true); ?>
</p>
</div>
<p>
<?php echo sprintf(__("If you have any questions, please don't hesitate to %se-mail%s us.", FOOTNOTES_PLUGIN_NAME), '<a href="mailto:mci@cheret.co.uk" class="footnote_plugin">', '</a>'); ?>
</p>
</div>
</div>
<?php
}
} // class MCI_Footnotes_Tab_HowTo
endif;

365
classes/task.php Normal file
View file

@ -0,0 +1,365 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 30.07.14 12:07
* Version: 1.0
* Since: 1.3
*/
// define class only once
if (!class_exists("MCI_Footnotes_Task")) :
/**
* Class MCI_Footnotes_Task
* @since 1.3
*/
class MCI_Footnotes_Task {
// array containing the settings
public $a_arr_Settings = array();
// bool admin allows the Love Me slug
public static $a_bool_AllowLoveMe = true;
// array containing all found footnotes
public static $a_arr_Footnotes = array();
/**
* @constructor
* @since 1.3
*/
public function __construct() {
require_once(dirname( __FILE__ ) . "/admin.php");
// load footnote settings
$this->a_arr_Settings = MCI_Footnotes_getOptions(false);
}
/**
* add WordPress hooks
* @since 1.3
*/
public function Register() {
// adds the custom css to the header
add_action('wp_head', array($this, "Header"));
// stops listening to the output and replaces the footnotes
add_action('get_footer', array($this, "Footer"));
// adds the love and share me slug to the footer
add_action('wp_footer', array($this, "Love"));
// moves these contents through the replacement function
add_filter('the_content', array($this, "Content"));
add_filter('the_excerpt', array($this, "Excerpt"));
add_filter('widget_title', array($this, "WidgetTitle"));
add_filter('widget_text', array($this, "WidgetText"));
}
/**
* outputs the custom css to the header
* @since 1.3
*/
public function Header() {
?>
<style type="text/css" media="screen"><?php echo $this->a_arr_Settings[FOOTNOTES_INPUT_CUSTOM_CSS]; ?></style>
<?php
}
/**
* replaces footnotes tags in the post content
* @since 1.3
* @param string $p_str_Content
* @return string
*/
public function Content($p_str_Content) {
// returns content
return $this->exec($p_str_Content, $this->a_arr_Settings[FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE] == "post_end" ? true : false);
}
/**
* replaces footnotes tags in the post excerpt
* @since 1.3
* @param string $p_str_Content
* @return string
*/
public function Excerpt($p_str_Content) {
require_once(dirname( __FILE__ ) . "/convert.php");
// search in the excerpt only if activated
if (MCI_Footnotes_Convert::toBool($this->a_arr_Settings[FOOTNOTES_INPUT_SEARCH_IN_EXCERPT])) {
return $this->exec($p_str_Content, false);
}
// returns content
return $p_str_Content;
}
/**
* replaces footnotes tags in the widget title
* @since 1.3
* @param string $p_str_Content
* @return string
*/
public function WidgetTitle($p_str_Content) {
// returns content
return $p_str_Content;
}
/**
* replaces footnotes tags in the widget text
* @since 1.3
* @param string $p_str_Content
* @return string
*/
public function WidgetText($p_str_Content) {
// returns content
return $this->exec( $p_str_Content, $this->a_arr_Settings[FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE] == "post_end" ? true : false);
}
/**
* outputs the reference container to the footer
* @since 1.3
*/
public function Footer() {
if ($this->a_arr_Settings[FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE] == "footer") {
echo $this->ReferenceContainer();
}
}
/**
* output the love me slug in the footer
* @since 1.3
*/
public function Love() {
// get setting for love and share this plugin and convert it to boolean
$l_str_LoveMeText = $this->a_arr_Settings[FOOTNOTES_INPUT_LOVE];
// check if the admin allows to add a link to the footer
if (empty($l_str_LoveMeText) || strtolower($l_str_LoveMeText) == "no" || !self::$a_bool_AllowLoveMe) {
return;
}
// get random love me text
if (strtolower($l_str_LoveMeText) == "random") {
$l_str_LoveMeText = "text-" . rand(1,3);
}
switch ($l_str_LoveMeText) {
case "text-1":
$l_str_LoveMeText = sprintf(__('I %s %s', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_LOVE_SYMBOL, FOOTNOTES_PLUGIN_PUBLIC_NAME_LINKED);
break;
case "text-2":
$l_str_LoveMeText = sprintf(__('this site uses the awesome %s Plugin', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME_LINKED);
break;
case "text-3":
default:
$l_str_LoveMeText = sprintf(__('extra smooth %s', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME_LINKED);
break;
}
echo '<div style="text-align:center; color:#acacac;">' . $l_str_LoveMeText . '</div>';
}
/**
* replaces all footnotes in the given content
* loading settings if not happened yet since 1.0-gamma
* @since 1.0
* @param string $p_str_Content
* @param bool $p_bool_OutputReferences [default: true]
* @return string
*/
public function exec($p_str_Content, $p_bool_OutputReferences = true) {
// replace all footnotes in the content
$p_str_Content = $this->Lookup($p_str_Content, true);
$p_str_Content = $this->Lookup($p_str_Content, false);
// add the reference list if set
if ($p_bool_OutputReferences) {
$p_str_Content = $p_str_Content . $this->ReferenceContainer();
}
// checks if the user doesn't want to have a 'love me' on current page
// @since 1.1.1
if (strpos($p_str_Content, FOOTNOTES_NO_SLUGME_PLUG) !== false) {
self::$a_bool_AllowLoveMe = false;
$p_str_Content = str_replace(FOOTNOTES_NO_SLUGME_PLUG, "", $p_str_Content);
}
// return the replaced content
return $p_str_Content;
}
/**
* replace all footnotes in the given string and adds them to an array
* using a personal starting and ending tag for the footnotes since 1.0-gamma
* @since 1.0
* @param string $p_str_Content
* @param bool $p_bool_ConvertHtmlChars
* @return string
*/
public function Lookup($p_str_Content, $p_bool_ConvertHtmlChars = true) {
require_once(dirname( __FILE__ ) . "/convert.php");
// contains the index for the next footnote on this page
$l_int_FootnoteIndex = count(self::$a_arr_Footnotes) + 1;
// contains the starting position for the lookup of a footnote
$l_int_PosStart = 0;
// contains the footnote template
$l_str_FootnoteTemplate = file_get_contents(FOOTNOTES_TEMPLATES_DIR . "footnote.html");
// get footnote starting tag
$l_str_StartingTag = $this->a_arr_Settings[FOOTNOTES_INPUT_PLACEHOLDER_START];
// get footnote ending tag
$l_str_EndingTag = $this->a_arr_Settings[FOOTNOTES_INPUT_PLACEHOLDER_END];
// get footnote counter style
$l_str_CounterStyle = $this->a_arr_Settings[FOOTNOTES_INPUT_COUNTER_STYLE];
if ($l_str_StartingTag == "userdefined" || $l_str_EndingTag == "userdefined") {
// get user defined footnote starting tag
$l_str_StartingTag = $this->a_arr_Settings[FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED];
// get user defined footnote ending tag
$l_str_EndingTag = $this->a_arr_Settings[FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED];
}
// decode html special chars
if ($p_bool_ConvertHtmlChars) {
$l_str_StartingTag = htmlspecialchars($l_str_StartingTag);
$l_str_EndingTag = htmlspecialchars($l_str_EndingTag);
}
// check for a footnote placeholder in the current page
do {
// get first occurrence of a footnote starting tag
$l_int_PosStart = strpos($p_str_Content, $l_str_StartingTag, $l_int_PosStart);
// tag not found
if ($l_int_PosStart === false) {
break;
}
// get first occurrence of a footnote ending tag after the starting tag
$l_int_PosEnd = strpos($p_str_Content, $l_str_EndingTag, $l_int_PosStart);
// tag not found
if ($l_int_PosEnd === false) {
$l_int_PosStart++;
continue;
}
// get length of footnote text
$l_int_Length = $l_int_PosEnd - $l_int_PosStart;
// get text inside footnote
$l_str_FootnoteText = substr($p_str_Content, $l_int_PosStart + strlen($l_str_StartingTag), $l_int_Length - strlen($l_str_StartingTag));
// set replacing string for the footnote
$l_str_ReplaceText = str_replace("[[FOOTNOTE INDEX]]", MCI_Footnotes_Convert::Index($l_int_FootnoteIndex, $l_str_CounterStyle), $l_str_FootnoteTemplate);
$l_str_ReplaceText = str_replace("[[FOOTNOTE TEXT]]", $l_str_FootnoteText, $l_str_ReplaceText);
$l_str_ReplaceText = preg_replace('@[\s]{2,}@',' ',$l_str_ReplaceText);
// replace footnote in content
$p_str_Content = substr_replace($p_str_Content, $l_str_ReplaceText, $l_int_PosStart, $l_int_Length + strlen($l_str_EndingTag));
// set footnote to the output box at the end
self::$a_arr_Footnotes[] = $l_str_FootnoteText;
// increase footnote index
$l_int_FootnoteIndex++;
// add offset to the new starting position
$l_int_PosStart += ($l_int_PosEnd - $l_int_PosStart);
} while (true);
// return content
return $p_str_Content;
}
/**
* looks through all footnotes that has been replaced in the current content and
* adds a reference to the footnote at the end of the content
* function to collapse the reference container since 1.0-beta
* @since 1.0
* @return string
*/
public function ReferenceContainer() {
// no footnotes has been replaced on this page
if (empty(self::$a_arr_Footnotes)) {
return "";
}
require_once(dirname( __FILE__ ) . "/convert.php");
// get setting for combine identical footnotes and convert it to boolean
$l_bool_CombineIdentical = MCI_Footnotes_Convert::toBool($this->a_arr_Settings[FOOTNOTES_INPUT_COMBINE_IDENTICAL]);
// get setting for preferences label
$l_str_ReferencesLabel = $this->a_arr_Settings[FOOTNOTES_INPUT_REFERENCES_LABEL];
// get setting for collapse reference footnotes and convert it to boolean
$l_bool_CollapseReference = MCI_Footnotes_Convert::toBool($this->a_arr_Settings[FOOTNOTES_INPUT_COLLAPSE_REFERENCES]);
// get footnote counter style
$l_str_CounterStyle = $this->a_arr_Settings[FOOTNOTES_INPUT_COUNTER_STYLE];
// add expand/collapse buttons to the reference label if collapsed by default
// @since 1.2.2
$l_str_CollapseButtons = "";
if ($l_bool_CollapseReference) {
$l_str_CollapseButtons = '&nbsp;&nbsp;&nbsp;[ <a id="footnote_reference_container_collapse_button" style="cursor:pointer;" onclick="footnote_expand_collapse_reference_container();">+</a> ]';
}
// output string, prepare it with the reference label as headline
$l_str_Output = '<div class="footnote_container_prepare"><p><span onclick="footnote_expand_reference_container();">' . $l_str_ReferencesLabel . '</span><span>' .$l_str_CollapseButtons . '</span></p></div>';
// add a box around the footnotes
$l_str_Output .= '<div id="' . FOOTNOTES_REFERENCES_CONTAINER_ID . '"';
// add class to hide the references by default, if the user wants it
if ($l_bool_CollapseReference) {
$l_str_Output .= ' class="footnote_hide_box"';
}
$l_str_Output .= '>';
// contains the footnote template
$l_str_FootnoteTemplate = file_get_contents(FOOTNOTES_TEMPLATES_DIR . "container.html");
// loop through all footnotes found in the page
for ($l_str_Index = 0; $l_str_Index < count(self::$a_arr_Footnotes); $l_str_Index++) {
// get footnote text
$l_str_FootnoteText = self::$a_arr_Footnotes[$l_str_Index];
// if footnote is empty, get to the next one
if (empty($l_str_FootnoteText)) {
continue;
}
// get footnote index
$l_str_FirstFootnoteIndex = ($l_str_Index + 1);
$l_str_FootnoteIndex = MCI_Footnotes_Convert::Index(($l_str_Index + 1), $l_str_CounterStyle);
// check if it isn't the last footnote in the array
if ($l_str_FirstFootnoteIndex < count(self::$a_arr_Footnotes) && $l_bool_CombineIdentical) {
// get all footnotes that I haven't passed yet
for ($l_str_CheckIndex = $l_str_FirstFootnoteIndex; $l_str_CheckIndex < count(self::$a_arr_Footnotes); $l_str_CheckIndex++) {
// check if a further footnote is the same as the actual one
if ($l_str_FootnoteText == self::$a_arr_Footnotes[$l_str_CheckIndex] && !empty($g_arr_Footnotes[$l_str_CheckIndex])) {
// set the further footnote as empty so it won't be displayed later
$g_arr_Footnotes[$l_str_CheckIndex] = "";
// add the footnote index to the actual index
$l_str_FootnoteIndex .= ", " . MCI_Footnotes_Convert::Index(($l_str_CheckIndex + 1), $l_str_CounterStyle);
}
}
}
// add the footnote to the output box
// added function to convert the counter style in the reference container (bugfix for the link to the footnote) in version 1.0.6
$l_str_ReplaceText = str_replace("[[FOOTNOTE INDEX SHORT]]", MCI_Footnotes_Convert::Index($l_str_FirstFootnoteIndex, $l_str_CounterStyle), $l_str_FootnoteTemplate);
$l_str_ReplaceText = str_replace("[[FOOTNOTE INDEX]]", $l_str_FootnoteIndex, $l_str_ReplaceText);
$l_str_ReplaceText = str_replace("[[FOOTNOTE TEXT]]", $l_str_FootnoteText, $l_str_ReplaceText);
$l_str_ReplaceText = preg_replace('@[\s]{2,}@',' ',$l_str_ReplaceText);
// add the footnote container to the output
$l_str_Output = $l_str_Output . $l_str_ReplaceText;
}
// add closing tag for the div of the references container
$l_str_Output = $l_str_Output . '</div>';
// add a javascript to expand the reference container when clicking on a footnote or the reference label
$l_str_Output .= '
<script type="text/javascript">
function footnote_expand_reference_container(p_str_ID) {
jQuery("#' . FOOTNOTES_REFERENCES_CONTAINER_ID . '").show();
if (p_str_ID.length > 0) {
jQuery(p_str_ID).focus();
}
}
function footnote_expand_collapse_reference_container() {
var l_obj_ReferenceContainer = jQuery("#' . FOOTNOTES_REFERENCES_CONTAINER_ID . '");
if (l_obj_ReferenceContainer.is(":hidden")) {
l_obj_ReferenceContainer.show();
jQuery("#footnote_reference_container_collapse_button").text("-");
} else {
l_obj_ReferenceContainer.hide();
jQuery("#footnote_reference_container_collapse_button").text("+");
}
}
</script>
';
// free all found footnotes if reference container will be displayed
self::$a_arr_Footnotes = array();
// return the output string
return $l_str_Output;
}
} // class MCI_Footnotes_Task
endif;

70
classes/widget.php Normal file
View file

@ -0,0 +1,70 @@
<?php
/**
* Created by PhpStorm.
* User: Stefan
* Date: 24.05.14
* Time: 13:57
*/
// define class only once
if (!class_exists("MCI_Footnotes_Widget")) :
/**
* Class MCI_Footnotes_Widget
* @since 1.0
*/
class MCI_Footnotes_Widget extends WP_Widget {
/**
* @constructor
*/
public function __construct() {
// set widget class and description
$l_arr_WidgetMeta = array(
'classname' => 'Class_FootnotesWidget',
'description' => __('The widget defines the position of the reference container if set to "widget area".', FOOTNOTES_PLUGIN_NAME)
);
// set widget layout information
$l_arr_WidgetLayout = array(
'width' => 300,
'height' => 350,
'id_base' => 'footnotes_widget'
);
// add widget to the list
$this->WP_Widget('footnotes_widget', FOOTNOTES_PLUGIN_NAME, $l_arr_WidgetMeta, $l_arr_WidgetLayout);
}
/**
* widget form creation
* @param $instance
* @return void
*/
public function form($instance) {
echo __('The widget defines the position of the reference container if set to "widget area".', FOOTNOTES_PLUGIN_NAME);
}
/**
* widget update
* @param $new_instance
* @param $old_instance
* @return mixed
*/
public function update($new_instance, $old_instance) {
return $new_instance;
}
/**
* widget display
* @param $args
* @param $instance
*/
public function widget($args, $instance) {
global $g_obj_MCI_Footnotes;
// reference container positioning is set to "widget area"
if ($g_obj_MCI_Footnotes->a_obj_Task->a_arr_Settings[FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE] == "widget") {
echo $g_obj_MCI_Footnotes->a_obj_Task->ReferenceContainer();
}
}
} // class MCI_Footnotes_Widget
endif;

View file

@ -1,119 +0,0 @@
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0.7
* Since: 1.0
*/
/*
* styling for the 'footnotes' tag
* @since 1.0.7
*/
.footnote_tag_styling, .footnote_tag_styling:hover {
text-decoration: none;
font-weight: normal;
}
.footnote_tag_styling_1 {
color: #2bb975;
}
.footnote_tag_styling_2 {
color: #545f5a;
}
/* container before the footnote appears at the bottom to get a space between footnote and content */
.footnote_container_prepare {
display: block !important;
padding-top: 24px !important;
}
.footnote_container_prepare > p {
line-height: 1.3 !important;
margin-top: 1em !important;
margin-bottom: 0.25em !important;
padding: 0 !important;
font-weight: normal !important;
overflow: hidden !important;
border-bottom: 1px solid #aaaaaa !important;
display: block !important;
-webkit-margin-before: 0.83em !important;
-webkit-margin-after: 0.83em !important;
-webkit-margin-start: 0px !important;
-webkit-margin-end: 0px !important;
text-align: left !important;
vertical-align: middle;
}
.footnote_container_prepare > p > span:first-child {
padding-left: 20px !important;
text-align: left !important;
cursor: pointer;
font-size: 1.5em !important;
}
.footnote_container_prepare > p > span:last-child {
}
.footnote_hide_box {
display: none;
}
/* container for the footnote in the bottom */
.footnote_plugin_container {
display: block !important;
width: 100% !important;
padding-bottom: 14px !important;
}
/* footnote (bottom) index */
.footnote_plugin_index {
/*float: left !important;*/
min-width: 40px !important;
white-space: nowrap !important;
text-align: right !important;
display: inline-block;
}
/* footnote (bottom) text */
.footnote_plugin_text {
/*float: left !important;*/
padding-left: 16px !important;
display: inline-block;
}
/* footnote (bottom) link to the footnote implementation */
.footnote_plugin_link {
outline: none !important;
text-decoration: none !important;
cursor: pointer !important;
}
.footnote_plugin_link:hover {
/*color: #4777ff !important;*/
text-decoration: none !important;
}
/* footnote (bottom) styling end tag */
.footnote_plugin_end {
/*clear: left !important;*/
}
/* tooltip */
.footnote_plugin_tooltip_text {
text-decoration: none !important;
}
/* tooltip styling */
.tooltip {
display: none;
background-color: #fff7a7;
border: 1px solid #cccc99;
border-radius: 3px;
padding: 12px;
font-size: 13px;
-moz-box-shadow: 2px 2px 11px #666;
-webkit-box-shadow: 2px 2px 11px #666;
}

25
css/footnotes.css Executable file
View file

@ -0,0 +1,25 @@
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0.7
* Since: 1.0
*/
/*
* styling for the 'footnotes' tag
* @since 1.0.7
*/
.footnote_tag_styling, .footnote_tag_styling:hover {
text-decoration: none;
font-weight: normal;
}
.footnote_tag_styling_1 {
color: #2bb975;
}
.footnote_tag_styling_2 {
color: #545f5a;
}

View file

@ -0,0 +1,84 @@
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 30.07.14 11:25
* Version: 1.0
* Since: 1.3
*/
/* container before the footnote appears at the bottom to get a space between footnote and content */
.footnote_container_prepare {
display: block !important;
padding-top: 24px !important;
}
.footnote_container_prepare > p {
line-height: 1.3 !important;
margin-top: 1em !important;
margin-bottom: 0.25em !important;
padding: 0 !important;
font-weight: normal !important;
overflow: hidden !important;
border-bottom: 1px solid #aaaaaa !important;
display: block !important;
-webkit-margin-before: 0.83em !important;
-webkit-margin-after: 0.83em !important;
-webkit-margin-start: 0px !important;
-webkit-margin-end: 0px !important;
text-align: left !important;
vertical-align: middle;
}
.footnote_container_prepare > p > span:first-child {
padding-left: 20px !important;
text-align: left !important;
cursor: pointer;
font-size: 1.5em !important;
}
.footnote_container_prepare > p > span:last-child {
}
/* container for the footnote in the bottom */
.footnote_plugin_container {
display: block !important;
width: 100% !important;
padding-bottom: 14px !important;
}
/* footnote (bottom) index */
.footnote_plugin_index {
/*float: left !important;*/
min-width: 40px !important;
white-space: nowrap !important;
text-align: right !important;
display: inline-block;
}
/* footnote (bottom) text */
.footnote_plugin_text {
/*float: left !important;*/
padding-left: 16px !important;
display: inline;
}
/* footnote (bottom) link to the footnote implementation */
.footnote_plugin_link {
outline: none !important;
text-decoration: none !important;
cursor: pointer !important;
}
.footnote_plugin_link:hover {
/*color: #4777ff !important;*/
text-decoration: none !important;
}
/* footnote (bottom) styling end tag */
.footnote_plugin_end {
/*clear: left !important;*/
}
.footnote_hide_box {
display: none;
}

View file

@ -7,11 +7,6 @@
* Since: 1.0
*/
/* overwrite some styling for inputs [type=text] and select-boxes */
input[type=text], input[type=checkbox], input[type=password], textarea, select {
/*margin-left: 12px !important;*/
}
input[type=text], input[type=password], textarea, select {
padding-left: 8px !important;
padding-right: 8px !important;

30
css/tooltip.css Normal file
View file

@ -0,0 +1,30 @@
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 30.07.14 11:26
* Version: 1.0
* Since: 1.3
*/
/* tooltip */
.footnote_plugin_tooltip_text {
text-decoration: none !important;
}
.footnote_plugin_tooltip_text > sup {
vertical-align: top !important;
position: relative !important;
top: -0.1em !important;
}
/* tooltip styling */
.footnote_tooltip {
display: none;
background-color: #fff7a7;
border: 1px solid #cccc99;
border-radius: 3px;
padding: 12px;
font-size: 13px;
-moz-box-shadow: 2px 2px 11px #666;
-webkit-box-shadow: 2px 2px 11px #666;
}

View file

@ -1,110 +0,0 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 17.05.14
* Time: 00:16
* Version: 1.0
* Since: 1.0-gamma
*/
/**
* converts a integer into the user-defined counter style for the footnotes
* @since 1.0-gamma
* @param int $p_int_Index
* @param string $p_str_ConvertStyle [counter style]
* @return string
*/
function footnote_convert_index($p_int_Index, $p_str_ConvertStyle = "arabic_plain")
{
switch ($p_str_ConvertStyle) {
case "romanic":
return footnote_convert_to_romanic($p_int_Index);
case "latin_high":
return footnote_convert_to_latin($p_int_Index, true);
case "latin_low":
return footnote_convert_to_latin($p_int_Index, false);
case "arabic_leading":
return footnote_convert_to_arabic_leading($p_int_Index);
case "arabic_plain":
default:
return $p_int_Index;
}
}
/**
* converts a integer into latin ascii characters, either lower or upper-case
* function available from A to ZZ ( means 676 footnotes at 1 page possible)
* @since 1.0-gamma
* @param int $p_int_Value
* @param bool $p_bool_UpperCase
* @return string
*/
function footnote_convert_to_latin($p_int_Value, $p_bool_UpperCase)
{
/* decimal value of the starting ascii character */
$l_int_StartinAscii = 65 - 1; // = A
/* if lower-case, change decimal to lower-case "a" */
if (!$p_bool_UpperCase) {
$l_int_StartinAscii = 97 - 1; // = a
}
/* output string */
$l_str_Return = "";
$l_int_Offset = 0;
/* check if the value is higher then 26 = Z */
while ($p_int_Value > 26) {
/* increase offset and reduce counter */
$l_int_Offset++;
$p_int_Value -= 26;
}
/* if offset set (more then Z), then add a new letter in fron */
if ($l_int_Offset > 0) {
$l_str_Return = chr($l_int_Offset + $l_int_StartinAscii);
}
/* add the origin letter */
$l_str_Return .= chr($p_int_Value + $l_int_StartinAscii);
/* return the latin character representing the integer */
return $l_str_Return;
}
/**
* converts a integer to a leading-0 integer
* @since 1.0-gamma
* @param int $p_int_Value
* @return string
*/
function footnote_convert_to_arabic_leading($p_int_Value)
{
/* add a leading 0 if number lower then 10 */
if ($p_int_Value < 10) {
return "0" . $p_int_Value;
}
return $p_int_Value;
}
/**
* converts a arabic integer value into a romanic letter value
* @since 1.0-gamma
* @param int $p_int_Value
* @return string
*/
function footnote_convert_to_romanic($p_int_Value)
{
/* table containing all necessary romanic letters */
$l_arr_RomanicLetters = array('M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1);
/* return value */
$l_str_Return = '';
/* loop through integer value until it is reduced to 0 */
while ($p_int_Value > 0) {
foreach ($l_arr_RomanicLetters as $l_str_Romanic => $l_int_Arabic) {
if ($p_int_Value >= $l_int_Arabic) {
$p_int_Value -= $l_int_Arabic;
$l_str_Return .= $l_str_Romanic;
break;
}
}
}
/* return romanic letters as string */
return $l_str_Return;
}

View file

@ -8,70 +8,56 @@
* Since: 1.0
*/
/*
* PLUGIN PUBLIC NAME WITH STYLING
* @since 1.0.7
*/
// PLUGIN INTERNAL NAME
define("FOOTNOTES_PLUGIN_NAME", "footnotes");
// PLUGIN PUBLIC NAME WITH STYLING
// @since 1.0.7
define("FOOTNOTES_PLUGIN_PUBLIC_NAME", '<span class="footnote_tag_styling footnote_tag_styling_1">foot</span><span class="footnote_tag_styling footnote_tag_styling_2">notes</span>');
/*
* PLUGIN LOVE SYMBOL WITH STYLING
* @since 1.2.2
*/
// PLUGIN PUBLIC NAME WITH STYLING AND LINK
// @since 1.2.2
define("FOOTNOTES_PLUGIN_PUBLIC_NAME_LINKED", '<a href="http://wordpress.org/plugins/footnotes/" target="_blank" style="text-decoration:none;">' . FOOTNOTES_PLUGIN_PUBLIC_NAME . '</a>');
// PLUGIN LOVE SYMBOL WITH STYLING
// @since 1.2.2
define("FOOTNOTES_LOVE_SYMBOL", '<span style="color:#ff6d3b; font-weight:bold;">&hearts;</span>');
/*
* PLUGIN PUBLIC NAME WITH LINK
* @since 1.2.2
*/
define("FOOTNOTES_PLUGIN_PUBLIC_NAME_LINKED", '<a href="http://wordpress.org/plugins/footnotes/" target="_blank" style="text-decoration:none;">' . FOOTNOTES_PLUGIN_PUBLIC_NAME . '</a>');
/* GENERAL PLUGIN CONSTANTS */
define("FOOTNOTES_PLUGIN_NAME", "footnotes"); /* plugin's internal name */
define("FOOTNOTE_SETTINGS_CONTAINER", "footnotes_storage"); /* database container where all footnote settings are stored */
/* PLUGIN SETTINGS PAGE */
define("FOOTNOTES_SETTINGS_PAGE_ID", "footnotes"); /* plugin's setting page internal id */
/* PLUGIN SETTINGS PAGE TABS */
define("FOOTNOTE_SETTINGS_LABEL_GENERAL", "footnotes_general_settings"); /* internal label for the plugin's settings tab */
define("FOOTNOTE_SETTINGS_LABEL_HOWTO", "footnotes_howto"); /* internal label for the plugin's settings tab */
/* PLUGIN SETTINGS INPUT FIELDS */
define("FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL", "footnote_inputfield_combine_identical"); /* id of input field for the combine identical setting */
define("FOOTNOTE_INPUTFIELD_REFERENCES_LABEL", "footnote_inputfield_references_label"); /* id of input field for the references label setting */
define("FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES", "footnote_inputfield_collapse_references"); /* id of input field for the "collapse references" setting */
define("FOOTNOTE_INPUTFIELD_PLACEHOLDER_START", "footnote_inputfield_placeholder_start"); /* id of input field for the "placeholder starting tag" setting */
define("FOOTNOTE_INPUTFIELD_PLACEHOLDER_END", "footnote_inputfield_placeholder_end"); /* id of input field for the "placeholder ending tag" setting */
define("FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT", "footnote_inputfield_search_in_excerpt"); /* id of input field for the "allow footnotes in the excerpt" setting */
define("FOOTNOTE_INPUTFIELD_LOVE", "footnote_inputfield_love"); /* id of input field for "love and share this plugin" setting */
define("FOOTNOTE_INPUTFIELD_COUNTER_STYLE", "footnote_inputfield_counter_style"); /* id of input field for "counter style of footnote index" setting */
/*
* id of input field "placement of reference container" setting
* @since 1.0.7
*/
define("FOOTNOTE_INPUTFIELD_REFERENCE_CONTAINER_PLACE", "footnote_inputfield_reference_container_place");
/*
* id of input field for 'user defined placeholder start and end tag
* @since 1.1.2
*/
define("FOOTNOTE_INPUTFIELD_PLACEHOLDER_START_USERDEFINED", "footnote_inputfield_placeholder_start_user_defined");
define("FOOTNOTE_INPUTFIELD_PLACEHOLDER_END_USERDEFINED", "footnote_inputfield_placeholder_end_user_defined");
/* PLUGIN REFERENCES CONTAINER ID */
define("FOOTNOTE_REFERENCES_CONTAINER_ID", "footnote_references_container"); /* id for the div surrounding the footnotes */
/* PLUGIN DIRECTORIES */
// PLUGIN DIRECTORIES
define("FOOTNOTES_PLUGIN_DIR_NAME", "footnotes");
define("FOOTNOTES_LANGUAGE_DIR", dirname(__FILE__) . "/../languages/");
define("FOOTNOTES_TEMPLATES_DIR", dirname(__FILE__) . "/../templates/");
/*
* PLUGIN PLACEHOLDER TO NOT DISPLAY THE 'LOVE ME' SLUG
* @since 1.1.1
*/
define("FOOTNOTES_NO_SLUGME_PLUG", "[[no footnotes: love]]");
define("FOOTNOTES_REFERENCE_CONTAINER_POSITION", "[[footnotes reference container position]]");
// SETTINGS CONTAINER
define("FOOTNOTES_SETTINGS_CONTAINER", "footnotes_storage"); // database container where all footnote settings are stored
define("FOOTNOTES_SETTINGS_CONTAINER_CUSTOM", "footnotes_storage_custom"); // database container where all 'custom' settings are stored
// PLUGIN SETTINGS PAGE
define("FOOTNOTES_SETTINGS_PAGE_ID", "footnotes"); // plugins setting page internal id
// PLUGIN SETTINGS PAGE TABS
define("FOOTNOTES_SETTINGS_TAB_GENERAL", "footnotes_general_settings"); // internal label for the plugins general settings tab
define("FOOTNOTES_SETTINGS_TAB_CUSTOM", "footnotes_custom_settings"); // internal label for the plugins custom settings tab
define("FOOTNOTES_SETTINGS_TAB_HOWTO", "footnotes_howto_settings"); // internal label for the plugins how to tab
// PLUGIN SETTINGS INPUT FIELDS
define("FOOTNOTES_INPUT_COMBINE_IDENTICAL", "footnote_inputfield_combine_identical"); // id of input field for the combine identical setting
define("FOOTNOTES_INPUT_REFERENCES_LABEL", "footnote_inputfield_references_label"); // id of input field for the references label setting
define("FOOTNOTES_INPUT_COLLAPSE_REFERENCES", "footnote_inputfield_collapse_references"); // id of input field for the "collapse references" setting
define("FOOTNOTES_INPUT_PLACEHOLDER_START", "footnote_inputfield_placeholder_start"); // id of input field for the "placeholder starting tag" setting
define("FOOTNOTES_INPUT_PLACEHOLDER_END", "footnote_inputfield_placeholder_end"); // id of input field for the "placeholder ending tag" setting
define("FOOTNOTES_INPUT_SEARCH_IN_EXCERPT", "footnote_inputfield_search_in_excerpt"); // id of input field for the "allow footnotes in the excerpt" setting
define("FOOTNOTES_INPUT_LOVE", "footnote_inputfield_love"); // id of input field for "love and share this plugin" setting
define("FOOTNOTES_INPUT_COUNTER_STYLE", "footnote_inputfield_counter_style"); // id of input field for "counter style of footnote index" setting
define("FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE", "footnote_inputfield_reference_container_place"); // id of input field "placement of reference container" setting
define("FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED", "footnote_inputfield_placeholder_start_user_defined"); // id of input field for 'user defined placeholder start tag
define("FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED", "footnote_inputfield_placeholder_end_user_defined"); // id of input field for 'user defined placeholder end tag
define("FOOTNOTES_INPUT_CUSTOM_CSS", "footnote_inputfield_custom_css"); // if of input field for 'custom css' setting
// PLUGIN REFERENCES CONTAINER ID
define("FOOTNOTES_REFERENCES_CONTAINER_ID", "footnote_references_container"); // id for the div surrounding the footnotes
define("FOOTNOTES_REFERENCE_CONTAINER_POSITION", "[[footnotes reference container position]]");
// PLUGIN PLACEHOLDER TO NOT DISPLAY THE 'LOVE ME' SLUG
// @since 1.1.1
define("FOOTNOTES_NO_SLUGME_PLUG", "[[no footnotes: love]]");

View file

@ -8,48 +8,48 @@
* Since: 1.0
*/
// action to locate language and load the WordPress-specific language file
add_action('plugins_loaded', 'MCI_Footnotes_LoadLanguage');
/**
* loads the langauge file including localization if exists
* otherwise loads the langauge file without localization information
* loads the language file including localization if exists
* otherwise loads the language file without localization information
* @since 1.0
*/
function footnotes_load_language()
{
/* read current wordpress langauge */
function MCI_Footnotes_LoadLanguage() {
// read current WordPress language
$l_str_locale = apply_filters('plugin_locale', get_locale(), FOOTNOTES_PLUGIN_NAME);
/* get only language code (removed localization code) */
$l_str_languageCode = footnotes_getLanguageCode();
// get only language code (removed localization code)
$l_str_languageCode = MCI_Footnotes_getLanguageCode();
/* language file with localization exists */
if ($l_bool_loaded = load_textdomain(FOOTNOTES_PLUGIN_NAME, FOOTNOTES_LANGUAGE_DIR . FOOTNOTES_PLUGIN_NAME . '-' . $l_str_locale . '.mo')) {
/* language file without localization exists */
} else if ($l_bool_loaded = load_textdomain(FOOTNOTES_PLUGIN_NAME, FOOTNOTES_LANGUAGE_DIR . FOOTNOTES_PLUGIN_NAME . '-' . $l_str_languageCode . '.mo')) {
/* load default language file, nothing will happen: default language will be used (=english) */
} else {
load_textdomain(FOOTNOTES_PLUGIN_NAME, FOOTNOTES_LANGUAGE_DIR . FOOTNOTES_PLUGIN_NAME . '-en.mo');
}
// language file with localization exists
$l_bool_loaded = load_textdomain(FOOTNOTES_PLUGIN_NAME, FOOTNOTES_LANGUAGE_DIR . FOOTNOTES_PLUGIN_NAME . '-' . $l_str_locale . '.mo');
if (empty($l_bool_loaded)) {
// language file without localization exists
$l_bool_loaded = load_textdomain(FOOTNOTES_PLUGIN_NAME, FOOTNOTES_LANGUAGE_DIR . FOOTNOTES_PLUGIN_NAME . '-' . $l_str_languageCode . '.mo');
if (empty($l_bool_loaded)) {
// fallback to english
load_textdomain(FOOTNOTES_PLUGIN_NAME, FOOTNOTES_LANGUAGE_DIR . FOOTNOTES_PLUGIN_NAME . '-en.mo');
}
}
}
/**
* reads the wordpress langauge and returns only the language code lowercase
* reads the WordPress language and returns only the language code lowercase
* removes the localization code
* @since 1.0
* @return string (only the "en" from "en_US")
*/
function footnotes_getLanguageCode()
{
/* read current wordpress langauge */
function MCI_Footnotes_getLanguageCode() {
// read current WordPress language
$l_str_locale = apply_filters('plugin_locale', get_locale(), FOOTNOTES_PLUGIN_NAME);
/* check if wordpress language has a localization (e.g. "en_US" or "de_AT") */
// check if WordPress language has a localization (e.g. "en_US" or "de_AT")
if (strpos($l_str_locale, "_") !== false) {
/* remove localization code */
// remove localization code
$l_arr_languageCode = explode("_", $l_str_locale);
$l_str_languageCode = $l_arr_languageCode[0];
return $l_str_languageCode;
}
/* return language code lowercase */
// return language code lowercase
return strtolower($l_str_locale);
}

View file

@ -8,95 +8,103 @@
* Since: 1.0
*/
// add link to the settings page in plugin main page
$l_str_plugin_file = FOOTNOTES_PLUGIN_DIR_NAME . '/index.php';
add_filter("plugin_action_links_{$l_str_plugin_file}", 'MCI_Footnotes_PluginLinks', 10, 2);
/**
* add short links to the plugin main page
* @since 1.0
* @param array $links
* @param mixed $file
* @param array $p_arr_Links
* @param string $p_str_File
* @return array
*/
function footnotes_plugin_settings_link($links, $file)
{
/* add link to the footnotes plugin settings page */
function MCI_Footnotes_PluginLinks($p_arr_Links, $p_str_File) {
// add link to the footnotes plugin settings page
$l_str_SettingsLink = '<a href="' . admin_url('options-general.php?page=' . FOOTNOTES_SETTINGS_PAGE_ID) . '">' . __('Settings', FOOTNOTES_PLUGIN_NAME) . '</a>';
/* add link to the footnotes plugin support page on wordpress.org */
// add link to the footnotes plugin support page on wordpress.org
$l_str_SupportLink = '<a href="http://wordpress.org/support/plugin/footnotes" target="_blank">' . __('Support', FOOTNOTES_PLUGIN_NAME) . '</a>';
/* add defined links to the plugin main page */
$links[] = $l_str_SupportLink;
$links[] = $l_str_SettingsLink;
// add defined links to the plugin main page
$p_arr_Links[] = $l_str_SupportLink;
$p_arr_Links[] = $l_str_SettingsLink;
/* return new links */
return $links;
// return new links
return $p_arr_Links;
}
/**
* reads a option field, filters the values and returns the filtered option array
* fallback to default value since 1.0-gamma
* @since 1.0
* @param string $p_str_OptionsField
* @param array $p_arr_DefaultValues
* @param bool $p_bool_ConvertHtmlChars
* @return array
*/
function footnotes_filter_options($p_str_OptionsField, $p_arr_DefaultValues, $p_bool_ConvertHtmlChars = true)
{
$l_arr_Options = get_option($p_str_OptionsField);
/* if no settings set yet return default values */
if (empty($l_arr_Options)) {
return $p_arr_DefaultValues;
}
/* loop through all keys in the array and filters them */
foreach ($l_arr_Options as $l_str_Key => $l_str_Value) {
/* removes special chars from the settings value */
$l_str_Value = stripcslashes($l_str_Value);
/* if set, convert html special chars */
if ($p_bool_ConvertHtmlChars) {
$l_str_Value = htmlspecialchars($l_str_Value);
}
/* check if settings value is not empty, otherwise load the default value, or empty string if no default is defined */
if (!empty($l_str_Value)) {
$l_arr_Options[$l_str_Key] = stripcslashes($l_str_Value);
/* check if default value is defined */
} else if (array_key_exists($l_str_Key, $p_arr_DefaultValues)) {
$l_arr_Options[$l_str_Key] = $p_arr_DefaultValues[$l_str_Key];
} else {
$l_arr_Options[$l_str_Key] = "";
}
}
function MCI_Footnotes_getOptions($p_bool_ConvertHtmlChars = true) {
// default settings for the 'general' settings container
$l_arr_Default_General = array(
FOOTNOTES_INPUT_COMBINE_IDENTICAL => 'yes',
FOOTNOTES_INPUT_REFERENCES_LABEL => 'References',
FOOTNOTES_INPUT_COLLAPSE_REFERENCES => '',
FOOTNOTES_INPUT_PLACEHOLDER_START => '((',
FOOTNOTES_INPUT_PLACEHOLDER_END => '))',
FOOTNOTES_INPUT_SEARCH_IN_EXCERPT => 'yes',
FOOTNOTES_INPUT_LOVE => 'no',
FOOTNOTES_INPUT_COUNTER_STYLE => 'arabic_plain',
FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE => 'post_end',
FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED => '',
FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED => ''
);
// default settings for the 'custom' settings container
$l_arr_Default_Custom = array(
FOOTNOTES_INPUT_CUSTOM_CSS => ''
);
// check if each key from the default values exist in return array
foreach($p_arr_DefaultValues as $l_str_Key => $l_str_Value) {
// if key not exists, add it with its default value
if (!array_key_exists($l_str_Key, $l_arr_Options)) {
$l_arr_Options[$l_str_Key] = $l_str_Value;
}
}
/* returns the filtered array */
return $l_arr_Options;
$l_arr_General = MCI_Footnotes_ValidateOptions(get_option(FOOTNOTES_SETTINGS_CONTAINER), $l_arr_Default_General, $p_bool_ConvertHtmlChars);
$l_arr_Custom = MCI_Footnotes_ValidateOptions(get_option(FOOTNOTES_SETTINGS_CONTAINER_CUSTOM), $l_arr_Default_Custom, $p_bool_ConvertHtmlChars);
return array_merge($l_arr_General, $l_arr_Custom);
}
/**
* converts a string depending on its value to a boolean
* @since 1.0-beta
* @param string $p_str_Value
* @return bool
* validate each option, fallback is the default value
* @since 1.3
* @param array $p_arr_Options
* @param array $p_arr_Default
* @param bool $p_bool_ConvertHtmlChars
* @return array
*/
function footnotes_ConvertToBool($p_str_Value)
{
/* convert string to lower-case to make it easier */
$p_str_Value = strtolower($p_str_Value);
/* check if string seems to contain a "true" value */
switch ($p_str_Value) {
case "checked":
case "yes":
case "true":
case "on":
case "1":
return true;
}
/* nothing found that says "true", so we return false */
return false;
function MCI_Footnotes_ValidateOptions($p_arr_Options, $p_arr_Default, $p_bool_ConvertHtmlChars) {
// if no settings set yet return default values
if (empty($p_arr_Options)) {
return $p_arr_Default;
}
// loop through all keys in the array and filters them
foreach ($p_arr_Options as $l_str_Key => $l_str_Value) {
// removes special chars from the settings value
$l_str_Value = stripcslashes($l_str_Value);
// if set, convert html special chars
if ($p_bool_ConvertHtmlChars) {
$l_str_Value = htmlspecialchars($l_str_Value);
}
// check if settings value is not empty, otherwise load the default value, or empty string if no default is defined
if (!empty($l_str_Value)) {
$p_arr_Options[$l_str_Key] = $l_str_Value;
// check if default value is defined
} else if (array_key_exists($l_str_Key, $p_arr_Default)) {
$p_arr_Options[$l_str_Key] = $p_arr_Default[$l_str_Key];
} else {
$p_arr_Options[$l_str_Key] = "";
}
}
// check if each key from the default values exist in return array
foreach($p_arr_Default as $l_str_Key => $l_str_Value) {
// if key not exists, add it with its default value
if (!array_key_exists($l_str_Key, $p_arr_Options)) {
$p_arr_Options[$l_str_Key] = $l_str_Value;
}
}
// returns the filtered array
return $p_arr_Options;
}

View file

@ -1,413 +0,0 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.1.1
* Since: 1.0
*/
/*
* collection of all footnotes found on the current page
* @since 1.0
*/
$g_arr_Footnotes = array();
/*
* collection of all footnotes settings
* @since 1.0-beta
*/
$g_arr_FootnotesSettings = array();
/*
* flag to know íf the user wants to have NO 'love me' slug on the current page
* @since 1.1.1
*/
$g_bool_NoLoveMeSlugOnCurrentPage = false;
/**
* register all functions needed for the replacement in the wordpress core
* @since 1.0-gamma
*/
function footnotes_RegisterReplacementFunctions()
{
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* load footnote settings */
$g_arr_FootnotesSettings = footnotes_filter_options(FOOTNOTE_SETTINGS_CONTAINER, Class_FootnotesSettings::$a_arr_Default_Settings, false);
/* stops listening to the output and replaces the footnotes */
add_action('get_footer', 'footnotes_StopReplacing');
/* moves these contents through the replacement function */
add_filter('the_content', 'footnotes_Replacer_Content');
add_filter('the_excerpt', 'footnotes_Replacer_Excerpt');
add_filter('widget_title', 'footnotes_Replacer_WidgetTitle');
add_filter('widget_text', 'footnotes_Replacer_WidgetText');
/* adds the love and share me slug to the footer */
add_action('wp_footer', 'footnotes_LoveAndShareMe');
}
/**
* replacement action for the_excerpt
* @param string $p_str_Content
* @return string
* @since 1.0.7
*/
function footnotes_Replacer_Content($p_str_Content)
{
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* get setting for 'display reference container position' */
$l_str_ReferenceContainerPosition = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_REFERENCE_CONTAINER_PLACE];
/* returns content */
return footnotes_replaceFootnotes($p_str_Content, $l_str_ReferenceContainerPosition == "post_end" ? true : false, false);
}
/**
* replacement action for the_excerpt
* @param string $p_str_Content
* @return string
* @since 1.0.7
*/
function footnotes_Replacer_Excerpt($p_str_Content)
{
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* get setting for accepting footnotes in the excerpt and convert it to boolean */
$l_bool_SearchExcerpt = footnotes_ConvertToBool($g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_SEARCH_IN_EXCERPT]);
/* search in the excerpt only if activated */
if ($l_bool_SearchExcerpt) {
return footnotes_replaceFootnotes($p_str_Content, false, false);
}
/* returns content */
return $p_str_Content;
}
/**
* replacement action for widget_title
* @param string $p_str_Content
* @return string
* @since 1.0.7
*/
function footnotes_Replacer_WidgetTitle($p_str_Content)
{
/* returns content */
return $p_str_Content;
}
/**
* replacement action for widget_text
* @param string $p_str_Content
* @return string
* @since 1.0.7
*/
function footnotes_Replacer_WidgetText($p_str_Content)
{
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* get setting for 'display reference container position' */
$l_str_ReferenceContainerPosition = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_REFERENCE_CONTAINER_PLACE];
/* returns content */
return footnotes_replaceFootnotes($p_str_Content, $l_str_ReferenceContainerPosition == "post_end" ? true : false, false);
}
/**
* stops buffering the output, automatically calls the ob_start() defined callback function
* replaces all footnotes in the whole buffer and outputs it
* @since 1.0
* cleared the flag in version 1.0.7
*/
function footnotes_StopReplacing()
{
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* get setting for 'display reference container position' */
$l_str_ReferenceContainerPosition = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_REFERENCE_CONTAINER_PLACE];
if ($l_str_ReferenceContainerPosition == "footer") {
echo footnotes_OutputReferenceContainer();
}
}
/**
* outputs a link to love and share this awesome plugin
* @since 1.0-gamma
*/
function footnotes_LoveAndShareMe()
{
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
global $g_bool_NoLoveMeSlugOnCurrentPage;
/*
* updated url to wordpress.org plugin page instead of the github page
* also updated the font-style and translation the string "footnotes"
* in version 1.0.6
*/
/*
* changed replacement of public plugin name to use global styling setting
* @since 1.0.7
*/
/* get setting for love and share this plugin and convert it to boolean */
$l_str_LoveMeText = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_LOVE];
/* check if the admin allows to add a link to the footer */
if (!empty($l_str_LoveMeText) && strtolower($l_str_LoveMeText) != "no" && !$g_bool_NoLoveMeSlugOnCurrentPage) {
if (strtolower($l_str_LoveMeText) == "random") {
$l_str_LoveMeText = "text-" . rand(1,3);
}
switch ($l_str_LoveMeText) {
case "text-1":
$l_str_LoveMeText = sprintf(__('I %s %s', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_LOVE_SYMBOL, FOOTNOTES_PLUGIN_PUBLIC_NAME_LINKED);
break;
case "text-2":
$l_str_LoveMeText = sprintf(__('this site uses the awesome %s Plugin', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME_LINKED);
break;
case "text-3":
default:
$l_str_LoveMeText = sprintf(__('extra smooth %s', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME_LINKED);
break;
}
echo '<div style="text-align:center; color:#acacac;">' . $l_str_LoveMeText . '</div>';
}
}
/**
* replaces all footnotes in the given content
* loading settings if not happened yet since 1.0-gamma
* @since 1.0
* @param string $p_str_Content
* @param bool $p_bool_OutputReferences [default: true]
* @param bool $p_bool_ReplaceHtmlCharsSettings [ default: false]
* @return string
*/
function footnotes_replaceFootnotes($p_str_Content, $p_bool_OutputReferences = true, $p_bool_ReplaceHtmlCharsSettings = false)
{
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* load footnote settings */
$g_arr_FootnotesSettings = footnotes_filter_options(FOOTNOTE_SETTINGS_CONTAINER, Class_FootnotesSettings::$a_arr_Default_Settings, $p_bool_ReplaceHtmlCharsSettings);
/* replace all footnotes in the content */
$p_str_Content = footnotes_getFromString($p_str_Content, true);
$p_str_Content = footnotes_getFromString($p_str_Content, false);
/* add the reference list if set */
if ($p_bool_OutputReferences) {
$p_str_Content = $p_str_Content . footnotes_OutputReferenceContainer();
}
/*
* checks if the user doesn't want to have a 'love me' on current page
* @since 1.1.1
*/
if (strpos($p_str_Content, FOOTNOTES_NO_SLUGME_PLUG) !== false) {
global $g_bool_NoLoveMeSlugOnCurrentPage;
$g_bool_NoLoveMeSlugOnCurrentPage = true;
$p_str_Content = str_replace(FOOTNOTES_NO_SLUGME_PLUG, "", $p_str_Content);
}
/* return the replaced content */
return $p_str_Content;
}
/**
* replace all footnotes in the given string and adds them to an array
* using a personal starting and ending tag for the footnotes since 1.0-gamma
* @since 1.0
* @param string $p_str_Content
* @param bool $p_bool_ConvertHtmlChars
* @return string
*/
function footnotes_getFromString($p_str_Content, $p_bool_ConvertHtmlChars = true)
{
/* get access to the global array to store footnotes */
global $g_arr_Footnotes;
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* contains the index for the next footnote on this page */
$l_int_FootnoteIndex = count($g_arr_Footnotes) + 1;
/* contains the starting position for the lookup of a footnote */
$l_int_PosStart = 0;
/* contains the footnote template */
$l_str_FootnoteTemplate = file_get_contents(FOOTNOTES_TEMPLATES_DIR . "footnote.html");
/* get footnote starting tag */
$l_str_StartingTag = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_PLACEHOLDER_START];
/*get footnote ending tag */
$l_str_EndingTag = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_PLACEHOLDER_END];
/*get footnote counter style */
$l_str_CounterStyle = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_COUNTER_STYLE];
if ($l_str_StartingTag == "userdefined" || $l_str_EndingTag == "userdefined") {
/* get user defined footnote starting tag */
$l_str_StartingTag = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_PLACEHOLDER_START_USERDEFINED];
/*get user defined footnote ending tag */
$l_str_EndingTag = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_PLACEHOLDER_END_USERDEFINED];
}
/* decode html special chars */
if ($p_bool_ConvertHtmlChars) {
$l_str_StartingTag = htmlspecialchars($l_str_StartingTag);
$l_str_EndingTag = htmlspecialchars($l_str_EndingTag);
}
/* check for a footnote placeholder in the current page */
do {
/* get first occurence of a footnote starting tag */
$l_int_PosStart = strpos($p_str_Content, $l_str_StartingTag, $l_int_PosStart);
/* tag found */
if ($l_int_PosStart !== false) {
/* get first occurence of a footnote ending tag after the starting tag */
$l_int_PosEnd = strpos($p_str_Content, $l_str_EndingTag, $l_int_PosStart);
/* tag found */
if ($l_int_PosEnd !== false) {
/* get length of footnote text */
$l_int_Length = $l_int_PosEnd - $l_int_PosStart;
/* get text inside footnote */
$l_str_FootnoteText = substr($p_str_Content, $l_int_PosStart + strlen($l_str_StartingTag), $l_int_Length - strlen($l_str_StartingTag));
/* set replacer for the footnote */
$l_str_ReplaceText = str_replace("[[FOOTNOTE INDEX]]", footnote_convert_index($l_int_FootnoteIndex, $l_str_CounterStyle), $l_str_FootnoteTemplate);
$l_str_ReplaceText = str_replace("[[FOOTNOTE TEXT]]", $l_str_FootnoteText, $l_str_ReplaceText);
$l_str_ReplaceText = preg_replace('@[\s]{2,}@',' ',$l_str_ReplaceText);
/* replace footnote in content */
$p_str_Content = substr_replace($p_str_Content, $l_str_ReplaceText, $l_int_PosStart, $l_int_Length + strlen($l_str_EndingTag));
/* set footnote to the output box at the end */
$g_arr_Footnotes[] = $l_str_FootnoteText;
/* increase footnote index */
$l_int_FootnoteIndex++;
/* add offset to the new starting position */
$l_int_PosStart += ($l_int_PosEnd - $l_int_PosStart);
/* no ending tag found */
} else {
$l_int_PosStart++;
}
/* no starting tag found */
} else {
break;
}
} while (true);
/* return content */
return $p_str_Content;
}
/**
* looks through all footnotes that has been replaced in the current content and
* adds a reference to the footnote at the end of the content
* function to collapse the reference container since 1.0-beta
* @since 1.0
* @return string
*/
function footnotes_OutputReferenceContainer()
{
/* get access to the global array to read footnotes */
global $g_arr_Footnotes;
/* access to the global settings collection */
global $g_arr_FootnotesSettings;
/* no footnotes has been replaced on this page */
if (empty($g_arr_Footnotes)) {
/* return empty string */
return "";
}
/* get setting for combine identical footnotes and convert it to boolean */
$l_bool_CombineIdentical = footnotes_ConvertToBool($g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_COMBINE_IDENTICAL]);
/* get setting for preferences label */
$l_str_ReferencesLabel = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_REFERENCES_LABEL];
/* get setting for collapse reference footnotes and convert it to boolean */
$l_bool_CollapseReference = footnotes_ConvertToBool($g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_COLLAPSE_REFERENCES]);
/*get footnote counter style */
$l_str_CounterStyle = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_COUNTER_STYLE];
/*
* add expand/collapse buttons to the reference label if collapsed by default
* @since 1.2.2
*/
$l_str_CollapseButtons = "";
if ($l_bool_CollapseReference) {
$l_str_CollapseButtons = '&nbsp;&nbsp;&nbsp;[ <a id="footnote_reference_container_collapse_button" style="cursor:pointer;" onclick="footnote_expand_collapse_reference_container();">+</a> ]';
}
/* output string, prepare it with the reference label as headline */
$l_str_Output = '<div class="footnote_container_prepare"><p><span onclick="footnote_expand_reference_container();">' . $l_str_ReferencesLabel . '</span><span>' .$l_str_CollapseButtons . '</span></p></div>';
/* add a box around the footnotes */
$l_str_Output .= '<div id="' . FOOTNOTE_REFERENCES_CONTAINER_ID . '"';
/* add class to hide the references by default, if the user wants it */
if ($l_bool_CollapseReference) {
$l_str_Output .= ' class="footnote_hide_box"';
}
$l_str_Output .= '>';
/* contains the footnote template */
$l_str_FootnoteTemplate = file_get_contents(FOOTNOTES_TEMPLATES_DIR . "container.html");
/* loop through all footnotes found in the page */
for ($l_str_Index = 0; $l_str_Index < count($g_arr_Footnotes); $l_str_Index++) {
/* get footnote text */
$l_str_FootnoteText = $g_arr_Footnotes[$l_str_Index];
/* if fottnote is empty, get to the next one */
if (empty($l_str_FootnoteText)) {
continue;
}
/* get footnote index */
$l_str_FirstFootnoteIndex = ($l_str_Index + 1);
$l_str_FootnoteIndex = footnote_convert_index(($l_str_Index + 1), $l_str_CounterStyle);
/* check if it isn't the last footnote in the array */
if ($l_str_FirstFootnoteIndex < count($g_arr_Footnotes) && $l_bool_CombineIdentical) {
/* get all footnotes that I haven't passed yet */
for ($l_str_CheckIndex = $l_str_FirstFootnoteIndex; $l_str_CheckIndex < count($g_arr_Footnotes); $l_str_CheckIndex++) {
/* check if a further footnote is the same as the actual one */
if ($l_str_FootnoteText == $g_arr_Footnotes[$l_str_CheckIndex] && !empty($g_arr_Footnotes[$l_str_CheckIndex])) {
/* set the further footnote as empty so it won't be displayed later */
$g_arr_Footnotes[$l_str_CheckIndex] = "";
/* add the footnote index to the actual index */
$l_str_FootnoteIndex .= ", " . footnote_convert_index(($l_str_CheckIndex + 1), $l_str_CounterStyle);
}
}
}
/* add the footnote to the output box */
/*
* added function to convert the counter style in the reference container (bugfix for the link to the footnote) in version 1.0.6
*/
$l_str_ReplaceText = str_replace("[[FOOTNOTE INDEX SHORT]]", footnote_convert_index($l_str_FirstFootnoteIndex, $l_str_CounterStyle), $l_str_FootnoteTemplate);
$l_str_ReplaceText = str_replace("[[FOOTNOTE INDEX]]", $l_str_FootnoteIndex, $l_str_ReplaceText);
$l_str_ReplaceText = str_replace("[[FOOTNOTE TEXT]]", $l_str_FootnoteText, $l_str_ReplaceText);
$l_str_ReplaceText = preg_replace('@[\s]{2,}@',' ',$l_str_ReplaceText);
/* add the footnote container to the output */
$l_str_Output = $l_str_Output . $l_str_ReplaceText;
}
/* add closing tag for the div of the references container */
$l_str_Output = $l_str_Output . '</div>';
/* add a javascript to expand the reference container when clicking on a footnote or the reference label */
$l_str_Output .= '
<script type="text/javascript">
function footnote_expand_reference_container(p_str_ID) {
jQuery("#' . FOOTNOTE_REFERENCES_CONTAINER_ID . '").show();
if (p_str_ID.length > 0) {
jQuery(p_str_ID).focus();
}
}
function footnote_expand_collapse_reference_container() {
var l_obj_ReferenceContainer = jQuery("#' . FOOTNOTE_REFERENCES_CONTAINER_ID . '");
if (l_obj_ReferenceContainer.is(":hidden")) {
l_obj_ReferenceContainer.show();
jQuery("#footnote_reference_container_collapse_button").text("-");
} else {
l_obj_ReferenceContainer.hide();
jQuery("#footnote_reference_container_collapse_button").text("+");
}
}
</script>
';
/* free all found footnotes if reference container will be displayed */
$g_arr_Footnotes = array();
/* return the output string */
return $l_str_Output;
}

View file

@ -1,38 +0,0 @@
<?php
/**
* Created by Stefan Herndler.
* User: Stefan
* Date: 15.05.14
* Time: 16:21
* Version: 1.0
* Since: 1.0
*/
/**
* register and add the public stylesheet
* @since 1.0
*/
function footnotes_add_public_stylesheet()
{
/* register public stylesheet */
wp_register_style('footnotes_public_style', plugins_url('../css/footnote.css', __FILE__));
/* add public stylesheet */
wp_enqueue_style('footnotes_public_style');
/* add the jQuery plugin (already registered by WP) */
wp_enqueue_script('jquery');
/* add jquery tools to public page */
wp_enqueue_script('footnotes_public_script', plugins_url('../js/jquery.tools.min.js', __FILE__), array());
}
/**
* register and add the settings stylesheet
* @since 1.0
*/
function footnotes_add_settings_stylesheet()
{
/* register settings stylesheet */
wp_register_style('footnotes_settings_style', plugins_url('../css/settings.css', __FILE__));
/* add settings stylesheet */
wp_enqueue_style('footnotes_settings_style');
}

View file

@ -8,13 +8,24 @@
* Since: 1.2.0
*/
// add new button to the WYSIWYG - editor
add_filter("mce_buttons", "MCI_Footnotes_wysiwyg_editor_functions");
add_filter("mce_external_plugins", "MCI_Footnotes_wysiwyg_editor_buttons");
// add new button to the plain text editor
add_action("admin_print_footer_scripts", "MCI_Footnotes_text_editor_buttons");
// defines the callback function for the editor buttons
add_action("wp_ajax_nopriv_footnotes_getTags", "MCI_Footnotes_wysiwyg_ajax_callback");
add_action("wp_ajax_footnotes_getTags", "MCI_Footnotes_wysiwyg_ajax_callback");
/**
* adds a new button to the WYSIWYG editor for pages and posts
* @param array $buttons
* @return array
* @since 1.2.0
*/
function footnotes_wysiwyg_editor_functions($buttons) {
function MCI_Footnotes_wysiwyg_editor_functions($buttons) {
array_push($buttons, FOOTNOTES_PLUGIN_NAME);
return $buttons;
}
@ -25,7 +36,7 @@ function footnotes_wysiwyg_editor_functions($buttons) {
* @return array
* @since 1.2.0
*/
function footnotes_wysiwyg_editor_buttons($plugin_array) {
function MCI_Footnotes_wysiwyg_editor_buttons($plugin_array) {
$plugin_array[FOOTNOTES_PLUGIN_NAME] = plugins_url('/../js/wysiwyg-editor.js', __FILE__);
return $plugin_array;
}
@ -34,16 +45,16 @@ function footnotes_wysiwyg_editor_buttons($plugin_array) {
* adds a new button to the plain text editor for pages and posts
* @since 1.2.0
*/
function footnotes_text_editor_buttons() {
function MCI_Footnotes_text_editor_buttons() {
?>
<script type="text/javascript">
/**
* adds a tag in at the beginning and at the end of a selected text in the specific textarea
* adds a tag in at the beginning and at the end of a selected text in the specific text area
* @param string elementID
* @param string openTag
* @param string closeTag
*/
function footnotes_wrapText(elementID, openTag, closeTag) {
function MCI_Footnotes_wrapText(elementID, openTag, closeTag) {
var textArea = jQuery('#' + elementID);
var len = textArea.val().length;
var start = textArea[0].selectionStart;
@ -55,13 +66,13 @@ function footnotes_text_editor_buttons() {
/**
* adds a new button to the plain text editor
*/
QTags.addButton( 'footnotes_quicktag_button', 'footnotes', footnotes_text_editor_callback );
QTags.addButton( 'MCI_Footnotes_QuickTag_button', 'footnotes', MCI_Footnotes_text_editor_callback );
/**
* callback function when the button is clicked
* executes a ajax call to get the start and end tag for the footnotes and
* adds them in before and after the selected text
*/
function footnotes_text_editor_callback() {
function MCI_Footnotes_text_editor_callback() {
jQuery.ajax({
type: 'POST',
url: '/wp-admin/admin-ajax.php',
@ -71,7 +82,7 @@ function footnotes_text_editor_buttons() {
},
success: function(data, textStatus, XMLHttpRequest){
var l_arr_Tags = JSON.parse(data);
footnotes_wrapText("content", l_arr_Tags['start'], l_arr_Tags['end']);
MCI_Footnotes_wrapText("content", l_arr_Tags['start'], l_arr_Tags['end']);
},
error: function(MLHttpRequest, textStatus, errorThrown){
}
@ -86,23 +97,24 @@ function footnotes_text_editor_buttons() {
* to get the start and end tag for the footnotes
* echos the tags as json-string ("start" | "end")
*/
function footnotes_wysiwyg_ajax_callback() {
require_once(dirname(__FILE__) . '/../includes/defines.php');
require_once(dirname(__FILE__) . '/../includes/plugin-settings.php');
function MCI_Footnotes_wysiwyg_ajax_callback() {
require_once(dirname(__FILE__) . "/defines.php");
require_once(dirname(__FILE__) . '/plugin-settings.php');
require_once(dirname(__FILE__) . '/../classes/admin.php');
/* load footnote settings */
$g_arr_FootnotesSettings = footnotes_filter_options(FOOTNOTE_SETTINGS_CONTAINER, Class_FootnotesSettings::$a_arr_Default_Settings, true);
$g_arr_FootnotesSettings = MCI_Footnotes_getOptions(true);
/* get footnote starting tag */
$l_str_StartingTag = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_PLACEHOLDER_START];
$l_str_StartingTag = $g_arr_FootnotesSettings[FOOTNOTES_INPUT_PLACEHOLDER_START];
/*get footnote ending tag */
$l_str_EndingTag = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_PLACEHOLDER_END];
$l_str_EndingTag = $g_arr_FootnotesSettings[FOOTNOTES_INPUT_PLACEHOLDER_END];
if ($l_str_StartingTag == "userdefined" || $l_str_EndingTag == "userdefined") {
/* get user defined footnote starting tag */
$l_str_StartingTag = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_PLACEHOLDER_START_USERDEFINED];
$l_str_StartingTag = $g_arr_FootnotesSettings[FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED];
/*get user defined footnote ending tag */
$l_str_EndingTag = $g_arr_FootnotesSettings[FOOTNOTE_INPUTFIELD_PLACEHOLDER_END_USERDEFINED];
$l_str_EndingTag = $g_arr_FootnotesSettings[FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED];
}
echo json_encode(array("start" => $l_str_StartingTag, "end" => $l_str_EndingTag));

View file

@ -4,7 +4,7 @@
Plugin URI: http://wordpress.org/plugins/footnotes/
Description: time to bring footnotes to your website! footnotes are known from offline publishing and everybody takes them for granted when reading a magazine.
Author: media competence institute
Version: 1.2.5
Version: 1.3.0
Author URI: http://cheret.co.uk/mci
Text Domain: footnotes
Domain Path: /languages
@ -35,72 +35,36 @@
* Since: 1.0
*/
/* include constants */
// include constants
require_once(dirname(__FILE__) . "/includes/defines.php");
/* include language functions */
// include language functions
require_once(dirname(__FILE__) . "/includes/language.php");
/* include storage functions and global plugin functions */
// include storage functions and global plugin functions
require_once(dirname(__FILE__) . "/includes/plugin-settings.php");
/* include script and stylesheet functions */
require_once(dirname(__FILE__) . "/includes/scripts.php");
/* include script and stylesheet functions */
require_once(dirname(__FILE__) . "/includes/convert.php");
/* include script and stylesheet functions */
require_once(dirname(__FILE__) . "/includes/wysiwyg-editor.php");
/* include script and stylesheet functions */
require_once(dirname(__FILE__) . "/includes/replacer.php");
/* require plugin class */
require_once(dirname(__FILE__) . "/classes/footnotes.php");
/* require plugin settings class */
require_once(dirname(__FILE__) . "/classes/footnotes_settings.php");
/* require plugin widget class */
require_once(dirname(__FILE__) . "/classes/footnotes_widget.php");
// require plugin class
require_once(dirname( __FILE__ ) . "/classes/footnotes.php");
/* register functions for the footnote replacement */
footnotes_RegisterReplacementFunctions();
/* adds javascript and stylesheets to the public page */
add_action('wp_enqueue_scripts', 'footnotes_add_public_stylesheet');
// initialize an object of the plugin class
global $g_obj_MCI_Footnotes;
// if object isn't initialized yet, initialize it now
if (empty($g_obj_MCI_Footnotes)) {
$g_obj_MCI_Footnotes = new MCI_Footnotes();
}
/* defines the callback function for the editor buttons */
add_action('wp_ajax_nopriv_footnotes_getTags', 'footnotes_wysiwyg_ajax_callback' );
add_action('wp_ajax_footnotes_getTags', 'footnotes_wysiwyg_ajax_callback' );
/* add new button to the WYSIWYG - editor */
add_filter('mce_buttons', 'footnotes_wysiwyg_editor_functions');
add_filter( "mce_external_plugins", "footnotes_wysiwyg_editor_buttons" );
/* add new button to the plain text editor */
add_action( 'admin_print_footer_scripts', 'footnotes_text_editor_buttons' );
// register hook for activating the plugin
register_activation_hook(__FILE__, array('MCI_Footnotes', 'activate'));
// register hook for deactivating the plugin
register_deactivation_hook(__FILE__, array('MCI_Footnotes', 'deactivate'));
/* action to locate language and load the wordpress-specific language file */
add_action('plugins_loaded', 'footnotes_load_language');
/* add link to the settings page in plugin main page */
$l_str_plugin_file = FOOTNOTES_PLUGIN_DIR_NAME . '/index.php';
add_filter("plugin_action_links_{$l_str_plugin_file}", 'footnotes_plugin_settings_link', 10, 2);
/* register footnotes widget */
add_action('widgets_init', create_function('', 'return register_widget("Class_FootnotesWidget");'));
/* register hook for activating the plugin */
register_activation_hook(__FILE__, array('Class_Footnotes', 'activate'));
/* register hook for deactivating the plugin */
register_deactivation_hook(__FILE__, array('Class_Footnotes', 'deactivate'));
/* only admin is allowed to execute the plugin settings */
// only admin is allowed to execute the following functions
if (!function_exists('is_admin')) {
header('Status: 403 Forbidden');
header('HTTP/1.1 403 Forbidden');
exit();
}
/* register hook for uninstalling the plugin */
register_uninstall_hook(__FILE__, array('Class_Footnotes', 'uninstall'));
// register hook for uninstalling the plugin
register_uninstall_hook(__FILE__, array('MCI_Footnotes', 'uninstall'));
/* initialize an object of the plugin class */
global $g_obj_FootnotesPlugin;
/* if object isn't initialized yet, initialize it now */
if (empty($g_obj_FootnotesPlugin)) {
$g_obj_FootnotesPlugin = new Class_Footnotes();
}

390
js/jquery.tools.min.js vendored
View file

@ -22,10 +22,386 @@
* -----
*
*/
(function(a){a.tools=a.tools||{version:"v1.2.7"};var b;b=a.tools.expose={conf:{maskId:"exposeMask",loadSpeed:"slow",closeSpeed:"fast",closeOnClick:!0,closeOnEsc:!0,zIndex:9998,opacity:.8,startOpacity:0,color:"#fff",onLoad:null,onClose:null}};function c(){if(a.browser.msie){var b=a(document).height(),c=a(window).height();return[window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,b-c<20?c:b]}return[a(document).width(),a(document).height()]}function d(b){if(b)return b.call(a.mask)}var e,f,g,h,i;a.mask={load:function(j,k){if(g)return this;typeof j=="string"&&(j={color:j}),j=j||h,h=j=a.extend(a.extend({},b.conf),j),e=a("#"+j.maskId),e.length||(e=a("<div/>").attr("id",j.maskId),a("body").append(e));var l=c();e.css({position:"absolute",top:0,left:0,width:l[0],height:l[1],display:"none",opacity:j.startOpacity,zIndex:j.zIndex}),j.color&&e.css("backgroundColor",j.color);if(d(j.onBeforeLoad)===!1)return this;j.closeOnEsc&&a(document).on("keydown.mask",function(b){b.keyCode==27&&a.mask.close(b)}),j.closeOnClick&&e.on("click.mask",function(b){a.mask.close(b)}),a(window).on("resize.mask",function(){a.mask.fit()}),k&&k.length&&(i=k.eq(0).css("zIndex"),a.each(k,function(){var b=a(this);/relative|absolute|fixed/i.test(b.css("position"))||b.css("position","relative")}),f=k.css({zIndex:Math.max(j.zIndex+1,i=="auto"?0:i)})),e.css({display:"block"}).fadeTo(j.loadSpeed,j.opacity,function(){a.mask.fit(),d(j.onLoad),g="full"}),g=!0;return this},close:function(){if(g){if(d(h.onBeforeClose)===!1)return this;e.fadeOut(h.closeSpeed,function(){d(h.onClose),f&&f.css({zIndex:i}),g=!1}),a(document).off("keydown.mask"),e.off("click.mask"),a(window).off("resize.mask")}return this},fit:function(){if(g){var a=c();e.css({width:a[0],height:a[1]})}},getMask:function(){return e},isLoaded:function(a){return a?g=="full":g},getConf:function(){return h},getExposed:function(){return f}},a.fn.mask=function(b){a.mask.load(b);return this},a.fn.expose=function(b){a.mask.load(b,this);return this}})(jQuery);
(function(){var a=document.all,b="http://www.adobe.com/go/getflashplayer",c=typeof jQuery=="function",d=/(\d+)[^\d]+(\d+)[^\d]*(\d*)/,e={width:"100%",height:"100%",id:"_"+(""+Math.random()).slice(9),allowfullscreen:!0,allowscriptaccess:"always",quality:"high",version:[3,0],onFail:null,expressInstall:null,w3c:!1,cachebusting:!1};window.attachEvent&&window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){},__flash_savedUnloadHandler=function(){}});function f(a,b){if(b)for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}function g(a,b){var c=[];for(var d in a)a.hasOwnProperty(d)&&(c[d]=b(a[d]));return c}window.flashembed=function(a,b,c){typeof a=="string"&&(a=document.getElementById(a.replace("#","")));if(a){typeof b=="string"&&(b={src:b});return new j(a,f(f({},e),b),c)}};var h=f(window.flashembed,{conf:e,getVersion:function(){var a,b;try{b=navigator.plugins["Shockwave Flash"].description.slice(16)}catch(c){try{a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"),b=a&&a.GetVariable("$version")}catch(e){try{a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"),b=a&&a.GetVariable("$version")}catch(f){}}}b=d.exec(b);return b?[b[1],b[3]]:[0,0]},asString:function(a){if(a===null||a===undefined)return null;var b=typeof a;b=="object"&&a.push&&(b="array");switch(b){case"string":a=a.replace(new RegExp("([\"\\\\])","g"),"\\$1"),a=a.replace(/^\s?(\d+\.?\d*)%/,"$1pct");return"\""+a+"\"";case"array":return"["+g(a,function(a){return h.asString(a)}).join(",")+"]";case"function":return"\"function()\"";case"object":var c=[];for(var d in a)a.hasOwnProperty(d)&&c.push("\""+d+"\":"+h.asString(a[d]));return"{"+c.join(",")+"}"}return String(a).replace(/\s/g," ").replace(/\'/g,"\"")},getHTML:function(b,c){b=f({},b);var d="<object width=\""+b.width+"\" height=\""+b.height+"\" id=\""+b.id+"\" name=\""+b.id+"\"";b.cachebusting&&(b.src+=(b.src.indexOf("?")!=-1?"&":"?")+Math.random()),b.w3c||!a?d+=" data=\""+b.src+"\" type=\"application/x-shockwave-flash\"":d+=" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"",d+=">";if(b.w3c||a)d+="<param name=\"movie\" value=\""+b.src+"\" />";b.width=b.height=b.id=b.w3c=b.src=null,b.onFail=b.version=b.expressInstall=null;for(var e in b)b[e]&&(d+="<param name=\""+e+"\" value=\""+b[e]+"\" />");var g="";if(c){for(var i in c)if(c[i]){var j=c[i];g+=i+"="+encodeURIComponent(/function|object/.test(typeof j)?h.asString(j):j)+"&"}g=g.slice(0,-1),d+="<param name=\"flashvars\" value='"+g+"' />"}d+="</object>";return d},isSupported:function(a){return i[0]>a[0]||i[0]==a[0]&&i[1]>=a[1]}}),i=h.getVersion();function j(c,d,e){if(h.isSupported(d.version))c.innerHTML=h.getHTML(d,e);else if(d.expressInstall&&h.isSupported([6,65]))c.innerHTML=h.getHTML(f(d,{src:d.expressInstall}),{MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title});else{c.innerHTML.replace(/\s/g,"")||(c.innerHTML="<h2>Flash version "+d.version+" or greater is required</h2><h3>"+(i[0]>0?"Your version is "+i:"You have no flash plugin installed")+"</h3>"+(c.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='"+b+"'>here</a></p>"),c.tagName=="A"&&(c.onclick=function(){location.href=b}));if(d.onFail){var g=d.onFail.call(this);typeof g=="string"&&(c.innerHTML=g)}}a&&(window[d.id]=document.getElementById(d.id)),f(this,{getRoot:function(){return c},getOptions:function(){return d},getConf:function(){return e},getApi:function(){return c.firstChild}})}c&&(jQuery.tools=jQuery.tools||{version:"v1.2.7"},jQuery.tools.flashembed={conf:e},jQuery.fn.flashembed=function(a,b){return this.each(function(){jQuery(this).data("flashembed",flashembed(this,a,b))})})})();
(function(a){var b,c,d,e;a.tools=a.tools||{version:"v1.2.7"},a.tools.history={init:function(g){e||(a.browser.msie&&a.browser.version<"8"?c||(c=a("<iframe/>").attr("src","javascript:false;").hide().get(0),a("body").append(c),setInterval(function(){var d=c.contentWindow.document,e=d.location.hash;b!==e&&a(window).trigger("hash",e)},100),f(location.hash||"#")):setInterval(function(){var c=location.hash;c!==b&&a(window).trigger("hash",c)},100),d=d?d.add(g):g,g.click(function(b){var d=a(this).attr("href");c&&f(d);if(d.slice(0,1)!="#"){location.href="#"+d;return b.preventDefault()}}),e=!0)}};function f(a){if(a){var b=c.contentWindow.document;b.open().close(),b.location.hash=a}}a(window).on("hash",function(c,e){e?d.filter(function(){var b=a(this).attr("href");return b==e||b==e.replace("#","")}).trigger("history",[e]):d.eq(0).trigger("history",[e]),b=e}),a.fn.history=function(b){a.tools.history.init(this);return this.on("history",b)}})(jQuery);
(function(a){a.fn.mousewheel=function(a){return this[a?"on":"trigger"]("wheel",a)},a.event.special.wheel={setup:function(){a.event.add(this,b,c,{})},teardown:function(){a.event.remove(this,b,c)}};var b=a.browser.mozilla?"DOMMouseScroll"+(a.browser.version<"1.9"?" mousemove":""):"mousewheel";function c(b){switch(b.type){case"mousemove":return a.extend(b.data,{clientX:b.clientX,clientY:b.clientY,pageX:b.pageX,pageY:b.pageY});case"DOMMouseScroll":a.extend(b,b.data),b.delta=-b.detail/3;break;case"mousewheel":b.delta=b.wheelDelta/120}b.type="wheel";return a.event.handle.call(this,b,b.delta)}})(jQuery);
(function(a){a.tools=a.tools||{version:"v1.2.7"},a.tools.tooltip={conf:{effect:"toggle",fadeOutSpeed:"fast",predelay:0,delay:30,opacity:1,tip:0,fadeIE:!1,position:["top","center"],offset:[0,0],relative:!1,cancelDefault:!0,events:{def:"mouseenter,mouseleave",input:"focus,blur",widget:"focus mouseenter,blur mouseleave",tooltip:"mouseenter,mouseleave"},layout:"<div/>",tipClass:"tooltip"},addEffect:function(a,c,d){b[a]=[c,d]}};var b={toggle:[function(a){var b=this.getConf(),c=this.getTip(),d=b.opacity;d<1&&c.css({opacity:d}),c.show(),a.call()},function(a){this.getTip().hide(),a.call()}],fade:[function(b){var c=this.getConf();!a.browser.msie||c.fadeIE?this.getTip().fadeTo(c.fadeInSpeed,c.opacity,b):(this.getTip().show(),b())},function(b){var c=this.getConf();!a.browser.msie||c.fadeIE?this.getTip().fadeOut(c.fadeOutSpeed,b):(this.getTip().hide(),b())}]};function c(b,c,d){var e=d.relative?b.position().top:b.offset().top,f=d.relative?b.position().left:b.offset().left,g=d.position[0];e-=c.outerHeight()-d.offset[0],f+=b.outerWidth()+d.offset[1],/iPad/i.test(navigator.userAgent)&&(e-=a(window).scrollTop());var h=c.outerHeight()+b.outerHeight();g=="center"&&(e+=h/2),g=="bottom"&&(e+=h),g=d.position[1];var i=c.outerWidth()+b.outerWidth();g=="center"&&(f-=i/2),g=="left"&&(f-=i);return{top:e,left:f}}function d(d,e){var f=this,g=d.add(f),h,i=0,j=0,k=d.attr("title"),l=d.attr("data-tooltip"),m=b[e.effect],n,o=d.is(":input"),p=o&&d.is(":checkbox, :radio, select, :button, :submit"),q=d.attr("type"),r=e.events[q]||e.events[o?p?"widget":"input":"def"];if(!m)throw"Nonexistent effect \""+e.effect+"\"";r=r.split(/,\s*/);if(r.length!=2)throw"Tooltip: bad events configuration for "+q;d.on(r[0],function(a){clearTimeout(i),e.predelay?j=setTimeout(function(){f.show(a)},e.predelay):f.show(a)}).on(r[1],function(a){clearTimeout(j),e.delay?i=setTimeout(function(){f.hide(a)},e.delay):f.hide(a)}),k&&e.cancelDefault&&(d.removeAttr("title"),d.data("title",k)),a.extend(f,{show:function(b){if(!h){l?h=a(l):e.tip?h=a(e.tip).eq(0):k?h=a(e.layout).addClass(e.tipClass).appendTo(document.body).hide().append(k):(h=d.next(),h.length||(h=d.parent().next()));if(!h.length)throw"Cannot find tooltip for "+d}if(f.isShown())return f;h.stop(!0,!0);var o=c(d,h,e);e.tip&&h.html(d.data("title")),b=a.Event(),b.type="onBeforeShow",g.trigger(b,[o]);if(b.isDefaultPrevented())return f;o=c(d,h,e),h.css({position:"absolute",top:o.top,left:o.left}),n=!0,m[0].call(f,function(){b.type="onShow",n="full",g.trigger(b)});var p=e.events.tooltip.split(/,\s*/);h.data("__set")||(h.off(p[0]).on(p[0],function(){clearTimeout(i),clearTimeout(j)}),p[1]&&!d.is("input:not(:checkbox, :radio), textarea")&&h.off(p[1]).on(p[1],function(a){a.relatedTarget!=d[0]&&d.trigger(r[1].split(" ")[0])}),e.tip||h.data("__set",!0));return f},hide:function(c){if(!h||!f.isShown())return f;c=a.Event(),c.type="onBeforeHide",g.trigger(c);if(!c.isDefaultPrevented()){n=!1,b[e.effect][1].call(f,function(){c.type="onHide",g.trigger(c)});return f}},isShown:function(a){return a?n=="full":n},getConf:function(){return e},getTip:function(){return h},getTrigger:function(){return d}}),a.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","),function(b,c){a.isFunction(e[c])&&a(f).on(c,e[c]),f[c]=function(b){b&&a(f).on(c,b);return f}})}a.fn.tooltip=function(b){var c=this.data("tooltip");if(c)return c;b=a.extend(!0,{},a.tools.tooltip.conf,b),typeof b.position=="string"&&(b.position=b.position.split(/,?\s/)),this.each(function(){c=new d(a(this),b),a(this).data("tooltip",c)});return b.api?c:this}})(jQuery);
(function(a){var b=a.tools.tooltip;b.dynamic={conf:{classNames:"top right bottom left"}};function c(b){var c=a(window),d=c.width()+c.scrollLeft(),e=c.height()+c.scrollTop();return[b.offset().top<=c.scrollTop(),d<=b.offset().left+b.width(),e<=b.offset().top+b.height(),c.scrollLeft()>=b.offset().left]}function d(a){var b=a.length;while(b--)if(a[b])return!1;return!0}a.fn.dynamic=function(e){typeof e=="number"&&(e={speed:e}),e=a.extend({},b.dynamic.conf,e);var f=a.extend(!0,{},e),g=e.classNames.split(/\s/),h;this.each(function(){var b=a(this).tooltip().onBeforeShow(function(b,e){var i=this.getTip(),j=this.getConf();h||(h=[j.position[0],j.position[1],j.offset[0],j.offset[1],a.extend({},j)]),a.extend(j,h[4]),j.position=[h[0],h[1]],j.offset=[h[2],h[3]],i.css({visibility:"hidden",position:"absolute",top:e.top,left:e.left}).show();var k=a.extend(!0,{},f),l=c(i);if(!d(l)){l[2]&&(a.extend(j,k.top),j.position[0]="top",i.addClass(g[0])),l[3]&&(a.extend(j,k.right),j.position[1]="right",i.addClass(g[1])),l[0]&&(a.extend(j,k.bottom),j.position[0]="bottom",i.addClass(g[2])),l[1]&&(a.extend(j,k.left),j.position[1]="left",i.addClass(g[3]));if(l[0]||l[2])j.offset[0]*=-1;if(l[1]||l[3])j.offset[1]*=-1}i.css({visibility:"visible"}).hide()});b.onBeforeShow(function(){var a=this.getConf(),b=this.getTip();setTimeout(function(){a.position=[h[0],h[1]],a.offset=[h[2],h[3]]},0)}),b.onHide(function(){var a=this.getTip();a.removeClass(e.classNames)}),ret=b});return e.api?ret:this}})(jQuery);
(function(a){var b=a.tools.tooltip;a.extend(b.conf,{direction:"up",bounce:!1,slideOffset:10,slideInSpeed:200,slideOutSpeed:200,slideFade:!a.browser.msie});var c={up:["-","top"],down:["+","top"],left:["-","left"],right:["+","left"]};b.addEffect("slide",function(a){var b=this.getConf(),d=this.getTip(),e=b.slideFade?{opacity:b.opacity}:{},f=c[b.direction]||c.up;e[f[1]]=f[0]+"="+b.slideOffset,b.slideFade&&d.css({opacity:0}),d.show().animate(e,b.slideInSpeed,a)},function(b){var d=this.getConf(),e=d.slideOffset,f=d.slideFade?{opacity:0}:{},g=c[d.direction]||c.up,h=""+g[0];d.bounce&&(h=h=="+"?"-":"+"),f[g[1]]=h+"="+e,this.getTip().animate(f,d.slideOutSpeed,function(){a(this).hide(),b.call()})})})(jQuery);
(function (a) {
a.tools = a.tools || {version: "v1.2.7"};
var b;
b = a.tools.expose = {conf: {maskId: "exposeMask", loadSpeed: "slow", closeSpeed: "fast", closeOnClick: !0, closeOnEsc: !0, zIndex: 9998, opacity: .8, startOpacity: 0, color: "#fff", onLoad: null, onClose: null}};
function c() {
if (a.browser.msie) {
var b = a(document).height(), c = a(window).height();
return[window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, b - c < 20 ? c : b]
}
return[a(document).width(), a(document).height()]
}
function d(b) {
if (b)return b.call(a.mask)
}
var e, f, g, h, i;
a.mask = {load: function (j, k) {
if (g)return this;
typeof j == "string" && (j = {color: j}), j = j || h, h = j = a.extend(a.extend({}, b.conf), j), e = a("#" + j.maskId), e.length || (e = a("<div/>").attr("id", j.maskId), a("body").append(e));
var l = c();
e.css({position: "absolute", top: 0, left: 0, width: l[0], height: l[1], display: "none", opacity: j.startOpacity, zIndex: j.zIndex}), j.color && e.css("backgroundColor", j.color);
if (d(j.onBeforeLoad) === !1)return this;
j.closeOnEsc && a(document).on("keydown.mask", function (b) {
b.keyCode == 27 && a.mask.close(b)
}), j.closeOnClick && e.on("click.mask", function (b) {
a.mask.close(b)
}), a(window).on("resize.mask", function () {
a.mask.fit()
}), k && k.length && (i = k.eq(0).css("zIndex"), a.each(k, function () {
var b = a(this);
/relative|absolute|fixed/i.test(b.css("position")) || b.css("position", "relative")
}), f = k.css({zIndex: Math.max(j.zIndex + 1, i == "auto" ? 0 : i)})), e.css({display: "block"}).fadeTo(j.loadSpeed, j.opacity, function () {
a.mask.fit(), d(j.onLoad), g = "full"
}), g = !0;
return this
}, close: function () {
if (g) {
if (d(h.onBeforeClose) === !1)return this;
e.fadeOut(h.closeSpeed, function () {
d(h.onClose), f && f.css({zIndex: i}), g = !1
}), a(document).off("keydown.mask"), e.off("click.mask"), a(window).off("resize.mask")
}
return this
}, fit: function () {
if (g) {
var a = c();
e.css({width: a[0], height: a[1]})
}
}, getMask: function () {
return e
}, isLoaded: function (a) {
return a ? g == "full" : g
}, getConf: function () {
return h
}, getExposed: function () {
return f
}}, a.fn.mask = function (b) {
a.mask.load(b);
return this
}, a.fn.expose = function (b) {
a.mask.load(b, this);
return this
}
})(jQuery);
(function () {
var a = document.all, b = "http://www.adobe.com/go/getflashplayer", c = typeof jQuery == "function", d = /(\d+)[^\d]+(\d+)[^\d]*(\d*)/, e = {width: "100%", height: "100%", id: "_" + ("" + Math.random()).slice(9), allowfullscreen: !0, allowscriptaccess: "always", quality: "high", version: [3, 0], onFail: null, expressInstall: null, w3c: !1, cachebusting: !1};
window.attachEvent && window.attachEvent("onbeforeunload", function () {
__flash_unloadHandler = function () {
}, __flash_savedUnloadHandler = function () {
}
});
function f(a, b) {
if (b)for (var c in b)b.hasOwnProperty(c) && (a[c] = b[c]);
return a
}
function g(a, b) {
var c = [];
for (var d in a)a.hasOwnProperty(d) && (c[d] = b(a[d]));
return c
}
window.flashembed = function (a, b, c) {
typeof a == "string" && (a = document.getElementById(a.replace("#", "")));
if (a) {
typeof b == "string" && (b = {src: b});
return new j(a, f(f({}, e), b), c)
}
};
var h = f(window.flashembed, {conf: e, getVersion: function () {
var a, b;
try {
b = navigator.plugins["Shockwave Flash"].description.slice(16)
} catch (c) {
try {
a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"), b = a && a.GetVariable("$version")
} catch (e) {
try {
a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"), b = a && a.GetVariable("$version")
} catch (f) {
}
}
}
b = d.exec(b);
return b ? [b[1], b[3]] : [0, 0]
}, asString: function (a) {
if (a === null || a === undefined)return null;
var b = typeof a;
b == "object" && a.push && (b = "array");
switch (b) {
case"string":
a = a.replace(new RegExp("([\"\\\\])", "g"), "\\$1"), a = a.replace(/^\s?(\d+\.?\d*)%/, "$1pct");
return"\"" + a + "\"";
case"array":
return"[" + g(a,function (a) {
return h.asString(a)
}).join(",") + "]";
case"function":
return"\"function()\"";
case"object":
var c = [];
for (var d in a)a.hasOwnProperty(d) && c.push("\"" + d + "\":" + h.asString(a[d]));
return"{" + c.join(",") + "}"
}
return String(a).replace(/\s/g, " ").replace(/\'/g, "\"")
}, getHTML: function (b, c) {
b = f({}, b);
var d = "<object width=\"" + b.width + "\" height=\"" + b.height + "\" id=\"" + b.id + "\" name=\"" + b.id + "\"";
b.cachebusting && (b.src += (b.src.indexOf("?") != -1 ? "&" : "?") + Math.random()), b.w3c || !a ? d += " data=\"" + b.src + "\" type=\"application/x-shockwave-flash\"" : d += " classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"", d += ">";
if (b.w3c || a)d += "<param name=\"movie\" value=\"" + b.src + "\" />";
b.width = b.height = b.id = b.w3c = b.src = null, b.onFail = b.version = b.expressInstall = null;
for (var e in b)b[e] && (d += "<param name=\"" + e + "\" value=\"" + b[e] + "\" />");
var g = "";
if (c) {
for (var i in c)if (c[i]) {
var j = c[i];
g += i + "=" + encodeURIComponent(/function|object/.test(typeof j) ? h.asString(j) : j) + "&"
}
g = g.slice(0, -1), d += "<param name=\"flashvars\" value='" + g + "' />"
}
d += "</object>";
return d
}, isSupported: function (a) {
return i[0] > a[0] || i[0] == a[0] && i[1] >= a[1]
}}), i = h.getVersion();
function j(c, d, e) {
if (h.isSupported(d.version))c.innerHTML = h.getHTML(d, e); else if (d.expressInstall && h.isSupported([6, 65]))c.innerHTML = h.getHTML(f(d, {src: d.expressInstall}), {MMredirectURL: location.href, MMplayerType: "PlugIn", MMdoctitle: document.title}); else {
c.innerHTML.replace(/\s/g, "") || (c.innerHTML = "<h2>Flash version " + d.version + " or greater is required</h2><h3>" + (i[0] > 0 ? "Your version is " + i : "You have no flash plugin installed") + "</h3>" + (c.tagName == "A" ? "<p>Click here to download latest version</p>" : "<p>Download latest version from <a href='" + b + "'>here</a></p>"), c.tagName == "A" && (c.onclick = function () {
location.href = b
}));
if (d.onFail) {
var g = d.onFail.call(this);
typeof g == "string" && (c.innerHTML = g)
}
}
a && (window[d.id] = document.getElementById(d.id)), f(this, {getRoot: function () {
return c
}, getOptions: function () {
return d
}, getConf: function () {
return e
}, getApi: function () {
return c.firstChild
}})
}
c && (jQuery.tools = jQuery.tools || {version: "v1.2.7"}, jQuery.tools.flashembed = {conf: e}, jQuery.fn.flashembed = function (a, b) {
return this.each(function () {
jQuery(this).data("flashembed", flashembed(this, a, b))
})
})
})();
(function (a) {
var b, c, d, e;
a.tools = a.tools || {version: "v1.2.7"}, a.tools.history = {init: function (g) {
e || (a.browser.msie && a.browser.version < "8" ? c || (c = a("<iframe/>").attr("src", "javascript:false;").hide().get(0), a("body").append(c), setInterval(function () {
var d = c.contentWindow.document, e = d.location.hash;
b !== e && a(window).trigger("hash", e)
}, 100), f(location.hash || "#")) : setInterval(function () {
var c = location.hash;
c !== b && a(window).trigger("hash", c)
}, 100), d = d ? d.add(g) : g, g.click(function (b) {
var d = a(this).attr("href");
c && f(d);
if (d.slice(0, 1) != "#") {
location.href = "#" + d;
return b.preventDefault()
}
}), e = !0)
}};
function f(a) {
if (a) {
var b = c.contentWindow.document;
b.open().close(), b.location.hash = a
}
}
a(window).on("hash", function (c, e) {
e ? d.filter(function () {
var b = a(this).attr("href");
return b == e || b == e.replace("#", "")
}).trigger("history", [e]) : d.eq(0).trigger("history", [e]), b = e
}), a.fn.history = function (b) {
a.tools.history.init(this);
return this.on("history", b)
}
})(jQuery);
(function (a) {
a.fn.mousewheel = function (a) {
return this[a ? "on" : "trigger"]("wheel", a)
}, a.event.special.wheel = {setup: function () {
a.event.add(this, b, c, {})
}, teardown: function () {
a.event.remove(this, b, c)
}};
var b = a.browser.mozilla ? "DOMMouseScroll" + (a.browser.version < "1.9" ? " mousemove" : "") : "mousewheel";
function c(b) {
switch (b.type) {
case"mousemove":
return a.extend(b.data, {clientX: b.clientX, clientY: b.clientY, pageX: b.pageX, pageY: b.pageY});
case"DOMMouseScroll":
a.extend(b, b.data), b.delta = -b.detail / 3;
break;
case"mousewheel":
b.delta = b.wheelDelta / 120
}
b.type = "wheel";
return a.event.handle.call(this, b, b.delta)
}
})(jQuery);
(function (a) {
a.tools = a.tools || {version: "v1.2.7"}, a.tools.tooltip = {conf: {effect: "toggle", fadeOutSpeed: "fast", predelay: 0, delay: 30, opacity: 1, tip: 0, fadeIE: !1, position: ["top", "center"], offset: [0, 0], relative: !1, cancelDefault: !0, events: {def: "mouseenter,mouseleave", input: "focus,blur", widget: "focus mouseenter,blur mouseleave", tooltip: "mouseenter,mouseleave"}, layout: "<div/>", tipClass: "tooltip"}, addEffect: function (a, c, d) {
b[a] = [c, d]
}};
var b = {toggle: [function (a) {
var b = this.getConf(), c = this.getTip(), d = b.opacity;
d < 1 && c.css({opacity: d}), c.show(), a.call()
}, function (a) {
this.getTip().hide(), a.call()
}], fade: [function (b) {
var c = this.getConf();
!a.browser.msie || c.fadeIE ? this.getTip().fadeTo(c.fadeInSpeed, c.opacity, b) : (this.getTip().show(), b())
}, function (b) {
var c = this.getConf();
!a.browser.msie || c.fadeIE ? this.getTip().fadeOut(c.fadeOutSpeed, b) : (this.getTip().hide(), b())
}]};
function c(b, c, d) {
var e = d.relative ? b.position().top : b.offset().top, f = d.relative ? b.position().left : b.offset().left, g = d.position[0];
e -= c.outerHeight() - d.offset[0], f += b.outerWidth() + d.offset[1], /iPad/i.test(navigator.userAgent) && (e -= a(window).scrollTop());
var h = c.outerHeight() + b.outerHeight();
g == "center" && (e += h / 2), g == "bottom" && (e += h), g = d.position[1];
var i = c.outerWidth() + b.outerWidth();
g == "center" && (f -= i / 2), g == "left" && (f -= i);
return{top: e, left: f}
}
function d(d, e) {
var f = this, g = d.add(f), h, i = 0, j = 0, k = d.attr("title"), l = d.attr("data-tooltip"), m = b[e.effect], n, o = d.is(":input"), p = o && d.is(":checkbox, :radio, select, :button, :submit"), q = d.attr("type"), r = e.events[q] || e.events[o ? p ? "widget" : "input" : "def"];
if (!m)throw"Nonexistent effect \"" + e.effect + "\"";
r = r.split(/,\s*/);
if (r.length != 2)throw"Tooltip: bad events configuration for " + q;
d.on(r[0],function (a) {
clearTimeout(i), e.predelay ? j = setTimeout(function () {
f.show(a)
}, e.predelay) : f.show(a)
}).on(r[1], function (a) {
clearTimeout(j), e.delay ? i = setTimeout(function () {
f.hide(a)
}, e.delay) : f.hide(a)
}), k && e.cancelDefault && (d.removeAttr("title"), d.data("title", k)), a.extend(f, {show: function (b) {
if (!h) {
l ? h = a(l) : e.tip ? h = a(e.tip).eq(0) : k ? h = a(e.layout).addClass(e.tipClass).appendTo(document.body).hide().append(k) : (h = d.next(), h.length || (h = d.parent().next()));
if (!h.length)throw"Cannot find tooltip for " + d
}
if (f.isShown())return f;
h.stop(!0, !0);
var o = c(d, h, e);
e.tip && h.html(d.data("title")), b = a.Event(), b.type = "onBeforeShow", g.trigger(b, [o]);
if (b.isDefaultPrevented())return f;
o = c(d, h, e), h.css({position: "absolute", top: o.top, left: o.left}), n = !0, m[0].call(f, function () {
b.type = "onShow", n = "full", g.trigger(b)
});
var p = e.events.tooltip.split(/,\s*/);
h.data("__set") || (h.off(p[0]).on(p[0], function () {
clearTimeout(i), clearTimeout(j)
}), p[1] && !d.is("input:not(:checkbox, :radio), textarea") && h.off(p[1]).on(p[1], function (a) {
a.relatedTarget != d[0] && d.trigger(r[1].split(" ")[0])
}), e.tip || h.data("__set", !0));
return f
}, hide: function (c) {
if (!h || !f.isShown())return f;
c = a.Event(), c.type = "onBeforeHide", g.trigger(c);
if (!c.isDefaultPrevented()) {
n = !1, b[e.effect][1].call(f, function () {
c.type = "onHide", g.trigger(c)
});
return f
}
}, isShown: function (a) {
return a ? n == "full" : n
}, getConf: function () {
return e
}, getTip: function () {
return h
}, getTrigger: function () {
return d
}}), a.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","), function (b, c) {
a.isFunction(e[c]) && a(f).on(c, e[c]), f[c] = function (b) {
b && a(f).on(c, b);
return f
}
})
}
a.fn.tooltip = function (b) {
var c = this.data("tooltip");
if (c)return c;
b = a.extend(!0, {}, a.tools.tooltip.conf, b), typeof b.position == "string" && (b.position = b.position.split(/,?\s/)), this.each(function () {
c = new d(a(this), b), a(this).data("tooltip", c)
});
return b.api ? c : this
}
})(jQuery);
(function (a) {
var b = a.tools.tooltip;
b.dynamic = {conf: {classNames: "top right bottom left"}};
function c(b) {
var c = a(window), d = c.width() + c.scrollLeft(), e = c.height() + c.scrollTop();
return[b.offset().top <= c.scrollTop(), d <= b.offset().left + b.width(), e <= b.offset().top + b.height(), c.scrollLeft() >= b.offset().left]
}
function d(a) {
var b = a.length;
while (b--)if (a[b])return!1;
return!0
}
a.fn.dynamic = function (e) {
typeof e == "number" && (e = {speed: e}), e = a.extend({}, b.dynamic.conf, e);
var f = a.extend(!0, {}, e), g = e.classNames.split(/\s/), h;
this.each(function () {
var b = a(this).tooltip().onBeforeShow(function (b, e) {
var i = this.getTip(), j = this.getConf();
h || (h = [j.position[0], j.position[1], j.offset[0], j.offset[1], a.extend({}, j)]), a.extend(j, h[4]), j.position = [h[0], h[1]], j.offset = [h[2], h[3]], i.css({visibility: "hidden", position: "absolute", top: e.top, left: e.left}).show();
var k = a.extend(!0, {}, f), l = c(i);
if (!d(l)) {
l[2] && (a.extend(j, k.top), j.position[0] = "top", i.addClass(g[0])), l[3] && (a.extend(j, k.right), j.position[1] = "right", i.addClass(g[1])), l[0] && (a.extend(j, k.bottom), j.position[0] = "bottom", i.addClass(g[2])), l[1] && (a.extend(j, k.left), j.position[1] = "left", i.addClass(g[3]));
if (l[0] || l[2])j.offset[0] *= -1;
if (l[1] || l[3])j.offset[1] *= -1
}
i.css({visibility: "visible"}).hide()
});
b.onBeforeShow(function () {
var a = this.getConf(), b = this.getTip();
setTimeout(function () {
a.position = [h[0], h[1]], a.offset = [h[2], h[3]]
}, 0)
}), b.onHide(function () {
var a = this.getTip();
a.removeClass(e.classNames)
}), ret = b
});
return e.api ? ret : this
}
})(jQuery);
(function (a) {
var b = a.tools.tooltip;
a.extend(b.conf, {direction: "up", bounce: !1, slideOffset: 10, slideInSpeed: 200, slideOutSpeed: 200, slideFade: !a.browser.msie});
var c = {up: ["-", "top"], down: ["+", "top"], left: ["-", "left"], right: ["+", "left"]};
b.addEffect("slide", function (a) {
var b = this.getConf(), d = this.getTip(), e = b.slideFade ? {opacity: b.opacity} : {}, f = c[b.direction] || c.up;
e[f[1]] = f[0] + "=" + b.slideOffset, b.slideFade && d.css({opacity: 0}), d.show().animate(e, b.slideInSpeed, a)
}, function (b) {
var d = this.getConf(), e = d.slideOffset, f = d.slideFade ? {opacity: 0} : {}, g = c[d.direction] || c.up, h = "" + g[0];
d.bounce && (h = h == "+" ? "-" : "+"), f[g[1]] = h + "=" + e, this.getTip().animate(f, d.slideOutSpeed, function () {
a(this).hide(), b.call()
})
})
})(jQuery);

View file

@ -64,6 +64,13 @@ No, this Plugin has been written from scratch. Of course some inspirations on ho
== Changelog ==
= 1.3.0 =
- Bugfix: Changed tooltip class to be unique
- Bugfix: Changed superscript styling to not manipulate the line height
- Bugfix: Changed styling of the footnotes text in the reference container to avoid line breaks
- Updated: Reformatted code
- Added: new settings tab for custom CSS settings
= 1.2.5 =
- Bugfix: New styling of the mouse-over box to stay in screen (thanks to Jori, France and Manuel345, undisclosed location)

View file

@ -5,13 +5,14 @@
onclick="footnote_expand_reference_container('#footnote_plugin_reference_[[FOOTNOTE INDEX]]');">
<sup>[[FOOTNOTE INDEX]])</sup>
</a>
<div class="tooltip" id="footnote_plugin_tooltip_text_[[FOOTNOTE INDEX]]">
<span class="footnote_tooltip" id="footnote_plugin_tooltip_text_[[FOOTNOTE INDEX]]">
[[FOOTNOTE TEXT]]
</div>
</span>
<script type="text/javascript">
jQuery("#footnote_plugin_tooltip_[[FOOTNOTE INDEX]]").tooltip({
tip: "#footnote_plugin_tooltip_text_[[FOOTNOTE INDEX]]",
tipClass: "footnote_tooltip",
effect: "fade",
fadeOutSpeed: 100,
predelay: 400,