Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Jul 20, 6:29 AM

in-portal

Index: branches/unlabeled/unlabeled-1.17.2/kernel/units/admin/admin_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.17.2/kernel/units/admin/admin_tag_processor.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.17.2/kernel/units/admin/admin_tag_processor.php (revision 4843)
@@ -0,0 +1,335 @@
+<?php
+
+ class AdminTagProcessor extends kDBTagProcessor {
+
+ function SetConst($params)
+ {
+ $name = $this->SelectParam($params, 'name,const');
+ safeDefine($name, $params['value']);
+ }
+
+ /**
+ * Allows to execute js script after the page is fully loaded
+ *
+ * @param Array $params
+ * @return string
+ */
+ function AfterScript($params)
+ {
+ $after_script = $this->Application->GetVar('after_script');
+ if ($after_script) {
+ return '<script type="text/javascript">'.$after_script.'</script>';
+ }
+ return '';
+ }
+
+ /**
+ * Returns section title with #section# keyword replaced with current section
+ *
+ * @param Array $params
+ * @return string
+ */
+ function GetSectionTitle($params)
+ {
+ $params['name'] = replaceModuleSection($params['phrase']);
+ return $this->Application->ProcessParsedTag('m', 'Phrase', $params);
+ }
+
+ /**
+ * Returns section icon with #section# keyword replaced with current section
+ *
+ * @param Array $params
+ * @return string
+ */
+ function GetSectionIcon($params)
+ {
+ return replaceModuleSection($params['icon']);
+ }
+
+ /**
+ * Allows to detect if current template is one of listed ones
+ *
+ * @param Array $params
+ * @return int
+ */
+ function TemplateMatches($params)
+ {
+ $templates = explode(',' ,$params['templates']);
+ $t = $this->Application->GetVar('t');
+ return in_array($t, $templates) ? 1 : 0;
+ }
+
+ /**
+ * Save return script in cases, when old sections are opened from new sections
+ *
+ * @param Array $params
+ */
+ function SaveReturnScript($params)
+ {
+ // admin/save_redirect.php?do=
+ $url = str_replace($this->Application->BaseURL(), '', $this->Application->ProcessParsedTag('m', 'Link', $params) );
+ $url = explode('?', $url, 2);
+ $url = 'save_redirect.php?'.$url[1].'&do='.$url[0];
+
+ $this->Application->StoreVar('ReturnScript', $url);
+ }
+
+ /**
+ * Redirects to correct next import step template based on import script data
+ *
+ * @param Array $params
+ */
+ function ImportRedirect($params)
+ {
+ $import_id = $this->Application->GetVar('import_id');
+ if ($import_id) {
+ // redirect forward to step3 (import parameters coosing)
+ $this->Application->StoreVar('ImportScriptID', $import_id);
+
+ $sql = 'SELECT *
+ FROM '.TABLE_PREFIX.'ImportScripts
+ WHERE is_id = '.$import_id;
+
+ $db =& $this->Application->GetADODBConnection();
+ $is_params = $db->GetRow($sql);
+
+ if ($is_params['is_type'] == 'db') {
+ $this->Application->Redirect('', null, '', 'import/step3.php');
+ }
+ elseif ($is_params['is_type'] == 'csv') {
+ $module = strtolower($is_params['is_Module']);
+ $template = $module.'/import';
+ $module_info = $this->Application->findModule('Name', $module);
+
+ $item_prefix = $module_info['Var'];
+ $pass_params = Array('m_opener' => 'd', $item_prefix.'.import_id' => 0, $item_prefix.'.import_event' => 'OnNew', 'pass' => 'm,'.$item_prefix.'.import', 'm_cat_id' => $module_info['RootCat']);
+
+ $this->Application->Redirect($template, $pass_params);
+ }
+ }
+ else {
+ // redirect back to step2 (import type choosing)
+ $this->Application->Redirect('', null, '', 'import/step2.php');
+ }
+ }
+
+ /**
+ * Returns version of module by name
+ *
+ * @param Array $params
+ * @return string
+ */
+ function ModuleVersion($params)
+ {
+ return $this->Application->findModule('Name', $params['module'], 'Version');
+ }
+
+ /**
+ * Used in table form section drawing
+ *
+ * @param Array $params
+ * @return string
+ */
+ function DrawTree($params)
+ {
+ static $deep_level = 0;
+
+ // when processings, then sort children by priority (key of children array)
+ $ret = '';
+ $section_name = $params['section_name'];
+ $params['name'] = $this->SelectParam($params, 'name,render_as,block');
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ $params['children_count'] = isset($section_data['children']) ? count($section_data['children']) : 0;
+ $params['deep_level'] = $deep_level++;
+ $template = $section_data['url']['t'];
+ unset($section_data['url']['t']);
+ $section_data['section_url'] = $this->Application->HREF($template, '', $section_data['url']);
+ $ret .= $this->Application->ParseBlock( array_merge_recursive2($params, $section_data) );
+ if (!isset($section_data['children'])) {
+ return $ret;
+ }
+
+ ksort($section_data['children'], SORT_NUMERIC);
+ foreach ($section_data['children'] as $section_name) {
+ $params['section_name'] = $section_name;
+ $ret .= $this->DrawTree($params);
+ $deep_level--;
+ }
+
+
+ return $ret;
+ }
+
+
+ function PrintSection($params)
+ {
+ $section_name = $params['section_name'];
+ if ($section_name == '#session#') {
+ $section_name = $this->Application->RecallVar('section');
+ }
+
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ $params['name'] = $this->SelectParam($params, 'name,render_as,block');
+ $params['section_name'] = $section_name;
+
+ $template = $section_data['url']['t'];
+ unset($section_data['url']['t']);
+
+ $section_data['section_url'] = $this->Application->HREF($template, '', $section_data['url']);
+ $ret = $this->Application->ParseBlock( array_merge_recursive2($params, $section_data) );
+
+ return $ret;
+ }
+
+ /**
+ * Used in XML drawing for tree
+ *
+ * @param Array $params
+ * @return string
+ */
+ function PrintSections($params)
+ {
+ // when processings, then sort children by priority (key of children array)
+ $ret = '';
+ $section_name = $params['section_name'];
+ if ($section_name == '#session#') {
+ $section_name = $this->Application->RecallVar('section');
+ }
+
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ $params['name'] = $this->SelectParam($params, 'name,render_as,block');
+ if (!isset($section_data['children'])) {
+ return '';
+ }
+
+ ksort($section_data['children'], SORT_NUMERIC);
+ foreach ($section_data['children'] as $section_name) {
+ $params['section_name'] = $section_name;
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ if (isset($section_data['tabs_only']) && $section_data['tabs_only']) {
+ $perm_status = false;
+ $folder_label = $section_data['label'];
+ ksort($section_data['children'], SORT_NUMERIC);
+ foreach ($section_data['children'] as $priority => $section_name) {
+ $perm_status = $this->Application->CheckPermission($section_name.'.view', 1);
+ if ($perm_status) {
+ break;
+ }
+ }
+ if (!$perm_status) {
+ // no permission for all tabs -> don't display tree node either
+ continue;
+ }
+
+ $params['section_name'] = $section_name;
+ $section_data =& $sections_helper->getSectionData($section_name);
+ $section_data['label'] = $folder_label; // use folder label in tree
+ $section_data['is_tab'] = 1;
+ }
+ elseif (!$this->Application->CheckPermission($section_name.'.view', 1)) {
+ continue;
+ }
+
+ $params['children_count'] = isset($section_data['children']) ? count($section_data['children']) : 0;
+
+ $template = $section_data['url']['t'];
+ unset($section_data['url']['t']);
+
+ $section_data['section_url'] = $this->Application->HREF($template, '', $section_data['url']);
+
+ $late_load = getArrayValue($section_data, 'late_load');
+ if ($late_load) {
+ $t = $late_load['t'];
+ unset($late_load['t']);
+ $section_data['late_load'] = $this->Application->HREF($t, '', $late_load);
+ $params['children_count'] = 99;
+ }
+ else {
+ $section_data['late_load'] = '';
+ }
+
+ $ret .= $this->Application->ParseBlock( array_merge_recursive2($params, $section_data) );
+ $params['section_name'] = $section_name;
+ }
+
+ return preg_replace("/\r\n|\n/", '', $ret);
+ }
+
+ function ListSectionPermissions($params)
+ {
+ $section_name = isset($params['section_name']) ? $params['section_name'] : $this->Application->GetVar('section_name');
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ $block_params = array_merge_recursive2($section_data, Array('name' => $params['render_as'], 'section_name' => $section_name));
+
+ $ret = '';
+ foreach ($section_data['permissions'] as $perm_name) {
+ if (preg_match('/^advanced:(.*)/', $perm_name) != $params['type']) continue;
+ $block_params['perm_name'] = $perm_name;
+ $ret .= $this->Application->ParseBlock($block_params);
+ }
+ return $ret;
+ }
+
+ function ModuleInclude($params)
+ {
+ foreach ($params as $param_name => $param_value) {
+ $params[$param_name] = replaceModuleSection($param_value);
+ }
+
+ return $this->Application->ProcessParsedTag('m', 'ModuleInclude', $params);
+ }
+
+ function TodayDate($params)
+ {
+ return date($params['format']);
+ }
+
+ function TreeEditWarrning($params)
+ {
+ $ret = $this->Application->Phrase($params['label']);
+ $ret = str_replace(Array('&lt;', '&gt;', 'br/', 'br /', "\n", "\r"), Array('<', '>', 'br', 'br', '', ''), $ret);
+ if (getArrayValue($params, 'escape')) {
+ $ret = addslashes($ret);
+ }
+ $ret = str_replace('<br>', '\n', $ret);
+ return $ret;
+ }
+
+ /**
+ * Draws section tabs using block name passed
+ *
+ * @param Array $params
+ */
+ function ListTabs($params)
+ {
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($params['section_name']);
+
+ $ret = '';
+ $block_params = Array('name' => $params['render_as']);
+ ksort($section_data['children'], SORT_NUMERIC);
+ foreach ($section_data['children'] as $priority => $section_name) {
+// if (!$this->Application->CheckPermission($section_name.'.view', 1)) continue;
+
+ $tab_data =& $sections_helper->getSectionData($section_name);
+ $block_params['t'] = $tab_data['url']['t'];
+ $block_params['title'] = $tab_data['label'];
+ $block_params['main_prefix'] = $section_data['SectionPrefix'];
+ $ret .= $this->Application->ParseBlock($block_params);
+ }
+
+
+ return $ret;
+ }
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.17.2/kernel/units/admin/admin_tag_processor.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.17
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.17.2/core/units/admin/admin_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.17.2/core/units/admin/admin_tag_processor.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.17.2/core/units/admin/admin_tag_processor.php (revision 4843)
@@ -0,0 +1,335 @@
+<?php
+
+ class AdminTagProcessor extends kDBTagProcessor {
+
+ function SetConst($params)
+ {
+ $name = $this->SelectParam($params, 'name,const');
+ safeDefine($name, $params['value']);
+ }
+
+ /**
+ * Allows to execute js script after the page is fully loaded
+ *
+ * @param Array $params
+ * @return string
+ */
+ function AfterScript($params)
+ {
+ $after_script = $this->Application->GetVar('after_script');
+ if ($after_script) {
+ return '<script type="text/javascript">'.$after_script.'</script>';
+ }
+ return '';
+ }
+
+ /**
+ * Returns section title with #section# keyword replaced with current section
+ *
+ * @param Array $params
+ * @return string
+ */
+ function GetSectionTitle($params)
+ {
+ $params['name'] = replaceModuleSection($params['phrase']);
+ return $this->Application->ProcessParsedTag('m', 'Phrase', $params);
+ }
+
+ /**
+ * Returns section icon with #section# keyword replaced with current section
+ *
+ * @param Array $params
+ * @return string
+ */
+ function GetSectionIcon($params)
+ {
+ return replaceModuleSection($params['icon']);
+ }
+
+ /**
+ * Allows to detect if current template is one of listed ones
+ *
+ * @param Array $params
+ * @return int
+ */
+ function TemplateMatches($params)
+ {
+ $templates = explode(',' ,$params['templates']);
+ $t = $this->Application->GetVar('t');
+ return in_array($t, $templates) ? 1 : 0;
+ }
+
+ /**
+ * Save return script in cases, when old sections are opened from new sections
+ *
+ * @param Array $params
+ */
+ function SaveReturnScript($params)
+ {
+ // admin/save_redirect.php?do=
+ $url = str_replace($this->Application->BaseURL(), '', $this->Application->ProcessParsedTag('m', 'Link', $params) );
+ $url = explode('?', $url, 2);
+ $url = 'save_redirect.php?'.$url[1].'&do='.$url[0];
+
+ $this->Application->StoreVar('ReturnScript', $url);
+ }
+
+ /**
+ * Redirects to correct next import step template based on import script data
+ *
+ * @param Array $params
+ */
+ function ImportRedirect($params)
+ {
+ $import_id = $this->Application->GetVar('import_id');
+ if ($import_id) {
+ // redirect forward to step3 (import parameters coosing)
+ $this->Application->StoreVar('ImportScriptID', $import_id);
+
+ $sql = 'SELECT *
+ FROM '.TABLE_PREFIX.'ImportScripts
+ WHERE is_id = '.$import_id;
+
+ $db =& $this->Application->GetADODBConnection();
+ $is_params = $db->GetRow($sql);
+
+ if ($is_params['is_type'] == 'db') {
+ $this->Application->Redirect('', null, '', 'import/step3.php');
+ }
+ elseif ($is_params['is_type'] == 'csv') {
+ $module = strtolower($is_params['is_Module']);
+ $template = $module.'/import';
+ $module_info = $this->Application->findModule('Name', $module);
+
+ $item_prefix = $module_info['Var'];
+ $pass_params = Array('m_opener' => 'd', $item_prefix.'.import_id' => 0, $item_prefix.'.import_event' => 'OnNew', 'pass' => 'm,'.$item_prefix.'.import', 'm_cat_id' => $module_info['RootCat']);
+
+ $this->Application->Redirect($template, $pass_params);
+ }
+ }
+ else {
+ // redirect back to step2 (import type choosing)
+ $this->Application->Redirect('', null, '', 'import/step2.php');
+ }
+ }
+
+ /**
+ * Returns version of module by name
+ *
+ * @param Array $params
+ * @return string
+ */
+ function ModuleVersion($params)
+ {
+ return $this->Application->findModule('Name', $params['module'], 'Version');
+ }
+
+ /**
+ * Used in table form section drawing
+ *
+ * @param Array $params
+ * @return string
+ */
+ function DrawTree($params)
+ {
+ static $deep_level = 0;
+
+ // when processings, then sort children by priority (key of children array)
+ $ret = '';
+ $section_name = $params['section_name'];
+ $params['name'] = $this->SelectParam($params, 'name,render_as,block');
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ $params['children_count'] = isset($section_data['children']) ? count($section_data['children']) : 0;
+ $params['deep_level'] = $deep_level++;
+ $template = $section_data['url']['t'];
+ unset($section_data['url']['t']);
+ $section_data['section_url'] = $this->Application->HREF($template, '', $section_data['url']);
+ $ret .= $this->Application->ParseBlock( array_merge_recursive2($params, $section_data) );
+ if (!isset($section_data['children'])) {
+ return $ret;
+ }
+
+ ksort($section_data['children'], SORT_NUMERIC);
+ foreach ($section_data['children'] as $section_name) {
+ $params['section_name'] = $section_name;
+ $ret .= $this->DrawTree($params);
+ $deep_level--;
+ }
+
+
+ return $ret;
+ }
+
+
+ function PrintSection($params)
+ {
+ $section_name = $params['section_name'];
+ if ($section_name == '#session#') {
+ $section_name = $this->Application->RecallVar('section');
+ }
+
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ $params['name'] = $this->SelectParam($params, 'name,render_as,block');
+ $params['section_name'] = $section_name;
+
+ $template = $section_data['url']['t'];
+ unset($section_data['url']['t']);
+
+ $section_data['section_url'] = $this->Application->HREF($template, '', $section_data['url']);
+ $ret = $this->Application->ParseBlock( array_merge_recursive2($params, $section_data) );
+
+ return $ret;
+ }
+
+ /**
+ * Used in XML drawing for tree
+ *
+ * @param Array $params
+ * @return string
+ */
+ function PrintSections($params)
+ {
+ // when processings, then sort children by priority (key of children array)
+ $ret = '';
+ $section_name = $params['section_name'];
+ if ($section_name == '#session#') {
+ $section_name = $this->Application->RecallVar('section');
+ }
+
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ $params['name'] = $this->SelectParam($params, 'name,render_as,block');
+ if (!isset($section_data['children'])) {
+ return '';
+ }
+
+ ksort($section_data['children'], SORT_NUMERIC);
+ foreach ($section_data['children'] as $section_name) {
+ $params['section_name'] = $section_name;
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ if (isset($section_data['tabs_only']) && $section_data['tabs_only']) {
+ $perm_status = false;
+ $folder_label = $section_data['label'];
+ ksort($section_data['children'], SORT_NUMERIC);
+ foreach ($section_data['children'] as $priority => $section_name) {
+ $perm_status = $this->Application->CheckPermission($section_name.'.view', 1);
+ if ($perm_status) {
+ break;
+ }
+ }
+ if (!$perm_status) {
+ // no permission for all tabs -> don't display tree node either
+ continue;
+ }
+
+ $params['section_name'] = $section_name;
+ $section_data =& $sections_helper->getSectionData($section_name);
+ $section_data['label'] = $folder_label; // use folder label in tree
+ $section_data['is_tab'] = 1;
+ }
+ elseif (!$this->Application->CheckPermission($section_name.'.view', 1)) {
+ continue;
+ }
+
+ $params['children_count'] = isset($section_data['children']) ? count($section_data['children']) : 0;
+
+ $template = $section_data['url']['t'];
+ unset($section_data['url']['t']);
+
+ $section_data['section_url'] = $this->Application->HREF($template, '', $section_data['url']);
+
+ $late_load = getArrayValue($section_data, 'late_load');
+ if ($late_load) {
+ $t = $late_load['t'];
+ unset($late_load['t']);
+ $section_data['late_load'] = $this->Application->HREF($t, '', $late_load);
+ $params['children_count'] = 99;
+ }
+ else {
+ $section_data['late_load'] = '';
+ }
+
+ $ret .= $this->Application->ParseBlock( array_merge_recursive2($params, $section_data) );
+ $params['section_name'] = $section_name;
+ }
+
+ return preg_replace("/\r\n|\n/", '', $ret);
+ }
+
+ function ListSectionPermissions($params)
+ {
+ $section_name = isset($params['section_name']) ? $params['section_name'] : $this->Application->GetVar('section_name');
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ $block_params = array_merge_recursive2($section_data, Array('name' => $params['render_as'], 'section_name' => $section_name));
+
+ $ret = '';
+ foreach ($section_data['permissions'] as $perm_name) {
+ if (preg_match('/^advanced:(.*)/', $perm_name) != $params['type']) continue;
+ $block_params['perm_name'] = $perm_name;
+ $ret .= $this->Application->ParseBlock($block_params);
+ }
+ return $ret;
+ }
+
+ function ModuleInclude($params)
+ {
+ foreach ($params as $param_name => $param_value) {
+ $params[$param_name] = replaceModuleSection($param_value);
+ }
+
+ return $this->Application->ProcessParsedTag('m', 'ModuleInclude', $params);
+ }
+
+ function TodayDate($params)
+ {
+ return date($params['format']);
+ }
+
+ function TreeEditWarrning($params)
+ {
+ $ret = $this->Application->Phrase($params['label']);
+ $ret = str_replace(Array('&lt;', '&gt;', 'br/', 'br /', "\n", "\r"), Array('<', '>', 'br', 'br', '', ''), $ret);
+ if (getArrayValue($params, 'escape')) {
+ $ret = addslashes($ret);
+ }
+ $ret = str_replace('<br>', '\n', $ret);
+ return $ret;
+ }
+
+ /**
+ * Draws section tabs using block name passed
+ *
+ * @param Array $params
+ */
+ function ListTabs($params)
+ {
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($params['section_name']);
+
+ $ret = '';
+ $block_params = Array('name' => $params['render_as']);
+ ksort($section_data['children'], SORT_NUMERIC);
+ foreach ($section_data['children'] as $priority => $section_name) {
+// if (!$this->Application->CheckPermission($section_name.'.view', 1)) continue;
+
+ $tab_data =& $sections_helper->getSectionData($section_name);
+ $block_params['t'] = $tab_data['url']['t'];
+ $block_params['title'] = $tab_data['label'];
+ $block_params['main_prefix'] = $section_data['SectionPrefix'];
+ $ret .= $this->Application->ParseBlock($block_params);
+ }
+
+
+ return $ret;
+ }
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.17.2/core/units/admin/admin_tag_processor.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.17
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property

Event Timeline