本文整理汇总了PHP中KTemplate::fetchBlock方法的典型用法代码示例。如果您正苦于以下问题:PHP KTemplate::fetchBlock方法的具体用法?PHP KTemplate::fetchBlock怎么用?PHP KTemplate::fetchBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KTemplate
的用法示例。
在下文中一共展示了KTemplate::fetchBlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
function get()
{
global $Permissions;
global $sRequest;
$tpl = new KTemplate();
$_s = file_get_contents(__FILE__);
$_s = substr($_s, strpos($_s, '?' . '>') + 2);
$tpl->loadTemplateContent($_s);
$sql = "SELECT * FROM `" . DB_PREFIX . DB_TBL_COMMENTS . "` WHERE `url`='" . $sRequest . "'";
$sql = mysql_query($sql);
if (false == $sql) {
my_die();
}
$aList = array();
while ($row = mysql_fetch_assoc($sql)) {
$aList[] = $row;
}
// dbg($aList);
if (empty($aList)) {
$tpl->assign('Comment', 'Нет комментариев');
}
foreach ($aList as $v) {
$sql = "SELECT * FROM. `" . DB_PREFIX . DB_TBL_USERS . "` WHERE `id`=" . $v['user_id'];
$sql = mysql_query($sql);
if (false == $sql) {
my_die();
}
$aUser = array();
while ($row = mysql_fetch_assoc($sql)) {
$aUser = $row;
}
// dbg($aUser);
$v = array_merge($v, $aUser);
// dbg($v);
$tplComment = $tpl->fetchBlock('Comment');
$tplComment->assign($v);
$tpl->assign('Comment', $tplComment);
$tplComment->reset();
}
if ($Permissions->bIsLogged()) {
$tpl->assign('CommentForm', $tpl->fetchBlock('CommentForm'));
} else {
$tpl->assign('CommentForm', 'Войдите, чтобы оставить комментарий');
}
return $tpl->get();
}
示例2: int_block
function int_block($aArray, $sFileNameItemsTpl, $sEmpty = "пусто")
{
// Console::log($aArray);
$tpl = new KTemplate(FLGR_ITEMS . '/int.htm');
if (!isset($aArray['More'])) {
$tpl->assign('More', '');
} elseif (is_array($aArray['More'])) {
foreach ($aArray['More'] as $k => $v) {
$tplMore = $tpl->fetchBlock('More');
$tplMore->assign('x_more', $k);
$tplMore->assign('more', $v);
$tpl->assign('More', $tplMore);
$tplMore->reset();
}
unset($aArray['More']);
}
// dbg($aArray['Items']);
if (is_array($aArray['Items'])) {
$tplItems = new KTemplate(FLGR_ITEMS . '/' . $sFileNameItemsTpl);
// dbg($tplItems);
if (empty($aArray['Items'])) {
$tplItems->assign('Item', $sEmpty . '<br /><br />');
}
foreach ($aArray['Items'] as $v) {
$tplItem = $tplItems->fetchBlock('Item');
// dbg($v);
$tplItem->assign($v);
$tplItems->assign('Item', $tplItem);
$tplItem->reset();
}
$tpl->assign('Items', $tplItems);
} else {
$tpl->assign('Items', $aArray['Items']);
}
if (!isset($aArray['count'])) {
$aArray['count'] = count($aArray['Items']);
}
unset($aArray['Items']);
$tpl->assign('info', '');
$tpl->assign($aArray);
return $tpl;
}
示例3: count
// Выводим саму фотографию
$tpl->assign($aItem);
// Выводим ее порядковый номер и кол-во фотографий в альбоме
$aPhotos = ${$owner}->getPhotos($aOwner['id']);
$tpl->assign('count', count($aPhotos));
foreach ($aPhotos as $k => $v) {
if ($v['id'] == $aItem['id']) {
break;
}
}
$tpl->assign('num', $k + 1);
// Выводим предыдущую и следующую фотографию в альбоме
$tpl->assign('Prew', '');
$tpl->assign('Next', '');
if (isset($aPhotos[$k - 1])) {
$tplPrew = $tpl->fetchBlock('Prew');
$tplPrew->assign('id', $aPhotos[$k - 1]['id']);
$tpl->assign('Prew', $tplPrew);
$tplPrew->reset();
}
if (isset($aPhotos[$k + 1])) {
$tplNext = $tpl->fetchBlock('Next');
$tplNext->assign('id', $aPhotos[$k + 1]['id']);
$tpl->assign('Next', $tplNext);
$tplNext->reset();
}
//dbg();
// Сбрасываем $bFlag404
$bFlag404 = false;
// CLOSE
$_t->assign('ContentBlock', $tpl);
示例4: array
$sql = "SELECT * FROM `" . DB_PREFIX . DB_TBL_CATALOGS . "`";
$sql = mysql_query($sql);
if (false == $sql) {
my_die();
}
$aListCatalogs = array();
while ($row = mysql_fetch_assoc($sql)) {
$aListCatalogs[$row['id']] = $row;
}
//dbg($aListCatalogs);
//Выводим список каталогов
if (empty($aListCatalogs)) {
$tpl->assign('catalogs', '');
} else {
foreach ($aListCatalogs as $k => $v) {
$tplCatalogs = $tpl->fetchBlock('catalogs');
$tplCatalogs->assign('cat-edit', $aCmsModules['catalog-edit']['key'] . '/' . $v['id']);
$tplCatalogs->assign('cat-del', $aCmsModules['catalog-del']['key'] . '/' . $v['id']);
$tplCatalogs->assign('cat-to', $aCmsModules['catalogs']['key'] . '/' . $v['id']);
if (isset($aRequest[$nLevel + 1]) && $aRequest[$nLevel + 1] == $v['id']) {
$tplCatalogs->assign('cat-name', '<b>' . $v['name'] . '</b>');
$BreadCrumbs->addBreadCrumbs($v['id'], $v['name']);
} else {
$tplCatalogs->assign('cat-name', $v['name']);
}
$tpl->assign('catalogs', $tplCatalogs);
$tplCatalogs->reset();
}
}
if (!$bFlag404) {
$tpl->assign('group-create', '');
示例5: KTemplate
<?php
// BREADCRUMBS
$BreadCrumbs->addBreadCrumbs($sKey, $sTitle);
if (!$bFlagLastModule) {
return;
}
$_t->assign('BreadCrumbs', $BreadCrumbs->getBreadCrumbs());
// TEMPLATE
$tpl = new KTemplate();
$_s = file_get_contents(__FILE__);
$_s = substr($_s, strpos($_s, '?' . '>') + 2);
$tpl->loadTemplateContent($_s);
// Left
$tplSub = $tpl->fetchBlock('subfunctions');
$tplSub->assign('subst', $sRequest);
$tpl->assign('subfunctions', $tplSub);
// Right
$sql = "SELECT * FROM `" . DB_PREFIX . DB_TBL_USERS . "`";
$sql = mysql_query($sql);
if (false == $sql) {
my_die();
}
$aAccounts = array();
while ($row = mysql_fetch_assoc($sql)) {
$aAccounts[] = $row;
}
if (empty($aAccounts)) {
$tpl->assign('content', 'Нет аккаунтов');
} else {
$tplContent = $tpl->fetchBlock('content');
示例6: KTemplate
$_t = new KTemplate(FLGR_CMS_TEMPLATES . '/login-form.htm');
$bFlagStop = true;
return;
}
// TEMPLATE
$_t = new KTemplate(FLGR_CMS_TEMPLATES . '/' . $sModuleTpl . '.htm');
// BREADCRUMBS
$BreadCrumbs->addBreadCrumbs($sKey, $sTitle);
// TOPMENU
$sql = "SELECT `key`, `title`, `annotation` \n\t\tFROM `" . DB_PREFIX . DB_TBL_PAGES . "` \n\t\tWHERE parent = " . $nId . " ORDER BY `order`";
$sql = mysql_query($sql);
if (false == $sql) {
my_die();
}
while ($row = mysql_fetch_assoc($sql)) {
$tpl_topmenu = $_t->fetchBlock('topmenu');
$tpl_topmenu->assign('topmenu_key', '/' . $sKey . '/' . $row['key']);
$tpl_topmenu->assign('topmenu_title', $row['title']);
$_t->assign('topmenu', $tpl_topmenu);
$tpl_topmenu->reset();
}
// PERMISSIONS
if (!$Permissions->bIsAdmin()) {
$_t->assign('content', "Доступ запрещен!");
$bFlagStop = true;
cStat::bSaveEvent(EVENT_PERMDENIED);
return;
}
if (defined('VERSION')) {
$_t->assign('VERSION', VERSION);
} else {
示例7: slashify
}
foreach ($aList as $v) {
$v['url'] = slashify($v['url']);
$sql = "SELECT * FROM. `" . DB_PREFIX . DB_TBL_USERS . "` WHERE `id`=" . $v['user_id'];
$sql = mysql_query($sql);
if (false == $sql) {
my_die();
}
$aUser = array();
while ($row = mysql_fetch_assoc($sql)) {
$aUser = $row;
}
// dbg($aUser);
$v = array_merge($aUser, $v);
// dbg($v);
$tplComment = $tpl->fetchBlock('Comment');
$tplComment->assign($v);
$tpl->assign('Comment', $tplComment);
$tplComment->reset();
}
$sql = 'SELECT count(*) FROM `' . DB_PREFIX . DB_TBL_COMMENTS . '`';
$sql = mysql_query($sql);
if (false == $sql) {
my_die();
}
$nCountComment = current(mysql_fetch_assoc($sql));
$tplPrevNext = $tpl->fetchBlock('prev_next');
if ($nCountComment > $nStart + POST_PER_PAGE) {
$tplPrev = $tplPrevNext->fetchBlock('block_prev');
$tplPrev->assign('prev', $nStart + POST_PER_PAGE);
$tplPrevNext->assign('block_prev', $tplPrev);
示例8: dbg
break;
case 'rename_role':
$Permissions->renameRole($_POST['id'], $_POST['name']);
break;
default:
dbg($_POST);
break;
}
}
// TEMPLATE
$tpl = new KTemplate(FLGR_CMS_TEMPLATES . '/' . $sModuleTpl . '.htm');
$aRoles = $Permissions->getAllRoles();
$tpl->assign('InRole', '');
$tpl->assign('Roles', '');
foreach ($aRoles as $v) {
$tplRoles = $tpl->fetchBlock('Roles');
$tplRoles->assign('subst', $aCmsModules['roles']['key']);
$tplRoles->assign('del', $aCmsModules['role-del']['key']);
$tplRoles->assign('id', $v['id']);
$tplRoles->assign('name', $v['name']);
$tplRoles->assign('cnt', '(' . count($Permissions->getUsersWithThisRole($v['id'])) . ')');
if (isset($aRequest[$nLevel + 1]) && $aRequest[$nLevel + 1] == $v['id']) {
$BreadCrumbs->addBreadCrumbs($v['id'], $v['name']);
$tplRoles->assign('b', '<b>');
$tplRoles->assign('/b', '</b>');
$bFlag404 = false;
$tplInRole = $tpl->fetchBlock('InRole');
$tplInRole->assign('role', $v['name']);
foreach ($Permissions->getUsersWithoutThisRole($v['id']) as $w) {
$tplFreeUsers = $tplInRole->fetchBlock('FreeUsers');
$tplFreeUsers->assign($w);
示例9: KTemplate
<?php
// BREADCRUMBS
$BreadCrumbs->addBreadCrumbs($sKey, $sTitle);
$tpl = new KTemplate(FLGR_CMS_TEMPLATES . '/' . $sModuleTpl . '.htm');
$act = 'security_class_create';
// POST
if (isset($_POST['act']) and $_POST['act'] == $act) {
$result = $Permissions->createClass($_POST['name'], $_POST['reference'], $_POST['default'], $_POST['hierarchical'], $_POST['policy']);
if ($result) {
header('Location: ' . $aCmsModules['security']['key']);
} else {
$tplError = $tpl->fetchBlock('Error');
$tplError->assign('error', 'ќшибка при заполнении полей!');
$tpl->assign('name', $_POST['name']);
$tpl->assign('reference', $_POST['reference']);
if ($_POST['default']) {
$tpl->assign('selected_default_1', 'selected');
$tpl->assign('selected_default_0', '');
} else {
$tpl->assign('selected_default_1', '');
$tpl->assign('selected_default_0', 'selected');
}
if ($_POST['hierarchical']) {
$tpl->assign('selected_hierarchical_1', 'selected');
$tpl->assign('selected_hierarchical_0', '');
} else {
$tpl->assign('selected_hierarchical_1', '');
$tpl->assign('selected_hierarchical_0', 'selected');
}
if ($_POST['policy']) {
示例10: KTemplate
<?php
// OPEN
if ('' == $sModuleTpl) {
my_die('Error: Template not found');
}
$_t = new KTemplate(FLGR_TEMPLATES . '/' . $sModuleTpl . '.htm');
if (!isset($aRequest[$nLevel + 1]) || !is_numeric($aRequest[$nLevel + 1]) || isset($aRequest[$nLevel + 2])) {
die('Error: ivalid URL!');
return;
}
$bFlag404 = false;
$aMessages = $Mails->getCorrespondence($aRequest[$nLevel + 1]);
//dbg($aMessages);
foreach ($aMessages as $v) {
$tplMessages = $_t->fetchBlock('Messages');
$tplMessages->assign($v);
$_t->assign('Messages', $tplMessages);
$tplMessages->reset();
}
$_t->assign('dbg', '');
//$_t->assign('corr', overbox('dbg', array(
// $aMessages
//)));
示例11: dbg
break;
default:
dbg($_POST);
break;
}
}
// TEMPLATE
$tpl = new KTemplate(FLGR_CMS_TEMPLATES . '/' . $sModuleTpl . '.htm');
$aClasses = $Permissions->getAllClasses();
if (empty($aClasses)) {
$tpl->assign('Classes', '');
$tpl->assign('InClass', '');
}
$tpl->assign('subst', $aCmsModules['security']['key']);
foreach ($aClasses as $aClass) {
$tplClasses = $tpl->fetchBlock('Classes');
$tplClasses->assign('subst', $aCmsModules['security']['key']);
$tplClasses->assign('del', $aCmsModules['security-del']['key']);
$tplClasses->assign('edit', $aCmsModules['security-edit']['key']);
$tplClasses->assign($aClass);
if (isset($aRequest[$nLevel + 1]) && $aRequest[$nLevel + 1] == $aClass['id']) {
$bFlag404 = false;
$tplClasses->assign('b', '<b>');
$tplClasses->assign('/b', '</b>');
$tplInClass = $tpl->fetchBlock('InClass');
$aActions = $Permissions->getActionsForClass($aClass['id']);
if (empty($aActions)) {
$tplInClass->assign('Actions', '<tr><td>Нет действий</td></tr>');
}
foreach ($aActions as $aAction) {
$tplActions = $tplInClass->fetchBlock('Actions');
示例12: array
}
$_t->assign('title', 'Последние записи');
$sql = 'SELECT * FROM `' . DB_PREFIX . DB_TBL_POSTS . '` ORDER BY `t` DESC LIMIT ' . $nStart . ',' . POST_PER_PAGE;
$sql = mysql_query($sql);
if (false == $sql) {
my_die();
}
$aPosts = array();
while ($row = mysql_fetch_assoc($sql)) {
$aPosts[] = $row;
}
if (empty($aPosts)) {
$_t->assign('ContentBlock', 'Больше записей нет');
}
$tplBlog = new KTemplate(FLGR_TEMPLATES . '/blog.htm');
$tplPost = $tplBlog->fetchBlock('post');
foreach ($aPosts as $k => $v) {
$tplPost->assign('link', $v['id']);
$tplPost->assign('title', $v['title']);
// dbg($sape_context);
$tplPost->assign('text', crbr($sape_context->replace_in_text_segment($v['text'])));
$tplPost->assign('t', str_replace(' ', ' ', date_humanize($v['t'])));
$tplPost->assign('comments', nGetCountComments_FromPostId($v['id']));
$_t->assign('ContentBlock', $tplPost);
$tplPost->reset();
}
$sql = 'SELECT count(*) FROM `' . DB_PREFIX . DB_TBL_POSTS . '`';
$sql = mysql_query($sql);
if (false == $sql) {
my_die();
}
示例13: while
// теперь стыкуем блоковые шаблоны
// ------ Список доступных для редактирования форм:
// Набираем доступные формы из мускуля
$sql = "SELECT `id`, `name` FROM `" . DB_PREFIX . DB_TBL_FORMS . "`";
$sql = mysql_query($sql);
if (false == $sql) {
my_die();
}
// ассигнуем шаблон
if (mysql_num_rows($sql) < 1) {
// Ф таблице нет доступных форм
$tpl->assign('FormItem', ' Пока нет доступных форм');
} else {
// Наполняем шаблон отвечающий за список форм
while ($row = mysql_fetch_assoc($sql)) {
$tplFormItem = $tpl->fetchBlock('FormItem');
$tplFormItem->assign($row);
$tpl->assign('FormItem', $tplFormItem);
$tplFormItem->reset();
}
}
// --- Блок редактирования полей выбранной формы:
// Проверяем, а выбрана ли какаянить форма
if (!$cur_form_sel) {
// Форма не выбрана, ассигнуем призыв ее выбрать
$tpl->assign('FieldsItem', 'Выберите форму из списка слева');
} else {
// Набираем поля выбранной формы из мускуля
$sql = "SELECT `id`, `name`, `id_type` FROM `" . DB_PREFIX . DB_TBL_FORMS_FIELDS . "` \n\t\t WHERE `id_form`= {$cur_form_sel}";
$sql = mysql_query($sql);
if (false == $sql) {
示例14: foreach
if (!empty($aList)) {
foreach ($aList as $k => $v) {
$aElts[$v['name']] = array($v['id'] => $v['alias']);
}
}
//dbg($aElts, 'elts');
// Tables (name=>?isset)
foreach ($aTables as $k => $v) {
if (isset($aElts[$k])) {
$aTables[$k] = 0;
}
}
//dbg($aTables, 'tables');
// Out tables
foreach ($aTables as $k => $v) {
$tplLoad = $tpl->fetchBlock('Load');
if ($v) {
$tplLoad->assign('checked', 'checked');
} else {
$tplLoad->assign('checked', '');
}
$tplLoad->assign('name', $k);
$tplLoad->assign('alias', $k);
$tpl->assign('Load', $tplLoad);
$tplLoad->reset();
}
if (empty($aElts)) {
$tpl->assign('Elt', '');
} else {
foreach ($aList as $v) {
$tplElt = $tpl->fetchBlock('Elt');
示例15: array
my_die();
}
$aFields = array();
while ($row = mysql_fetch_assoc($sql)) {
if (empty($row['Key'])) {
if (isset($aCatalog['fields'][$row['Field']])) {
$row['Value'] = $aCatalog['fields'][$row['Field']];
$aFields[$row['Field']] = $row;
}
}
}
//dbg($aFields);
if (empty($aFields)) {
$tpl->assign('content', 'Нет полей');
} else {
$tplContent = $tpl->fetchBlock('content');
foreach ($aFields as $k => $v) {
$tplFields = $tplContent->fetchBlock('Fields');
$tplFields->assign($v);
// select
//dbg($v);
foreach ($aOptTypes as $c => $w) {
$tplSelType = $tplFields->fetchBlock('SelType');
$tplSelType->assign('TypeName', $w);
$tplSelType->assign('Type', $c);
if ($v['Type'] == $c) {
$tplSelType->assign('selected', 'selected');
} else {
$tplSelType->assign('selected', '');
}
$tplFields->assign('SelType', $tplSelType);