diff --git a/classes/admin.php b/classes/admin.php new file mode 100644 index 0000000..19ef25a --- /dev/null +++ b/classes/admin.php @@ -0,0 +1,396 @@ +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 '
'; + echo ''; + + // outputs a form with the content of the current active tab + echo '
'; + 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 '
'; + echo '
'; + + // 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() { + ?> + + + 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 '

'; + } + + /** + * outputs a simple text + * @param string $p_str_Text + * @since 1.1.1 + */ + public function AddText($p_str_Text) { + echo '' . $p_str_Text . ''; + } + + /** + * 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 '' . $p_str_Text . ''; + } + + /** + * 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 ''; + } + + /** + * 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 ''; + } + + /** + * 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('', $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 = ''; + // 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 ''; + } + +}// class MCI_Footnotes_Admin + +endif; \ No newline at end of file diff --git a/classes/convert.php b/classes/convert.php new file mode 100644 index 0000000..5e8413b --- /dev/null +++ b/classes/convert.php @@ -0,0 +1,152 @@ + 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; \ No newline at end of file diff --git a/classes/footnotes.php b/classes/footnotes.php index a101373..436709c 100644 --- a/classes/footnotes.php +++ b/classes/footnotes.php @@ -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 */ \ No newline at end of file +endif; \ No newline at end of file diff --git a/classes/footnotes_settings.php b/classes/footnotes_settings.php deleted file mode 100644 index b1bd59c..0000000 --- a/classes/footnotes_settings.php +++ /dev/null @@ -1,626 +0,0 @@ - '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 '
'; - $this->OutputSettingsPageTabs(); - /* outputs a form with the content of the current active tab */ - echo '
'; - 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 '
'; - echo '
'; - /* - * 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 ''; - } - - /** - * outputs page specific javascript code - * @since 1.0.7 - */ - function OutputJavascript() - { - ?> - - - 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 '

'; - } - - /** - * outputs a simple text - * @param string $p_str_Text - * @since 1.1.1 - */ - function AddText($p_str_Text) - { - echo '' . $p_str_Text . ''; - } - - /** - * 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 ''; - } - - /** - * 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 ''; - } - - /** - * 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('', $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 = ''; - /* 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 . ' ' . 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( - "((" => "((", - "" => htmlspecialchars(""), - "[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( - "))" => "))", - "" => htmlspecialchars(""), - "[/ref]" => "[/ref]", - "userdefined" => __('user defined', FOOTNOTES_PLUGIN_NAME) - ); - $this->AddLabel(FOOTNOTE_INPUTFIELD_PLACEHOLDER_END, __("and ends with:", FOOTNOTES_PLUGIN_NAME) . '   ', '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 = "     "; - $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("      "); - $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", " ", 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); - } - ?> -
-
-

- - -

- -

- - -

- -
-

- - -      - -

-
- -

- ', ''); ?> -

-
-
- '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(); - } - } -} \ No newline at end of file diff --git a/classes/tab_custom.php b/classes/tab_custom.php new file mode 100644 index 0000000..076b3b2 --- /dev/null +++ b/classes/tab_custom.php @@ -0,0 +1,77 @@ +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:")) . "
"); + + echo "
"; + $this->AddText($this->Highlight(".footnote_plugin_tooltip_text") . $l_str_Separator . gettext("inline footnotes") . "
"); + $this->AddText($this->Highlight(".footnote_tooltip") . $l_str_Separator . gettext("inline footnotes, mouse over highlight box") . "

"); + + $this->AddText($this->Highlight(".footnote_plugin_index") . $l_str_Separator . gettext("reference container footnotes index") . "
"); + $this->AddText($this->Highlight(".footnote_plugin_link") . $l_str_Separator . gettext("reference container footnotes linked arrow") . "
"); + $this->AddText($this->Highlight(".footnote_plugin_text") . $l_str_Separator . gettext("reference container footnotes text")); + echo "
"; + } +} // class MCI_Footnotes_Tab_Custom + +endif; \ No newline at end of file diff --git a/classes/tab_general.php b/classes/tab_general.php new file mode 100644 index 0000000..3850185 --- /dev/null +++ b/classes/tab_general.php @@ -0,0 +1,190 @@ +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( + "((" => "((", + "" => htmlspecialchars(""), + "[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( + "))" => "))", + "" => htmlspecialchars(""), + "[/ref]" => "[/ref]", + "userdefined" => __('user defined', FOOTNOTES_PLUGIN_NAME) + ); + $this->AddLabel(FOOTNOTES_INPUT_PLACEHOLDER_END, __("and ends with:", FOOTNOTES_PLUGIN_NAME) . '   ', '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 = "     "; + $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("      "); + $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; \ No newline at end of file diff --git a/classes/tab_howto.php b/classes/tab_howto.php new file mode 100644 index 0000000..99e114b --- /dev/null +++ b/classes/tab_howto.php @@ -0,0 +1,102 @@ +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"]; + ?> +
+
+

+ + + + +

+

+ + + + +

+
+

+ + +      + a_obj_Task->exec($l_str_Example, true); ?> +

+
+

+ ', ''); ?> +

+
+
+ 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() { + ?> + + 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 '
' . $l_str_LoveMeText . '
'; + } + + + /** + * 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 = '   [ + ]'; + } + + // output string, prepare it with the reference label as headline + $l_str_Output = '

' . $l_str_ReferencesLabel . '' .$l_str_CollapseButtons . '

'; + // add a box around the footnotes + $l_str_Output .= '
'; + // add a javascript to expand the reference container when clicking on a footnote or the reference label + $l_str_Output .= ' + + '; + + // 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; \ No newline at end of file diff --git a/classes/widget.php b/classes/widget.php new file mode 100644 index 0000000..bb0a3c9 --- /dev/null +++ b/classes/widget.php @@ -0,0 +1,70 @@ + '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; \ No newline at end of file diff --git a/css/footnote.css b/css/footnote.css deleted file mode 100755 index 45a956c..0000000 --- a/css/footnote.css +++ /dev/null @@ -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; -} \ No newline at end of file diff --git a/css/footnotes.css b/css/footnotes.css new file mode 100755 index 0000000..dc1e9da --- /dev/null +++ b/css/footnotes.css @@ -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; +} \ No newline at end of file diff --git a/css/reference_container.css b/css/reference_container.css new file mode 100644 index 0000000..876bcc5 --- /dev/null +++ b/css/reference_container.css @@ -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; +} \ No newline at end of file diff --git a/css/settings.css b/css/settings.css index 3d33927..ead8280 100755 --- a/css/settings.css +++ b/css/settings.css @@ -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; diff --git a/css/tooltip.css b/css/tooltip.css new file mode 100644 index 0000000..73a983f --- /dev/null +++ b/css/tooltip.css @@ -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; +} \ No newline at end of file diff --git a/includes/convert.php b/includes/convert.php deleted file mode 100644 index d2dfaf2..0000000 --- a/includes/convert.php +++ /dev/null @@ -1,110 +0,0 @@ - 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; -} \ No newline at end of file diff --git a/includes/defines.php b/includes/defines.php index 9c3be67..285d11f 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -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", 'footnotes'); - -/* - * 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", '' . FOOTNOTES_PLUGIN_PUBLIC_NAME . ''); +// PLUGIN LOVE SYMBOL WITH STYLING +// @since 1.2.2 define("FOOTNOTES_LOVE_SYMBOL", ''); -/* - * PLUGIN PUBLIC NAME WITH LINK - * @since 1.2.2 - */ -define("FOOTNOTES_PLUGIN_PUBLIC_NAME_LINKED", '' . FOOTNOTES_PLUGIN_PUBLIC_NAME . ''); -/* 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]]"); \ No newline at end of file +// 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]]"); \ No newline at end of file diff --git a/includes/language.php b/includes/language.php index 9f8501c..ff7d579 100644 --- a/includes/language.php +++ b/includes/language.php @@ -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); } \ No newline at end of file diff --git a/includes/plugin-settings.php b/includes/plugin-settings.php index 79ea68b..bce2891 100644 --- a/includes/plugin-settings.php +++ b/includes/plugin-settings.php @@ -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 = '' . __('Settings', FOOTNOTES_PLUGIN_NAME) . ''; - /* 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 = '' . __('Support', FOOTNOTES_PLUGIN_NAME) . ''; - /* 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; } \ No newline at end of file diff --git a/includes/replacer.php b/includes/replacer.php deleted file mode 100644 index be4f400..0000000 --- a/includes/replacer.php +++ /dev/null @@ -1,413 +0,0 @@ -' . $l_str_LoveMeText . '
'; - } -} - -/** - * 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 = '   [ + ]'; - } - - /* output string, prepare it with the reference label as headline */ - $l_str_Output = '

' . $l_str_ReferencesLabel . '' .$l_str_CollapseButtons . '

'; - /* add a box around the footnotes */ - $l_str_Output .= '
'; - /* add a javascript to expand the reference container when clicking on a footnote or the reference label */ - $l_str_Output .= ' - - '; - - /* free all found footnotes if reference container will be displayed */ - $g_arr_Footnotes = array(); - - /* return the output string */ - return $l_str_Output; -} \ No newline at end of file diff --git a/includes/scripts.php b/includes/scripts.php deleted file mode 100644 index 55d846e..0000000 --- a/includes/scripts.php +++ /dev/null @@ -1,38 +0,0 @@ -