Beispiel #1
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $exporter;
     require_once get_config('docroot') . 'artefact/lib.php';
     safe_require('artefact', 'plans');
     $configdata = $instance->get('configdata');
     $smarty = smarty_core();
     if (isset($configdata['artefactid'])) {
         $plan = artefact_instance_from_id($configdata['artefactid']);
         $tasks = ArtefactTypeTask::get_tasks($configdata['artefactid']);
         $template = 'artefact:plans:taskrows.tpl';
         $blockid = $instance->get('id');
         if ($exporter) {
             $pagination = false;
         } else {
             $baseurl = $instance->get_view()->get_url();
             $baseurl .= (false === strpos($baseurl, '?') ? '?' : '&') . 'block=' . $blockid;
             $pagination = array('baseurl' => $baseurl, 'id' => 'block' . $blockid . '_pagination', 'datatable' => 'tasktable_' . $blockid, 'jsonscript' => 'artefact/plans/viewtasks.json.php');
         }
         ArtefactTypeTask::render_tasks($tasks, $template, $configdata, $pagination);
         if ($exporter && $tasks['count'] > $tasks['limit']) {
             $artefacturl = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $configdata['artefactid'] . '&view=' . $instance->get('view');
             $tasks['pagination'] = '<a href="' . $artefacturl . '">' . get_string('alltasks', 'artefact.plans') . '</a>';
         }
         $smarty->assign('owner', $plan->get('owner'));
         $smarty->assign('tags', $plan->get('tags'));
         $smarty->assign('tasks', $tasks);
     } else {
         $smarty->assign('noplans', 'blocktype.plans/plans');
     }
     $smarty->assign('blockid', $instance->get('id'));
     return $smarty->fetch('blocktype:plans:content.tpl');
 }
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $exporter;
     require_once get_config('docroot') . 'artefact/lib.php';
     safe_require('artefact', 'ilps');
     $configdata = $instance->get('configdata');
     $smarty = smarty_core();
     if (isset($configdata['artefactid'])) {
         $units = ArtefactTypeunit::get_units($configdata['artefactid']);
         $template = 'artefact:ilps:unitrows.tpl';
         $blockid = $instance->get('id');
         if ($exporter) {
             $pagination = false;
         } else {
             $pagination = array('baseurl' => $instance->get_view()->get_url() . '&block=' . $blockid, 'id' => 'block' . $blockid . '_pagination', 'datatable' => 'unittable_' . $blockid, 'jsonscript' => 'artefact/ilps/viewunits.json.php');
         }
         ArtefactTypeUnit::render_units($units, $template, $configdata, $pagination);
         if ($exporter && $units['count'] > $units['limit']) {
             $artefacturl = get_config('wwwroot') . 'view/artefact.php?artefact=' . $configdata['artefactid'] . '&amp;view=' . $instance->get('view');
             $units['pagination'] = '<a href="' . $artefacturl . '">' . get_string('allunits', 'artefact.ilps') . '</a>';
         }
         $smarty->assign('units', $units);
     } else {
         $smarty->assign('noilps', 'blocktype.ilps/ilps');
     }
     $smarty->assign('blockid', $instance->get('id'));
     return $smarty->fetch('blocktype:ilps:content.tpl');
 }
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     require_once get_config('docroot') . 'artefact/lib.php';
     $smarty = smarty_core();
     $configdata = $instance->get('configdata');
     $data = array();
     // add in the selected email address
     if (!empty($configdata['email'])) {
         $configdata['artefactids'][] = $configdata['email'];
     }
     // Get data about the profile fields in this blockinstance
     if (!empty($configdata['artefactids'])) {
         $viewowner = get_field('view', 'owner', 'id', $instance->get('view'));
         foreach ($configdata['artefactids'] as $id) {
             try {
                 $artefact = artefact_instance_from_id($id);
                 if (is_a($artefact, 'ArtefactTypeProfile') && $artefact->get('owner') == $viewowner) {
                     $rendered = $artefact->render_self(array('link' => true));
                     $data[$artefact->get('artefacttype')] = $rendered['html'];
                 }
             } catch (ArtefactNotFoundException $e) {
                 log_debug('Artefact not found when rendering contactinfo block instance. ' . 'There might be a bug with deleting artefacts of this type? ' . 'Original error follows:');
                 log_debug($e->getMessage());
             }
         }
     }
     $smarty->assign('profileinfo', $data);
     return $smarty->fetch('blocktype:contactinfo:content.tpl');
 }
Beispiel #4
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     $result = '';
     if (!empty($configdata['artefactids'])) {
         $artefactids = implode(', ', array_map('db_quote', $configdata['artefactids']));
         if (!($mostrecent = get_records_sql_array('SELECT a.title, ' . db_format_tsfield('a.ctime', 'ctime') . ', p.title AS parenttitle, a.id, a.parent
             FROM {artefact} a
             JOIN {artefact} p ON a.parent = p.id
             WHERE a.artefacttype = \'blogpost\'
             AND a.parent IN ( ' . $artefactids . ' ) 
             AND a.owner = (SELECT owner from {view} WHERE id = ?)
             ORDER BY a.ctime DESC
             LIMIT 10', array($instance->get('view'))))) {
             $mostrecent = array();
         }
         // format the dates
         foreach ($mostrecent as &$data) {
             $data->displaydate = format_date($data->ctime);
         }
         $smarty = smarty_core();
         $smarty->assign('mostrecent', $mostrecent);
         $smarty->assign('view', $instance->get('view'));
         $result = $smarty->fetch('blocktype:recentposts:recentposts.tpl');
     }
     return $result;
 }
Beispiel #5
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     $sort = !empty($configdata['sort']) ? $configdata['sort'] : null;
     $limit = !empty($configdata['limitto']) ? $configdata['limitto'] : null;
     $view = $instance->get_view();
     $baseurl = $view->get('type') == 'dashboard' ? $view->get_url() . '?id=' . $view->get('id') : $view->get_url();
     $baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'block=' . $instance->get('id');
     $userid = $view->get('owner');
     if (!$userid) {
         return '';
     }
     $smarty = smarty_core();
     require_once 'group.php';
     // Group stuff
     if (!empty($limit)) {
         list($usergroups, $count) = group_get_user_groups($userid, null, $sort, $limit, 0);
     } else {
         $usergroups = group_get_user_groups($userid, null, $sort);
         $count = count($usergroups);
     }
     foreach ($usergroups as $group) {
         $group->roledisplay = get_string($group->role, 'grouptype.' . $group->grouptype);
     }
     $groups = array('data' => $usergroups, 'count' => $count, 'limit' => $limit, 'offset' => 0);
     $pagination = array('baseurl' => $baseurl, 'id' => 'mygroups_pagination', 'datatable' => 'usergroupstable', 'jsonscript' => 'blocktype/mygroups/mygroups.json.php', 'resultcounttextsingular' => get_string('group', 'group'), 'resultcounttextplural' => get_string('groups', 'group'));
     self::render_items($groups, 'blocktype:mygroups:mygroupslist.tpl', $configdata, $pagination);
     $smarty->assign('USERGROUPS', $groups);
     $smarty->assign('userid', $userid);
     return $smarty->fetch('blocktype:mygroups:mygroups.tpl');
 }
Beispiel #6
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     require_once get_config('docroot') . 'artefact/lib.php';
     $smarty = smarty_core();
     //$configdata = $instance->get('configdata');
     //$configdata['viewid'] = $instance->get('view');
     // Get data about the resume fields the user has
     $return = '';
     if ($artefacts = get_records_sql_array('
         SELECT va.artefact, a.artefacttype
         FROM {view_artefact} va
         INNER JOIN {artefact} a ON (va.artefact = a.id)
         WHERE va.view = ?
         AND va.block = ?', array($instance->get('view'), $instance->get('id')))) {
         foreach ($artefacts as $artefact) {
             $resumefield = $instance->get_artefact_instance($artefact->artefact);
             $rendered = $resumefield->render_self(array('viewid' => $instance->get('view')));
             $result = $rendered['html'];
             if (!empty($rendered['javascript'])) {
                 $result .= '<script type="text/javascript">' . $rendered['javascript'] . '</script>';
             }
             $smarty->assign($artefact->artefacttype, $result);
         }
     }
     return $smarty->fetch('blocktype:entireresume:content.tpl');
 }
Beispiel #7
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $USER;
     $configdata = $instance->get('configdata');
     $limit = isset($configdata['count']) ? (int) $configdata['count'] : 10;
     $userid = $USER->get('id');
     $smarty = smarty_core();
     $sql = '
         SELECT v.id, v.title, v.owner, v.group, v.institution, v.ownerformat, v.urlid
         FROM {view} v
         JOIN {usr_watchlist_view} wv ON wv.view = v.id
         WHERE wv.usr = ?
         ORDER BY v.title
         LIMIT ?';
     $results = get_records_sql_assoc($sql, array($userid, $limit));
     // if there are no watched views, notify the user
     if (!$results) {
         $smarty->assign('watchlistempty', true);
         return $smarty->fetch('blocktype:watchlist:watchlist.tpl');
     }
     View::get_extra_view_info($results, false, false);
     foreach ($results as &$r) {
         $r = (object) $r;
     }
     $smarty->assign('blockid', 'blockinstance_' . $instance->get('id'));
     $smarty->assign('views', array_values($results));
     return $smarty->fetch('blocktype:watchlist:watchlist.tpl');
 }
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     require_once get_config('docroot') . 'artefact/lib.php';
     $configdata = $instance->get('configdata');
     $viewid = $instance->get('view');
     $wwwroot = get_config('wwwroot');
     $files = array();
     if (isset($configdata['artefactids']) && is_array($configdata['artefactids'])) {
         foreach ($configdata['artefactids'] as $artefactid) {
             try {
                 $artefact = $instance->get_artefact_instance($artefactid);
             } catch (ArtefactNotFoundException $e) {
                 continue;
             }
             $file = array('id' => $artefactid, 'title' => $artefact->get('title'), 'description' => $artefact->get('description'), 'size' => $artefact->get('size'), 'ctime' => $artefact->get('ctime'), 'iconsrc' => call_static_method(generate_artefact_class_name($artefact->get('artefacttype')), 'get_icon', array('id' => $artefactid, 'viewid' => $viewid)), 'downloadurl' => $wwwroot);
             if ($artefact instanceof ArtefactTypeProfileIcon) {
                 $file['downloadurl'] .= 'thumb.php?type=profileiconbyid&id=' . $artefactid;
             } else {
                 if ($artefact instanceof ArtefactTypeFile) {
                     $file['downloadurl'] .= 'artefact/file/download.php?file=' . $artefactid . '&view=' . $viewid;
                 }
             }
             $files[] = $file;
         }
     }
     $smarty = smarty_core();
     $smarty->assign('viewid', $instance->get('view'));
     $smarty->assign('files', $files);
     return $smarty->fetch('blocktype:filedownload:filedownload.tpl');
 }
Beispiel #9
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     // this will make sure to unserialize it for us
     $configdata['viewid'] = $instance->get('view');
     // This can be either an image or profileicon. They both implement
     // render_self
     $result = '';
     if (isset($configdata['artefactid'])) {
         $image = $instance->get_artefact_instance($configdata['artefactid']);
         if ($image instanceof ArtefactTypeProfileIcon) {
             $src = get_config('wwwroot') . 'thumb.php?type=profileiconbyid&id=' . $configdata['artefactid'];
             $description = $image->get('title');
         } else {
             $src = get_config('wwwroot') . 'artefact/file/download.php?file=' . $configdata['artefactid'];
             $src .= '&view=' . $instance->get('view');
             $description = $image->get('description');
         }
         if (!empty($configdata['width'])) {
             $src .= '&maxwidth=' . $configdata['width'];
         }
         $result = '<div class="center"><div>';
         $result .= '<a href="' . get_config('wwwroot') . 'view/artefact.php?artefact=' . $configdata['artefactid'] . '&view=' . $instance->get('view') . '"><img src="' . hsc($src) . '" alt="' . hsc($description) . '"></a>';
         $result .= '</div>';
         $description = is_a($image, 'ArtefacttypeImage') ? $image->get('description') : $image->get('title');
         if (!empty($configdata['showdescription']) && $description) {
             $result .= '<p>' . hsc($description) . '</p>';
         }
         $result .= '</div>';
     }
     return $result;
 }
Beispiel #10
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $USER;
     $configdata = $instance->get('configdata');
     $type = isset($configdata['displaytype']) ? $configdata['displaytype'] : 'texticon';
     $showicon = $type == 'icononly' || $type == 'texticon' ? true : false;
     $showtext = $type == 'textonly' || $type == 'texticon' ? true : false;
     // Whether to include email button
     if (isset($configdata['displayemail']) && $configdata['displayemail']) {
         $email = get_field('artefact_internal_profile_email', 'email', 'principal', 1, 'owner', $instance->get('view_obj')->get('owner'));
     } else {
         $email = false;
     }
     if (!isset($configdata['artefactids']) || empty($configdata['artefactids'])) {
         // When we first come into this block, it will have
         // no social profiles configured yet.
         $configdata['artefactids'] = array(0);
     }
     // Include selected social profiles
     $sql = 'SELECT title, description, note FROM {artefact}
         WHERE id IN (' . join(',', $configdata['artefactids']) . ')
             AND owner = ? AND artefacttype = ?
         ORDER BY description ASC';
     if (!($data = get_records_sql_array($sql, array($USER->get('id'), 'socialprofile')))) {
         $data = array();
     }
     safe_require('artefact', 'internal');
     $data = ArtefactTypeSocialprofile::get_profile_icons($data);
     $smarty = smarty_core();
     $smarty->assign('showicon', $showicon);
     $smarty->assign('showtext', $showtext);
     $smarty->assign('profiles', $data);
     $smarty->assign('email', $email);
     return $smarty->fetch('blocktype:socialprofile:content.tpl');
 }
Beispiel #11
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     // this will make sure to unserialize it for us
     if (!isset($configdata['artefactid'])) {
         return '';
     }
     $id = $configdata['artefactid'];
     $image = $instance->get_artefact_instance($id);
     $wwwroot = get_config('wwwroot');
     $viewid = $instance->get('view');
     if ($image instanceof ArtefactTypeProfileIcon) {
         $src = $wwwroot . 'thumb.php?type=profileiconbyid&id=' . $id;
         $description = $image->get('title');
     } else {
         $src = $wwwroot . 'artefact/file/download.php?file=' . $id . '&view=' . $viewid;
         $description = $image->get('description');
     }
     if (!empty($configdata['width'])) {
         $src .= '&maxwidth=' . $configdata['width'];
     }
     $smarty = smarty_core();
     $smarty->assign('url', $wwwroot . 'artefact/artefact.php?artefact=' . $id . '&view=' . $viewid);
     $smarty->assign('src', $src);
     $smarty->assign('description', $description);
     $smarty->assign('showdescription', !empty($configdata['showdescription']) && !empty($description));
     return $smarty->fetch('blocktype:image:image.tpl');
 }
Beispiel #12
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $exporter;
     require_once get_config('docroot') . 'artefact/lib.php';
     safe_require('artefact', 'calendar');
     $smarty = smarty_core();
     $blockid = param_integer('block', '');
     $this_instance_id = $instance->get('id');
     if (!$blockid or $blockid and $blockid == $this_instance_id) {
         $offset = param_integer('offset', 0);
         $limit = param_integer('limit', 3);
     } else {
         $offset = 0;
         $limit = 3;
         $blockid = $this_instance_id;
     }
     $events = ArtefactTypeEvent::get_all_events($blockid, $offset, $limit);
     $template = 'artefact:calendar:eventrows.tpl';
     if ($exporter) {
         $pagination = false;
     } else {
         $baseurl = $instance->get_view()->get_url();
         $baseurl .= (false === strpos($baseurl, '?') ? '?' : '&') . 'block=' . $blockid;
         $pagination = array('baseurl' => $baseurl, 'id' => 'block' . $blockid . '_pagination', 'datatable' => 'eventtable_' . $blockid, 'jsonscript' => 'artefact/calendar/viewevents.json.php');
     }
     ArtefactTypeEvent::render_events($events, $template, $pagination);
     if ($exporter && $events['count'] > $events['limit']) {
         $artefacturl = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $blockid . '&view=' . $instance->get('view');
         $events['pagination'] = '<a href="' . $artefacturl . '">' . get_string('allevents', 'artefact.calendar') . '</a>';
     }
     $smarty->assign('events', $events);
     $smarty->assign('blockid', $blockid);
     return $smarty->fetch('blocktype:events:content.tpl');
 }
Beispiel #13
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $CFG;
     safe_require('artefact', 'courses');
     $configdata = $instance->get('configdata');
     $list_size = isset($configdata['maxcourses']) ? $configdata['maxcourses'] : 8;
     $smarty = smarty_core();
     $smarty->assign('list_size', $list_size);
     $smarty->assign('view', $instance->get('view'));
     return $smarty->fetch('blocktype:mycourses:mycourses.tpl');
 }
Beispiel #14
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     $smarty = smarty_core();
     if (!empty($configdata['collection'])) {
         $views = $instance->get_data('collection', $configdata['collection'])->views();
         if (!empty($views)) {
             $smarty->assign('views', $views['views']);
         }
     }
     $smarty->assign('currentview', $instance->get('view'));
     return $smarty->fetch('blocktype:navigation:navigation.tpl');
 }
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     $smarty = smarty_core();
     if (!empty($configdata['collection'])) {
         $sql = "SELECT cv.*, v.title\n                    FROM {collection_view} cv\n                        LEFT JOIN {collection} c ON cv.collection = c.id\n                        LEFT JOIN {view} v ON cv.view = v.id\n                    WHERE c.id = ?\n                    ORDER BY cv.displayorder, v.title, v.ctime ASC";
         if ($views = get_records_sql_array($sql, array($configdata['collection']))) {
             $smarty->assign('views', $views);
         }
     }
     $smarty->assign('currentview', $instance->get('view'));
     return $smarty->fetch('blocktype:navigation:navigation.tpl');
 }
Beispiel #16
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $USER;
     // Get site wide Embed.ly API key
     $embedlyapikey = get_config_plugin('blocktype', 'embedly', 'embedlysiteapikey');
     // Get user's Embed.ly API key if site wide key is empty or not set
     if (empty($embedlyapikey) || !isset($embedlyapikey)) {
         $owner = $instance->get('view_obj')->get('owner');
         $embedlyapikey = get_account_preference($owner, 'embedlyapikey');
     }
     $configdata = $instance->get('configdata');
     $width = !empty($configdata['width']) ? hsc($configdata['width']) : null;
     $height = !empty($configdata['height']) ? hsc($configdata['height']) : null;
     $align = !empty($configdata['align']) ? hsc($configdata['align']) : 'left';
     $result = '';
     // To silence warning
     if (isset($configdata['mediaid'])) {
         // IE seems to wait for all elements on the page to load
         // fully before the onload event goes off.  This means the
         // view editor isn't initialised until all videos have
         // finished loading, and an invalid video URL can stop the
         // editor from loading and result in an uneditable view.
         // Therefore, when this block appears on first load of the
         // view editing page, keep the embed code out of the page
         // initially and add it in after the page has loaded.
         $url = 'http://api.embed.ly/1/oembed?key=' . $embedlyapikey . '&url=' . urlencode($configdata['mediaid']) . '&maxwidth=' . $width . '&maxheight=' . $height . '&wmode=transparent';
         $request = array(CURLOPT_URL => $url);
         $result = mahara_http_request($request);
         $data = json_decode($result->data, true);
         $result = '<div class="' . $align . '">';
         $result .= '<p>' . $configdata['mediadesc'] . '</p>';
         switch ($data['type']) {
             case 'photo':
                 $result .= '<img src="' . $data['url'] . '" width="' . $width . '" height="' . $height . '" border="0">';
                 break;
             case 'video':
             case 'rich':
                 $result .= $data['html'];
                 break;
             case 'link':
                 $result .= $configdata['mediaid'];
                 break;
         }
         if (isset($data['description']) && !empty($configdata['showdescription'])) {
             $result .= '<p>' . nl2br($data['description']) . '</p>';
         }
         $result .= '</div>';
     }
     return $result;
 }
Beispiel #17
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     // Check if XSLT extension is loaded properly, because we will need it...
     // The XSL extension implements the XSL standard, performing XSLT transformations using the libxslt library.
     $xslext = extension_loaded('xsl');
     if (!$xslext) {
         $missingextensions = array();
         !$xslext && ($missingextensions[] = 'xsl');
         $errormsg = '<p>' . get_string('europassextensionmissing', 'artefact.europass') . '</p>';
         $errormsg .= '<ul>';
         foreach ($missingextensions as $extension) {
             $errormsg .= '<li><a href="http://www.php.net/' . $extension . '">' . $extension . '</a></li>';
         }
         $errormsg .= '</ul>';
         return $errormsg;
         exit;
     }
     global $USER;
     $configdata = $instance->get('configdata');
     if ($configdata == array()) {
         $locale = set_default_locale(get_config('lang'));
     } else {
         $locale = $configdata['locale'];
     }
     $configdata['viewid'] = $instance->get('view');
     // Load up the Europass CV generated XML string
     //$xmlDoc = new DOMDocument;
     //$xmlDoc->loadXML(generate_europasscv_xml((!empty($configdata['userid']) ? $configdata['userid'] : $USER->get('id')), true, $locale, (!empty($configdata['internaldate']) ? $configdata['internaldate'] : 'dmy11'), (!empty($configdata['externaldate']) ? $configdata['externaldate'] : '/numeric/long')));
     $xmlDoc = simplexml_load_string(generate_europasscv_xml(!empty($configdata['userid']) ? $configdata['userid'] : $USER->get('id'), true, $locale, !empty($configdata['internaldate']) ? $configdata['internaldate'] : 'dmy11', !empty($configdata['externaldate']) ? $configdata['externaldate'] : '/numeric/long'));
     // Load up the appropriate XSL file, according to selected locale
     //$xslDoc = new DOMDocument;
     //$xslDoc->load(get_config('docroot') . 'artefact/europass/blocktype/europasscv/xsl/cv_' . $locale . '_V2.0.xsl');
     $xslDoc = simplexml_load_string(file_get_contents(get_config('wwwroot') . 'artefact/europass/blocktype/europasscv/xsl/cv_' . $locale . '_V2.0.xsl'));
     //Start the XSLT processor and import stylesheet
     $xslt = new XSLTProcessor();
     $xslt->importStyleSheet($xslDoc);
     // Apply the transformation
     $html = $xslt->transformToXml($xmlDoc);
     $start = stripos($html, '<body>');
     $finish = stripos($html, '</body>');
     $result = '<link rel="stylesheet" type="text/css" href="' . get_config('wwwroot') . 'artefact/europass/theme/raw/static/style/html.css">';
     //$result .= '<table width="700" border="0" cellspacing="0" cellpadding="0" class="CV" id="CV">';
     $result .= substr($html, $start + 6, $finish - $start);
     //$result .= '</table>';
     $result = html_entity_decode($result);
     // Replace the following reference because it does not exist anymore:
     // http://europass.cedefop.europa.eu/instruments/images/logospace.gif
     $result = str_replace('http://europass.cedefop.europa.eu/instruments/images/logospace.gif', get_config('wwwroot') . 'artefact/europass/images/space.png', $result);
     return $result;
 }
Beispiel #18
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $CFG;
     $configdata = $instance->get('configdata');
     $result = '';
     $width = !empty($configdata['width']) ? hsc($configdata['width']) : self::$default_width;
     $height = !empty($configdata['height']) ? hsc($configdata['height']) : self::$default_height;
     if (isset($configdata['videoid'])) {
         $block = $instance->get('id');
         $configuring = $block == param_integer('blockconfig', 0);
         $result = GcrFileLib::getVideoEmbedHtml($configdata['videoid'], $width, $height);
     }
     return $result;
 }
Beispiel #19
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     // this will make sure to unserialize it for us
     $configdata['viewid'] = $instance->get('view');
     if (isset($configdata['artefactid'])) {
         $pdf = $instance->get_artefact_instance($configdata['artefactid']);
         if (!file_exists($pdf->get_path())) {
             return '';
         }
         return '<iframe src="' . get_config('wwwroot') . 'artefact/file/blocktype/pdf/viewer.php?file=' . $configdata['artefactid'] . '&view=' . $instance->get('view') . '" width="100%" height="500" frameborder="0"></iframe>';
     }
     return '';
 }
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     // this will make sure to unserialize it for us
     $configdata['viewid'] = $instance->get('view');
     $result = '';
     if (isset($configdata['artefactid'])) {
         $html = $instance->get_artefact_instance($configdata['artefactid']);
         if (!file_exists($html->get_path())) {
             return;
         }
         $result = clean_html(file_get_contents($html->get_path()));
     }
     return $result;
 }
Beispiel #21
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     $result = '';
     $limit = isset($configdata['count']) ? (int) $configdata['count'] : 10;
     if (!empty($configdata['artefactids'])) {
         $before = 'TRUE';
         if ($instance->get_view()->is_submitted()) {
             if ($submittedtime = $instance->get_view()->get('submittedtime')) {
                 // Don't display posts added after the submitted date.
                 $before = "a.ctime < '{$submittedtime}'";
             }
         }
         $artefactids = implode(', ', array_map('db_quote', $configdata['artefactids']));
         if (!($mostrecent = get_records_sql_array('SELECT a.title, ' . db_format_tsfield('a.ctime', 'ctime') . ', p.title AS parenttitle, a.id, a.parent
             FROM {artefact} a
             JOIN {artefact} p ON a.parent = p.id
             JOIN {artefact_blog_blogpost} ab ON (ab.blogpost = a.id AND ab.published = 1)
             WHERE a.artefacttype = \'blogpost\'
             AND a.parent IN ( ' . $artefactids . ' )
             AND a.owner = (SELECT "owner" from {view} WHERE id = ?)
             AND ' . $before . '
             ORDER BY a.ctime DESC, a.id DESC
             LIMIT ' . $limit, array($instance->get('view'))))) {
             $mostrecent = array();
         }
         // format the dates
         foreach ($mostrecent as &$data) {
             $data->displaydate = format_date($data->ctime);
         }
         $smarty = smarty_core();
         $smarty->assign('mostrecent', $mostrecent);
         $smarty->assign('view', $instance->get('view'));
         $smarty->assign('blockid', $instance->get('id'));
         $smarty->assign('editing', $editing);
         if ($editing) {
             // Get id and title of configued blogs
             $recentpostconfigdata = $instance->get('configdata');
             $wherestm = ' WHERE id IN (' . join(',', array_fill(0, count($recentpostconfigdata['artefactids']), '?')) . ')';
             if (!($selectedblogs = get_records_sql_array('SELECT id, title FROM {artefact}' . $wherestm, $recentpostconfigdata['artefactids']))) {
                 $selectedblogs = array();
             }
             $smarty->assign('blogs', $selectedblogs);
         }
         $result = $smarty->fetch('blocktype:recentposts:recentposts.tpl');
     }
     return $result;
 }
Beispiel #22
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     safe_require('artefact', 'survey');
     //require_once(dirname(dirname(dirname(__FILE__))) . '/dwoo/function.survey_name.php');
     $configdata = $instance->get('configdata');
     // this will make sure to unserialize it for us
     $survey = isset($configdata['survey']) ? $configdata['survey'] : '';
     $userid = isset($configdata['userid']) ? $configdata['userid'] : '';
     //$showresponses = (isset($configdata['showresponses']) ? $configdata['showresponses'] : false);
     //$showresults = (isset($configdata['showresults']) ? $configdata['showresults'] : true);
     $showchart = isset($configdata['showchart']) ? $configdata['showchart'] : true;
     $palette = isset($configdata['palette']) ? $configdata['palette'] : 'default';
     $legend = isset($configdata['legend']) ? $configdata['legend'] : 'key';
     $fonttype = isset($configdata['fonttype']) ? $configdata['fonttype'] : 'sans';
     $fontsize = isset($configdata['fontsize']) ? $configdata['fontsize'] : 10;
     $height = isset($configdata['height']) ? $configdata['height'] : 250;
     $width = isset($configdata['width']) ? $configdata['width'] : 400;
     $artefactids = get_records_sql_array("SELECT\ta.id\n\t\t\tFROM {artefact} a\n\t\t\tWHERE a.artefacttype = 'survey' AND a.title = ? AND a.owner = ?\n\t\t\tORDER BY a.ctime DESC, a.mtime DESC", array($survey, $userid));
     $data = array();
     $first = true;
     foreach ($artefactids as $artefactid) {
         if ($first) {
             $alpha = 30;
         } else {
             $alpha = 10;
         }
         $data[] = array('id' => $artefactid->id, 'palette' => $palette, 'legend' => $legend, 'fonttype' => $fonttype, 'fontsize' => $fontsize, 'height' => $height, 'width' => $width, 'alpha' => $alpha);
         $first = false;
     }
     $smarty = smarty_core();
     //$smarty->addPlugin('survey_name', 'Dwoo_Plugin_survey_name');
     $smarty->assign('CHART', $showchart ? true : false);
     $smarty->assign('data', $data);
     return $smarty->fetch('blocktype:surveyhistory:surveyhistory.tpl');
 }
Beispiel #23
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     safe_require('artefact', 'survey');
     //require_once(dirname(dirname(dirname(__FILE__))) . '/dwoo/function.survey_name.php');
     $configdata = $instance->get('configdata');
     // this will make sure to unserialize it for us
     if (!isset($configdata['artefactid'])) {
         return '';
     }
     $id = $configdata['artefactid'];
     $survey = $instance->get_artefact_instance($id);
     $showresponses = isset($configdata['showresponses']) ? $configdata['showresponses'] : false;
     $showresults = isset($configdata['showresults']) ? $configdata['showresults'] : true;
     $showchart = isset($configdata['showchart']) ? $configdata['showchart'] : true;
     $palette = isset($configdata['palette']) ? $configdata['palette'] : 'default';
     $legend = isset($configdata['legend']) ? $configdata['legend'] : 'key';
     $fonttype = isset($configdata['fonttype']) ? $configdata['fonttype'] : 'sans';
     $fontsize = isset($configdata['fontsize']) ? $configdata['fontsize'] : 10;
     $height = isset($configdata['height']) ? $configdata['height'] : 250;
     $width = isset($configdata['width']) ? $configdata['width'] : 400;
     $smarty = smarty_core();
     //$smarty->addPlugin('survey_name', 'Dwoo_Plugin_survey_name');
     $smarty->assign('RESPONSES', $showresponses ? true : false);
     $smarty->assign('responseshtml', ArtefactTypeSurvey::build_user_responses_output_html($survey->get('title'), unserialize($survey->get('description'))));
     $smarty->assign('RESULTS', $showresults ? true : false);
     $smarty->assign('resultshtml', ArtefactTypeSurvey::build_user_responses_summary_html($survey->get('title'), unserialize($survey->get('description'))));
     $smarty->assign('CHART', $showchart ? true : false);
     $smarty->assign('charturl', get_config('wwwroot') . 'artefact/survey/chart.php?id=' . $id . '&width=' . $width . '&height=' . $height . '&palette=' . $palette . '&legend=' . $legend . '&fonttype=' . $fonttype . '&fontsize=' . $fontsize);
     return $smarty->fetch('blocktype:survey:survey.tpl');
 }
Beispiel #24
0
 public static function instance_config_form(BlockInstance $instance)
 {
     $configdata = $instance->get('configdata');
     safe_require('artefact', 'file');
     $instance->set('artefactplugin', 'file');
     return array('artefactfieldset' => array('type' => 'fieldset', 'collapsible' => true, 'collapsed' => true, 'legend' => get_string('Files', 'blocktype.file/filedownload'), 'class' => 'last with-formgroup', 'elements' => array('artefactid' => self::filebrowser_element($instance, isset($configdata['artefactids']) ? $configdata['artefactids'] : null))));
 }
Beispiel #25
0
 public static function instance_config_form(BlockInstance $instance)
 {
     $configdata = $instance->get('configdata');
     safe_require('artefact', 'file');
     $instance->set('artefactplugin', 'file');
     return array('artefactid' => self::filebrowser_element($instance, isset($configdata['artefactid']) ? array($configdata['artefactid']) : null), 'showdescription' => array('type' => 'switchbox', 'title' => get_string('showdescription', 'blocktype.file/image'), 'defaultvalue' => !empty($configdata['showdescription']) ? true : false), 'width' => array('type' => 'text', 'title' => get_string('width', 'blocktype.file/image'), 'size' => 3, 'description' => get_string('widthdescription1', 'blocktype.file/image'), 'rules' => array('minvalue' => 16, 'maxvalue' => get_config('imagemaxwidth')), 'defaultvalue' => isset($configdata['width']) ? $configdata['width'] : ''));
 }
Beispiel #26
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     require_once get_config('docroot') . 'artefact/lib.php';
     $configdata = $instance->get('configdata');
     $configdata['viewid'] = $instance->get('view');
     $configdata['simpledisplay'] = true;
     // This can be either an image or profileicon. They both implement
     // render_self
     $result = '';
     if (isset($configdata['artefactid'])) {
         $folder = $instance->get_artefact_instance($configdata['artefactid']);
         $result = $folder->render_self($configdata);
         $result = $result['html'];
     }
     return $result;
 }
Beispiel #27
0
 public static function instance_config_form(BlockInstance $instance)
 {
     $configdata = $instance->get('configdata');
     safe_require('artefact', 'file');
     $instance->set('artefactplugin', 'file');
     return array('artefactids' => self::filebrowser_element($instance, isset($configdata['artefactids']) ? $configdata['artefactids'] : null));
 }
Beispiel #28
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $THEME;
     $configdata = $instance->get('configdata');
     if (!isset($configdata['license'])) {
         return '';
     }
     $licensetype = reset(preg_grep('/^([a-z\\-]+)$/', array($configdata['license'])));
     if (isset($configdata['version'])) {
         $licenseversion = get_string('version' . $configdata['version'], 'blocktype.creativecommons');
     } else {
         $licenseversion = get_string('version30', 'blocktype.creativecommons');
     }
     $licenseurl = "http://creativecommons.org/licenses/{$licensetype}/{$licenseversion}/";
     $view = $instance->get_view();
     $workname = '<span rel="dc:type" href="http://purl.org/dc/dcmitype/Text" property="dc:title">' . $view->display_title(true, false, false) . '</span>';
     $authorurl = $view->owner_link();
     $authorname = hsc($view->formatted_owner());
     $licensename = get_string('cclicensename', 'blocktype.creativecommons', get_string($licensetype, 'blocktype.creativecommons'), $licenseversion);
     $licenselink = '<a rel="license" href="' . $licenseurl . '">' . $licensename . '</a>';
     $attributionlink = '<a rel="cc:attributionURL" property="cc:attributionName" href="' . $authorurl . '">' . $authorname . '</a>';
     $licensestatement = get_string('cclicensestatement', 'blocktype.creativecommons', $workname, $attributionlink, $licenselink);
     $permissionlink = '<a rel="cc:morePermissions" href="' . $authorurl . '">' . $authorname . '</a>';
     $otherpermissions = get_string('otherpermissions', 'blocktype.creativecommons', $permissionlink);
     $smarty = smarty_core();
     $smarty->assign('licenseurl', $licenseurl);
     $smarty->assign('licenselogo', $THEME->get_url('images/' . $licensetype . '-3_0.png', false, 'blocktype/creativecommons'));
     $smarty->assign('licensestatement', $licensestatement);
     $smarty->assign('otherpermissions', $otherpermissions);
     return $smarty->fetch('blocktype:creativecommons:statement.tpl');
 }
Beispiel #29
0
 public static function instance_config_form(BlockInstance $instance)
 {
     $configdata = $instance->get('configdata');
     $options = range(0, 100);
     unset($options[0]);
     return array('numtoshow' => array('type' => 'select', 'title' => get_string('options_numtoshow_title', 'blocktype.groupmembers'), 'description' => get_string('options_numtoshow_desc', 'blocktype.groupmembers'), 'defaultvalue' => !empty($configdata['numtoshow']) ? $configdata['numtoshow'] : self::$default_numtoshow, 'options' => $options), 'order' => array('type' => 'select', 'title' => get_string('options_order_title', 'blocktype.groupmembers'), 'description' => get_string('options_order_desc', 'blocktype.groupmembers'), 'defaultvalue' => !empty($configdata['order']) ? $configdata['order'] : 'latest', 'options' => array('latest' => get_string('Latest', 'blocktype.groupmembers'), 'random' => get_string('Random', 'blocktype.groupmembers'))));
 }
Beispiel #30
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     if (!isset($configdata['appsid'])) {
         return;
     }
     $apps = self::make_apps_url($configdata['appsid']);
     $url = hsc($apps['url']);
     $type = hsc($apps['type']);
     $height = !empty($configdata['height']) ? intval($configdata['height']) : self::$default_height;
     if (isset($configdata['appsid']) && !empty($type)) {
         $smarty = smarty_core();
         $smarty->assign('url', $apps['url']);
         switch ($type) {
             case 'iframe':
                 // Google Docs (documents, presentations, spreadsheets, forms), Google Calendar, Google Maps
                 $smarty->assign('height', $height);
                 return $smarty->fetch('blocktype:googleapps:iframe.tpl');
             case 'spanicon':
                 // Google Docs collections (folder icon)
                 $smarty->assign('img', get_config('wwwroot') . 'blocktype/googleapps/images/folder_documents.png');
                 return $smarty->fetch('blocktype:googleapps:spanicon.tpl');
             case 'image':
                 // Google Docs drawing
                 $smarty->assign('height', $height);
                 return $smarty->fetch('blocktype:googleapps:image.tpl');
         }
     }
     return get_string('badurlerror', 'blocktype.googleapps', $url);
 }