本文整理汇总了PHP中BlockInstance::get_artefact_instance方法的典型用法代码示例。如果您正苦于以下问题:PHP BlockInstance::get_artefact_instance方法的具体用法?PHP BlockInstance::get_artefact_instance怎么用?PHP BlockInstance::get_artefact_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlockInstance
的用法示例。
在下文中一共展示了BlockInstance::get_artefact_instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'), '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');
}
示例2: 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');
}
示例3: render_instance
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');
}
示例4: render_instance
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');
}
示例5: 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'];
}
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');
}
示例6: 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;
}
示例7: get_instance_title
/**
* Optional method. If exists, allows this class to decide the title for
* all blockinstances of this type
*/
public static function get_instance_title(BlockInstance $bi)
{
$configdata = $bi->get('configdata');
if (!empty($configdata['artefactid'])) {
return $bi->get_artefact_instance($configdata['artefactid'])->get('title');
}
return '';
}
示例8: get_artefacts
/**
* Returns a list of artefact IDs that are in this blockinstance.
*
* Normally this would just include the blogpost ID itself (children such
* as attachments don't need to be included here, they're handled by the
* artefact parent cache). But people might just link to artefacts without
* using the attachment facility. There's nothing wrong with them doing
* that, so if they do we should scrape the post looking for such links and
* include those artefacts as being part of this blockinstance.
*
* @return array List of artefact IDs that are 'in' this blogpost - all
* the blogpost ID plus links to other artefacts that are
* part of the blogpost text. Note that proper artefact
* children, such as blog post attachments, aren't included -
* the artefact parent cache is used for them
* @see PluginBlocktypeBlog::get_artefacts()
*/
public static function get_artefacts(BlockInstance $instance)
{
$configdata = $instance->get('configdata');
$artefacts = array();
if (isset($configdata['artefactid'])) {
$artefacts[] = $configdata['artefactid'];
// Add all artefacts found in the blogpost text
$blogpost = $instance->get_artefact_instance($configdata['artefactid']);
$artefacts = array_unique(array_merge($artefacts, $blogpost->get_referenced_artefacts_from_postbody()));
}
return $artefacts;
}
示例9: 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');
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 '';
}
示例10: 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;
}
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 field in this blockinstance
if (!empty($configdata['artefactid'])) {
$europassfield = $instance->get_artefact_instance($configdata['artefactid']);
if ($europassfield->get('artefacttype') != 'application') {
$rendered = $europassfield->render_self($configdata);
$result = $rendered['html'];
if (!empty($rendered['javascript'])) {
$result .= '<script type="text/javascript">' . $rendered['javascript'] . '</script>';
}
} else {
require_once get_config('docroot') . 'artefact/europass/lib/locale.php';
$personalinformation = null;
try {
$personalinformation = artefact_instance_from_type('personalinformation');
} catch (Exception $e) {
}
if (!empty($personalinformation)) {
$gender = $personalinformation->get_composite('gender');
} else {
$gender = null;
}
$occupation = get_occupation($europassfield->get('description'), get_config('lang'), $gender);
$result = $occupation['label'];
}
return $result;
}
return '';
}
示例11: 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');
$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;
}
示例12: 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 field in this blockinstance
if (!empty($configdata['artefactid'])) {
$resumefield = $instance->get_artefact_instance($configdata['artefactid']);
$rendered = $resumefield->render_self($configdata);
$result = $rendered['html'];
if (!empty($rendered['javascript'])) {
$result .= '<script type="text/javascript">' . $rendered['javascript'] . '</script>';
}
return $result;
}
return '';
}
示例13: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
$configdata = $instance->get('configdata');
$viewid = $instance->get('view');
$artefactid = isset($configdata['artefactid']) ? $configdata['artefactid'] : null;
if (empty($artefactid)) {
return '';
}
$result = self::get_js_source();
require_once get_config('docroot') . 'artefact/lib.php';
$artefact = $instance->get_artefact_instance($artefactid);
$defaultwidth = get_config_plugin('blocktype', 'internalmedia', 'width') ? get_config_plugin('blocktype', 'internalmedia', 'width') : 300;
$defaultheight = get_config_plugin('blocktype', 'internalmedia', 'height') ? get_config_plugin('blocktype', 'internalmedia', 'height') : 300;
$width = !empty($configdata['width']) ? hsc($configdata['width']) : $defaultwidth;
$height = !empty($configdata['height']) ? hsc($configdata['height']) : $defaultheight;
$mimetype = $artefact->get('filetype');
$mimetypefiletypes = self::get_allowed_mimetype_filetypes();
if (!isset($mimetypefiletypes[$mimetype])) {
return get_string('typeremoved', 'blocktype.file/internalmedia');
}
$callbacks = self::get_all_filetype_players();
$result .= '<div class="mediaplayer-container center"><div class="mediaplayer">' . call_static_method('PluginBlocktypeInternalmedia', $callbacks[$mimetypefiletypes[$mimetype]], $artefact, $instance, $width, $height) . '</div></div>';
if ($artefactid) {
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($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:internalmedia:internalmedia.tpl');
}
示例14: instance_config_form
public static function instance_config_form(BlockInstance $instance)
{
global $USER;
safe_require('artefact', 'blog');
$configdata = $instance->get('configdata');
if (!empty($configdata['artefactid'])) {
$blog = $instance->get_artefact_instance($configdata['artefactid']);
}
$elements = array();
// If the blog post in this block is owned by the owner of the View,
// then the block can be configured. Otherwise, the blog post was
// copied in from another View. We won't confuse users by asking them to
// choose a blog post to put in this block, when the one that is
// currently in it isn't choosable.
//
// Note: the owner check will have to change when we do group/site
// blogs
if (empty($configdata['artefactid']) || $blog->get('owner') == $USER->get('id')) {
$publishedposts = get_column_sql('
SELECT a.id
FROM {artefact} a
INNER JOIN {artefact_blog_blogpost} p ON p.blogpost = a.id
WHERE p.published = 1 AND a.owner= ?', array($USER->get('id')));
$elements[] = self::artefactchooser_element(isset($configdata['artefactid']) ? $configdata['artefactid'] : null, $publishedposts);
$elements[] = PluginArtefactBlog::block_advanced_options_element($configdata, 'blogpost');
} else {
$elements[] = array('type' => 'html', 'name' => 'notice', 'value' => '<div class="metadata">' . get_string('blogcopiedfromanotherview', 'artefact.blog', get_string('blogpost', 'artefact.blog')) . '</div>');
}
return $elements;
}
示例15: watchlist_process_notifications
/**
* is called by the cron-job to process the notifications stored into
* watchlist_queue.
*/
function watchlist_process_notifications()
{
$delayMin = get_config('watchlistnotification_delay');
$comparetime = time() - $delayMin * 60;
$sql = "SELECT usr, view, MAX(changed_on) AS time\n FROM {watchlist_queue}\n GROUP BY usr, view";
$results = get_records_sql_array($sql, array());
if (false === $results) {
return;
}
foreach ($results as $viewuserdaterow) {
if ($viewuserdaterow->time > date('Y-m-d H:i:s', $comparetime)) {
continue;
}
// don't send a notification if only blockinstances are referenced
// that were deleted (block exists but corresponding
// block_instance doesn't)
$sendnotification = false;
$blockinstance_ids = get_column('watchlist_queue', 'block', 'usr', $viewuserdaterow->usr, 'view', $viewuserdaterow->view);
if (is_array($blockinstance_ids)) {
$blockinstance_ids = array_unique($blockinstance_ids);
}
$viewuserdaterow->blocktitles = array();
// need to check if view has an owner, group or institution
$view = get_record('view', 'id', $viewuserdaterow->view);
if (empty($view->owner) && empty($view->group) && empty($view->institution)) {
continue;
}
// ignore root pages, owner = 0, this account is not meant to produce content
if (isset($view->owner) && empty($view->owner)) {
continue;
}
foreach ($blockinstance_ids as $blockinstance_id) {
if (empty($blockinstance_id)) {
// if no blockinstance is given, assume that the form itself
// was changed, e.g. the theme, or a block was removed
$sendnotification = true;
continue;
}
require_once get_config('docroot') . 'blocktype/lib.php';
try {
$block = new BlockInstance($blockinstance_id);
} catch (BlockInstanceNotFoundException $exc) {
// maybe the block was deleted
continue;
}
$blocktype = $block->get('blocktype');
$title = '';
// try to get title rendered by plugin-class
safe_require('blocktype', $blocktype);
if (class_exists(generate_class_name('blocktype', $blocktype))) {
$title = $block->get_title();
} else {
log_warn('class for blocktype could not be loaded: ' . $blocktype);
$title = $block->get('title');
}
// if no title was given to the blockinstance, try to get one
// from the artefact
if (empty($title)) {
$configdata = $block->get('configdata');
if (array_key_exists('artefactid', $configdata)) {
try {
$artefact = $block->get_artefact_instance($configdata['artefactid']);
$title = $artefact->get('title');
} catch (Exception $exc) {
log_warn('couldn\'t identify title of blockinstance ' . $block->get('id') . $exc->getMessage());
}
}
}
// still no title, maybe the default-name for the blocktype
if (empty($title)) {
$title = get_string('title', 'blocktype.' . $blocktype);
}
// no title could be retrieved, so let's tell the user at least
// what type of block was changed
if (empty($title)) {
$title = '[' . $blocktype . '] (' . get_string('nonamegiven', 'activity') . ')';
}
$viewuserdaterow->blocktitles[] = $title;
$sendnotification = true;
}
// only send notification if there is something to talk about (don't
// send notification for example when new blockelement was aborted)
if ($sendnotification) {
try {
$watchlistnotification = new ActivityTypeWatchlistnotification($viewuserdaterow, false);
$watchlistnotification->notify_users();
} catch (ViewNotFoundException $exc) {
// Seems like the view has been deleted, don't do anything
} catch (SystemException $exc) {
// if the view that was changed doesn't have an owner
}
}
delete_records('watchlist_queue', 'usr', $viewuserdaterow->usr, 'view', $viewuserdaterow->view);
}
}