当前位置: 首页>>代码示例>>PHP>>正文


PHP KTTemplating::loadTemplate方法代码示例

本文整理汇总了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";
}
开发者ID:5haman,项目名称:knowledgetree,代码行数:21,代码来源:smartyTemplate.php

示例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";
}
开发者ID:5haman,项目名称:knowledgetree,代码行数:21,代码来源:loadTemplate.php

示例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);
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:73,代码来源:KTPermissions.php


注:本文中的KTTemplating::loadTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。