/** * List of service profiles * * Parameters: * * - **category:** (optional) "social", "donation" or "all". Default: "all" * - **type:** (optional) Filter services by type. List of all service types: 500px, about.me, amazon wishlist, app.net, auphonic credits, bandcamp, bitbucket, bitcoin, deviantart, diaspora, dogecoin, dribbble, email, facebook, flattr, flickr, foursquare, generic wishlist, github, gittip, google+, instagram, jabber, last.fm, linkedin, litecoin, openstreetmap, orcid, patreon, paypal, miiverse, pinboard, pinterest, playstation network, researchgate, scous, skype, soundcloud, soup, steam, steam wishlist, thomann wishlist, tumblr, twitch, twitter, vimeo, website, xbox live, xing, youtube * * Example: * * ```html * {% for service in contributor.services({category: "social"}) %} * <a target="_blank" title="{{ service.title }}" href="{{ service.profileUrl }}"> * {{ service.image.html({width: 20}) }} * </a> * {% endfor %} * ``` * * @accessor * @dynamicAccessor contributor.services */ public static function accessorContributorServices($return, $method_name, $contributor, $contribution, $args = array()) { return $contributor->with_blog_scope(function () use($contributor, $args) { $category = isset($args['category']) && in_array($args['category'], array("social", "donation", "all")) ? $args['category'] : "all"; if ($category == "all") { $services = ContributorService::find_all_by_contributor_id($contributor->id); } else { $services = ContributorService::find_by_contributor_id_and_category($contributor->id, $category); } if (isset($args["type"]) && $args["type"]) { $services = array_filter($services, function ($s) use($args) { return $s->get_service()->type == $args["type"]; }); } usort($services, function ($a, $b) { if ($a == $b) { return 0; } return $a->position < $b->position ? -1 : 1; }); return array_map(function ($service) { return new Template\Service($service, $service->get_service()); }, $services); }); }
public static function adn_tags($text, $post_id, $selected_role, $selected_group) { $contributor_adn_accounts = ''; $episode = \Podlove\Model\Episode::find_or_create_by_post_id($post_id); $contributions = \Podlove\Modules\Contributors\Model\EpisodeContribution::find_all_by_episode_id($episode->id); $adn_service = \Podlove\Modules\Social\Model\Service::find_one_by_property('type', 'app.net'); if (!$adn_service) { return; } foreach ($contributions as $contribution) { $contributor_adn_accounts .= ''; $social_accounts = \Podlove\Modules\Social\Model\ContributorService::find_all_by_contributor_id($contribution->contributor_id); array_map(function ($account) use($adn_service, &$contributor_adn_accounts, $contribution, $selected_role, $selected_group) { if ($account->service_id == $adn_service->id) { if ($selected_role == '') { if ($selected_group == '') { $contributor_adn_accounts .= "@" . $account->value . " "; } else { if ($contribution->group_id == $selected_group) { $contributor_adn_accounts .= "@" . $account->value . " "; } } } else { if ($selected_group == '' && $contribution->role_id == $selected_role) { $contributor_adn_accounts .= "@" . $account->value . " "; } else { if ($contribution->group_id == $selected_group && $contribution->role_id == $selected_role) { $contributor_adn_accounts .= "@" . $account->value . " "; } } } } }, $social_accounts); } $total_text_length = strlen($text) + strlen($contributor_adn_accounts); if ($total_text_length <= 256) { return str_replace('{episodeContributors}', $contributor_adn_accounts, $text); } return str_replace('{episodeContributors}', '', $text); }