本文整理汇总了PHP中KTTemplating::loadTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP KTTemplating::loadTemplate方法的具体用法?PHP KTTemplating::loadTemplate怎么用?PHP KTTemplating::loadTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KTTemplating
的用法示例。
在下文中一共展示了KTTemplating::loadTemplate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: KTTemplating
<?php
require_once "../../config/dmsDefaults.php";
require_once KT_LIB_DIR . "/templating/templating.inc.php";
error_reporting(E_ALL);
$oTemplating = new KTTemplating();
$oTemplating->aLocationRegistry = array("test" => "tests/templating/mytemplates");
$oTemplate = $oTemplating->loadTemplate("smartyTemplate");
if (PEAR::isError($oTemplate)) {
print "Failure!\n";
print $oTemplate->toString();
}
$aExpectedRet = "Hello there Neil.";
$aRet = $oTemplate->render(array("name" => "Neil"));
$aRet = $aExpectedRet;
if ($aRet === $aExpectedRet) {
print "Success!\n";
} else {
print "Expected: {$aExpectedRet}\n";
print "Got: {$aRet}\n";
}
示例2: KTTemplating
<?php
require_once "../../config/dmsDefaults.php";
require_once KT_LIB_DIR . "/templating/templating.inc.php";
error_reporting(E_ALL);
$oTemplating = new KTTemplating();
$oTemplating->aLocationRegistry = array("test" => "tests/templating/mytemplates");
$oTemplate = $oTemplating->loadTemplate("loadTemplate");
if (PEAR::isError($oTemplate)) {
print "Failure!\n";
print $oTemplate->toString();
}
$aExpectedRet = "Hello there.";
$aRet = $oTemplate->render(array());
$aRet = $aExpectedRet;
if ($aRet === $aExpectedRet) {
print "Success!\n";
} else {
print "Expected: {$aExpectedRet}\n";
print "Got: {$aRet}\n";
}
示例3: KTTemplating
function do_main()
{
$this->oPage->setTitle(_kt("View Roles"));
$this->oPage->setBreadcrumbDetails(_kt("View Roles"));
$oTemplating = new KTTemplating();
$oTemplate = $oTemplating->loadTemplate("ktcore/action/view_roles");
// we need to have:
// - a list of roles
// - with their users / groups
// - and that allocation id
$aRoles = array();
// stores data for display.
$aRoleList = Role::getList();
foreach ($aRoleList as $oRole) {
$iRoleId = $oRole->getId();
$aRoles[$iRoleId] = array("name" => $oRole->getName());
$oRoleAllocation = DocumentRoleAllocation::getAllocationsForDocumentAndRole($this->oDocument->getId(), $iRoleId);
if (is_null($oRoleAllocation)) {
$oRoleAllocation = RoleAllocation::getAllocationsForFolderAndRole($this->oDocument->getFolderID(), $iRoleId);
}
$u = array();
$g = array();
$aid = null;
$raid = null;
if (is_null($oRoleAllocation)) {
// nothing.
} else {
//var_dump($oRoleAllocation);
$raid = $oRoleAllocation->getId();
// real_alloc_id
$aAllowed = $oRoleAllocation->getAllowed();
if (!empty($aAllowed['user'])) {
$u = $aAllowed['user'];
}
if (!empty($aAllowed['group'])) {
$g = $aAllowed['group'];
}
}
$aRoles[$iRoleId]['users'] = $u;
$aRoles[$iRoleId]['groups'] = $g;
$aRoles[$iRoleId]['real_allocation_id'] = $raid;
}
// final step.
// map to users, groups.
foreach ($aRoles as $key => $role) {
$_users = array();
foreach ($aRoles[$key]['users'] as $iUserId) {
$oUser = User::get($iUserId);
if (!(PEAR::isError($oUser) || $oUser == false)) {
$_users[] = $oUser->getName();
}
}
if (empty($_users)) {
$aRoles[$key]['users'] = '<span class="descriptiveText"> ' . _kt('no users') . '</span>';
} else {
$aRoles[$key]['users'] = implode(', ', $_users);
}
$_groups = array();
foreach ($aRoles[$key]['groups'] as $iGroupId) {
$oGroup = Group::get($iGroupId);
if (!(PEAR::isError($oGroup) || $oGroup == false)) {
$_groups[] = $oGroup->getName();
}
}
if (empty($_groups)) {
$aRoles[$key]['groups'] = '<span class="descriptiveText"> ' . _kt('no groups') . '</span>';
} else {
$aRoles[$key]['groups'] = implode(', ', $_groups);
}
}
$aTemplateData = array('context' => &$this, 'roles' => $aRoles);
return $oTemplate->render($aTemplateData);
}