本文整理汇总了PHP中BlockInstance::get方法的典型用法代码示例。如果您正苦于以下问题:PHP BlockInstance::get方法的具体用法?PHP BlockInstance::get怎么用?PHP BlockInstance::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlockInstance
的用法示例。
在下文中一共展示了BlockInstance::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_instance
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');
}
示例2: render_instance
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');
}
示例3: render_instance
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');
}
示例4: render_instance
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;
}
示例5: render_instance
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');
}
示例6: render_instance
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');
}
示例7: render_instance
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');
}
示例8: render_instance
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;
}
示例9: render_instance
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');
}
示例10: render_instance
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');
}
示例11: render_instance
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');
}
示例12: render_instance
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');
}
示例13: render_instance
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');
}
示例14: render_instance
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;
}
示例15: render_instance
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;
}