<commit_before><?php

//  Include NAILS_Admin_Controller; executes common admin functionality.
require_once '_admin.php';
/**
 * This class brings various admin utilities
 *
 * @package     Nails
 * @subpackage  module-admin
 * @category    Controller
 * @author      <NAME>
 * @link
 */
class NAILS_Utilities extends NAILS_Admin_Controller
{
    protected $exportSources;
    protected $exportFormats;

    // --------------------------------------------------------------------------

    /**
     * Announces this controllers details
     * @return stdClass
     */
    public static function announce()
    {
        $d = new stdClass();

        // --------------------------------------------------------------------------

        //  Load the laguage file
        get_instance()->lang->load('admin_utilities');

        // --------------------------------------------------------------------------

        //  Configurations
        $d->name = lang('utilities_module_name');
        $d->icon = 'fa-sliders';

        // --------------------------------------------------------------------------

        //  Navigation options
        $d->funcs                   = array();
        $d->funcs['test_email']     = lang('utilities_nav_test_email');
        $d->funcs['rewrite_routes'] = lang('utilities_nav_rewrite_routes');
        $d->funcs['export']         = lang('utilities_nav_export');

        if (isModuleEnabled('cdn')) {

            $d->funcs['cdn/orphans'] = 'CDN: Find orphaned objects';
        }

        // --------------------------------------------------------------------------

        return $d;
    }

    // --------------------------------------------------------------------------

    /**
     * Constructs the controller
     */
    public function __construct()
    {
        parent::__construct();

        // --------------------------------------------------------------------------

        //  Default export sources
        $this->exportSources = array();

        if (user_has_permission('admin.accounts:0')) {

            $this->exportSources[] = array('Members: All', 'Export a list of all the site\'s registered users and their meta data.', 'users_all');
        }

        // --------------------------------------------------------------------------

        //  Default export formats
        $this->exportFormats   = array();
        $this->exportFormats[] = array('CSV', 'Easily imports to many software packages, including Microsoft Excel.', 'csv');
        $this->exportFormats[] = array('HTML', 'Produces an HTML table containing the data', 'html');
        $this->exportFormats[] = array('PDF', 'Saves a PDF using the data from the HTML export option', 'pdf');
        $this->exportFormats[] = array('PHP Serialize', 'Export as an object serialized using PHP\'s serialize() function', 'serialize');
        $this->exportFormats[] = array('JSON', 'Export as a JSON array', 'json');
    }

    // --------------------------------------------------------------------------

    /**
     * Send a test email
     * @return void
     */
    public function test_email()
    {
        //  Page Title
        $this->data['page']->title = lang ('utilities_test_email_title');

        // --------------------------------------------------------------------------

        if ($this->input->post()) {

            //  Form validation and update
            $this->load->library('form_validation');

            //  Define rules
            $this->form_validation->set_rules('recipient', lang('utilities_test_email_field_name'), 'xss_clean|required|valid_email');

            //  Set Messages
            $this->form_validation->set_message('required', lang('fv_required'));
            $this->form_validation->set_message('valid_email', lang('fv_valid_email'));<commit_msg>Documenting how to use admin's export functionality<commit_after><?php

//  Include NAILS_Admin_Controller; executes common admin functionality.
require_once '_admin.php';
/**
 * This class brings various admin utilities
 *
 * @package     Nails
 * @subpackage  module-admin
 * @category    Controller
 * @author      Nails Dev Team
 * @link
 */
class NAILS_Utilities extends NAILS_Admin_Controller
{
    protected $exportSources;
    protected $exportFormats;

    // --------------------------------------------------------------------------

    /**
     * Announces this controllers details
     * @return stdClass
     */
    public static function announce()
    {
        $d = new stdClass();

        // --------------------------------------------------------------------------

        //  Load the laguage file
        get_instance()->lang->load('admin_utilities');

        // --------------------------------------------------------------------------

        //  Configurations
        $d->name = lang('utilities_module_name');
        $d->icon = 'fa-sliders';

        // --------------------------------------------------------------------------

        //  Navigation options
        $d->funcs                   = array();
        $d->funcs['test_email']     = lang('utilities_nav_test_email');
        $d->funcs['rewrite_routes'] = lang('utilities_nav_rewrite_routes');
        $d->funcs['export']         = lang('utilities_nav_export');

        if (isModuleEnabled('cdn')) {

            $d->funcs['cdn/orphans'] = 'CDN: Find orphaned objects';
        }

        // --------------------------------------------------------------------------

        return $d;
    }

    // --------------------------------------------------------------------------

    /**
     * Constructs the controller
     */
    public function __construct()
    {
        parent::__construct();

        // --------------------------------------------------------------------------

        /**
         * Define the export sources
         *
         * Each item in this array is an array which defines the source, in the
         * following format:
         *
         * array(
         *    0 => 'Source Title',
         *    1 => 'Source Description',
         *    2 => 'sourceMethod'
         * )
         *
         * The source method should be a callable method which is prefixed with
         * _export_source_, using the above as an example, the method would be:
         *
         * _export_source_sourceMethod()
         *
         * This method should return an array where the indexes are the column
         * names and the values are not arrays, i.e stuff which would fit into
         * a single cell in Excel).
         */

        $this->exportSources = array();

        if (user_has_permission('admin.accounts:0')) {

            $this->exportSources[] = array(
                'Members: All',
                'Export a list of all the site\'s registered users and their meta data.',
                'users_all'
            );
        }

        // --------------------------------------------------------------------------

        /**
         * Define the export formats
         *
         * Each item in this array is an array which defines the formats, in the
         * following format:
         *
         * array(
         *    0 => 'Format Title',
         *    1 => 'Format Description',
         *    2 => 'formatMethod'
         * )
         *
         * The format method should be a callable method which is prefixed with
         * _export_format_, using the above as an example, the method would be:
         *
         * _export_format_formatMethod($data, $returnData = false)
         *
         * Where $data is the values generated from a source method. The method
         * should handle generating the file and sending to the user, unless
         * $returnData is true, in which case it should return the file's content
         */

        $this->exportFormats   = array();
        $this->exportFormats[] = array(
            'CSV',
            'Easily imports to many software packages, including Microsoft Excel.',
            'csv');

        $this->exportFormats[] = array(
            'HTML',
            'Produces an HTML table containing the data',
            'html');

        $this->exportFormats[] = array(
            'PDF',
            'Saves a PDF using the data from the HTML export option',
            'pdf');

        $this->exportFormats[] = array(
            'PHP Serialize',
            'Export as an object serialized using PHP\'s serialize() function',
            'serialize');

        $this->exportFormats[] = array(
            'JSON',
            'Export as a JSON array',
            'json');
    }

    // --------------------------------------------------------------------------

    /**
     * Send a test email
     * @return void
     */
    public function test_email()
    {
        //  Page Title
        $this->data['page']->title = lang ('utilities_test_email_title');

        // --------------------------------------------------------------------------

        if ($this->input->post()) {

            //  Form validation and update
            $this->load->library('form_validation');

            //  Define rules
            $this->form_validation->set_rules('recipient', '', 'xss_clean|required|valid_email');

            //  Set Messages
            $this->form_validation->set_message('required', lang('fv_required'));
            $this->form_validation->set_message('valid_email', lang('fv_valid_email'));
{'fraction_non_alphanumeric': 0.2603945693678405, 'fraction_numerical': 0.0008485362749257531, 'mean_word_length': 1.221201413427562, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 68, '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': '3721550', 'n_tokens_mistral': 2218, 'n_tokens_neox': 2132, 'n_words': 577}