/**
  * Render a template using data. Adds a few common parameters to data.
  * 
  * @see /main/template/default/course_description/
  * @param string $template
  * @param array $data 
  */
 protected function render($template_name, $data)
 {
     $data = (object) $data;
     $data->www = \Chamilo::url();
     $data->messages = isset($data->messages) ? $data->messages : array();
     $javascript = $this->javascript();
     if ($javascript) {
         $data->javascript = $javascript;
     }
     $tpl = new Template();
     foreach ($data as $key => $value) {
         $tpl->assign($key, $value);
     }
     $template = $tpl->get_template($template_name);
     $content = $tpl->fetch($template);
     $tpl->assign('content', $content);
     $tpl->display_one_col_template();
 }
 /**
  * returns all the javascript that is required for easily
  * setting the target people/groups
  * this goes into the $htmlHeadXtra[] array
  */
 public static function to_javascript()
 {
     $www = api_get_path(WEB_PATH);
     $src = $www . 'main/announcements/resources/js/main.js';
     $result = Javascript::tag($src);
     $root = Chamilo::url();
     $code = "var www = '{$root}';\n";
     $code .= Javascript::get_lang('FieldRequired', 'Send2All', 'AddAnAttachment', 'Everybody');
     $result .= Javascript::tag_code($code);
     return $result;
 }
    /**
     * Display the component.
     * 
     * @return string 
     */
    function display()
    {
        if (!Portfolio::is_enabled()) {
            return '';
        }
        $id = $this->id;
        $tool = $this->tool;

        $attributes = $this->attributes;
        $attributes['z-index'] = 100000;
        $s = ' ';
        foreach ($attributes as $key => $value) {
            $s .= $key . '="' . $value . '" ';
        }

        $result = array();
        $result[] = '<span ' . $s . ' >';
        $result[] = '<span class="dropdown" >';
        $result[] = '<a href="#" data-toggle="dropdown" class="dropdown-toggle">';
        $result[] = Display::return_icon('document_send.png', get_lang('Send'), array(), ICON_SIZE_SMALL) . '<b class="caret"></b>';
        $result[] = '</a>';
        $result[] = '<ul class="dropdown-menu">';

        $portfolios = Portfolio::all();
        foreach ($portfolios as $portfolio) {
            $parameters = Uri::course_params();
            $parameters[PortfolioController::PARAM_ACTION] = PortfolioController::ACTION_SHARE;
            $parameters[PortfolioController::PARAM_CONTROLLER] = PortfolioController::NAME;
            $parameters[PortfolioController::PARAM_PORTFOLIO] = $portfolio->get_name();
            $parameters[PortfolioController::PARAM_SECURITY_TOKEN] = self::security_token();
            $parameters[PortfolioController::PARAM_TOOL] = $this->get_tool();
            $parameters[PortfolioController::PARAM_ID] = $id;
            $parameters[PortfolioController::PARAM_TOOL] = $tool;
            $url = Chamilo::url('/main/portfolio/share.php', $parameters);
            $result[] = '<li>';
            $result[] = '<a href="' . $url . '">' . $portfolio->get_title() . '</a>';
            $result[] = '</li>';
        }
        $result[] = '</ul>';
        $result[] = '</span>';
        $result[] = '</span>';
        return implode("\n", $result);
    }
 /**
  * returns all the javascript that is required for easily
  * setting the target people/groups
  * this goes into the $htmlHeadXtra[] array
  */
 public static function to_javascript()
 {
     $www = api_get_path(WEB_PATH);
     /*
              * Do not allow this kind of behaviour. js minifieds should be manage by the template class or assetic or whatever see #4757 for more info
             if (api_get_setting('server_type') == 'test') {
                 $src = $www . 'main/announcements/resources/js/main.js';
             } else {
                 $src = $www . 'main/announcements/resources/js/main.min.js';
             }*/
     $src = $www . 'main/announcements/resources/js/main.js';
     $result = Javascript::tag($src);
     $root = Chamilo::url();
     $code = "var www = '{$root}';\n";
     $code .= Javascript::get_lang('FieldRequired', 'Send2All', 'AddAnAttachment', 'Everybody');
     $result .= Javascript::tag_code($code);
     return $result;
 }