/**
  * 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, amazon wishlist, app.net, bandcamp, bitbucket, bitcoin, deviantart, diaspora, dogecoin, dribbble, facebook, flattr, flickr, generic wishlist, github, google+, instagram, jabber, last.fm, linkedin, litecoin, openstreetmap, paypal, miiverse, pinboard, pinterest, playstation network, skype, soundcloud, soup, steam, steam wishlist, thomann wishlist, twitch, tumblr, twitter, website, xbox live, xing, youtube
  *
  * Example:
  *
  * ```html
  * {% for service in podcast.services({category: "social"}) %}
  *   <a target="_blank" title="{{ service.title }}" href="{{ service.profileUrl }}">
  *		{{ service.image.html({width: 20}) }}
  *   </a>
  * {% endfor %}
  * ```
  * 
  * @accessor
  * @dynamicAccessor podcast.services
  */
 public static function accessorPodcastServices($return, $method_name, $podcast, $args = array())
 {
     return $podcast->with_blog_scope(function () use($args) {
         $category = isset($args['category']) && in_array($args['category'], array("social", "donation", "all")) ? $args['category'] : "all";
         if ($category == "all") {
             $services = ShowService::all("ORDER BY position ASC");
         } else {
             $services = ShowService::find_by_category($category);
         }
         if (isset($args["type"]) && $args["type"]) {
             $services = array_filter($services, function ($s) use($args) {
                 return $s->get_service()->type == $args["type"];
             });
         }
         return array_map(function ($service) {
             return new Template\Service($service, $service->get_service());
         }, $services);
     });
 }
 public function save_service_setting($old, $new, $form_key = 'services', $type = 'social')
 {
     foreach (\Podlove\Modules\Social\Model\ShowService::find_by_category($type) as $service) {
         $service->delete();
     }
     if (!isset($new[$form_key])) {
         return;
     }
     $services_appearances = $new[$form_key];
     $position = 0;
     foreach ($services_appearances as $service_appearance) {
         foreach ($service_appearance as $service_id => $service) {
             $c = new \Podlove\Modules\Social\Model\ShowService();
             $c->position = $position;
             $c->service_id = $service_id;
             $c->value = $service['value'];
             $c->title = $service['title'];
             $c->save();
         }
         $position++;
     }
 }
 public static function podcast_form_extension_form()
 {
     $services = \Podlove\Modules\Social\Model\ShowService::find_by_category();
     \Podlove\Modules\Social\Social::services_form_table($services, 'podlove_podcast[services]');
 }