<commit_before><?php

/**
 * Abstraction of the procedural Drupal world into OOP.
 *
 * @author     <NAME> <<EMAIL>>
 * @license    http://www.opensource.org/licenses/mit-license.php The MIT License
 * @copyright  Copyright (c) 2012 liip ag
 *
 * @package DrupalConnector
 * @subpackage Filter
 */

namespace Liip\Drupal\Modules\DrupalConnector;

/**
 * Cumulates the filter functions of Drupal 7 in one class.
 *
 * Please order the functions alphabetically!
 */
class Filter
{
    /**
     * Returns the ID of the default text format for a particular user.
     *
     * The default text format is the first available format that the user is
     * allowed to access, when the formats are ordered by weight. It should
     * generally be used as a default choice when presenting the user with a list
     * of possible text formats (for example, in a node creation form).
     *
     * Conversely, when existing content that does not have an assigned text format
     * needs to be filtered for display, the default text format is the wrong
     * choice, because it is not guaranteed to be consistent from user to user, and
     * some trusted users may have an unsafe text format set by default, which
     * should not be used on text of unknown origin. Instead, the fallback format
     * returned by filter_fallback_format() should be used, since that is intended
     * to be a safe, consistent format that is always available to all users.
     *
     * @param $account
     *   (optional) The user account to check. Defaults to the currently logged-in
     *   user.
     * @return
     *   The ID of the user's default text format.
     *
     * @see filter_fallback_format()
     */
    public function filter_default_format($account = null)
    {
        return filter_default_format($account);
    }

    /**
     * Load a text format object from the database.
     *
     * @param $format_id
     *   The format ID.
     *
     * @return
     *   A fully-populated text format object, if the requested format exists and
     *   is enabled. If the format does not exist, or exists in the database but
     *   has been marked as disabled, FALSE is returned.
     *
     * @see filter_format_exists()
     */
    public function filter_format_load($format_id)
    {
        return filter_format_load($format_id);
    }

    /**
     * Save a text format object to the database.
     *
     * @param $format
     *   A format object using the properties:
     *   - 'format': A machine-readable name representing the ID of the text format
     *     to save. If this corresponds to an existing text format, that format
     *     will be updated; otherwise, a new format will be created.
     *   - 'name': The title of the text format.
     *   - 'status': (optional) An integer indicating whether the text format is
     *     enabled (1) or not (0). Defaults to 1.
     *   - 'weight': (optional) The weight of the text format, which controls its
     *     placement in text format lists. If omitted, the weight is set to 0.
     *   - 'filters': (optional) An associative, multi-dimensional array of filters
     *     assigned to the text format, keyed by the name of each filter and using
     *     the properties:
     *     - 'weight': (optional) The weight of the filter in the text format. If
     *       omitted, either the currently stored weight is retained (if there is
     *       one), or the filter is assigned a weight of 10, which will usually
     *       put it at the bottom of the list.
     *     - 'status': (optional) A boolean indicating whether the filter is
     *       enabled in the text format. If omitted, the filter will be disabled.
     *     - 'settings': (optional) An array of configured settings for the filter.
     *       See hook_filter_info() for details.
     */
    public function filter_format_save($format)
    {
        return filter_format_save($format);
    }

    /**
     * Disable a text format.
     *
     * There is no core facility to re-enable a disabled format. It is not deleted
     * to keep information for contrib and to make sure the format ID is never
     * reused. As there might be content using the disabled format, this would lead
     * to data corruption.
     *
     * @param $format
     *   The text format object to be disabled.
     */
    public function filter_format_disable($format)
    {
        return filter_format_disable($format);
    }

    /**
     * Determines if a text format exists.
     *
     * @param $format_id
     *   The ID of the text format to check.
     *
     * @return
     *   TRUE if the text format exists, FALSE otherwise. Note that for disabled
     *   formats filter_format_exists() will return TRUE while filter_format_load()
     *   will return FALSE.
     *
     * @see filter_format_load()
     */
    public function filter_format_exists($format_id)
    {
        return filter_format_exists($format_id);
    }

    /**
     * Display a text format form title.
     */
    public function filter_admin_format_title($format)
    {
        return filter_admin_format_title($format);
    }

    /**
     * Returns the machine-readable permission name for a provided text format.
     *
     * @param $format
     *   An object representing a text format.
     * @return
     *   The machine-readable permission name, or FALSE if the provided text format
     *   is malformed or is the fallback format (which is available to all users).
     */
    public function filter_permission_name($format)
    {
        return filter_permission_name($format);
    }

    /**
     * Retrieve a list of text formats, ordered by weight.
     *
     * @param $account
     *   (optional) If provided, only those formats that are allowed for this user
     *   account will be returned. All formats will be returned otherwise.
     * @return
     *   An array of text format objects, keyed by the format ID and ordered by
     *   weight.
     *
     * @see filter_formats_reset()
     */
    public function filter_formats($account = null)
    {
        return filter_formats($account);
    }

    /**
     * Resets text format caches.
     *
     * @see filter_formats()
     */
    public function filter_formats_reset()
    {
        return filter_formats_reset();
    }

    /**
     * Retrieves a list of roles that are allowed to use a given text format.
     *
     * @param $format
     *   An object representing the text format.
     * @return
     *   An array of role names, keyed by role ID.
     */
    public function filter_get_roles_by_format($format)
    {
        return filter_get_roles_by_format($format);
    }

    /**
     * Retrieves a list of text formats that are allowed for a given role.
     *
     * @param $rid
     *   The user role ID to retrieve text formats for.
     * @return
     *   An array of text format objects that are allowed for the role, keyed by
     *   the text format ID and ordered by weight.
     */
    public function filter_get_formats_by_role($rid)
    {
        return filter_get_formats_by_role($rid);
    }

    /**
     * Returns the ID of the default text format for a particular user.
     *
     * The default text format is the first available format that the user is
     * allowed to access, when the formats are ordered by weight. It should
     * generally be used as a default choice when presenting the user with a list
     * of possible text formats (for example, in a node creation form).
     *
     * Conversely, when existing content that does not have an assigned text format
     * needs to be filtered for display, the default text format is the wrong
     * choice, because it is not guaranteed to be consistent from user to user, and
     * some trusted users may have an unsafe text format set by default, which
     * should not be used on text of unknown origin. Instead, the fallback format
     * returned by filter_fallback_format() should be used, since that is intended
     * to be a safe, consistent format that is always available to all users.
     *
     * @param $account
     *   (optional) The user account to check. Defaults to the currently logged-in
     *   user.
     * @return
     *   The ID of the user's default text format.
     *
     * @see filter_fallback_format()
     */
    public function filter_default_format($account = null)
    {
        return filter_default_format($account);
    }

    /**
     * Returns the ID of the fallback text format that all users have access to.
     *
     * The fallback text format is a regular text format in every respect, except
     * it does not participate in the filter permission system and cannot be
     * disabled. It needs to exist because any user who has permission to create
     * formatted content must always have at least one text format they can use.
     *
     * Because the fallback format is available to all users, it should always be
     * configured securely. For example, when the Filter module is installed, this
     * format is initialized to output plain text. Installation profiles and site
     * administrators have the freedom to configure it further.
     *
     * Note that the fallback format is completely distinct from the default
     * format, which differs per user and is simply the first format which that
     * user has access to. The default and fallback formats are only guaranteed to
     * be the same for users who do not have access to any other format; otherwise,
     * the fallback format's weight determines its placement with respect to the
     * user's other formats.
     *
     * Any modules implementing a format deletion functionality must not delete
     * this format.
     *
     * @see hook_filter_format_disable()
     * @see filter_default_format()
     */
    public function filter_fallback_format()
    {
        return filter_fallback_format();
    }<commit_msg>Removed duplicated method definition<commit_after><?php

/**
 * Abstraction of the procedural Drupal world into OOP.
 *
 * @author     <NAME> <<EMAIL>>
 * @license    http://www.opensource.org/licenses/mit-license.php The MIT License
 * @copyright  Copyright (c) 2012 liip ag
 *
 * @package DrupalConnector
 * @subpackage Filter
 */

namespace Liip\Drupal\Modules\DrupalConnector;

/**
 * Cumulates the filter functions of Drupal 7 in one class.
 *
 * Please order the functions alphabetically!
 */
class Filter
{
    /**
     * Returns the ID of the default text format for a particular user.
     *
     * The default text format is the first available format that the user is
     * allowed to access, when the formats are ordered by weight. It should
     * generally be used as a default choice when presenting the user with a list
     * of possible text formats (for example, in a node creation form).
     *
     * Conversely, when existing content that does not have an assigned text format
     * needs to be filtered for display, the default text format is the wrong
     * choice, because it is not guaranteed to be consistent from user to user, and
     * some trusted users may have an unsafe text format set by default, which
     * should not be used on text of unknown origin. Instead, the fallback format
     * returned by filter_fallback_format() should be used, since that is intended
     * to be a safe, consistent format that is always available to all users.
     *
     * @param $account
     *   (optional) The user account to check. Defaults to the currently logged-in
     *   user.
     * @return
     *   The ID of the user's default text format.
     *
     * @see filter_fallback_format()
     */
    public function filter_default_format($account = null)
    {
        return filter_default_format($account);
    }

    /**
     * Load a text format object from the database.
     *
     * @param $format_id
     *   The format ID.
     *
     * @return
     *   A fully-populated text format object, if the requested format exists and
     *   is enabled. If the format does not exist, or exists in the database but
     *   has been marked as disabled, FALSE is returned.
     *
     * @see filter_format_exists()
     */
    public function filter_format_load($format_id)
    {
        return filter_format_load($format_id);
    }

    /**
     * Save a text format object to the database.
     *
     * @param $format
     *   A format object using the properties:
     *   - 'format': A machine-readable name representing the ID of the text format
     *     to save. If this corresponds to an existing text format, that format
     *     will be updated; otherwise, a new format will be created.
     *   - 'name': The title of the text format.
     *   - 'status': (optional) An integer indicating whether the text format is
     *     enabled (1) or not (0). Defaults to 1.
     *   - 'weight': (optional) The weight of the text format, which controls its
     *     placement in text format lists. If omitted, the weight is set to 0.
     *   - 'filters': (optional) An associative, multi-dimensional array of filters
     *     assigned to the text format, keyed by the name of each filter and using
     *     the properties:
     *     - 'weight': (optional) The weight of the filter in the text format. If
     *       omitted, either the currently stored weight is retained (if there is
     *       one), or the filter is assigned a weight of 10, which will usually
     *       put it at the bottom of the list.
     *     - 'status': (optional) A boolean indicating whether the filter is
     *       enabled in the text format. If omitted, the filter will be disabled.
     *     - 'settings': (optional) An array of configured settings for the filter.
     *       See hook_filter_info() for details.
     */
    public function filter_format_save($format)
    {
        return filter_format_save($format);
    }

    /**
     * Disable a text format.
     *
     * There is no core facility to re-enable a disabled format. It is not deleted
     * to keep information for contrib and to make sure the format ID is never
     * reused. As there might be content using the disabled format, this would lead
     * to data corruption.
     *
     * @param $format
     *   The text format object to be disabled.
     */
    public function filter_format_disable($format)
    {
        return filter_format_disable($format);
    }

    /**
     * Determines if a text format exists.
     *
     * @param $format_id
     *   The ID of the text format to check.
     *
     * @return
     *   TRUE if the text format exists, FALSE otherwise. Note that for disabled
     *   formats filter_format_exists() will return TRUE while filter_format_load()
     *   will return FALSE.
     *
     * @see filter_format_load()
     */
    public function filter_format_exists($format_id)
    {
        return filter_format_exists($format_id);
    }

    /**
     * Display a text format form title.
     */
    public function filter_admin_format_title($format)
    {
        return filter_admin_format_title($format);
    }

    /**
     * Returns the machine-readable permission name for a provided text format.
     *
     * @param $format
     *   An object representing a text format.
     * @return
     *   The machine-readable permission name, or FALSE if the provided text format
     *   is malformed or is the fallback format (which is available to all users).
     */
    public function filter_permission_name($format)
    {
        return filter_permission_name($format);
    }

    /**
     * Retrieve a list of text formats, ordered by weight.
     *
     * @param $account
     *   (optional) If provided, only those formats that are allowed for this user
     *   account will be returned. All formats will be returned otherwise.
     * @return
     *   An array of text format objects, keyed by the format ID and ordered by
     *   weight.
     *
     * @see filter_formats_reset()
     */
    public function filter_formats($account = null)
    {
        return filter_formats($account);
    }

    /**
     * Resets text format caches.
     *
     * @see filter_formats()
     */
    public function filter_formats_reset()
    {
        return filter_formats_reset();
    }

    /**
     * Retrieves a list of roles that are allowed to use a given text format.
     *
     * @param $format
     *   An object representing the text format.
     * @return
     *   An array of role names, keyed by role ID.
     */
    public function filter_get_roles_by_format($format)
    {
        return filter_get_roles_by_format($format);
    }

    /**
     * Retrieves a list of text formats that are allowed for a given role.
     *
     * @param $rid
     *   The user role ID to retrieve text formats for.
     * @return
     *   An array of text format objects that are allowed for the role, keyed by
     *   the text format ID and ordered by weight.
     */
    public function filter_get_formats_by_role($rid)
    {
        return filter_get_formats_by_role($rid);
    }

    /**
     * Returns the ID of the fallback text format that all users have access to.
     *
     * The fallback text format is a regular text format in every respect, except
     * it does not participate in the filter permission system and cannot be
     * disabled. It needs to exist because any user who has permission to create
     * formatted content must always have at least one text format they can use.
     *
     * Because the fallback format is available to all users, it should always be
     * configured securely. For example, when the Filter module is installed, this
     * format is initialized to output plain text. Installation profiles and site
     * administrators have the freedom to configure it further.
     *
     * Note that the fallback format is completely distinct from the default
     * format, which differs per user and is simply the first format which that
     * user has access to. The default and fallback formats are only guaranteed to
     * be the same for users who do not have access to any other format; otherwise,
     * the fallback format's weight determines its placement with respect to the
     * user's other formats.
     *
     * Any modules implementing a format deletion functionality must not delete
     * this format.
     *
     * @see hook_filter_format_disable()
     * @see filter_default_format()
     */
    public function filter_fallback_format()
    {
        return filter_fallback_format();
    }
{'fraction_non_alphanumeric': 0.06616971857613568, 'fraction_numerical': 0.0011883541295306002, 'mean_word_length': 2.439346089541148, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '5389834', 'n_tokens_mistral': 4861, 'n_tokens_neox': 4792, 'n_words': 2198}