本文整理汇总了PHP中phpbb\template\template::destroy_block_vars方法的典型用法代码示例。如果您正苦于以下问题:PHP template::destroy_block_vars方法的具体用法?PHP template::destroy_block_vars怎么用?PHP template::destroy_block_vars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpbb\template\template
的用法示例。
在下文中一共展示了template::destroy_block_vars方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load_answer
/**
* Look up everything we need and populate the instance variables.
*/
public function load_answer()
{
if (!strlen($this->confirm_id) || !sizeof($this->question_ids)) {
return false;
}
$sql = 'SELECT con.question_id, attempts, question_text, sort, name_left, name_right
FROM ' . $this->table_sortables_confirm . ' con, ' . $this->table_sortables_questions . " qes\n\t\t\tWHERE con.question_id = qes.question_id\n\t\t\t\tAND confirm_id = '" . $this->db->sql_escape($this->confirm_id) . "'\n\t\t\t\tAND session_id = '" . $this->db->sql_escape($this->user->session_id) . "'\n\t\t\t\tAND qes.lang_iso = '" . $this->db->sql_escape($this->question_lang) . "'\n\t\t\t\tAND confirm_type = " . $this->type;
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
if ($row) {
$this->question = $row['question_id'];
$this->attempts = $row['attempts'];
$this->question_sort = $row['sort'];
$this->question_text = $row['question_text'];
$this->name_left = $row['name_left'];
$this->name_right = $row['name_right'];
// Let's load the answers
$sql = 'SELECT answer_id, answer_text
FROM ' . $this->table_sortables_answers . "\n\t\t\t\tWHERE question_id = " . (int) $this->question . "\n\t\t\t\tORDER BY " . $this->sql_random();
$result = $this->db->sql_query($sql);
$this->template->destroy_block_vars('options');
// It's running twice, only grab the lastest see topic 1732385
$this->total_options = 0;
while ($row = $this->db->sql_fetchrow($result)) {
$this->template->assign_block_vars('options', array('ID' => $row['answer_id'], 'TEXT' => $row['answer_text']));
$this->total_options++;
}
$this->db->sql_freeresult($result);
return true;
}
return false;
}
示例2: viewforum_modify_topicrow
/**
* Event: core.viewforum_modify_topicrow
*
* Get and assign tags to topic-row-template -> RH_TOPICTAGS_TAGS.
*
* Note that we assign a string which includes the a-href-links already,
* because we cannot assign sub-blocks before the outer-block with
* assign_block_vars(...) and the event is before the actual assignment.
*
* @param $event
*/
public function viewforum_modify_topicrow($event)
{
if ($this->config[prefixes::CONFIG . '_display_tags_in_viewforum']) {
$data = $event->get_data();
$topic_id = (int) $data['row']['topic_id'];
$forum_id = (int) $data['row']['forum_id'];
if ($this->tags_manager->is_tagging_enabled_in_forum($forum_id)) {
$tags = $this->tags_manager->get_assigned_tags($topic_id);
if (!empty($tags)) {
// we cannot use assign_block_vars('topicrow.tags', ...) here, because the block 'topicrow' is not yet assigned
// add links
$this->assign_tags_to_template('rh_tags_tmp', $tags);
// small_tag.html might want to use our extension's css.
$this->template->assign_var('S_RH_TOPICTAGS_INCLUDE_CSS', true);
// we cannot just use 'small_tag.html' because in viewforum.php twig only searches in phpbb_root/styles/prosilver/template,
// but we need a template from our extension.
$rendered_tags = $this->template->assign_display('./../../../ext/robertheim/topictags/styles/all/template/small_tag.html');
// remove temporary data
$this->template->destroy_block_vars('rh_tags_tmp');
// assign the template data
$data['topic_row']['RH_TOPICTAGS_TAGS'] = $rendered_tags;
$event->set_data($data);
}
}
}
}
示例3: process_field_row
/**
* Return templated value/field. Possible values for $mode are:
* change == user is able to set/enter profile values; preview == just show the value
*/
public function process_field_row($mode, $profile_row)
{
$preview_options = $mode == 'preview' ? $profile_row['lang_options'] : false;
// set template filename
$this->template->set_filenames(array('cp_body' => $this->get_template_filename()));
// empty previously filled blockvars
$this->template->destroy_block_vars($this->get_name_short());
// Assign template variables
$this->generate_field($profile_row, $preview_options);
return $this->template->assign_display('cp_body');
}
示例4: show_sitemaker
public function show_sitemaker()
{
$this->blocks->show();
$this->set_assets();
if ($this->startpage) {
$this->template->destroy_block_vars('navlinks');
$this->template->assign_var('S_PT_SHOW_FORUM', true);
}
// Hide login/whois/birthday on index_body.html
$this->template->assign_vars(array('S_USER_LOGGED_IN' => true, 'S_DISPLAY_ONLINE_LIST' => false, 'S_DISPLAY_BIRTHDAY_LIST' => false));
}
示例5: parse_uploader
/**
* Parse the uploader
*
* @param string $tpl_file The name of the template file to use to create the uploader
* @param bool $custom_sort Function used to sort the attachments
* @return string The parsed HTML code ready for output
*/
public function parse_uploader($tpl_file = 'posting/attachments/default.html', $custom_sort = false)
{
// If the upload max filesize is less than 0, do not show the uploader (0 = unlimited)
if (!$this->access->is_team()) {
if (isset($this->ext_config->upload_max_filesize[$this->object_type]) && $this->ext_config->upload_max_filesize[$this->object_type] < 0) {
return '';
}
}
$this->template->assign_vars(array('FORM_NAME' => $this->form_name, 'MAX_LENGTH' => $this->access->is_team() ? $this->config['max_filesize'] : false, 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', 'S_INLINE_ATTACHMENT_OPTIONS' => true, 'S_PLUPLOAD_ENABLED' => $this->use_plupload, 'S_SET_CUSTOM_ORDER' => $this->set_custom_order, 'S_UPLOADER_KEY' => generate_link_hash('uploader_key'), 'SELECT_PREVIEW' => $this->object_type == TITANIA_SCREENSHOT, 'SELECT_REVIEW_VAR' => 'set_preview_file' . $this->object_type));
$index_dir = '-';
$index = $this->operator->get_count() - 1;
if ($custom_sort == false && !$this->config['display_order']) {
$index_dir = '+';
$index = 0;
}
$this->operator->sort($custom_sort);
// Delete previous attachments list
$this->template->destroy_block_vars('attach_row');
$base_url = $this->controller_helper->get_current_url();
$hash = generate_link_hash('attach_manage');
$comments = $this->get_request_comments();
$hidden_data = $this->get_basic_attachment_data();
$index_prefix = $this->use_plupload ? '' : $this->form_name . '_';
foreach ($this->operator->get_all() as $attachment_id => $attach) {
$params = array('a' => $attachment_id, 'hash' => $hash);
$_hidden_data = array();
foreach ($hidden_data[$attachment_id] as $property => $value) {
$_hidden_data["attachment_data[{$index_prefix}{$index}][{$property}]"] = $value;
}
$output = array_merge($attach->get_display_vars(''), array('FILENAME' => $attach->get_filename(), 'FILE_COMMENT' => isset($comments[$attachment_id]) ? $comments[$attachment_id] : $attach->get('attachment_comment'), 'ATTACH_ID' => $attachment_id, 'INDEX' => $index_prefix . $index, 'FILESIZE' => get_formatted_filesize($attach->get('filesize')), 'S_HIDDEN' => build_hidden_fields($_hidden_data), 'S_PREVIEW' => $attach->is_preview(), 'U_VIEW_ATTACHMENT' => $attach->get_url(), 'U_DELETE' => $this->path_helper->append_url_params($base_url, array_merge($params, array('action' => 'delete_attach')))));
if ($attach->is_type(TITANIA_SCREENSHOT)) {
$output = array_merge($output, array('U_MOVE_UP' => $this->path_helper->append_url_params($base_url, array_merge($params, array('action' => 'attach_up'))), 'U_MOVE_DOWN' => $this->path_helper->append_url_params($base_url, array_merge($params, array('action' => 'attach_down')))));
}
$index += $index_dir == '+' ? 1 : -1;
$this->template->assign_block_vars('attach_row', $output);
}
$this->template->assign_var('S_ATTACH_DATA', json_encode(array_values($hidden_data)));
$this->template->set_filenames(array($tpl_file => $tpl_file));
return $this->template->assign_display($tpl_file);
}
示例6: assign_messages
/**
* Assigns all message rows to the template
*
* @param $rows array
*/
protected function assign_messages($rows)
{
if (empty($rows)) {
return;
}
// Reverse the array if messages appear at the bottom
if (!$this->config['mchat_message_top']) {
$rows = array_reverse($rows);
}
$foes = $this->functions_mchat->mchat_foes();
$this->template->destroy_block_vars('mchatrow');
$user_avatars = array();
foreach ($rows as $i => $row) {
if (!isset($user_avatars[$row['user_id']])) {
$display_avatar = $this->display_avatars() && $row['user_avatar'];
$user_avatars[$row['user_id']] = !$display_avatar ? '' : phpbb_get_user_avatar(array('avatar' => $row['user_avatar'], 'avatar_type' => $row['user_avatar_type'], 'avatar_width' => $row['user_avatar_width'] > $row['user_avatar_height'] ? 40 : 40 / $row['user_avatar_height'] * $row['user_avatar_width'], 'avatar_height' => $row['user_avatar_height'] > $row['user_avatar_width'] ? 40 : 40 / $row['user_avatar_width'] * $row['user_avatar_height']));
}
}
foreach ($rows as $i => $row) {
// Auth checks
if ($row['forum_id'] != 0 && !$this->auth->acl_get('f_read', $row['forum_id'])) {
continue;
}
$message_edit = $row['message'];
decode_message($message_edit, $row['bbcode_uid']);
$message_edit = str_replace('"', '"', $message_edit);
$message_edit = mb_ereg_replace("'", '’', $message_edit);
if (in_array($row['user_id'], $foes)) {
$row['message'] = sprintf($this->user->lang('MCHAT_FOE'), get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST')));
}
$row['username'] = mb_ereg_replace("'", "’", $row['username']);
$message = str_replace("'", '’', $row['message']);
$username_full = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST'));
// Remove root path if we render messages for the index page
if (strpos($this->user->data['session_page'], 'app.' . $this->php_ext) === false) {
$username_full = str_replace('.' . $this->root_path, '', $username_full);
}
$this->template->assign_block_vars('mchatrow', array('S_ROW_COUNT' => $i, 'MCHAT_ALLOW_BAN' => $this->auth->acl_get('a_authusers'), 'MCHAT_ALLOW_EDIT' => $this->auth_message('u_mchat_edit', $row['user_id'], $row['message_time']), 'MCHAT_ALLOW_DEL' => $this->auth_message('u_mchat_delete', $row['user_id'], $row['message_time']), 'MCHAT_USER_AVATAR' => $user_avatars[$row['user_id']], 'U_VIEWPROFILE' => $row['user_id'] != ANONYMOUS ? generate_board_url() . append_sid("/{$this->root_path}memberlist.{$this->php_ext}", 'mode=viewprofile&u=' . $row['user_id']) : '', 'MCHAT_IS_POSTER' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] == $row['user_id'], 'MCHAT_PM' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id'] && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) ? generate_board_url() . append_sid("/{$this->root_path}ucp.{$this->php_ext}", 'i=pm&mode=compose&u=' . $row['user_id']) : '', 'MCHAT_MESSAGE_EDIT' => $message_edit, 'MCHAT_MESSAGE_ID' => $row['message_id'], 'MCHAT_USERNAME_FULL' => $username_full, 'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST')), 'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST')), 'MCHAT_USER_IP' => $row['user_ip'], 'MCHAT_U_IP' => $this->helper->route('dmzx_mchat_page_controller', array('page' => 'whois', 'ip' => $row['user_ip'])), 'MCHAT_U_BAN' => generate_board_url() . append_sid("/{$this->root_path}adm/index.{$this->php_ext}", 'i=permissions&mode=setting_user_global&user_id[0]=' . $row['user_id'], true, $this->user->session_id), 'MCHAT_MESSAGE' => censor_text(generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options'])), 'MCHAT_TIME' => $this->user->format_date($row['message_time'], $this->config['mchat_date']), 'MCHAT_MESSAGE_TIME' => $row['message_time'], 'MCHAT_EDIT_TIME' => $row['edit_time']));
}
}
示例7: parse_attachments
/**
* General attachment parsing
* From phpBB (includes/functions_content.php)
*
* @param string &$message The message
* @param string $tpl The template file to use
* @param array $preview_comments true if previewing from the posting page
* @param string|bool $template_block If not false we will output the parsed attachments to this template block
* @param bool $custom_sort Whether attachments have a custom order.
*
* @return array the parsed attachments
*/
public function parse_attachments(&$message, $tpl = 'common/attachment.html', $preview_comments = array(), $template_block = false, $custom_sort = false)
{
if (empty($this->attachments)) {
return array();
}
$this->user->add_lang('viewtopic');
if ($tpl !== false && !isset($this->template->filename['titania_attachment_tpl'])) {
$this->template->set_filenames(array('titania_attachment_tpl' => $tpl));
}
$this->sort($custom_sort);
$compiled_attachments = array();
$total_attachments = 0;
foreach ($this->attachments as $id => $attach) {
// We need to reset/empty the _file block var, because this function might be called more than once
$this->template->destroy_block_vars('_file');
$comment = $attach->get('attachment_comment');
if (isset($preview_comments[$id])) {
$comment = $preview_comments[$id];
}
$vars = $attach->get_display_vars($comment);
// If a template block is specified, output to that also
if ($template_block) {
$this->template->assign_block_vars($template_block, $vars);
}
if ($attach->is_preview() && $attach->is_type(TITANIA_SCREENSHOT)) {
$this->template->assign_block_vars('preview', $vars);
}
if ($tpl !== false) {
$this->template->assign_block_vars('_file', $vars);
$compiled_attachments[] = $this->template->assign_display('titania_attachment_tpl');
}
$total_attachments++;
}
$tpl_size = sizeof($compiled_attachments);
$unset_tpl = array();
// For inline attachments
if ($message) {
preg_match_all('#<!\\-\\- ia([0-9]+) \\-\\->(.*?)<!\\-\\- ia\\1 \\-\\->#', $message, $matches, PREG_PATTERN_ORDER);
$replace = array();
foreach ($matches[0] as $num => $capture) {
// Flip index if we are displaying the reverse way
$index = $this->config['display_order'] ? $tpl_size - ($matches[1][$num] + 1) : $matches[1][$num];
$replace['from'][] = $matches[0][$num];
if (isset($compiled_attachments[$index])) {
$replace['to'][] = $compiled_attachments[$index];
} else {
$replaced['to'][] = $this->user->lang('MISSING_INLINE_ATTACHMENT', $matches[2][array_search($index, $matches[1])]);
}
$unset_tpl[] = $index;
}
if (isset($replace['from'])) {
$message = str_replace($replace['from'], $replace['to'], $message);
}
$unset_tpl = array_unique($unset_tpl);
// Needed to let not display the inlined attachments at the end of the post again
foreach ($unset_tpl as $index) {
unset($compiled_attachments[$index]);
}
}
return $compiled_attachments;
}