/** * 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); }); }
private function service_column_templates($contributor, $type = 'social') { $contributor_services = \Podlove\Modules\Social\Model\ContributorService::find_by_contributor_id_and_category($contributor->id, $type); $source = ''; foreach ($contributor_services as $contributor_service) { $service = $contributor_service->get_service(); $source .= "<li>" . $service->image()->setWidth(16)->image(['class' => 'podlove-contributor-list-social-logo']) . "<a href='" . $contributor_service->get_service_url() . "'>" . ($service->url_scheme == '%account-placeholder%' ? 'link' : $contributor_service->value) . "</a>" . "</li>\n"; } return '<ul class="podlove-contributor-social-list">' . $source . '</ul>'; }
public function register_contributor_sections($sections) { $sections['social'] = ['title' => __('Social', 'podlove'), 'fields' => ['services_form_table' => ['field_type' => 'callback', 'field_options' => ['nolabel' => true, 'callback' => function () { if (isset($_GET['contributor'])) { $services = \Podlove\Modules\Social\Model\ContributorService::find_by_contributor_id_and_category($_GET['contributor'], 'social'); } else { $services = []; } \Podlove\Modules\Social\Social::services_form_table($services, 'podlove_contributor[services]', 'social'); }]]]]; $sections['donation'] = ['title' => __('Donation', 'podlove'), 'fields' => ['services_form_table' => ['field_type' => 'callback', 'field_options' => ['nolabel' => true, 'callback' => function () { if (isset($_GET['contributor'])) { $services = \Podlove\Modules\Social\Model\ContributorService::find_by_contributor_id_and_category($_GET['contributor'], 'donation'); } else { $services = []; } \Podlove\Modules\Social\Social::services_form_table($services, 'podlove_contributor[donations]', 'donation'); }]]]]; return $sections; }