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