Classes

File content/share/ContentSharingActionsMenuService.class.php

File content/share/ContentSharingActionsMenuService.class.php

 1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 
<?php
/**
 * @package     Content
 * @subpackage  Share
 * @copyright   &copy; 2005-2019 PHPBoost
 * @license     https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL-3.0
 * @author      Kevin MASSY <reidlos@phpboost.com>
 * @version     PHPBoost 5.2 - last update: 2018 06 19
 * @since       PHPBoost 5.1 - 2018 01 30
 * @contributor Julien BRISWALTER <j1.seth@phpboost.com>
*/

class ContentSharingActionsMenuService
{
    private static $tpl;

    public static function get_content_sharing_actions_links()
    {
        $content_sharing_actions_menu_links = array();
        $extension_point = AppContext::get_extension_provider_service()->get_extension_point(ContentSharingActionsMenuLinksExtensionPoint::EXTENSION_POINT);

        foreach ($extension_point as $id => $provider)
        {
            foreach ($provider as $link)
            {
                $content_sharing_actions_menu_links[] = $link;
            }
        }
        return $content_sharing_actions_menu_links;
    }

    public static function display_sharing_elements($tpl = null)
    {
        if ($tpl instanceof Template)
        {
            self::$tpl = $tpl;
        }
        else if (!empty($tpl))
        {
            self::$tpl = new FileTemplate($tpl);
        }
        else
        {
            self::$tpl = new FileTemplate('framework/content/share/ContentSharingActionsMenu.tpl');
        }

        $content_sharing_actions_menu_links = self::get_content_sharing_actions_links();
        foreach ($content_sharing_actions_menu_links as $link)
        {
            self::$tpl->assign_block_vars('element', array(
                'ELEMENT' => $link->export()->render()
            ));
        }

        return self::$tpl->render();
    }

    public static function display($tpl = null)
    {
        return ContentManagementConfig::load()->is_content_sharing_enabled() ? self::display_sharing_elements($tpl) : '';
    }
}
?>