Ejemplo n.º 1
0
    // from GET parameters
    $template_family = $family;
} elseif (isset($node_family) and !empty($node_family)) {
    // from node definition
    $template_family = $node_family;
} elseif (isset($course_family) and !empty($course_family)) {
    // from course definition
    $template_family = $course_family;
} elseif (isset($user_family) and !empty($user_family)) {
    // from user's profile
    $template_family = $user_family;
} else {
    $template_family = ADA_TEMPLATE_FAMILY;
    // default template famliy
}
$layoutObj = read_layout_from_DB($id_profile, $template_family);
$layout_CSS = $layoutObj->CSS_filename;
$layout_template = $layoutObj->template;
// END LAYOUT
// *****************************************************
/* 1.
Retrieving node's data filtered by user'properties

*/
// lettura dei dati dal database
//$userObj->get_history_dataFN($id_course_instance) ;
if ($period != "all") {
    // Nodi visitati negli ultimi n giorni. Periodo in giorni.
    $history .= "<p>";
    //    $history .= translateFN("Nodi visitati negli ultimi $period giorni:") ;
    $history .= $user_historyObj->history_nodes_list_filtered_FN($period);
Ejemplo n.º 2
0
 public static function render($layout_dataAr = array(), $content_dataAr = array(), $renderer = NULL, $options = array(), $menuoptions = array())
 {
     /**
      * @author giorgio 03/apr/2014
      * 
      * If query string wants a pdf, let's obey by setting the $renderer
      */
     if (isset($_GET['pdfExport']) && intval($_GET['pdfExport']) === 1) {
         $renderer = ARE_PDF_RENDER;
     }
     if (!isset($id_profile)) {
         $id_profile = null;
     }
     switch ($renderer) {
         case ARE_PRINT_RENDER:
             $layoutObj = read_layout_from_DB($id_profile, isset($layout_dataAr['family']) ? $layout_dataAr['family'] : '', isset($layout_dataAr['node_type']) ? $layout_dataAr['node_type'] : '', isset($layout_dataAr['node_author_id']) ? $layout_dataAr['node_author_id'] : '', isset($layout_dataAr['node_course_id']) ? $layout_dataAr['node_course_id'] : '', isset($layout_dataAr['module_dir']) ? $layout_dataAr['module_dir'] : '');
             // TODO: controlli su layoutObj
             $layout_template = $layoutObj->template;
             $layout_CSS = $layoutObj->CSS_filename;
             if (!empty($layout_dataAr['CSS_filename']) && is_array($layout_dataAr['CSS_filename'])) {
                 $tmp = explode(';', $layoutObj->CSS_filename);
                 $tmp = array_merge($tmp, $layout_dataAr['CSS_filename']);
                 //$tmp = array_merge($layout_dataAr['JS_filename'],$tmp);
                 $layoutObj->CSS_filename = implode(';', $tmp);
                 $layout_CSS = implode(';', $tmp);
             }
             /*
              * optional arguments for HTML constructor
              */
             $user_name = isset($options['user_name']) ? $options['user_name'] : '';
             $course_title = isset($options['course_title']) ? $options['course_title'] : '';
             $node_title = isset($options['node_title']) ? $options['user_name'] : '';
             $meta_keywords = isset($options['meta_keywords']) ? $options['meta_keywords'] : '';
             $author = isset($options['author']) ? $options['author'] : '';
             $meta_refresh_time = isset($options['meta_refresh_time']) ? $options['meta_refresh_time'] : '';
             $meta_refresh_url = isset($options['meta_refresh_url']) ? $options['meta_refresh_url'] : '';
             $onload_func = isset($options['onload_func']) ? $options['onload_func'] : '';
             $static_dir = isset($options['static_dir']) ? $options['static_dir'] : ROOT_DIR . 'services/media/cache/';
             $html_renderer = new HTML($layout_template, $layout_CSS, $user_name, $course_title, $node_title, $meta_keywords, $author, null, null, $onload_func, $layoutObj);
             $html_renderer->fillin_templateFN($content_dataAr);
             $imgpath = dirname($layout_template);
             $html_renderer->resetImgSrcFN($imgpath, isset($layoutObj->family) ? $layoutObj->family : ADA_TEMPLATE_FAMILY);
             $html_renderer->apply_styleFN();
             $html_renderer->outputFN('page');
             break;
         case ARE_XML_RENDER:
             $today = today_dateFN();
             $title = $options['course_title'];
             $portal = $options['portal'];
             $xml_renderer = new Generic_XML($portal, $today, $title);
             $xml_renderer->idNode = $options['id'];
             $xml_renderer->URL = $options['URL'];
             $xml_renderer->fillinFN($content_dataAr);
             $xml_renderer->outputFN('page');
             break;
         case ARE_FILE_RENDER:
             $layoutObj = read_layout_from_DB($id_profile, isset($layout_dataAr['family']) ? $layout_dataAr['family'] : null, isset($layout_dataAr['node_type']) ? $layout_dataAr['node_type'] : null, isset($layout_dataAr['node_author_id']) ? $layout_dataAr['node_author_id'] : null, isset($layout_dataAr['node_course_id']) ? $layout_dataAr['node_course_id'] : null, isset($layout_dataAr['module_dir']) ? $layout_dataAr['module_dir'] : null);
             // TODO: controlli su layoutObj
             $layout_template = $layoutObj->template;
             $layout_CSS = $layoutObj->CSS_filename;
             /*
              * optional arguments for HTML constructor
              */
             $user_name = isset($options['user_name']) ? $options['user_name'] : '';
             $course_title = isset($options['course_title']) ? $options['course_title'] : '';
             $node_title = isset($options['node_title']) ? $options['user_name'] : '';
             $meta_keywords = isset($options['meta_keywords']) ? $options['meta_keywords'] : '';
             $author = isset($options['author']) ? $options['author'] : '';
             $meta_refresh_time = isset($options['meta_refresh_time']) ? $options['meta_refresh_time'] : '';
             $meta_refresh_url = isset($options['meta_refresh_url']) ? $options['meta_refresh_url'] : '';
             $onload_func = isset($options['onload_func']) ? $options['onload_func'] : '';
             $static_dir = isset($options['static_dir']) ? $options['static_dir'] : ROOT_DIR . 'services/media/cache/';
             if (!file_exists($static_dir)) {
                 mkdir($static_dir);
             }
             $static_filename = md5($_SERVER['REQUEST_URI'] . $_SERVER['QUERY_STRING']);
             $cached_file = $static_dir . $static_filename;
             $html_renderer = new HTML($layout_template, $layout_CSS, $user_name, $course_title, $node_title, $meta_keywords, $author, $meta_refresh_time, $meta_refresh_url, $onload_func, $layoutObj);
             $html_renderer->full_static_filename = $cached_file;
             $html_renderer->static_filename = $static_filename;
             $html_renderer->fillin_templateFN($content_dataAr);
             $imgpath = dirname($layout_template);
             $html_renderer->resetImgSrcFN($imgpath, isset($layoutObj->family) ? $layoutObj->family : ADA_TEMPLATE_FAMILY);
             $html_renderer->apply_styleFN();
             $html_renderer->outputFN('file');
             break;
         case ARE_HTML_RENDER:
         case ARE_PDF_RENDER:
         default:
             $layoutObj = read_layout_from_DB($id_profile, isset($layout_dataAr['family']) ? $layout_dataAr['family'] : null, isset($layout_dataAr['node_type']) ? $layout_dataAr['node_type'] : null, isset($layout_dataAr['node_author_id']) ? $layout_dataAr['node_author_id'] : null, isset($layout_dataAr['node_course_id']) ? $layout_dataAr['node_course_id'] : null, isset($layout_dataAr['module_dir']) ? $layout_dataAr['module_dir'] : null);
             // TODO: controlli su layoutObj
             $layout_template = $layoutObj->template;
             $layout_CSS = $layoutObj->CSS_filename;
             /**
              * @author giorgio 19/ago/2014
              * 
              * fix javascript inclusion as follows:
              * - if the PhP has not included JQUERY, include it as first element
              * - if the PhP has not included SEMANTICUI_JS, include it just after JQUERY
              * - if the PhP has not included JQUERY_NO_CONFLICT include it as last element
              * 
              * This way, any PhP can include what it needs and in the right order of inclusion
              */
             /**
              * @author giorgio 10/nov/2014
              * 
              * If the browser is InternetExplorer 8 or less, use smartmenus instead of semantic-ui
              * 
              * NOTE: $_SESSION['IE-version'] is set by module_init_functions.inc.php
              */
             $JSToUse = isset($_SESSION['IE-version']) && $_SESSION['IE-version'] !== false && $_SESSION['IE-version'] <= 8 ? SMARTMENUS_JS : SEMANTICUI_JS;
             $CSSToUse = isset($_SESSION['IE-version']) && $_SESSION['IE-version'] !== false && $_SESSION['IE-version'] <= 8 ? SMARTMENUS_CSS : SEMANTICUI_CSS;
             if (!empty($layout_dataAr['JS_filename']) && is_array($layout_dataAr['JS_filename'])) {
                 // if jquery is not included in the script itself, add it at first position
                 if (!in_array(JQUERY, $layout_dataAr['JS_filename'])) {
                     $layout_dataAr['JS_filename'] = array_merge(array(JQUERY), $layout_dataAr['JS_filename']);
                 }
                 // if $JSToUse is not included in the script itself, add it just after JQUERY
                 if (!in_array($JSToUse, $layout_dataAr['JS_filename'])) {
                     // find the key for JQUERY
                     $key = array_search(JQUERY, $layout_dataAr['JS_filename']);
                     // add $JSToUse after JQUERY slicing the original array
                     $layout_dataAr['JS_filename'] = array_merge(array_slice($layout_dataAr['JS_filename'], 0, $key + 1), array($JSToUse), array_slice($layout_dataAr['JS_filename'], $key + 1));
                 }
                 // if jquery noconflict is not included in the script itself, add it at last position
                 if (!in_array(JQUERY_NO_CONFLICT, $layout_dataAr['JS_filename'])) {
                     array_push($layout_dataAr['JS_filename'], JQUERY_NO_CONFLICT);
                 }
                 $tmp = explode(';', $layoutObj->JS_filename);
                 $tmp = array_merge($tmp, $layout_dataAr['JS_filename']);
                 //$tmp = array_merge($layout_dataAr['JS_filename'],$tmp);
                 $layoutObj->JS_filename = implode(';', $tmp);
             } else {
                 // add jquery, semantic and jquery noconflict
                 $layoutObj->JS_filename .= ';' . JQUERY . ';' . $JSToUse . ';' . JQUERY_NO_CONFLICT;
             }
             $tmp = explode(';', $layoutObj->CSS_filename);
             if (!empty($layout_dataAr['CSS_filename']) && is_array($layout_dataAr['CSS_filename'])) {
                 $tmp = array_merge($tmp, $layout_dataAr['CSS_filename']);
             }
             /**
              * @author giorgio 06/ago/2014
              * add $CSSToUse last
              */
             $tmp[] = $CSSToUse;
             //$tmp = array_merge($layout_dataAr['JS_filename'],$tmp);
             $layoutObj->CSS_filename = implode(';', $tmp);
             $layout_CSS = implode(';', $tmp);
             /*
              * optional arguments for HTML constructor
              */
             $user_name = isset($options['user_name']) ? $options['user_name'] : '';
             $course_title = isset($options['course_title']) ? $options['course_title'] : '';
             $node_title = isset($options['node_title']) ? $options['user_name'] : '';
             $meta_keywords = isset($options['meta_keywords']) ? $options['meta_keywords'] : '';
             $author = isset($options['author']) ? $options['author'] : '';
             $meta_refresh_time = isset($options['meta_refresh_time']) ? $options['meta_refresh_time'] : '';
             $meta_refresh_url = isset($options['meta_refresh_url']) ? $options['meta_refresh_url'] : '';
             $onload_func = isset($options['onload_func']) ? $options['onload_func'] : '';
             /**
              * @author giorgio 19/ago/2014
              *
              * make menu here
              */
             require_once ROOT_DIR . '/include/menu_class.inc.php';
             // menu property created 'on-the-fly'
             $layoutObj->menu = new Menu($layoutObj->module_dir, basename($_SERVER['SCRIPT_FILENAME']), $_SESSION['sess_userObj']->getType(), $menuoptions);
             if ($renderer == ARE_PDF_RENDER) {
                 $orientation = isset($options['orientation']) ? $options['orientation'] : '';
                 $outputfile = isset($options['outputfile']) ? $options['outputfile'] : '';
                 // must be called $html_renderer for below code, but it's not :)
                 $html_renderer = new PDF($layout_template, $layout_CSS, $user_name, $course_title, $node_title, $meta_keywords, $author, $meta_refresh_time, $meta_refresh_url, $onload_func, $layoutObj, $outputfile, $orientation);
             } else {
                 $html_renderer = new HTML($layout_template, $layout_CSS, $user_name, $course_title, $node_title, $meta_keywords, $author, $meta_refresh_time, $meta_refresh_url, $onload_func, $layoutObj);
             }
             /**
              * @author giorgio 25/set/2013
              * merge the content_dataAr with the one generated by the widgets if it's needed
              */
             if (!is_null($layoutObj->WIDGET_filename)) {
                 if (!isset($layout_dataAr['widgets'])) {
                     $layout_dataAr['widgets'] = '';
                 }
                 $widgets_dataAr = $html_renderer->fillin_widgetsFN($layoutObj->WIDGET_filename, $layout_dataAr['widgets']);
                 if (!ADA_Error::isError($widgets_dataAr)) {
                     $content_dataAr = array_merge($content_dataAr, $widgets_dataAr);
                 }
             }
             /**
              * adamenu must be the first key of $content_dataAr
              * for the template_field substitution to work inside the menu
              */
             $content_dataAr = array('adamenu' => $layoutObj->menu->getHtml()) + $content_dataAr;
             $content_dataAr['isVertical'] = $layoutObj->menu->isVertical() ? ' vertical' : '';
             $html_renderer->fillin_templateFN($content_dataAr);
             $imgpath = dirname($layout_template);
             // $html_renderer->resetImgSrcFN($imgpath,$template_family);
             $html_renderer->resetImgSrcFN($imgpath, $layoutObj->family);
             $html_renderer->apply_styleFN();
             $html_renderer->outputFN($renderer == ARE_PDF_RENDER ? 'pdf' : 'page');
             break;
     }
 }