Exemplo n.º 1
0
 /**
  * Get/set our social helper class
  */
 private function social_helper()
 {
     if (!isset($this->social_helper)) {
         $this->social_helper = reason_get_social_integration_helper();
     }
     return $this->social_helper;
 }
Exemplo n.º 2
0
 /**
  * Make sure that the model is configured with a valid URL.
  *
  * @return string json
  */
 function build()
 {
     if ($site_id = $this->config('site_id')) {
         $s = get_microtime();
         $es = new entity_selector();
         $es->add_type(id_of('social_account_type'));
         $es->add_right_relationship($site_id, relationship_id_of('site_to_social_account'));
         $es->add_rel_sort_field($site_id, relationship_id_of('site_to_social_account'));
         $es->set_order('rel_sort_order ASC');
         $es->limit_tables();
         $es->limit_fields();
         if ($results = $es->run_one()) {
             $result_keys = array_keys($results);
             $sih = reason_get_social_integration_helper();
             foreach ($result_keys as $id) {
                 // get the integrator if it supports the SocialAccountProfileLinks interface
                 if ($integrator = $sih->get_social_account_integrator($id, 'SocialAccountProfileLinks')) {
                     $profile_links[$id]['icon'] = $integrator->get_profile_link_icon($id);
                     $profile_links[$id]['text'] = $integrator->get_profile_link_text($id);
                     $profile_links[$id]['href'] = $integrator->get_profile_link_href($id);
                 }
             }
             if (!empty($profile_links)) {
                 return $profile_links;
             }
         }
         return false;
     } else {
         trigger_error('The ReasonSocialProfileLinksModel must be provided with the configuration parameter site_id.', FATAL);
     }
 }
Exemplo n.º 3
0
		/**
		 * Get social sharing links from social sharing integrators that support social sharing links.
		 *
		 * Returns an array where each item is an array with these keys:
		 *
		 * - src (for the image)
		 * - alt (for the image)
		 * - href (the actual link)
		 *
		 * We only return items is the page is public and the publication has social sharing enabled.
		 *
		 * @param object
		 * @return array
		 */
		function get_item_social_sharing($item)
		{
			if ($this->page_is_public() && 
				$this->publication->has_value('enable_social_sharing') && (
				$this->publication->get_value('enable_social_sharing') == 'yes' )
				)
			{
				reason_include_once('classes/social.php');
				$helper = reason_get_social_integration_helper();
				$integrators = $helper->get_social_integrators_by_interface('SocialSharingLinks');
				if (!empty($integrators))
				{
					foreach ($integrators as $integrator_type => $integrator)
					{
						$item_social_sharing[$integrator_type]['icon'] = $integrator->get_sharing_link_icon();
						$item_social_sharing[$integrator_type]['text'] = $integrator->get_sharing_link_text();
						$item_social_sharing[$integrator_type]['href'] = $integrator->get_sharing_link_href();
					}
					return $item_social_sharing;
				}
			}
			return false;
		}