<commit_before><?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4; */

/**
 * PHP version 5
 *
 * This is the Plugin object that sets up and contains the hooks and filters
 * for the plugins.
 *
 * @package     omeka
 * @subpackage  nlfeatures
 * @author      Scholars' Lab <>
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @copyright   2011 The Board and Visitors of the University of Virginia
 * @license     http://www.apache.org/licenses/LICENSE-2.0.html Apache 2 License
 */
?><?php

require_once NEATLINE_FEATURES_PLUGIN_DIR .
    '/lib/NeatlineFeatures/Utils/View.php';
require_once NEATLINE_FEATURES_PLUGIN_DIR .
    '/lib/NeatlineFeatures_Functions.php';

/**
 * This class manages the plugin itself. It defines controllers for all the
 * hooks and filters.
 **/
class NeatlineFeaturesPlugin
{
    // Vars {{{
    /**
     * This is a pointer to the current database.
     *
     * @var Object
     **/
    private $_db;

    /**
     * This is a list of the hooks this manager defines.
     *
     * @var array
     **/
    private static $_hooks = array(
        'install',
        'uninstall',
        'admin_theme_header',
        'public_theme_header'
    );

    /**
     * This is a list of the filters this manager defines.
     *
     * @var array
     **/
    private static $_filters = array(
        array('formItemDublinCoreCoverage',
              array('Form', 'Item', 'Dublin Core', 'Coverage')),
        array('elementFormDisplayHtmlFlag',
              'element_form_display_html_flag'),
        array('displayItemDublinCoreCoverage',
              array('Display', 'Item', 'Dublin Core', 'Coverage'))
    );
    // }}}

    // Class setup {{{
    function __construct()
    {
        $this->_db = get_db();
        self::addHooksAndFilters();
    }

    /**
     * Iterate over the hooks and filters, define callbacks.
     *
     * @return void
     * @author <NAME> <<EMAIL>>
     **/
    public function addHooksAndFilters()
    {
        foreach (self::$_hooks as $hookName) {
            $functionName = Inflector::variablize($hookName);
            get_plugin_broker()->addHook(
                $hookName,
                array($this, $functionName),
                'NeatlineFeatures'
            );
        }

        foreach (self::$_filters as $filterInfo) {
            $functionName = $filterInfo[0];
            add_filter($filterInfo[1], array($this, $functionName));
        }
    }
    // }}}

    // Hooks {{{
    /**
     * This installs the NeatlineFeatures plugin.
     *
     * @return void
     * @author <NAME> <<EMAIL>>
     **/
    public function install()
    {
    }

    /**
     * This uninstalls the NeatlineFeatures plugin.
     *
     * @return void
     * @author <NAME> <<EMAIL>>
     **/
    public function uninstall()
    {
    }

    /**
     * This is a utility function that appends a javascript URL.
     *
     * @param $uri string This is the URI to queue.
     *
     * @return void
     * @author <NAME> <<EMAIL>>
     **/
    private function _queueJsUri($uri)
    {
        // We are also outputting the script tags to load OpenLayers here.
        $head = __v()->headScript();<commit_msg>Added database to track neatline features' metadata.<commit_after><?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4; */

/**
 * PHP version 5
 *
 * This is the Plugin object that sets up and contains the hooks and filters
 * for the plugins.
 *
 * @package     omeka
 * @subpackage  nlfeatures
 * @author      <NAME> <>
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @copyright   2011 The Board and Visitors of the University of Virginia
 * @license     http://www.apache.org/licenses/LICENSE-2.0.html Apache 2 License
 */
?><?php

require_once NEATLINE_FEATURES_PLUGIN_DIR .
    '/lib/NeatlineFeatures/Utils/View.php';
require_once NEATLINE_FEATURES_PLUGIN_DIR .
    '/lib/NeatlineFeatures_Functions.php';

/**
 * This class manages the plugin itself. It defines controllers for all the
 * hooks and filters.
 **/
class NeatlineFeaturesPlugin
{
    // Vars {{{
    /**
     * This is a pointer to the current database.
     *
     * @var Object
     **/
    private $_db;

    /**
     * This is a list of the hooks this manager defines.
     *
     * @var array
     **/
    private static $_hooks = array(
        'install',
        'uninstall',
        'admin_theme_header',
        'public_theme_header'
    );

    /**
     * This is a list of the filters this manager defines.
     *
     * @var array
     **/
    private static $_filters = array(
        array('formItemDublinCoreCoverage',
              array('Form', 'Item', 'Dublin Core', 'Coverage')),
        array('elementFormDisplayHtmlFlag',
              'element_form_display_html_flag'),
        array('displayItemDublinCoreCoverage',
              array('Display', 'Item', 'Dublin Core', 'Coverage'))
    );
    // }}}

    // Class setup {{{
    function __construct()
    {
        $this->_db = get_db();
        self::addHooksAndFilters();
    }

    /**
     * Iterate over the hooks and filters, define callbacks.
     *
     * @return void
     * @author <NAME> <<EMAIL>>
     **/
    public function addHooksAndFilters()
    {
        foreach (self::$_hooks as $hookName) {
            $functionName = Inflector::variablize($hookName);
            get_plugin_broker()->addHook(
                $hookName,
                array($this, $functionName),
                'NeatlineFeatures'
            );
        }

        foreach (self::$_filters as $filterInfo) {
            $functionName = $filterInfo[0];
            add_filter($filterInfo[1], array($this, $functionName));
        }
    }
    // }}}

    // Hooks {{{
    /**
     * This installs the NeatlineFeatures plugin.
     *
     * @return void
     * @author <NAME> <<EMAIL>>
     **/
    public function install()
    {
        $sql = "
            CREATE TABLE IF NOT EXISTS `{$this->_db->prefix}neatline_features` (
                id              INT(10)    UNSIGNED NOT NULL AUTO_INCREMENT,
                added           TIMESTAMP  DEFAULT CURRENT_TIMESTAMP,
                item_id         INT(10)    UNSIGNED NOT NULL,
                element_text_id INT(10)    UNSIGNED NOT NULL,
                is_map          TINYINT(1) NOT NULL DEFAULT 0,
                CONSTRAINT PRIMARY KEY (id),
                INDEX (item_id, element_text_id)
            ) ENGINE=innodb DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
        $this->_db->query($sql);
    }

    /**
     * This uninstalls the NeatlineFeatures plugin.
     *
     * @return void
     * @author <NAME> <<EMAIL>>
     **/
    public function uninstall()
    {
        $sql = "DROP TABLE IF EXISTS `{$this->_db->prefix}neatline_features`;";
        $this->_db->query($sql);
    }

    /**
     * This is a utility function that appends a javascript URL.
     *
     * @param $uri string This is the URI to queue.
     *
     * @return void
     * @author <NAME> <<EMAIL>>
     **/
    private function _queueJsUri($uri)
    {
        // We are also outputting the script tags to load OpenLayers here.
        $head = __v()->headScript();
{'fraction_non_alphanumeric': 0.12564943943122778, 'fraction_numerical': 0.004922067268252666, 'mean_word_length': 2.032752902155887, 'pattern_counts': {'":': 0, '<': 58, '<?xml version=': 0, '>': 70, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '209416', 'n_tokens_mistral': 2265, 'n_tokens_neox': 2191, 'n_words': 574}