本文整理汇总了PHP中BlockInstance::get_view方法的典型用法代码示例。如果您正苦于以下问题:PHP BlockInstance::get_view方法的具体用法?PHP BlockInstance::get_view怎么用?PHP BlockInstance::get_view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlockInstance
的用法示例。
在下文中一共展示了BlockInstance::get_view方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_blog_posts_in_block
/**
* Get the blog entries that will be displayed by this block.
* (This list will change depending when new blog entries are created, published, etc
*
* @param BlockInstance $instance
* @return array of objects
*/
public static function get_blog_posts_in_block(BlockInstance $instance)
{
$configdata = $instance->get('configdata');
$limit = isset($configdata['count']) ? (int) $configdata['count'] : 10;
$mostrecent = array();
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}'";
}
}
$blogids = $configdata['artefactids'];
$artefactids = implode(', ', array_map('db_quote', $blogids));
$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')));
if (!$mostrecent) {
$mostrecent = array();
}
}
return $mostrecent;
}
示例2: render_instance
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');
}
示例3: render_instance
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;
}
示例4: render_instance
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');
}
示例5: 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');
}
示例6: 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');
}
示例7: 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');
}
示例8: render_instance
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');
}
示例9: override_instance_title
public static function override_instance_title(BlockInstance $instance)
{
global $USER;
$ownerid = $instance->get_view()->get('owner');
if ($ownerid === null || $ownerid == $USER->get('id')) {
return get_string('title', 'blocktype.myviews');
}
return get_string('otherusertitle', 'blocktype.myviews', display_name($ownerid, null, true));
}
示例10: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
$configdata = $instance->get('configdata');
$type = isset($configdata['linkedindata']) ? $configdata['linkedindata'] : 'basicprofile';
$owner = $instance->get_view()->get('owner');
$profile = self::get_user_profile($type, $owner);
$smarty = smarty_core();
$smarty->assign('profile', $profile);
return $smarty->fetch('blocktype:linkedinprofile:' . $type . '.tpl');
}
示例11: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
$groupid = $instance->get_view()->get('group');
if (!$groupid) {
return '';
}
$data = self::get_data($groupid);
$dwoo = smarty_core();
$dwoo->assign('group', $data);
$dwoo->assign('editwindow', group_format_editwindow($data));
return $dwoo->fetch('blocktype:groupinfo:groupinfo.tpl');
}
示例12: instance_config_form
public static function instance_config_form(BlockInstance $instance)
{
$statusoptions = self::get_allowed_status();
$configdata = $instance->get('configdata');
$view = $instance->get_view();
$status = 0;
if (isset($configdata['status']) && isset($statusoptions[$configdata['status']])) {
$status = $configdata['status'];
}
$elements = array('status' => array('type' => 'select', 'options' => $statusoptions, 'title' => get_string('pagestatus', 'blocktype.pagestatus'), 'defaultvalue' => $status));
return $elements;
}
示例13: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
global $USER;
if ($editing) {
$smarty = smarty_core();
$smarty->assign('editing', get_string('ineditordescription1', 'blocktype.comment/comment'));
$html = $smarty->fetch('blocktype:comment:comment.tpl');
return $html;
}
// Feedback list pagination requires limit/offset params
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$showcomment = param_integer('showcomment', null);
// Create the "make feedback private form" now if it's been submitted
if (param_variable('make_public_submit', null)) {
pieform(ArtefactTypeComment::make_public_form(param_integer('comment')));
} else {
if (param_variable('delete_comment_submit_x', null)) {
pieform(ArtefactTypeComment::delete_comment_form(param_integer('comment')));
}
}
$view = new View($instance->get('view'));
$submittedgroup = (int) $view->get('submittedgroup');
if ($USER->is_logged_in() && $submittedgroup && group_user_can_assess_submitted_views($submittedgroup, $USER->get('id'))) {
$releaseform = true;
} else {
$releaseform = false;
}
// If the view has comments turned off, tutors can still leave
// comments if the view is submitted to their group.
if (!empty($releaseform) || $view->user_comments_allowed($USER)) {
$addfeedbackpopup = true;
}
safe_require('artefact', 'comment');
$commentoptions = ArtefactTypeComment::get_comment_options();
$commentoptions->limit = $limit;
$commentoptions->offset = $offset;
$commentoptions->showcomment = $showcomment;
$commentoptions->view = $instance->get_view();
$feedback = ArtefactTypeComment::get_comments($commentoptions);
$smarty = smarty_core();
$smarty->assign('feedback', $feedback);
if (isset($addfeedbackpopup)) {
$smarty->assign('enablecomments', 1);
$smarty->assign('addfeedbackpopup', $addfeedbackpopup);
}
$html = $smarty->fetch('blocktype:comment:comment.tpl');
return $html;
}
示例14: instance_config_form
public static function instance_config_form(BlockInstance $instance)
{
require_once 'license.php';
$configdata = $instance->get('configdata');
if (!($height = get_config('blockeditorheight'))) {
$cfheight = param_integer('cfheight', 0);
$height = $cfheight ? $cfheight * 0.7 : 150;
}
$view = $instance->get_view();
$text = '';
if (array_key_exists('text', $configdata)) {
$text = $configdata['text'];
}
$elements = array('text' => array('type' => 'wysiwyg', 'title' => get_string('blockcontent', 'blocktype.text'), 'width' => '100%', 'height' => $height . 'px', 'defaultvalue' => $text, 'rules' => array('maxlength' => 65536)));
return $elements;
}
示例15: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
$groupid = $instance->get_view()->get('group');
if (!$groupid) {
return '';
}
$data = self::get_data($groupid);
$dwoo = smarty_core();
$dwoo->assign('group', $data['group']);
$dwoo->assign('groupid', $data['group']->id);
$dwoo->assign('membercount', count_records('group_member', 'group', $data['group']->id));
$dwoo->assign('viewcount', count_records('view', 'group', $data['group']->id));
$dwoo->assign('filecount', $data['filecounts']->files);
$dwoo->assign('foldercount', $data['filecounts']->folders);
return $dwoo->fetch('blocktype:groupinfo:groupinfo.tpl');
}