<commit_before><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

if (!defined('STATUSNET')) {
    exit(1);
}

class NotesPDFPlugin extends Plugin {

    function onInitializePlugin() {
        // A chance to initialize a plugin in a complete environment
    }

    function onCleanupPlugin() {
        // A chance to cleanup a plugin at the end of a program
    }

    function onAutoload($cls) {

        $dir = dirname(__FILE__);

        switch ($cls) {

            case 'NotesgroupsAction':
            case 'NotescustomizeAction':
            case 'NotesgenerateAction':
                include_once $dir . '/actions/' . $cls . '.php';
                return false;
            case 'Notesgroupsform':
            case 'Notescustomizeform':
                include_once $dir . '/lib/' . $cls . '.php';
                return false;
            case 'NotesPDF':
            case 'GenerarPDF':
                include_once $dir . '/classes/' . $cls . '.php';
                return false;
                break;

            default:
                return true;
        }
    }

    function onRouterInitialized($m) {
        $m->connect('main/notespdf', array('action' => 'notesgroups'));
        $m->connect('main/notespdf/customize', array('action' => 'notescustomize'));
        $m->connect('main/notespdf/generate', array('action' => 'notesgenerate'));
        return true;
    }

    function onStartDefaultLocalNav($action) {
        // '''common_local_url()''' gets the correct URL for the action name we provide
        
        $actionName = $action->trimmed('action');
        
        $user = common_current_user();
        if (!empty($user)) {
            $action->out->elementStart('li');
            $action->out->element('h3', null, 'Herramientas');
            $action->out->elementStart('ul', array('class' => 'nav'));
            $action->menuItem(common_local_url('notesgroups'), _m('Apuntes'), _m('Apuntes en PDF'), ($actionName === 'notesgroups' || $actionName === 'notescustomize'), 'nav_notespdf');
            $action->out->elementEnd('ul');
            $action->out->elementEnd('li');
        }

        return true;
    }

    function onEndShowStyles($action) {
        $action->cssLink($this->path('css/notespdf.css'));
        return true;
    }

    function onPluginVersion(&$versions) {
        $versions[] = array('name' => 'NotesPDF',
            'version' => STATUSNET_VERSION,
            'author' => '<NAME>',
            'rawdescription' =>
            _m('A plugin to export notes in PDF'));
        return true;
    }

    /* function onEndShowScripts($action)
      {
      $action->script($this->path('js/notespdf.js'));
      return true;<commit_msg>Cambiado NotesPDFPlugin. Ahora el submenu "Apuntes" se crea utilizando el nuevo hook onStartToolsLocalNav.<commit_after><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

if (!defined('STATUSNET')) {
    exit(1);
}

class NotesPDFPlugin extends Plugin {

    function onInitializePlugin() {
        // A chance to initialize a plugin in a complete environment
    }

    function onCleanupPlugin() {
        // A chance to cleanup a plugin at the end of a program
    }

    function onAutoload($cls) {

        $dir = dirname(__FILE__);

        switch ($cls) {

            case 'NotesgroupsAction':
            case 'NotescustomizeAction':
            case 'NotesgenerateAction':
                include_once $dir . '/actions/' . $cls . '.php';
                return false;
            case 'Notesgroupsform':
            case 'Notescustomizeform':
                include_once $dir . '/lib/' . $cls . '.php';
                return false;
            case 'NotesPDF':
            case 'GenerarPDF':
                include_once $dir . '/classes/' . $cls . '.php';
                return false;
                break;

            default:
                return true;
        }
    }

    function onRouterInitialized($m) {
        $m->connect('main/notespdf', array('action' => 'notesgroups'));
        $m->connect('main/notespdf/customize', array('action' => 'notescustomize'));
        $m->connect('main/notespdf/generate', array('action' => 'notesgenerate'));
        return true;
    }

    function onStartToolsLocalNav($action) {
        // '''common_local_url()''' gets the correct URL for the action name we provide
        
        $actionName = $action->trimmed('action');
        
        $user = common_current_user();
        if (!empty($user)) {
            $action->menuItem(common_local_url('notesgroups'), _m('Apuntes'), _m('Apuntes en PDF'), ($actionName === 'notesgroups' || $actionName === 'notescustomize'), 'nav_notespdf');
        }

        return true;
    }

    function onEndShowStyles($action) {
        $action->cssLink($this->path('css/notespdf.css'));
        return true;
    }

    function onPluginVersion(&$versions) {
        $versions[] = array('name' => 'NotesPDF',
            'version' => STATUSNET_VERSION,
            'author' => '<NAME>',
            'rawdescription' =>
            _m('A plugin to export notes in PDF'));
        return true;
    }

    /* function onEndShowScripts($action)
      {
      $action->script($this->path('js/notespdf.js'));
      return true;
{'fraction_non_alphanumeric': 0.13927728345741783, 'fraction_numerical': 0.0005447612130016343, 'mean_word_length': 2.1206798866855525, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3735799', 'n_tokens_mistral': 1528, 'n_tokens_neox': 1484, 'n_words': 376}