<commit_before><?php 
namespace Podlove\Modules\Contributors;

use \Podlove\Modules\Contributors\Model\Contributor;
use \Podlove\Modules\Contributors\Model\ContributorRole;
use \Podlove\Modules\Contributors\Model\ContributorGroup;
use \Podlove\Modules\Contributors\Model\EpisodeContribution;
use \Podlove\Modules\Contributors\Model\ShowContribution;
use \Podlove\Modules\Contributors\Model\DefaultContribution;

class TemplateExtensions {
	
	/**
	 * List of episode contributors
	 *
	 * Examples:
	 *
	 * ```
	 * {# iterating over a list of contributors #}
	 * {% for contributor in episode.contributors %}
	 * 	{{ contributor.name }}
	 * 	{% if not loop.last %}, {% endif %}
	 * {% endfor %}
	 * ```
	 * ```
	 * {# iterating over a grouped list of contributors #}
	 * {% for contributorGroup in episode.contributors({groupby: "group"}) %}
	 * 	<strong>{{ contributorGroup.group.title }}:</strong> 
	 * 	{% for contributor in contributorGroup.contributors %}
	 * 		{{ contributor.name }}
	 * 		{% if not loop.last %}, {% endif %}
	 * 	{% endfor %}
	 * {% endfor %}
	 * ```
	 * 
	 * Options:
	 *
	 * - **id:**      Fetch one contributor by its id. Ignores all other parameters. 
	 *                Returns null if the id belongs to an existing contributor which is not part of the episode. 
	 *                Example: `episode.contributors({id: 'james'}).name`
	 * - **group:**   group slug. If none is given, show all contributors.
	 * - **role:**    role slug. If none is given, show all contributors.
	 * - **groupby:** group or role slug. Group by "group" or "role".
	 * 	         If used, the returned data is has another layer for the groups.
	 * 	         See examples for more details.
	 *
	 * @accessor
	 * @dynamicAccessor episode.contributors
	 */
	public function accessorEpisodeContributors($return, $method_name, $episode, $post, $args = array()) {
		$contributions = EpisodeContribution::find_all_by_episode_id($episode->id);
		return \Podlove\Modules\Contributors\Contributors::filterContributions($contributions, $args);
	}

	/**
	 * List of podcast contributors.
	 *
	 * Examples:
	 *<commit_msg>Update template_extensions.php<commit_after><?php 
namespace Podlove\Modules\Contributors;

use \Podlove\Modules\Contributors\Model\Contributor;
use \Podlove\Modules\Contributors\Model\ContributorRole;
use \Podlove\Modules\Contributors\Model\ContributorGroup;
use \Podlove\Modules\Contributors\Model\EpisodeContribution;
use \Podlove\Modules\Contributors\Model\ShowContribution;
use \Podlove\Modules\Contributors\Model\DefaultContribution;

class TemplateExtensions {
	
	/**
	 * List of episode contributors
	 *
	 * Examples:
	 *
	 * ```
	 * {# iterating over a list of contributors #}
	 * {% for contributor in episode.contributors %}
	 * 	{{ contributor.name }}
	 * 	{% if not loop.last %}, {% endif %}
	 * {% endfor %}
	 * ```
	 * ```
	 * {# iterating over a grouped list of contributors #}
	 * {% for contributorGroup in episode.contributors({groupby: "group"}) %}
	 * 	<strong>{{ contributorGroup.group.title }}:</strong> 
	 * 	{% for contributor in contributorGroup.contributors %}
	 * 		{{ contributor.name }}
	 * 		{% if not loop.last %}, {% endif %}
	 * 	{% endfor %}
	 * {% endfor %}
	 * ```
	 * 
	 * Options:
	 *
	 * - **id:**      Fetch one contributor by its id. Ignores all other parameters. 
	 *                Returns null if the id belongs to an existing contributor which is not part of the episode. 
	 *                Example: `episode.contributors({id: 'james'}).name`
	 * - **group:**   group slug. If none is given, show all contributors.
	 * - **role:**    role slug. If none is given, show all contributors.
	 * - **groupby:** group or role slug. Group by "group" or "role".
	 * 	         If used, the returned data is has another layer for the groups.
	 * 	         See examples for more details.
	 * - **order:**   Designates the ascending or descending order of the 'orderby' parameter. Defaults to 'DESC'.
         *   - 'ASC' - ascending order from lowest to highest values (1, 2, 3; a, b, c).
         *   - 'DESC' - descending order from highest to lowest values (3, 2, 1; c, b, a).
         * - **orderby:** Sort contributors by parameter. Defaults to 'name'.
         *   - 'position' - Order by the contributors position in the episode.
         *   - 'comment' - Order by the contributors comment in the episode.
	 *
	 * @accessor
	 * @dynamicAccessor episode.contributors
	 */
	public function accessorEpisodeContributors($return, $method_name, $episode, $post, $args = array()) {
		$contributions = EpisodeContribution::find_all_by_episode_id($episode->id);
		$contributions = \Podlove\Modules\Contributors\Contributors::orderContributions($contributions, $args);
		return \Podlove\Modules\Contributors\Contributors::filterContributions($contributions, $args);
	}

	/**
	 * List of podcast contributors.
	 *
	 * Examples:
	 *
{'fraction_non_alphanumeric': 0.13348369899528398, 'fraction_numerical': 0.001230264506868977, 'mean_word_length': 3.2940140845070425, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6338315', 'n_tokens_mistral': 1602, 'n_tokens_neox': 1381, 'n_words': 400}