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; }
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']; } require_once get_config('docroot') . 'artefact/comment/lib.php'; require_once get_config('docroot') . 'lib/view.php'; $view = new View($viewid); list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($image, $view, $instance->get('id'), true, $editing); $smarty = smarty_core(); $smarty->assign('commentcount', $commentcount); $smarty->assign('comments', $comments); $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'); }
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'); }
/** * Provides an email list, with verification to enable addresses * * @param array $element The element to render * @param Pieform $form The form to render the element for * @return string The HTML for the element */ function pieform_element_authlist(Pieform $form, $element) { $smarty = smarty_core(); $smarty->left_delimiter = '{{'; $smarty->right_delimiter = '}}'; $value = $form->get_value($element); if (!is_array($value) && isset($element['defaultvalue']) && is_array($element['defaultvalue'])) { $value = $element['defaultvalue']; } if (!isset($value['default'])) { $value['default'] = ''; } if (is_array($value) && count($value)) { $smarty->assign('authtypes', $value['authtypes']); $smarty->assign('instancelist', $value['instancelist']); $smarty->assign('instancestring', implode(',', $value['instancearray'])); $smarty->assign('default', $value['default']); $smarty->assign('institution', $value['institution']); } $smarty->assign('name', $element['name']); $smarty->assign('cannotremove', json_encode(get_string('cannotremove', 'auth'))); $smarty->assign('cannotremoveinuse', json_encode(get_string('cannotremoveinuse', 'auth'))); $smarty->assign('saveinstitutiondetailsfirst', json_encode(get_string('saveinstitutiondetailsfirst', 'auth'))); $smarty->assign('noauthpluginconfigoptions', json_encode(get_string('noauthpluginconfigoptions', 'auth'))); return $smarty->fetch('form/authlist.tpl'); }
public static function render_instance(BlockInstance $instance, $editing = false) { global $exporter; require_once get_config('docroot') . 'artefact/lib.php'; safe_require('artefact', 'cpds'); $configdata = $instance->get('configdata'); $smarty = smarty_core(); if (isset($configdata['artefactid'])) { $cpd = artefact_instance_from_id($configdata['artefactid']); $activities = ArtefactTypeActivity::get_activities($configdata['artefactid']); $template = 'artefact:cpds:activityrows.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' => 'activitytable_' . $blockid, 'jsonscript' => 'artefact/cpds/viewactivities.json.php'); } ArtefactTypeActivity::render_activities($activities, $template, $configdata, $pagination); if ($exporter && $activities['count'] > $activities['limit']) { $artefacturl = get_config('wwwroot') . 'view/artefact.php?artefact=' . $configdata['artefactid'] . '&view=' . $instance->get('view'); $activities['pagination'] = '<a href="' . $artefacturl . '">' . get_string('allactivities', 'artefact.cpds') . '</a>'; } $smarty->assign('description', $cpd->get('description')); $smarty->assign('activities', $activities); $smarty->assign('owner', $cpd->get('owner')); $smarty->assign('tags', $cpd->get('tags')); } else { $smarty->assign('nocpds', 'blocktype.cpds/cpds'); } $smarty->assign('blockid', $instance->get('id')); return $smarty->fetch('blocktype:cpds: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) { $artefact = artefact_instance_from_id($id); if ($artefact->get('owner') == $viewowner) { $rendered = $artefact->render_self(array('link' => true)); $data[$artefact->get('artefacttype')] = $rendered['html']; } } } // Work out the path to the thumbnail for the profile image if (!empty($configdata['profileicon'])) { $downloadpath = get_config('wwwroot') . 'thumb.php?type=profileiconbyid&id=' . $configdata['profileicon']; $downloadpath .= '&maxwidth=80'; $smarty->assign('profileiconpath', $downloadpath); } // Override the introduction text if the user has any for this // particular blockinstance if (!empty($configdata['introtext'])) { $data['introduction'] = $configdata['introtext']; } $smarty->assign('profileinfo', $data); return $smarty->fetch('blocktype:profileinfo:content.tpl'); }
/** * Provides a tag input field * * @param Pieform $form The form to render the element for * @param array $element The element to render * @return string The HTML for the element */ function pieform_element_tags(Pieform $form, $element) { $smarty = smarty_core(); $value = array(); if (isset($element['defaultvalue']) && is_array($element['defaultvalue'])) { $value = $element['defaultvalue']; } if ($tempvalue = $form->get_value($element)) { $value = $tempvalue; } if (isset($element['value']) && is_array($element['value'])) { $value = $element['value']; } if (!is_array($value)) { $value = array(); } if (!isset($element['size'])) { $element['size'] = 60; } $smarty->assign('name', $element['name']); $smarty->assign('size', $element['size']); $smarty->assign('id', $form->get_name() . '_' . $element['id']); $smarty->assign('value', join(', ', $value)); if (isset($element['description'])) { $smarty->assign('describedby', $form->element_descriptors($element)); } $smarty->left_delimiter = '{{'; $smarty->right_delimiter = '}}'; return $smarty->fetch('form/tags.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'); }
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'); }
public static function render_instance(BlockInstance $instance, $editing = false) { global $USER; $userid = $instance->get_view()->get('owner'); if (!$userid) { // 'My Friends' doesn't make sense for group/site views return ''; } $smarty = smarty_core(); $records = get_records_sql_array('SELECT usr1, usr2 FROM {usr_friend} JOIN {usr} u1 ON (u1.id = usr1 AND u1.deleted = 0) JOIN {usr} u2 ON (u2.id = usr2 AND u2.deleted = 0) WHERE usr1 = ? OR usr2 = ? ORDER BY ' . db_random() . ' LIMIT ?', array($userid, $userid, MAXFRIENDDISPLAY)); // get the friends into a 4x4 array if ($records) { $friends = array(); for ($i = 0; $i < 4; $i++) { if (isset($records[4 * $i])) { $friends[$i] = array(); for ($j = 4 * $i; $j < ($i + 1) * 4; $j++) { if (isset($records[$j])) { if ($records[$j]->usr1 == $userid) { $friends[$i][] = $records[$j]->usr2; } else { $friends[$i][] = $records[$j]->usr1; } } } } } } else { $friends = false; } $smarty->assign('friends', $friends); // If the user has no friends, try and display something useful, such // as a 'request friendship' button $loggedinid = $USER->get('id'); $is_friend = is_friend($userid, $loggedinid); if ($is_friend) { $relationship = 'existingfriend'; } else { if (record_exists('usr_friend_request', 'requester', $loggedinid, 'owner', $userid)) { $relationship = 'requestedfriendship'; } else { $relationship = 'none'; $friendscontrol = get_account_preference($userid, 'friendscontrol'); if ($friendscontrol == 'auto') { $newfriendform = pieform(array('name' => 'myfriends_addfriend', 'successcallback' => 'addfriend_submit', 'autofocus' => false, 'renderer' => 'div', 'elements' => array('add' => array('type' => 'submit', 'value' => get_string('addtomyfriends', 'group')), 'id' => array('type' => 'hidden', 'value' => $userid)))); $smarty->assign('newfriendform', $newfriendform); } $smarty->assign('friendscontrol', $friendscontrol); } } $smarty->assign('relationship', $relationship); $smarty->assign_by_ref('USER', $USER); $smarty->assign('USERID', $userid); return $smarty->fetch('blocktype:myfriends:myfriends.tpl'); }
public static function render_instance(BlockInstance $instance, $editing = false) { $configdata = $instance->get('configdata'); $result = ''; $artefactid = isset($configdata['artefactid']) ? $configdata['artefactid'] : null; if ($artefactid) { require_once get_config('docroot') . 'artefact/lib.php'; $artefact = $instance->get_artefact_instance($artefactid); $configdata['hidetitle'] = true; $configdata['countcomments'] = true; $configdata['viewid'] = $instance->get('view'); $configdata['blockid'] = $instance->get('id'); $result = $artefact->render_self($configdata); $result = $result['html']; require_once get_config('docroot') . 'artefact/comment/lib.php'; require_once get_config('docroot') . 'lib/view.php'; $view = new View($configdata['viewid']); list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing); } $smarty = smarty_core(); if ($artefactid) { $smarty->assign('commentcount', $commentcount); $smarty->assign('comments', $comments); } $smarty->assign('html', $result); return $smarty->fetch('blocktype:blogpost:blogpost.tpl'); }
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 = ''; $artefactid = isset($configdata['artefactid']) ? $configdata['artefactid'] : null; if ($artefactid) { $artefact = $instance->get_artefact_instance($artefactid); if (!file_exists($artefact->get_path())) { return; } $result = clean_html(file_get_contents($artefact->get_path())); require_once get_config('docroot') . 'artefact/comment/lib.php'; require_once get_config('docroot') . 'lib/view.php'; $view = new View($configdata['viewid']); list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing); } $smarty = smarty_core(); if ($artefactid) { $smarty->assign('commentcount', $commentcount); $smarty->assign('comments', $comments); } $smarty->assign('html', $result); return $smarty->fetch('blocktype:html:html.tpl'); }
public static function render_instance(BlockInstance $instance, $editing = false) { $configdata = $instance->get('configdata'); if (!empty($configdata['feedid'])) { $data = get_record('blocktype_externalfeed_data', 'id', $configdata['feedid'], null, null, null, null, 'id,url,link,title,description,content,' . db_format_tsfield('lastupdate') . ',image'); $data->content = unserialize($data->content); $data->image = unserialize($data->image); // only keep the number of entries the user asked for $chunks = array_chunk($data->content, isset($configdata['count']) ? $configdata['count'] : 10); $data->content = $chunks[0]; // Attempt to fix relative URLs in the feeds if (!empty($data->image['link'])) { $data->description = preg_replace('/src="(\\/[^"]+)"/', 'src="' . $data->image['link'] . '$1"', $data->description); foreach ($data->content as &$entry) { $entry->description = preg_replace('/src="(\\/[^"]+)"/', 'src="' . $data->image['link'] . '$1"', $entry->description); } } $smarty = smarty_core(); $smarty->assign('title', $data->title); $smarty->assign('description', $data->description); $smarty->assign('url', $data->url); // 'full' won't be set for feeds created before 'full' support was added $smarty->assign('full', isset($configdata['full']) ? $configdata['full'] : false); $smarty->assign('link', $data->link); $smarty->assign('entries', $data->content); $smarty->assign('feedimage', self::make_feed_image_tag($data->image)); $smarty->assign('lastupdated', get_string('lastupdatedon', 'blocktype.externalfeed', format_date($data->lastupdate))); return $smarty->fetch('blocktype:externalfeed:feed.tpl'); } return ''; }
/** * Get results for log search with results containing markup/pagination * * @param object Contains: * - userquery string * - functionquery string * - protocol string * - authtype string * - sortby string * - sortdir string * - offset int * - limit int * - onlyerrors string optional * - institution string optional * - institution_requested string optional * * @return array Contains search results markup/pagination */ function build_webservice_log_search_results($search) { global $THEME; $THEME->templatedirs[] = get_config('docroot') . 'auth/webservice/theme/raw/'; $results = get_log_search_results($search); $params = array(); foreach ($search as $k => $v) { if (!empty($v)) { $params[] = $k . '=' . $v; } } $searchurl = get_config('wwwroot') . 'webservice/admin/webservicelogs.php?' . join('&', $params); $pagination = $results['pagination'] = build_pagination(array('id' => 'admin_usersearch_pagination', 'class' => 'center', 'url' => $searchurl, 'count' => $results['count'], 'limit' => $search->limit, 'setlimit' => true, 'jumplinks' => 8, 'numbersincludeprevnext' => 2, 'offset' => $search->offset, 'datatable' => 'searchresults', 'jsonscript' => 'webservice/admin/logsearch.json.php')); $cols = array('username' => array('name' => get_string('userauth', 'auth.webservice'), 'template' => 'auth:webservice:username.tpl', 'class' => 'center', 'sort' => true), 'institution' => array('name' => get_string('institution'), 'sort' => true), 'protocol' => array('name' => get_string('protocol', 'auth.webservice'), 'sort' => true), 'auth' => array('name' => get_string('authtype', 'auth.webservice'), 'sort' => true), 'functionname' => array('name' => get_string('function', 'auth.webservice'), 'sort' => true), 'timetaken' => array('name' => get_string('timetaken', 'auth.webservice'), 'sort' => true), 'timelogged' => array('name' => get_string('timelogged', 'auth.webservice'), 'sort' => true), 'info' => array('name' => get_string('info', 'auth.webservice'), 'class' => 'webservicelogs-info')); $smarty = smarty_core(); $smarty->assign_by_ref('results', $results); $smarty->assign_by_ref('institutions', $institutions); $smarty->assign('searchurl', $searchurl); $smarty->assign('sortby', $search->sortby); $smarty->assign('sortdir', $search->sortdir); $smarty->assign('limitoptions', array(10, 50, 100, 200, 500)); $smarty->assign('pagebaseurl', $searchurl . '&sortby=' . $search->sortby . '&sortdir=' . $search->sortdir); $smarty->assign('cols', $cols); return array($smarty->fetch('searchresulttable.tpl'), $cols, array('url' => $searchurl . '&sortby=' . $search->sortby . '&sortdir=' . $search->sortdir, 'sortby' => $search->sortby, 'sortdir' => $search->sortdir), $pagination); }
public static function render_instance(BlockInstance $instance, $editing = false) { $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; $owner = $instance->get('view_obj')->get('owner'); // Whether to include email button if (isset($configdata['displayemail']) && $configdata['displayemail']) { $email = get_field('artefact_internal_profile_email', 'email', 'principal', 1, 'owner', $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($owner, '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'); }
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, v.ctime, v.mtime 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('loggedin', $USER->is_logged_in()); $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'; $smarty = smarty_core(); $filter = param_alpha('filter', 'all'); $offset = param_integer('offset', 0); $limit = 1000; //get list online friend $result_friend_online_id = get_onlinefriends($limit, $offset); $str_eselma_online = implode(',', $result_friend_online_id['data']); if ($str_eselma_online) { $query_result_friend_online = "\n SELECT *\n FROM {usr}\n WHERE id in ({$str_eselma_online})\n "; $result_friend_online = get_records_sql_array($query_result_friend_online); } //get list offline friend $result_friend_offline_id = get_offlinefriends($limit, $offset); $str_eselma_offline = implode(',', $result_friend_offline_id['data']); if ($str_eselma_offline) { $query_result_friend_offline = "\n SELECT *\n FROM {usr}\n WHERE id in ({$str_eselma_offline})\n "; $result_friend_offline = get_records_sql_array($query_result_friend_offline); } $smarty->assign('eselma_get_online', $result_friend_online); $smarty->assign('eselma_get_offline', $result_friend_offline); $smarty->assign('lastminutes', floor(get_config('accessidletimeout') / 60)); $smarty->assign('eselma_count_online', $result_friend_online_id['count']); $smarty->assign('eselma_count_offline', $result_friend_offline_id['count']); return $smarty->fetch('blocktype:eselmaonoff: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'] . '&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) { 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_image_url($licensetype . '-3_0', 'blocktype/creativecommons')); $smarty->assign('licensestatement', $licensestatement); $smarty->assign('otherpermissions', $otherpermissions); return $smarty->fetch('blocktype:creativecommons:statement.tpl'); }
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'); }
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'), 'artefacttype' => $artefact->get('artefacttype'), '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; } } $file['is_image'] = $artefact instanceof ArtefactTypeImage ? true : false; $files[] = $file; } } $smarty = smarty_core(); $smarty->assign('viewid', $instance->get('view')); $smarty->assign('files', $files); return $smarty->fetch('blocktype:filedownload:filedownload.tpl'); }
public static function render_instance(BlockInstance $instance, $editing = false) { global $exporter; $configdata = $instance->get('configdata'); $result = ''; if (!empty($configdata['artefactid'])) { require_once get_config('docroot') . 'artefact/lib.php'; $blog = $instance->get_artefact_instance($configdata['artefactid']); $configdata['hidetitle'] = true; $configdata['countcomments'] = true; $configdata['viewid'] = $instance->get('view'); if ($instance->get_view()->is_submitted()) { // Don't display posts added after the submitted date. if ($submittedtime = $instance->get_view()->get('submittedtime')) { $configdata['before'] = $submittedtime; } } $limit = isset($configdata['count']) ? intval($configdata['count']) : 5; $posts = ArtefactTypeBlogpost::get_posts($blog->get('id'), $limit, 0, $configdata); $template = 'artefact:blog:viewposts.tpl'; if ($exporter) { $pagination = false; } else { $baseurl = $instance->get_view()->get_url(); $baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'block=' . $instance->get('id'); $pagination = array('baseurl' => $baseurl, 'id' => 'blogpost_pagination_' . $instance->get('id'), 'datatable' => 'postlist_' . $instance->get('id'), 'jsonscript' => 'artefact/blog/posts.json.php'); } $configdata['blockid'] = $instance->get('id'); $configdata['editing'] = $editing; ArtefactTypeBlogpost::render_posts($posts, $template, $configdata, $pagination); $smarty = smarty_core(); if (isset($configdata['viewid'])) { $artefacturl = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $blog->get('id') . '&view=' . $configdata['viewid']; $smarty->assign('artefacttitle', '<a href="' . $artefacturl . '">' . hsc($blog->get('title')) . '</a>'); if ($exporter && $posts['count'] > $limit) { $posts['pagination'] = '<a href="' . $artefacturl . '">' . get_string('allposts', 'artefact.blog') . '</a>'; } } else { $smarty->assign('artefacttitle', hsc($blog->get('title'))); } // Only show the 'New entry' link for blogs that you can add an entry to $canaddpost = false; $institution = $blog->get('institution'); $group = $blog->get('group'); if (ArtefactTypeBlog::can_edit_blog($blog, $institution, $group)) { $canaddpost = true; } $smarty->assign('options', $configdata); $smarty->assign('description', $blog->get('description')); $smarty->assign('owner', $blog->get('owner')); $smarty->assign('tags', $blog->get('tags')); $smarty->assign('blockid', $instance->get('id')); $smarty->assign('editing', $editing); $smarty->assign('canaddpost', $canaddpost); $smarty->assign('blogid', $blog->get('id')); $smarty->assign('posts', $posts); $result = $smarty->fetch('artefact:blog:blog.tpl'); } return $result; }
/** * Provides an email list, with verification to enable addresses * * @param array $element The element to render * @param Pieform $form The form to render the element for * @return string The HTML for the element */ function pieform_element_emaillist(Pieform $form, $element) { $smarty = smarty_core(); $smarty->left_delimiter = '{{'; $smarty->right_delimiter = '}}'; $value = $form->get_value($element); if (!is_array($value) && isset($element['defaultvalue']) && is_array($element['defaultvalue'])) { $value = $element['defaultvalue']; } if (!isset($value['validated'])) { $value['validated'] = array(); } if (!isset($value['unvalidated'])) { $value['unvalidated'] = array(); } if (!isset($value['unsent'])) { $value['unsent'] = array(); } if (!isset($value['default'])) { $value['default'] = ''; } if (is_array($value) && count($value)) { $smarty->assign('validated', $value['validated']); $smarty->assign('unvalidated', $value['unvalidated']); $smarty->assign('unsent', $value['unsent']); $smarty->assign('default', $value['default']); } $smarty->assign('name', $element['name']); $smarty->assign('addbuttonstr', get_string('addbutton', 'artefact.internal')); $smarty->assign('validationemailstr', json_encode(get_string('validationemailwillbesent', 'artefact.internal'))); return $smarty->fetch('form/emaillist.tpl'); }
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) { 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 = ''; $artefactid = isset($configdata['artefactid']) ? $configdata['artefactid'] : null; if ($artefactid) { $artefact = $instance->get_artefact_instance($artefactid); $result = $artefact->render_self($configdata); $result = $result['html']; require_once get_config('docroot') . 'artefact/comment/lib.php'; require_once get_config('docroot') . 'lib/view.php'; $view = new View($configdata['viewid']); list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing); } $smarty = smarty_core(); if ($artefactid) { $smarty->assign('commentcount', $commentcount); $smarty->assign('comments', $comments); } $smarty->assign('html', $result); return $smarty->fetch('blocktype:folder:folder.tpl'); }
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'); }
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'); }
function build_pending_html($data, $institution) { $smarty = smarty_core(); $smarty->assign('data', isset($data) ? $data : null); $smarty->assign('institution', $institution); $tablerows = $smarty->fetch('admin/users/pendinguserslist.tpl'); return $tablerows; }
public static function render_instance(BlockInstance $instance, $editing = false) { $configdata = $instance->get('configdata'); if (!isset($configdata['showgroupviews'])) { // If not set, use default $configdata['showgroupviews'] = 1; } if (!isset($configdata['showsharedviews'])) { $configdata['showsharedviews'] = 1; } if (!isset($configdata['showsharedcollections'])) { $configdata['showsharedcollections'] = 1; } if (!isset($configdata['showsubmitted'])) { $configdata['showsubmitted'] = 1; } $groupid = $instance->get_view()->get('group'); if (!$groupid) { return ''; } $data = self::get_data($groupid, $editing); $dwoo = smarty_core(); $dwoo->assign('group', $data['group']); $dwoo->assign('groupid', $data['group']->id); $baseurl = $instance->get_view()->get_url(); $baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'group=' . $groupid; if (!empty($configdata['showgroupviews']) && isset($data['groupviews'])) { $groupviews = (array) $data['groupviews']; $pagination = array('baseurl' => $baseurl, 'id' => 'groupviews_pagination', 'datatable' => 'groupviewlist', 'jsonscript' => 'blocktype/groupviews/groupviews.json.php', 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view')); self::render_items($groupviews, 'blocktype:groupviews:groupviewssection.tpl', $configdata, $pagination); $dwoo->assign('groupviews', $groupviews); } if (!empty($configdata['showsharedviews']) && isset($data['sharedviews'])) { $sharedviews = (array) $data['sharedviews']; $pagination = array('baseurl' => $baseurl, 'id' => 'sharedviews_pagination', 'datatable' => 'sharedviewlist', 'jsonscript' => 'blocktype/groupviews/sharedviews.json.php', 'resultcounttextsingular' => get_string('view', 'view'), 'resultcounttextplural' => get_string('views', 'view')); self::render_items($sharedviews, 'blocktype:groupviews:sharedviews.tpl', $configdata, $pagination); $dwoo->assign('sharedviews', $sharedviews); } if (!empty($configdata['showsharedcollections']) && isset($data['sharedcollections'])) { $sharedcollections = (array) $data['sharedcollections']; $pagination = array('baseurl' => $baseurl, 'id' => 'sharedcollections_pagination', 'datatable' => 'sharedcollectionlist', 'jsonscript' => 'blocktype/groupviews/sharedcollections.json.php', 'resultcounttextsingular' => get_string('collection', 'collection'), 'resultcounttextplural' => get_string('collections', 'collection')); self::render_items($sharedcollections, 'blocktype:groupviews:sharedcollections.tpl', $configdata, $pagination); $dwoo->assign('sharedcollections', $sharedcollections); } if (!empty($configdata['showsubmitted']) && isset($data['allsubmitted'])) { $allsubmitted = $data['allsubmitted']; $pagination = array('baseurl' => $baseurl, 'id' => 'allsubmitted_pagination', 'datatable' => 'allsubmissionlist', 'jsonscript' => 'blocktype/groupviews/allsubmissions.json.php', 'resultcounttextsingular' => get_string('vieworcollection', 'view'), 'resultcounttextplural' => get_string('viewsandcollections', 'view')); self::render_items($allsubmitted, 'blocktype:groupviews:allsubmissions.tpl', $configdata, $pagination); $dwoo->assign('allsubmitted', $allsubmitted); } if (isset($data['mysubmitted'])) { $dwoo->assign('mysubmitted', $data['mysubmitted']); } if (!$editing && isset($data['group_view_submission_form'])) { $dwoo->assign('group_view_submission_form', $data['group_view_submission_form']); } return $dwoo->fetch('blocktype:groupviews:groupviews.tpl'); }
/** * Autocomplete list selector element * * @param array $element The element to render * @param Pieform $form The form to render the element for * @return string The HTML for the element */ function pieform_element_autocomplete(Pieform $form, $element) { global $USER; $wwwroot = get_config('wwwroot'); $smarty = smarty_core(); $smarty->left_delimiter = '{{'; $smarty->right_delimiter = '}}'; $value = $form->get_value($element); $multiple = !empty($element['multiple']); if ($multiple) { $valuestr = implode(',', $value); } else { $valuestr = $value; } if (!empty($element['initfunction'])) { $initvalue = json_encode(call_user_func($element['initfunction'], $value)); } else { $initvalue = '[]'; } if (array_key_exists('mininputlength', $element)) { $mininputlength = $element['mininputlength']; } else { $mininputlength = 1; } $extraparams = ''; if (!empty($element['extraparams'])) { foreach ($element['extraparams'] as $k => $v) { if (!is_numeric($v) && !preg_match('/^function/', $v)) { if (preg_match('/^\'(.*)\'$/', $v, $match)) { $v = $match[1]; } $element['extraparams'][$k] = json_encode($v); } $extraparams .= $k . ': ' . $element['extraparams'][$k] . ','; } } $smarty->assign('id', $form->get_name() . '_' . $element['id']); $smarty->assign('name', $element['name']); $smarty->assign('value', $valuestr); // Pre-populate form element. $smarty->assign('initvalue', $initvalue); $smarty->assign('width', empty($element['width']) ? '300px' : $element['width']); $smarty->assign('multiple', $multiple ? 'true' : 'false'); $smarty->assign('mininputlength', $mininputlength); $smarty->assign('allowclear', empty($element['allowclear']) ? 'false' : 'true'); $smarty->assign('disabled', !empty($element['disabled']) ? 'true' : 'false'); $smarty->assign('ajaxurl', $element['ajaxurl']); $smarty->assign('sesskey', $USER->get('sesskey')); $smarty->assign('hint', empty($element['hint']) ? get_string('defaulthint') : $element['hint']); $smarty->assign('extraparams', $extraparams); $smarty->assign('inblockconfig', !empty($element['inblockconfig']) ? 'true' : 'false'); if (isset($element['description'])) { $smarty->assign('describedby', $form->element_descriptors($element)); } return $smarty->fetch('form/autocomplete.tpl'); }