• Главная
  • » PHP
  • » Smarty на примере модификации форума PunBB

#141 2012.03.09 13:53

Gemorroj
Administrator
Откуда: Белоруссия
Зарегистрирован: 2007.11.03
Сообщений: 6593
Карма: 107
Профиль Веб-сайт

Re: Smarty на примере модификации форума PunBB

какой конкретно ошибки?

Неактивен

#142 2012.03.09 18:39

tipsun
Moderator
Зарегистрирован: 2009.10.14
Сообщений: 2277
Карма: 19
Профиль

Re: Smarty на примере модификации форума PunBB

Не знаю почему, но я думал про exit(); ошибки.

Неактивен

#143 2012.03.09 18:46

Gemorroj
Administrator
Откуда: Белоруссия
Зарегистрирован: 2007.11.03
Сообщений: 6593
Карма: 107
Профиль Веб-сайт

Re: Smarty на примере модификации форума PunBB

не понимаю, - exit - языковая конструкция, а не ошибка.

Неактивен

#144 2012.03.10 12:34

tipsun
Moderator
Зарегистрирован: 2009.10.14
Сообщений: 2277
Карма: 19
Профиль

Re: Smarty на примере модификации форума PunBB

"wap/index.php" потихоньку собираю.

Неактивен

#145 2012.03.12 11:54

tipsun
Moderator
Зарегистрирован: 2009.10.14
Сообщений: 2277
Карма: 19
Профиль

Re: Smarty на примере модификации форума PunBB

Индексная вроде тоже готова.

Найдите 1 отличие big_smile (оно есть)

http://wapinet.ru/files/f/1/6/wap-index-php.jpg

Код:

1
span style="color: #0000BB"><?php{include file='header.tpl'}{assign var='date_format' value='%d/%m/%y %H:%I:%S'}{assign var='Show_new_posts' value='Show new posts'}{assign var='Mark_all_as_read' value='Mark all as read'}{assign var='Empty_board' value='Empty board'}{assign var='Link_separator_m' value='|'}<div class="navlinks"> {if $pun_user.is_guest} <a href="login.php">{$lang_common.Login}</a>{$Link_separator_m}<a href="register.php">{$lang_common.Register}</a> {else} {if $pun_user.g_id > $smarty.const.PUN_MOD} <a href="profile.php?id={$pun_user.id}">{$lang_common.Profile} (<span style="font-weight: bold">{$pun_user.username|escape}</span>)</a> {if $pun_config.o_pms_enabled && $pun_user.g_pm == 1} {$Link_separator_m}<a href="message_list.php">{$lang_pms.Private}</a> {/if} {$Link_separator_m}<a href="login.php?action=out&amp;id={$pun_user.id}&amp;csrf_token=">{$lang_common.Logout}</a> {/if} {if $pun_user.g_id < $smarty.const.PUN_MOD} <a href="{$smarty.const.PUN_ROOT}admin_index.php">{$lang_common.Admin_m}</a> {/if} {/if}</div>{assign var='j' value=false}{assign var='cur_category' value=''}{foreach from=$forums item=cur_forum} {if $cur_forum.cid != $cur_category} {assign var='cur_category' value={$cur_forum.cid}} {* assign var='cat_count' value=($cat_count + 1) *} <div class="cat"> <span class="sp_cat">{$cur_forum.cat_name|escape}</span> </div> {/if} <div class="{if $j = ! $j}in{else}in2{/if}"> {if $cur_forum.redirect_url} <a href="{$cur_forum.redirect_url|escape}">{$cur_forum.forum_name|escape}</a> {else} <a href="viewforum.php?id={$cur_forum.fid}">{$cur_forum.forum_name|escape}</a> ({$cur_forum.num_topics}/{$cur_forum.num_posts}) {/if} {if $cur_forum.last_post} <br/> <span class="sub"> » <a href="viewtopic.php?pid={$cur_forum.last_post_id}#p{$cur_forum.last_post_id}">{$cur_forum.subject|escape}</a> ({$cur_forum.last_post|date_format:$date_format} {$lang_common.by} {$cur_forum.last_poster|escape}) </span> {/if} </div>{foreachelse}<div class="in">{$lang_index.$Empty_board}</div>{/foreach}{if ! $pun_user.is_guest}<div class="go_to"><a class="but" href="search.php?action=show_new">{$lang_common.$Show_new_posts}</a><a class="but" href="misc.php?action=markread">{$lang_common.$Mark_all_as_read}</a></div>{/if}{assign var='No_of_users' value='No of users'}{assign var='No_of_topics' value='No of topics'}{assign var='No_of_posts' value='No of posts'}{assign var='Users_online' value='Users online'}{assign var='Guests_online' value='Guests online'}<div class="incqbox">{$lang_index.$No_of_users}: {$stats.total_users}<br/>{$lang_index.$No_of_topics}: {$stats.total_topics}<br/>{$lang_index.$No_of_posts}: {$stats.total_posts}<br/>{if $pun_config.o_users_online == 1}{$lang_index.$Users_online}: {$num_users|default:'0'}<br/>{$lang_index.$Guests_online}: {$num_guests|default:'0'}{if $num_users}</div><div class="act">{$lang_index.Online}:{foreach from=$users item=pun_user_online}<a href="profile.php?id={$pun_user_online.user_id}">{$pun_user_online.ident|escape}</a>{/foreach}{/if}{/if}</div>{include file='footer.tpl'}

Отредактировано tipsun (2012.03.12 12:02)

Неактивен

#146 2012.03.19 17:03

tipsun
Moderator
Зарегистрирован: 2009.10.14
Сообщений: 2277
Карма: 19
Профиль

Re: Smarty на примере модификации форума PunBB

wap/post.php

Код:

1
span style="color: #0000BB"><?php{include file='header.tpl'}<div class="inbox"><a href="index.php">{$lang_common.Index}</a> »{if $tip}<a href="viewforum.php?id={$cur_posting.id}">{$cur_posting.forum_name|escape}</a>{elseif $fid}{$cur_posting.forum_name|escape}{/if}{if isset($cur_posting.subject)}» {$cur_posting.subject|escape}{/if}</div>{if $errors}{assign var='Post_errors' value='Post errors'}<div class="red">{$lang_post.$Post_errors}</div><div class="msg">{foreach from=$errors item=cur_error}» {$cur_error}<br/>{/foreach}</div>{elseif isset($smarty.post.preview)}{assign var='Post_preview' value='Post preview'}<div class="info">{$lang_post.$Post_preview}</div><div class="msg">{* parse_message($message, $hide_smilies) *}</div>{/if}{assign var='Post_a_reply' value='Post a reply'}{assign var='Post_new_topic' value='Post new topic'}<div class="con">{if $tid} {$lang_post.$Post_a_reply}{elseif $fid} {$lang_post.$Post_new_topic}{/if}</div>{if $tid}<form method="post" action="post.php?action=post&amp;tid={$tid}" {if $file_limit}enctype="multipart/form-data"{/if}>{elseif $fid}<form method="post" action="post.php?action=post&amp;fid={$fid}" enctype="multipart/form-data">{/if}<div class="input">{*if ($pun_config['poll_enabled'] == 1 && $fid) { if (!$_GET['poll']) { include PUN_ROOT.'lang/'.$pun_user['language'].'/poll.php'; echo '<a href="post.php?fid='.$fid.'&amp;poll=1">'.$lang_poll['poll'].'</a><br/>'; } else { include_once PUN_ROOT.'include/poll/poll.inc.php'; $Poll->wap_showContainer(); $cur_index = 8; }}*}<input type="hidden" name="form_sent" value="1" /><input type="hidden" name="form_user" value="{$pun_user.username|escape|default:'Guest'}" />{if $pun_user.is_guest} {assign var='Guest_name' value='Guest name'} <strong>{$lang_post.$Guest_name}</strong><br /> <input type="text" name="req_username" value="{$username|escape}" tabindex="{assign var='cur_index' value=$cur_index+1}" /><br /> {if $pun_config.p_force_guest_email == 1}<strong>{$lang_common.E-mail}</strong>{else}{$lang_common.E-mail}{/if}<br /> <input type="text" name="{if $pun_config.p_force_guest_email == 1}req_email{else}email{/if}" value="{$email|escape}" tabindex="{assign var='cur_index' value=$cur_index+1}" /><br />{/if}{if $fid} <strong>{$lang_common.Subject}</strong><br /> <input type="text" name="req_subject" value="{$subject|escape}" maxlength="70" tabindex="{assign var='cur_index' value=$cur_index+1}" /><br />{/if}<textarea name="req_message" rows="4" cols="24" tabindex="{assign var='cur_index' value=$cur_index+1}">{if $smarty.post.req_message}{$message|escape}{elseif $quote}{$quote}{/if}</textarea><br /><a href="help.php?id=3">{$lang_common.Smilies}</a>{if $pun_config.o_smilies == 1}<span class="green">{$lang_common.on_m}</span>{else}<span class="grey">{$lang_common.off_m}</span>{/if}<a href="help.php?id=1">{$lang_common.BBCode}</a>{if $pun_config.p_message_bbcode == 1}<span class="green">{$lang_common.on_m}</span>{else}<span class="grey">{$lang_common.off_m}</span>{/if}{assign var='img_tag' value='img tag'}<a href="help.php?id=4">{$lang_common.$img_tag}</a>{if $pun_config.p_message_img_tag == 1}<span class="green">{$lang_common.on_m}</span>{else}<span class="grey">{$lang_common.off_m}</span>{/if}</div><div class="input2">{if $pun_user.g_post_replies == 2}<img src="{$pun_config.o_base_url}/include/captcha/captcha.php?{session_name()}={session_id()}" alt="" /><br />{assign var='Image_text' value='Image text'}{$lang_post.$Image_text}<br /><input type="text" name="req_image_" size="16" maxlength="16" /><br />{/if}{assign var='num_to_upload' value=min($file_limit, 20)}{if $can_upload && $num_to_upload > 0} {$lang_fu.Attachments}<br/> {include file='{$smarty.const.PUN_ROOT}include/attach/wap_post_input.php'}{/if}{assign var='Hide_smilies' value='Hide smilies'}{assign var='Merge_posts' value='Merge posts'}{if ! $pun_user.is_guest} {if $pun_config.o_smilies == 1} <input type="checkbox" name="hide_smilies" value="1" tabindex="{assign var='cur_index' value=$cur_index+1}" {if isset($smarty.post.hide_smilies)}checked="checked"{/if} />{$lang_post.$Hide_smilies}<br/> {/if} {if $is_admmod} <input type="checkbox" name="merge" value="1" checked="checked" />{$lang_post.$Merge_posts}<br/> {/if} {if $pun_config.o_subscriptions == 1} <input type="checkbox" name="subscribe" value="1" tabindex="{assign var='cur_index' value=$cur_index+1}" {if isset($smarty.post.subscribe)}checked="checked"{/if} />{$lang_post.Subscribe}<br/> {/if}{elseif $pun_config.o_smilies == 1}<input type="checkbox" name="hide_smilies" value="1" tabindex="{assign var='cur_index' value=$cur_index+1}" {if isset($smary.post.hide_smilies)}checked="checked"{/if} />{$lang_post.$Hide_smilies}{/if}</div><div class="go_to"><input type="hidden" name="form_t" value="{$smarty.server.REQUEST_TIME}" /><input type="submit" name="submit" value="{$lang_common.Submit}" tabindex="{assign var='cur_index' value=$cur_index+1}" accesskey="s" /><input type="submit" name="preview" value="{$lang_post.Preview}" tabindex="{assign var='cur_index' value=$cur_index+1}" accesskey="p" /></div></form>{include file='footer.tpl'}

Отредактировано tipsun (2012.03.19 17:03)

Неактивен

#147 2012.03.26 22:41

tipsun
Moderator
Зарегистрирован: 2009.10.14
Сообщений: 2277
Карма: 19
Профиль

Re: Smarty на примере модификации форума PunBB

wap/edit.php

Код:

1
span style="color: #0000BB"><?php<div class="inbox"><a href="index.php">{$lang_common.Index}</a> &#187; <a href="viewforum.php?id={$cur_post.fid}">{$cur_post.forum_name|escape}</a> &#187; {$cur_post.subject|escape}</div>{if $errors}<div class="red">{assign var='Post_errors' value='Post errors'}{$lang_post.$Post_errors}</div>{assign var='Post_errors_info' value='Post errors info'}<div class="msg">{$lang_post.$Post_errors_info}{foreach from=$errors item=cur_error}&#187; {$cur_error}<br/>{/foreach}</div>{elseif $smarty.post.preview}{include file='{$smarty.const.PUN_ROOT}include/parser.php'}{assign var='Post_preview' value='Post preview'}<div class="info">{$lang_post.$Post_preview}</div><div class="msg">{* parse_message($message, $hide_smilies) *}</div>{/if}{assign var='Edit_post' value='Edit post'}<div class="con">{$lang_post.$Edit_post}</div><form method="post" action="edit.php?id={$id}&amp;action=edit" enctype="multipart/form-data"><div class="input"><input type="hidden" name="form_sent" value="1" />{if $can_edit_subject}{$lang_common.Subject}<br/><input type="text" name="req_subject" tabindex="{assign var='cur_index' value=$cur_index+1}" value="{{$smarty.post.req_subject|define:$cur_post.subject}|escape}" /><br/><!-- /label -->{/if}{* include file='{$smarty.const.PUN_ROOT}include/attach/fetch.php' *}{$lang_common.Message}:<br/><textarea name="req_message" rows="4" cols="24" tabindex="{assign var='cur_index' value=$cur_index+1}">{{$message|define:$cur_post.message}|escape}</textarea><br/><a href="help.php?id=3">{$lang_common.Smilies}</a>{if $pun_config.o_smilies == 1}<span class="green">{$lang_common.on_m}</span>;{else}<span class="grey">{$lang_common.off_m}</span>;{/if}<a href="help.php?id=1">{$lang_common.BBCode}</a>{if $pun_config.p_message_bbcode == 1}<span class="green">{$lang_common.on_m}</span>;{else}<span class="grey">{$lang_common.off_m}</span>;{/if}{assign var='img_tag' value='img tag'}<a href="help.php?id=4">{$lang_common.$img_tag}</a>{if $pun_config.p_message_img_tag == 1}<span class="green">{$lang_common.on_m}</span>{else}<span class="grey">{$lang_common.off_m}</span>;{/if}<br/>{*$num_to_upload = $file_limit;$num_to_upload = min($num_to_upload, 20);if ($uploaded_to_post || ($can_upload && $num_to_upload > 0)) { //Attachments include PUN_ROOT.'include/attach/wap_view_attachments.php'; if ($can_upload && $num_to_upload > 0) { echo '</div><div class="input2">'.$lang_fu['Choose a file'].'<br/>'; } include PUN_ROOT.'include/attach/wap_post_input.php';}*}{if $pun_config.o_smilies == 1}{assign var='Hide_smilies' value='Hide smilies'}<input type="checkbox" name="hide_smilies" value="1" {if isset($smarty.post.hide_smilies) || $cur_post.hide_smilies == 1}checked="checked"{/if} tabindex="{assign var='cur_index' value=$cur_index+1}" /> {$lang_post.$Hide_smilies}<br/>{/if}{if $is_admmod}<input type="checkbox" name="silent" value="1" tabindex="{assign var='cur_index' value=$cur_index+1}" {if (isset($smarty.post.form_sent) && isset($smarty.post.silent)) || ! isset($smarty.post.form_sent)}checked="checked"{/if} /> {$lang_post.$Silent_edit}<br/>{/if}</div><div class="go_to"><input type="submit" name="submit" value="{$lang_common.Submit}" tabindex="{assign var='cur_index' value=$cur_index+1}" accesskey="s" /><input type="submit" name="preview" value="{$lang_post.Preview}" tabindex="{assign var='cur_index' value=$cur_index+1}" accesskey="p" /></div></form>

Неактивен

#148 2012.03.27 06:53

LEXIN
Участник
Зарегистрирован: 2011.10.31
Сообщений: 26
Карма: 5
Профиль Веб-сайт

Re: Smarty на примере модификации форума PunBB

tipsun написал:


Индексная вроде тоже готова.

Найдите 1 отличие big_smile (оно есть)

1. Нет фоновых изображений
2. Добавлена ссылка "RSS"
3. Перед ссылкой "Админ панель" отсутствуют 2 ссылки, а после - еще одна.
4. Жоская генерация. (1331538677.555 s)

На код приятно посмотреть. Круууть roll

Неактивен

#149 2012.03.27 10:41

Gemorroj
Administrator
Откуда: Белоруссия
Зарегистрирован: 2007.11.03
Сообщений: 6593
Карма: 107
Профиль Веб-сайт

Re: Smarty на примере модификации форума PunBB

да, шаблонизация рулит. код намного чище

Неактивен

#150 2012.03.27 11:35

tipsun
Moderator
Зарегистрирован: 2009.10.14
Сообщений: 2277
Карма: 19
Профиль

Re: Smarty на примере модификации форума PunBB

LEXIN, smile
Еще есть, где активных показывает форум, там еще строка с ссылками. Это было поле с выбором, оно было выше.
- - - -
Еще я пропускал интимные места, может где забыл "htmlSpecialChars()"/"|escape"
Можно было все в массив занести, и получилось бы что мы 1 раз заносим все переменные, т.е.

Код:

1
span style="color: #0000BB"><?php$allVars = array($title, $users, $trololo);$smarty->assign($allVars);

Отредактировано tipsun (2012.03.27 11:41)

Неактивен

  • Главная
  • » PHP
  • » Smarty на примере модификации форума PunBB

Дополнительно

forum.wapinet.ru

PunBB Mod v0.6.2
0.018 s