<commit_before><?php

namespace Craft;

/**
 * Task Manager.
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2015, <NAME>
 * @license   MIT
 *
 * @link      http://github.com/boboldehampsink
 */
class TaskManagerElementType extends BaseElementType
{
    /**
     * Returns the element type name.
     *
     * @return string
     */
    public function getName()
    {
        return Craft::t('Task Manager');
    }

    /**
     * Returns whether this element type has content.
     *
     * @return bool
     */
    public function hasContent()
    {
        return false;
    }

    /**
     * Returns whether this element type has titles.
     *
     * @return bool
     */
    public function hasTitles()
    {
        return false;
    }

    /**
     * Returns whether this element type has statuses.
     *
     * @return bool
     */
    public function hasStatuses()
    {
        return true;
    }

    /**
     * Returns this element's statuses.
     *
     * @return array
     */
    public function getStatuses()
    {
        return array(
            EntryModel::PENDING => Craft::t('Pending'),
            EntryModel::EXPIRED => Craft::t('Error'),
            EntryModel::LIVE    => Craft::t('Running'),
        );
    }

    /**
     * Return sources.
     *
     * @param string $context
     *
     * @return array
     */
    public function getSources($context = null)
    {
        $sources = array(
            '*' => array(
                'label'    => Craft::t('All tasks'),
                'criteria' => array('editable' => true),
            ),
        );

        // Get sources by type
        $results = craft()->db->createCommand()
            ->select('id, type')
            ->from('tasks')
            ->order('root asc, lft asc')
            ->group('type')
            ->queryAll();
        foreach ($results as $result) {
            $sources['type:'.$result['type']] = array(
                'label' => $result['type'],
                'data' => array('id' => $result['id']),
                'criteria' => array('type' => $result['type'], 'editable' => true),
            );
        }

        // Allow plugins to modify the sources
        craft()->plugins->call('modifyTaskManagerSources', array(&$sources, $context));

        return $sources;
    }

    /**
     * @inheritDoc IElementType::getAvailableActions()
     *
     * @param string|null $source
     *
     * @return array|null
     */
    public function getAvailableActions($source = null)
    {
        $actions = array();

        $restartAction = craft()->elements->getAction('TaskManager_Restart');
        $restartAction->setParams(array(
            'confirmationMessage' => Craft::t('Are you sure you want to restart the selected tasks?'),
            'successMessage' => Craft::t('Tasks restarted.'),
        ));
        $actions[] = $restartAction;

        $deleteAction = craft()->elements->getAction('Delete');
        $deleteAction->setParams(array(
            'confirmationMessage' => Craft::t('Are you sure you want to delete the selected tasks?'),
            'successMessage' => Craft::t('Tasks deleted.'),
        ));
        $actions[] = $deleteAction;

        return $actions;
    }

    /**
     * Returns the attributes that can be shown/sorted by in table views.
     *
     * @param string|null $source
     *
     * @return array
     */
    public function defineTableAttributes($source = null)
    {
        $attributes = array(
            'description' => Craft::t('Description'),
            'dateCreated' => Craft::t('Created'),
            'currentStep' => Craft::t('Current step'),
            'totalSteps'  => Craft::t('Total steps'),
        );

        // Allow plugins to modify the attributes
        craft()->plugins->call('modifyTaskManagerTableAttributes', array(&$attributes, $source));
<commit_msg>Added "addTaskManagerActions" hook<commit_after><?php

namespace Craft;

/**
 * Task Manager.
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2015, <NAME>
 * @license   MIT
 *
 * @link      http://github.com/boboldehampsink
 */
class TaskManagerElementType extends BaseElementType
{
    /**
     * Returns the element type name.
     *
     * @return string
     */
    public function getName()
    {
        return Craft::t('Task Manager');
    }

    /**
     * Returns whether this element type has content.
     *
     * @return bool
     */
    public function hasContent()
    {
        return false;
    }

    /**
     * Returns whether this element type has titles.
     *
     * @return bool
     */
    public function hasTitles()
    {
        return false;
    }

    /**
     * Returns whether this element type has statuses.
     *
     * @return bool
     */
    public function hasStatuses()
    {
        return true;
    }

    /**
     * Returns this element's statuses.
     *
     * @return array
     */
    public function getStatuses()
    {
        return array(
            EntryModel::PENDING => Craft::t('Pending'),
            EntryModel::EXPIRED => Craft::t('Error'),
            EntryModel::LIVE    => Craft::t('Running'),
        );
    }

    /**
     * Return sources.
     *
     * @param string $context
     *
     * @return array
     */
    public function getSources($context = null)
    {
        $sources = array(
            '*' => array(
                'label'    => Craft::t('All tasks'),
                'criteria' => array('editable' => true),
            ),
        );

        // Get sources by type
        $results = craft()->db->createCommand()
            ->select('id, type')
            ->from('tasks')
            ->order('root asc, lft asc')
            ->group('type')
            ->queryAll();
        foreach ($results as $result) {
            $sources['type:'.$result['type']] = array(
                'label' => $result['type'],
                'data' => array('id' => $result['id']),
                'criteria' => array('type' => $result['type'], 'editable' => true),
            );
        }

        // Allow plugins to modify the sources
        craft()->plugins->call('modifyTaskManagerSources', array(&$sources, $context));

        return $sources;
    }

    /**
     * @inheritDoc IElementType::getAvailableActions()
     *
     * @param string|null $source
     *
     * @return array|null
     */
    public function getAvailableActions($source = null)
    {
        $actions = array();

        $restartAction = craft()->elements->getAction('TaskManager_Restart');
        $restartAction->setParams(array(
            'confirmationMessage' => Craft::t('Are you sure you want to restart the selected tasks?'),
            'successMessage' => Craft::t('Tasks restarted.'),
        ));
        $actions[] = $restartAction;

        $deleteAction = craft()->elements->getAction('Delete');
        $deleteAction->setParams(array(
            'confirmationMessage' => Craft::t('Are you sure you want to delete the selected tasks?'),
            'successMessage' => Craft::t('Tasks deleted.'),
        ));
        $actions[] = $deleteAction;

        // Allow plugins to add additional actions
        $allPluginActions = craft()->plugins->call('addTaskManagerActions', array($source), true);

        foreach ($allPluginActions as $pluginActions) {
            $actions = array_merge($actions, $pluginActions);
        }

        return $actions;
    }

    /**
     * Returns the attributes that can be shown/sorted by in table views.
     *
     * @param string|null $source
     *
     * @return array
     */
    public function defineTableAttributes($source = null)
    {
        $attributes = array(
            'description' => Craft::t('Description'),
            'dateCreated' => Craft::t('Created'),
            'currentStep' => Craft::t('Current step'),
            'totalSteps'  => Craft::t('Total steps'),
        );

        // Allow plugins to modify the attributes
        craft()->plugins->call('modifyTaskManagerTableAttributes', array(&$attributes, $source));

{'fraction_non_alphanumeric': 0.14671814671814673, 'fraction_numerical': 0.0009963880931622867, 'mean_word_length': 1.9360146252285193, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 89, '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': '2124718', 'n_tokens_mistral': 2204, 'n_tokens_neox': 2163, 'n_words': 517}