Updated FP-specific Smarty plugin "Admin" to v4 OOP style. Replaced obsolete get_template_vars() calls with getTemplateVars().
This commit is contained in:
parent
e7a64816d6
commit
25c1618042
@ -80,8 +80,8 @@ function main() {
|
|||||||
if ($retval > 0) { // if has REDIRECT option
|
if ($retval > 0) { // if has REDIRECT option
|
||||||
// clear postdata by a redirect
|
// clear postdata by a redirect
|
||||||
|
|
||||||
sess_add("success_{$panel}", $smarty->get_template_vars('success'));
|
sess_add("success_{$panel}", $smarty->getTemplateVars('success'));
|
||||||
$smarty->get_template_vars('success');
|
$smarty->getTemplateVars('success');
|
||||||
|
|
||||||
$to_action = $retval > 1 ? ('&action=' . $action) : '';
|
$to_action = $retval > 1 ? ('&action=' . $action) : '';
|
||||||
$with_mod = isset($_GET ['mod']) ? ('&mod=' . $_GET ['mod']) : '';
|
$with_mod = isset($_GET ['mod']) ? ('&mod=' . $_GET ['mod']) : '';
|
||||||
@ -176,7 +176,7 @@ if (isset($_GET ['mod'])) {
|
|||||||
$smarty->display(ABS_PATH . ADMIN_DIR . 'admin-inline.tpl');
|
$smarty->display(ABS_PATH . ADMIN_DIR . 'admin-inline.tpl');
|
||||||
break;
|
break;
|
||||||
case 'ajax':
|
case 'ajax':
|
||||||
echo $smarty->get_template_vars('success');
|
echo $smarty->getTemplateVars('success');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$smarty->display('admin.tpl');
|
$smarty->display('admin.tpl');
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
function smarty_function_flag_classes($params, &$smarty) {
|
function smarty_function_flag_classes($params, &$smarty) {
|
||||||
$flags = entry_flags_get();
|
$flags = entry_flags_get();
|
||||||
($active_flags = array_intersect($smarty->get_template_vars('categories'), $flags));
|
($active_flags = array_intersect($smarty->getTemplateVars('categories'), $flags));
|
||||||
return implode(' ', $active_flags);
|
return implode(' ', $active_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
<p>
|
<p>
|
||||||
<label for="content">{$panelstrings.content}</label>
|
<label for="content">{$panelstrings.content}</label>
|
||||||
</p>
|
</p>
|
||||||
|
{* FIXME AZI: Smarty compiler error "unknown tag 'toolbar'". How did this ever work? Should that be better {include file='plugin:bbcode/toolbar'}? *}
|
||||||
{toolbar}
|
{toolbar}
|
||||||
<p>
|
<p>
|
||||||
<textarea name="content" class="{$class}"
|
<textarea name="content" class="{$class}"
|
||||||
|
@ -177,7 +177,7 @@ function smarty_block_draft($params, $content, &$smarty, &$repeat) {
|
|||||||
'version' => '',
|
'version' => '',
|
||||||
'id' => ''
|
'id' => ''
|
||||||
));
|
));
|
||||||
$arr = & $smarty->get_template_vars('draft_list');
|
$arr = & $smarty->getTemplateVars('draft_list');
|
||||||
|
|
||||||
$id = $subject = null;
|
$id = $subject = null;
|
||||||
if ($arr) {
|
if ($arr) {
|
||||||
|
@ -101,8 +101,8 @@ function smarty_block_static($params, $content, &$smarty, &$repeat) {
|
|||||||
'id' => ''
|
'id' => ''
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($arr = $smarty->get_template_vars('static_page')) {
|
if ($arr = $smarty->getTemplateVars('static_page')) {
|
||||||
$smarty->assign('id', $smarty->get_template_vars('static_id'));
|
$smarty->assign('id', $smarty->getTemplateVars('static_id'));
|
||||||
if (THEME_LEGACY_MODE)
|
if (THEME_LEGACY_MODE)
|
||||||
theme_entry_filters($arr);
|
theme_entry_filters($arr);
|
||||||
$smarty->assign($arr);
|
$smarty->assign($arr);
|
||||||
@ -119,7 +119,7 @@ function smarty_block_static($params, $content, &$smarty, &$repeat) {
|
|||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = $smarty->get_template_vars('statics');
|
$list = $smarty->getTemplateVars('statics');
|
||||||
|
|
||||||
if (isset($list [$pointer])) {
|
if (isset($list [$pointer])) {
|
||||||
// foreach ($entry as $k => $val)
|
// foreach ($entry as $k => $val)
|
||||||
|
@ -1,58 +1,39 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
|
||||||
* Smarty plugin
|
/**
|
||||||
* -------------------------------------------------------------
|
* Resoure plugin that conveniently allows to include templates from the admin templates folder.
|
||||||
* File: resource.admin.php
|
*
|
||||||
* Type: admin tpls
|
* @author FlatPress
|
||||||
* Name: admin
|
* @see https://www.smarty.net/docs/en/plugins.resources.tpl
|
||||||
* Purpose: convenient way to call stored tpls in ADMIN_DIR
|
|
||||||
* -------------------------------------------------------------
|
|
||||||
*/
|
*/
|
||||||
|
class Smarty_Resource_Admin extends Smarty_Resource_Custom {
|
||||||
|
|
||||||
function smarty_resource_admin_parsename($tpl_name) {
|
/**
|
||||||
$path = null;
|
*
|
||||||
|
* {@inheritdoc}
|
||||||
$tpl_name;
|
* @see Smarty_Resource_Custom::fetch()
|
||||||
|
*/
|
||||||
$panel = strtok($tpl_name, '/');
|
protected function fetch($name, &$source, &$mtime) {
|
||||||
if ($action = strtok('/'))
|
$filePath = $this->getFilePath($name);
|
||||||
$path = ABS_PATH . ADMIN_DIR . "panels/$panel/admin.$panel.$action.tpl";
|
|
||||||
if (!$action || !file_exists($path))
|
|
||||||
$path = ABS_PATH . ADMIN_DIR . "panels/$panel/admin.$panel.tpl";
|
|
||||||
|
|
||||||
return $path;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function smarty_resource_admin_source($tpl_name, &$tpl_source, &$smarty)
|
if ($source = io_load_file($filePath)) {
|
||||||
{
|
$mtime = filemtime($filePath);
|
||||||
$fname = smarty_resource_admin_parsename($tpl_name);
|
} else {
|
||||||
if ($tpl_source = io_load_file($fname)) {
|
$source = null;
|
||||||
return true;
|
$mtime = null;
|
||||||
} else {
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function smarty_resource_admin_timestamp($tpl_name, &$tpl_timestamp, &$smarty)
|
private function getFilePath($templateName) {
|
||||||
{
|
$path = null;
|
||||||
$fname = smarty_resource_admin_parsename($tpl_name);
|
$panel = strtok($templateName, '/');
|
||||||
if (file_exists($fname)) {
|
if ($action = strtok('/')) {
|
||||||
$tpl_timestamp = filemtime($fname);
|
$path = ABS_PATH . ADMIN_DIR . "panels/$panel/admin.$panel.$action.tpl";
|
||||||
return true;
|
}
|
||||||
} else {
|
if (!$action || !file_exists($path)) {
|
||||||
return false;
|
$path = ABS_PATH . ADMIN_DIR . "panels/$panel/admin.$panel.tpl";
|
||||||
}
|
}
|
||||||
}
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
function smarty_resource_admin_secure($tpl_name, &$smarty)
|
}
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function smarty_resource_admin_trusted($tpl_name, &$smarty)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
?>
|
|
@ -135,9 +135,9 @@ class admin_entry_commentcenter extends AdminPanelAction {
|
|||||||
function _redirect($cmd, $cmdval = 1, $nosuccess = false) {
|
function _redirect($cmd, $cmdval = 1, $nosuccess = false) {
|
||||||
global $panel;
|
global $panel;
|
||||||
$smarty = &$this->smarty;
|
$smarty = &$this->smarty;
|
||||||
sess_add("success_{$panel}", $smarty->get_template_vars('success'));
|
sess_add("success_{$panel}", $smarty->getTemplateVars('success'));
|
||||||
|
|
||||||
$action_url = $smarty->get_template_vars('action_url');
|
$action_url = $smarty->getTemplateVars('action_url');
|
||||||
$url = admin_filter_command($action_url, $cmd, $cmdval);
|
$url = admin_filter_command($action_url, $cmd, $cmdval);
|
||||||
$url = html_entity_decode($url);
|
$url = html_entity_decode($url);
|
||||||
$url = substr($url, strlen(BLOG_BASEURL));
|
$url = substr($url, strlen(BLOG_BASEURL));
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* This file integrates the plugin into the entry editor.
|
* This file integrates the plugin into the entry editor.
|
||||||
*/
|
*/
|
||||||
|
if (!class_exists('plugin_commentcenter')) {
|
||||||
if(!class_exists('plugin_commentcenter')) {
|
|
||||||
die('Don\'t try to hack us.');
|
die('Don\'t try to hack us.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,26 +12,26 @@ if(!class_exists('plugin_commentcenter')) {
|
|||||||
*/
|
*/
|
||||||
function plugin_commentcenter_editor() {
|
function plugin_commentcenter_editor() {
|
||||||
// Just on existent entries
|
// Just on existent entries
|
||||||
if(empty($_REQUEST['entry'])) {
|
if (empty($_REQUEST ['entry'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
global $smarty, $lang, $action;
|
global $smarty, $lang, $action;
|
||||||
$entry=$_REQUEST['entry'];
|
$entry = $_REQUEST ['entry'];
|
||||||
$plugin=&$GLOBALS['plugin_commentcenter'];
|
$plugin = &$GLOBALS ['plugin_commentcenter'];
|
||||||
$plang=&$lang['admin']['entry']['commentcenter'];
|
$plang = &$lang ['admin'] ['entry'] ['commentcenter'];
|
||||||
$arr=$smarty->get_template_vars('post');
|
$arr = $smarty->getTemplateVars('post');
|
||||||
$panel_url=$smarty->get_template_vars('panel_url');
|
$panel_url = $smarty->getTemplateVars('panel_url');
|
||||||
|
|
||||||
$plugin->loadPolicies();
|
$plugin->loadPolicies();
|
||||||
$do=$plugin->behavoirFromPolicies($entry, @$arr['categories']);
|
$do = $plugin->behavoirFromPolicies($entry, @$arr ['categories']);
|
||||||
$do='simple_'.$do;
|
$do = 'simple_' . $do;
|
||||||
|
|
||||||
$oldact=$action;
|
$oldact = $action;
|
||||||
$action='commentcenter';
|
$action = 'commentcenter';
|
||||||
$policies=admin_filter_action($panel_url, 'commentcenter');
|
$policies = admin_filter_action($panel_url, 'commentcenter');
|
||||||
$manage=admin_filter_command($policies, 'manage', $entry);
|
$manage = admin_filter_command($policies, 'manage', $entry);
|
||||||
$action=$oldact;
|
$action = $oldact;
|
||||||
|
|
||||||
echo "<fieldset id=\"commentcenter\">\n";
|
echo "<fieldset id=\"commentcenter\">\n";
|
||||||
echo "<legend>Comment Center</legend>\n<ul>\n<li>";
|
echo "<legend>Comment Center</legend>\n<ul>\n<li>";
|
||||||
|
@ -66,7 +66,7 @@ class footnotes_class {
|
|||||||
function plugin_footnotes_filter($text) {
|
function plugin_footnotes_filter($text) {
|
||||||
global $smarty;
|
global $smarty;
|
||||||
|
|
||||||
$footnotes_obj = new footnotes_class($id = $smarty->get_template_vars('id'));
|
$footnotes_obj = new footnotes_class($id = $smarty->getTemplateVars('id'));
|
||||||
|
|
||||||
// *STRONG* emphasis
|
// *STRONG* emphasis
|
||||||
$text = preg_replace('|(?<!\S)\*(?=\S) (?! \*) (.+?) (?<=\S) \*(?!>\w)|xs', '<strong>$1</strong>', $text);
|
$text = preg_replace('|(?<!\S)\*(?=\S) (?! \*) (.+?) (?<=\S) \*(?!>\w)|xs', '<strong>$1</strong>', $text);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user