Cheetah
templates.php
Go to the documentation of this file.
1 <?php
2 
8 require_once( '../inc/header.inc.php' );
9 require_once( CH_DIRECTORY_PATH_INC . 'design.inc.php' );
10 require_once( CH_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
11 require_once( CH_DIRECTORY_PATH_INC . 'admin.inc.php' );
12 
13 ch_import('ChWsbInstallerUi');
14 ch_import('ChWsbFtp');
15 
16 $logged['admin'] = member_auth(1, true, true);
17 
18 //--- Check actions ---//
20  'upload' => 1,
21  'delete' => 1,
22  'change_default' => 1,
23 );
24 $oZ = new ChWsbAlerts('system', 'admin_templates_actions', 0, 0, array(
25  'actions' => &$aEnabledTemplateAction
26 ));
27 $oZ->alert();
28 
29 $sResult = '';
30 if ($_POST['set_default'] && file_exists(CH_DIRECTORY_PATH_ROOT . 'templates/tmpl_' . $_POST['set_default']) && isset($aEnabledTemplateAction['change_default'])) {
31  setParam('template', $_POST['set_default']);
32 } elseif ($_POST['del_template'] && $_POST['del_template'] != 'uni' && file_exists(CH_DIRECTORY_PATH_ROOT . 'templates/tmpl_' . $_POST['del_template']) && isset($aEnabledTemplateAction['delete'])) {
34  $sResult = $oInstallerUi->actionDelete(array('tmpl_' . $_POST['del_template']), 'template');
35  $sResult = _t($sResult);
36 }
37 
38 $aPages = array (
39  'templates' => array (
40  'title' => _t('_adm_txt_list'),
41  'url' => CH_WSB_URL_ADMIN . 'templates.php?mode=templates',
42  'func' => 'PageCodeTemplates',
43  'func_params' => array($sResult),
44  ),
45  'add' => array (
46  'title' => _t('_add'),
47  'url' => CH_WSB_URL_ADMIN . 'templates.php?mode=add',
48  'func' => 'PageCodeAdd',
49  'func_params' => array(),
50  ),
51  'settings' => array (
52  'title' => _t('_Settings'),
53  'url' => CH_WSB_URL_ADMIN . 'templates.php?mode=settings',
54  'func' => 'PageCodeSettings',
55  'func_params' => array(),
56  ),
57 );
58 
59 if (!isset($_GET['mode']) || !isset($aPages[$_GET['mode']]))
60  $sMode = 'templates';
61 else
62  $sMode = $_GET['mode'];
63 
64 $aTopItems = array();
65 foreach ($aPages as $k => $r)
66  $aTopItems['dbmenu_' . $k] = array(
67  'href' => $r['url'],
68  'title' => $r['title'],
69  'active' => $k == $sMode ? 1 : 0
70  );
71 
72 $oZ = new ChWsbAlerts('system', 'admin_templates_tabs', 0, 0, array(
73  'items' => &$aTopItems,
74 ));
75 $oZ->alert();
76 
78 $sPageTitle = _t('_adm_txt_templates');
79 $_page_cont[$iNameIndex]['page_main_code'] = call_user_func($aPages[$sMode]['func'], $aPages[$sMode]['func_params'][0], $aPages[$sMode]['func_params'][1]);
80 
81 $_page = array(
82  'name_index' => $iNameIndex,
83  'header' => $sPageTitle,
84  'header_text' => $sPageTitle,
85  'css_name' => array('templates.css'),
86 );
87 
89 
91 {
92  $a = get_templates_array(true);
93 
94  $aTemplates = array ();
95  foreach ($a as $k => $r) {
96  $aTemplates[] = array(
97  'key' => $k,
98  'name' => htmlspecialchars_adv($r['name']),
99  'ver' => htmlspecialchars_adv($r['ver']),
100  'vendor' => htmlspecialchars_adv($r['vendor']),
101  'desc' => $r['desc'],
102  'ch_if:preview' => array (
103  'condition' => (bool)$r['preview'],
104  'content' => array ('img' => $r['preview']),
105  ),
106  'ch_if:no_preview' => array (
107  'condition' => !$r['preview'],
108  'content' => array (),
109  ),
110  'ch_if:default' => array (
111  'condition' => $k == getParam('template'),
112  'content' => array (),
113  ),
114  'ch_if:make_default' => array (
115  'condition' => $k != getParam('template'),
116  'content' => array ('key' => $k),
117  ),
118  'ch_if:delete' => array (
119  'condition' => $k != getParam('template') && $k != 'uni' && $k != 'alt',
120  'content' => array ('key' => $k),
121  ),
122  );
123  }
124 
125  $s = $sResult ? MsgBox($sResult, 10) : '';
126  $s .= $GLOBALS['oAdmTemplate']->parseHtmlByName('templates.html', array(
127  'ch_repeat:templates' => $aTemplates,
128  ));
129 
130  $sCode = DesignBoxAdmin ($GLOBALS['sPageTitle'], $s, $GLOBALS['aTopItems'], '', 11);
131 
132  if ('on' == getParam('feeds_enable'))
133  $sCode = $sCode . DesignBoxAdmin (_t('_adm_box_cpt_design_templates'), '<div class="RSSAggrCont" rssid="cheetah_market_templates" rssnum="5" member="0">' . $GLOBALS['oFunctions']->loadingBoxInline() . '</div>');
134 
135  $GLOBALS['oAdmTemplate']->addJsTranslation(array('_Are_you_sure'));
136 
137  return $sCode;
138 }
139 
140 function PageCodeAdd()
141 {
143 
144  $sResult = '';
145  if (isset($_POST['submit_upload']) && isset($_FILES['module']) && !empty($_FILES['module']['tmp_name']) && isset($GLOBALS['aEnabledTemplateAction']['upload']))
146  $sResult = $oInstallerUi->actionUpload('template', $_FILES['module'], $_POST);
147 
148  $sContent = $oInstallerUi->getUploader($sResult, '_Template', true, $GLOBALS['aPages']['add']['url']);
149  $sContent = DesignBoxAdmin($GLOBALS['sPageTitle'], $sContent, $GLOBALS['aTopItems'], '', 11);
150 
151  $oZ = new ChWsbAlerts('system', 'admin_templates_blocks_add', 0, 0, array(
152  'title' => &$GLOBALS['sPageTitle'],
153  'code' => &$sContent,
154  ));
155  $oZ->alert();
156 
157  return $sContent;
158 }
159 
161 {
162  ch_import('ChWsbAdminSettings');
163  $oSettings = new ChWsbAdminSettings(13);
164 
165  $sResults = false;
166  if (isset($_POST['save']) && isset($_POST['cat']))
167  $sResult = $oSettings->saveChanges($_POST);
168 
169  $s = $sResult . $oSettings->getForm();
170 
171  return DesignBoxAdmin($GLOBALS['sPageTitle'], $s, $GLOBALS['aTopItems'], '', 11);
172 }
$oSettings
$oSettings
Definition: advanced_settings.php:20
$_page
$_page
Definition: templates.php:81
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
$sCode
$sCode
Definition: explanation.php:19
$_page_cont
$_page_cont[$iNameIndex]['page_main_code']
Definition: templates.php:79
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
php
$logged
$logged['admin']
Definition: templates.php:16
PageCodeSettings
PageCodeSettings()
Definition: templates.php:160
PageCodeAdd
PageCodeAdd()
Definition: templates.php:140
$aTopItems
$aTopItems
Definition: templates.php:64
get_templates_array
get_templates_array($isAllParams=false)
Definition: utils.inc.php:573
DesignBoxAdmin
DesignBoxAdmin($sTitle, $sContent, $mixedTopItems='', $sBottomItems='', $iIndex=1)
Definition: admin_design.inc.php:50
ChWsbAlerts
Definition: ChWsbAlerts.php:39
$_GET
$_GET['debug']
Definition: index.php:67
$sMode
else $sMode
Definition: templates.php:62
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
PageCodeTemplates
PageCodeTemplates($sResult)
Definition: templates.php:90
htmlspecialchars_adv
htmlspecialchars_adv($string)
Definition: utils.inc.php:302
$oInstallerUi
$oInstallerUi
Definition: modules.php:20
$iNameIndex
$iNameIndex
Definition: templates.php:77
PageCodeAdmin
PageCodeAdmin($oTemplate=null)
Definition: admin_design.inc.php:45
$sContent
$sContent
Definition: bottom_menu_compose.php:169
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChWsbInstallerUi
Definition: ChWsbInstallerUi.php:13
member_auth
member_auth($member=0, $error_handle=true, $bAjx=false)
Definition: admin.inc.php:262
$sResult
$sResult
Definition: templates.php:29
$aPages
if($_POST['set_default'] &&file_exists(CH_DIRECTORY_PATH_ROOT . 'templates/tmpl_' . $_POST['set_default']) &&isset($aEnabledTemplateAction['change_default'])) elseif($_POST['del_template'] && $_POST['del_template'] !='uni' &&file_exists(CH_DIRECTORY_PATH_ROOT . 'templates/tmpl_' . $_POST['del_template']) &&isset($aEnabledTemplateAction['delete'])) $aPages
Definition: templates.php:38
ChWsbAdminSettings
Definition: ChWsbAdminSettings.php:35
$s
$s
Definition: embed.php:13
setParam
setParam($sParamName, $sParamValue)
Definition: db.inc.php:149
$oZ
$oZ
Definition: templates.php:24
$sPageTitle
$sPageTitle
Definition: templates.php:78
$aEnabledTemplateAction
$aEnabledTemplateAction
Definition: templates.php:19
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10