本文整理汇总了PHP中PHPWS_Template::getTplDir方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPWS_Template::getTplDir方法的具体用法?PHP PHPWS_Template::getTplDir怎么用?PHP PHPWS_Template::getTplDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPWS_Template
的用法示例。
在下文中一共展示了PHPWS_Template::getTplDir方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addStyle
/**
* Adds a module's style sheet to the style sheet list
*/
public static function addStyle($module, $filename = NULL)
{
if (!LAYOUT_ALLOW_STYLE_LINKS) {
return;
}
if (!PHPWS_Settings::get('layout', 'include_css_order')) {
return;
}
if (!isset($filename)) {
$filename = 'style.css';
}
$tag = md5($module . $filename);
if (isset($GLOBALS['Style'][$tag])) {
return;
}
$cssFile['tag'] =& $tag;
$moduleLoc = sprintf('mod/%s/templates/%s', $module, $filename);
$cssFile['file'] = $moduleLoc;
$themeFile['file'] = PHPWS_Template::getTplDir($module) . $filename;
if (is_file($themeFile['file'])) {
Layout::addToStyleList(str_replace(PHPWS_SOURCE_DIR, '', $themeFile));
} else {
Layout::addToStyleList($cssFile);
}
}
示例2: view
/**
* Returns a menu and its links for display
*/
public function view($admin = false)
{
$key = Key::getCurrent();
if ($key && $key->isDummy(true)) {
return;
}
$theme_tpl_dir = \PHPWS_Template::getTplDir('menu') . 'menu_layout/';
$menu_tpl_dir = PHPWS_SOURCE_DIR . 'mod/menu/templates/menu_layout/';
$theme_path = $theme_tpl_dir . $this->template . '/';
$menu_path = $menu_tpl_dir . $this->template . '/';
if (is_file($theme_path . 'menu.tpl')) {
$file = $theme_path . 'menu.tpl';
$path = $theme_path;
$http = 'themes/' . Layout::getTheme() . '/templates/menu/menu_layout/' . $this->template . '/';
} elseif (is_file($menu_path . 'menu.tpl')) {
$file = $menu_path . 'menu.tpl';
$path = $menu_path;
$http = 'mod/menu/templates/menu_layout/' . $this->template . '/';
} else {
$this->template = 'basic';
$this->save();
$path = $menu_tpl_dir . 'basic/';
$http = 'mod/menu/templates/menu_layout/basic/';
$file = $path . '/menu.tpl';
}
$this->parseIni($path);
if ($this->_style) {
$style = $http . 'style.css';
Layout::addToStyleList($style);
}
$tpl['TITLE'] = $this->getTitle();
$tpl['LINKS'] = $this->displayLinks($admin);
$tpl['MENU_ID'] = sprintf('menu-%s', $this->id);
$content = PHPWS_Template::process($tpl, 'menu', $file, true);
return $content;
}
示例3: setFile
/**
* Sets the template file specified. Function decides which file to use based
* on template.php settings and file availability
*/
public function setFile($file, $strict = false)
{
$module = $this->getModule();
$this->setCache();
if ($strict == true) {
$result = $this->loadTemplateFile($file);
$used_tpl =& $file;
} else {
$theme_tpl = PHPWS_Template::getTplDir($module) . $file;
$mod_tpl = PHPWS_SOURCE_DIR . "mod/{$module}/templates/{$file}";
if (PHPWS_Error::isError($theme_tpl)) {
return $theme_tpl;
}
if (is_file($theme_tpl)) {
$result = $this->loadTemplateFile($theme_tpl);
$used_tpl =& $theme_tpl;
} elseif (is_file($mod_tpl)) {
$result = $this->loadTemplateFile($mod_tpl);
$used_tpl =& $mod_tpl;
} else {
throw new Exception(t('Missing template file: %s', $file));
}
}
if ($result) {
PHPWS_Error::logIfError($result);
$this->lastTemplatefile = $used_tpl;
return $result;
} else {
return $this->err[0];
}
}
示例4: menuList
private function menuList()
{
\Layout::addStyle('menu', 'admin.css');
javascript('jquery');
javascript('jquery_ui');
//commenting out for now. problem clearing select dropdown
//javascript('select2');
$template = new \Template();
$template->setModuleTemplate('menu', 'admin/administrate.html');
$first_menu_pin_all = 0;
$first_menu_template = null;
$db = new PHPWS_DB('menus');
$db->addOrder('queue');
$result = $db->getObjects('Menu_Item');
$first_menu = null;
if (!empty($result)) {
foreach ($result as $menu) {
$menu->_show_all = true;
if (empty($first_menu)) {
$first_menu = $menu;
$active = 'active';
} else {
$active = null;
}
$tpl['menus'][] = array('title' => $menu->title, 'id' => $menu->id, 'active' => $active);
}
$first_menu_template = $first_menu->template;
// for display, use the admin template
$first_menu->template = 'admin';
$tpl['first_menu'] = $first_menu->view(true);
$first_menu_pin_all = $first_menu->pin_all;
$first_menu_id = $first_menu->id;
} else {
$first_menu_id = 0;
$tpl['first_menu'] = null;
}
$vars['delete'] = t('Delete');
$vars['confirm_delete'] = t('Confirm deletion');
$vars['first_menu_id'] = $first_menu_id;
$vars['authkey'] = \Current_User::getAuthKey();
$vars['blank_title'] = t('Title must not be blank');
$vars['title_error'] = t('Make sure you have filled in the required inputs.');
$vars['url_error'] = t('Please enter a url or choose a PageSmith page.');
$vars['delete_menu_message'] = t('Are you sure you want to delete this menu and links?');
$vars['edit'] = t('Edit');
$vars['title_error'] = t('Please enter a menu title');
if (PHPWS_Settings::get('menu', 'display_type')) {
$vars['pin_all'] = null;
$vars['pin_some'] = null;
} else {
$vars['pin_all'] = t('Shown on all pages');
$vars['pin_some'] = t('Shown on some pages');
}
$jvar = json_encode($vars);
$script = <<<EOF
<script type="text/javascript">var translate = {$jvar}; var fmp={$first_menu_pin_all};</script>
EOF;
\Layout::addJSHeader($script);
\Layout::addJSHeader('<script type="text/javascript" src="' . PHPWS_SOURCE_HTTP . 'mod/menu/javascript/administrate/script.js"></script>');
$main_menu_templates = PHPWS_File::listDirectories(PHPWS_Template::getTemplateDirectory('menu') . 'menu_layout/');
$theme_menu_templates = PHPWS_File::listDirectories(PHPWS_Template::getTplDir('menu') . 'menu_layout/');
$menu_tpls[] = '<optgroup label="' . t('Menu module templates') . '">';
foreach ($main_menu_templates as $menu_tpl) {
if ($first_menu_template == $menu_tpl) {
$selected = ' selected="selected"';
} else {
$selected = null;
}
$menu_tpls[] = "<option value='{$menu_tpl}'{$selected}>{$menu_tpl}</option>";
}
$menu_tpls[] = '</optgroup>';
if (!empty($theme_menu_templates)) {
$menu_tpls[] = '<optgroup label="' . t('Theme templates') . '">';
foreach ($theme_menu_templates as $menu_tpl) {
if ($first_menu_template == $menu_tpl) {
$selected = ' selected="selected"';
} else {
$selected = null;
}
$menu_tpls[] = "<option value='{$menu_tpl}'{$selected}>{$menu_tpl}</option>";
}
$menu_tpls[] = '</optgroup>';
}
$tpl['templates'] = implode('', $menu_tpls);
$tpl['display_type'] = \PHPWS_Settings::get('menu', 'display_type');
if (isset($first_menu) && $first_menu->pin_all) {
$tpl['pin_all'] = $vars['pin_all'];
$tpl['pin_button_class'] = 'btn-primary';
} else {
$tpl['pin_all'] = $vars['pin_some'];
$tpl['pin_button_class'] = 'btn-default';
}
if (\Current_User::isDeity()) {
$tpl['reset_menu_link'] = PHPWS_Text::linkAddress('menu', array('command' => 'reset_menu'), true);
} else {
$tpl['reset_menu_link'] = '#';
}
$tpl['link_limit'] = \PHPWS_Settings::get('menu', 'max_link_characters');
if (\PHPWS_Core::moduleExists('carousel')) {
$tpl['carousel'] = $this->carouselSlidesForm();
//.........这里部分代码省略.........