示例#1
0
	public static function RequestAction($action = '')
	{
		global $USER, $APPLICATION;
		$result = array();

		switch($action)
		{
			case "load_site_template":
				if (!$USER->CanDoOperation('fileman_view_file_structure'))
					break;
				$siteTemplate = $_REQUEST['site_template'];
				$siteId = isset($_REQUEST['site_id']) ? $_REQUEST['site_id'] : SITE_ID;
				$result = self::GetSiteTemplateParams($siteTemplate, $siteId);
				break;
			case "load_components_list":
				if (!$USER->CanDoOperation('fileman_view_file_structure'))
					break;
				$siteTemplate = $_REQUEST['site_template'];
				$result = self::GetComponents($siteTemplate, true);
				break;

			case "video_oembed":
				$result = self::GetVideoOembed($_REQUEST['video_source']);
				break;

			// Snippets actions
			case "load_snippets_list":
				if (!$USER->CanDoOperation('fileman_view_file_structure'))
					break;
				$template = $_REQUEST['site_template'];
				$result = array(
					'result' => true,
					'snippets' => array($template => self::GetSnippets($template, $_REQUEST['clear_cache'] == 'Y'))
				);
				break;
			case "edit_snippet":
				if (!$USER->CanDoOperation('fileman_view_file_structure'))
					break;
				CUtil::JSPostUnEscape();
				$template = $_REQUEST['site_template'];

				// Update
				if ($_REQUEST['current_path'])
				{
					$result = CSnippets::Update(array(
						'template' => $template,
						'path' => $_REQUEST['path'],
						'code' => $_REQUEST['code'],
						'title' => $_REQUEST['name'],
						'current_path' => $_REQUEST['current_path'],
						'description' => $_REQUEST['description']
					));
				}
				// Add new
				else
				{
					$result = CSnippets::Add(array(
						'template' => $template,
						'path' => $_REQUEST['path'],
						'code' => $_REQUEST['code'],
						'title' => $_REQUEST['name'],
						'description' => $_REQUEST['description']
					));
				}

				if ($result && $result['result'])
				{
					$result['snippets'] = array($template => self::GetSnippets($template));
				}

				break;
			case "remove_snippet":
				if (!$USER->CanDoOperation('fileman_view_file_structure'))
					break;
				CUtil::JSPostUnEscape();
				$template = $_REQUEST['site_template'];

				$res = CSnippets::Remove(array(
					'template' => $template,
					'path' => $_REQUEST['path']
				));

				if ($res)
				{
					$result = array(
						'result' => true,
						'snippets' => array($template => self::GetSnippets($template))
					);
				}
				else
				{
					$result = array('result' => false);
				}

				break;
			case "snippet_add_category":
				if (!$USER->CanDoOperation('fileman_view_file_structure'))
					break;
				CUtil::JSPostUnEscape();
				$template = $_REQUEST['site_template'];
				$res = CSnippets::CreateCategory(array(
					'template' => $template,
					'name' => $_REQUEST['category_name'],
					'parent' => $_REQUEST['category_parent']
				));

				if ($res)
				{
					$result = array(
						'result' => true,
						'snippets' => array($template => self::GetSnippets($template))
					);
				}
				else
				{
					$result = array('result' => false);
				}
				break;
			case "snippet_remove_category":
				if (!$USER->CanDoOperation('fileman_view_file_structure'))
					break;
				CUtil::JSPostUnEscape();
				$template = $_REQUEST['site_template'];
				$res = CSnippets::RemoveCategory(array(
					'template' => $template,
					'path' => $_REQUEST['category_path']
				));

				if ($res)
				{
					$result = array(
						'result' => true,
						'snippets' => array($template => self::GetSnippets($template))
					);
				}
				else
				{
					$result = array('result' => false);
				}
				break;
			case "snippet_rename_category":
				if (!$USER->CanDoOperation('fileman_view_file_structure'))
					break;
				CUtil::JSPostUnEscape();
				$template = $_REQUEST['site_template'];
				$res = CSnippets::RenameCategory(array(
					'template' => $template,
					'path' => $_REQUEST['category_path'],
					'new_name' => $_REQUEST['category_new_name']
				));

				if ($res)
				{
					$result = array(
						'result' => true,
						'snippets' => array($template => self::GetSnippets($template))
					);
				}
				else
				{
					$result = array('result' => false);
				}
				break;
			// END *** Snippets actions

			// spellcheck
			case "spellcheck_words":
			case "spellcheck_add_word":
				CUtil::JSPostUnEscape();
				$spellChecker = new CSpellchecker(array(
					"lang" => $_REQUEST['lang'],
					"skip_length" => 2,
					"use_pspell" => $_REQUEST['use_pspell'] !== "N",
					"use_custom_spell" => $_REQUEST['use_custom_spell'] !== "N",
					"mode" => PSPELL_FAST
				));

				if ($action == "spellcheck_words")
				{
					$words = (isset($_REQUEST['words']) && is_array($_REQUEST['words'])) ? $_REQUEST['words'] : array();
					$result = array(
						'words' => $spellChecker->checkWords($words)
					);
				}
				else // Add word
				{
					$word = CFileMan::SecurePathVar($_REQUEST['word']);
					$spellChecker->addWord($word);
				}
				break;
			// END *** spellcheck
		}

		self::ShowResponse(intVal($_REQUEST['reqId']), $result);
	}
示例#2
0
	public static function DisplayJSGroups($template, $ar = array())
	{
		$template = CUtil::JSEscape(htmlspecialcharsex($template));
		?><script>
		window.arSnGroups['<?php 
echo $template;
?>
'] = {};
		window.rootDefaultName['<?php 
echo $template;
?>
'] = '<?php 
echo CSnippets::GetDefaultFileName($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/" . $template . "/snippets");
?>
';
		<?
		for($i=0,$len = count($ar); $i < $len; $i++)
		{
			$key = CUtil::JSEscape($ar[$i]['path'].($ar[$i]['path'] != '' ? '/' : '').$ar[$i]['name']);
		?>
window.arSnGroups['<?php 
echo $template;
?>
']['<?php 
echo $key;
?>
'] =
{
	name: '<?php 
echo CUtil::JSEscape($ar[$i]['name']);
?>
',
	path: '<?php 
echo CUtil::JSEscape($ar[$i]['path']);
?>
',
	level: '<?php 
echo CUtil::JSEscape($ar[$i]['level']);
?>
',
	default_name: '<?php 
echo CUtil::JSEscape($ar[$i]['default_name']);
?>
'
};
		<?
		}
		?></script><?
	}
			CSnippets::Edit(array(
				'bNew' => $_REQUEST['target'] == 'add',
				'name' => $_REQUEST['name'],
				'path' => $_REQUEST['target'] == 'add' && isset($_REQUEST['path']) ? $_REQUEST['path'] : false,
				'template' => $_REQUEST['templateID'],
				'site' => $_REQUEST['site'],
				'title' => isset($_REQUEST['title']) ? $_REQUEST['title'] : '',
				'description' => isset($_REQUEST['description']) ? $_REQUEST['description'] : '',
				'code' => $code,
				'thumb' => isset($_REQUEST['thumb']) ? $_REQUEST['thumb'] : false,
				'location' => isset($_REQUEST["location"]) ? $_REQUEST["location"] : false,
				'newGroup' => isset($_REQUEST["new_group"]) ? $_REQUEST["new_group"] : false
			));
			break;
		case "delete":
			CSnippets::Delete(array(
				'name' => $APPLICATION->UnJSEscape($_REQUEST['name']),
				'path' => isset($_REQUEST['path']) ? $APPLICATION->UnJSEscape($_REQUEST['path']) : false,
				'template' => $APPLICATION->UnJSEscape($_REQUEST['templateID']),
				'site' => $_REQUEST['site'],
				'thumb' => isset($_REQUEST['thumb']) ? $_REQUEST['thumb'] : ''
			));
			break;
		case "getgroups":
			CSnippets::GetGroups(array('template' => $APPLICATION->UnJSEscape($_REQUEST['templateID'])));
			break;
	}
}

require($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/include/epilog_admin_after.php");
?>
示例#4
0
 public static function RequestAction($action = '')
 {
     global $USER, $APPLICATION;
     $result = array();
     switch ($action) {
         case "load_site_template":
             if (!$USER->CanDoOperation('fileman_view_file_structure')) {
                 break;
             }
             $siteTemplate = $_REQUEST['site_template'];
             $siteId = isset($_REQUEST['site_id']) ? $_REQUEST['site_id'] : SITE_ID;
             $result = self::GetSiteTemplateParams($siteTemplate, $siteId);
             break;
         case "load_components_list":
             if (!$USER->CanDoOperation('fileman_view_file_structure')) {
                 break;
             }
             $siteTemplate = $_REQUEST['site_template'];
             $componentFilter = isset($_REQUEST['componentFilter']) ? $_REQUEST['componentFilter'] : false;
             $result = self::GetComponents($siteTemplate, true, $componentFilter);
             break;
         case "video_oembed":
             $result = self::GetVideoOembed($_REQUEST['video_source']);
             break;
             // Snippets actions
         // Snippets actions
         case "load_snippets_list":
             if (!$USER->CanDoOperation('fileman_view_file_structure')) {
                 break;
             }
             $template = $_REQUEST['site_template'];
             $result = array('result' => true, 'snippets' => array($template => self::GetSnippets($template, $_REQUEST['clear_cache'] == 'Y')));
             break;
         case "edit_snippet":
             if (!$USER->CanDoOperation('fileman_view_file_structure')) {
                 break;
             }
             CUtil::JSPostUnEscape();
             $template = $_REQUEST['site_template'];
             // Update
             if ($_REQUEST['current_path']) {
                 $result = CSnippets::Update(array('template' => $template, 'path' => $_REQUEST['path'], 'code' => $_REQUEST['code'], 'title' => $_REQUEST['name'], 'current_path' => $_REQUEST['current_path'], 'description' => $_REQUEST['description']));
             } else {
                 $result = CSnippets::Add(array('template' => $template, 'path' => $_REQUEST['path'], 'code' => $_REQUEST['code'], 'title' => $_REQUEST['name'], 'description' => $_REQUEST['description']));
             }
             if ($result && $result['result']) {
                 $result['snippets'] = array($template => self::GetSnippets($template));
             }
             break;
         case "remove_snippet":
             if (!$USER->CanDoOperation('fileman_view_file_structure')) {
                 break;
             }
             CUtil::JSPostUnEscape();
             $template = $_REQUEST['site_template'];
             $res = CSnippets::Remove(array('template' => $template, 'path' => $_REQUEST['path']));
             if ($res) {
                 $result = array('result' => true, 'snippets' => array($template => self::GetSnippets($template)));
             } else {
                 $result = array('result' => false);
             }
             break;
         case "snippet_add_category":
             if (!$USER->CanDoOperation('fileman_view_file_structure')) {
                 break;
             }
             CUtil::JSPostUnEscape();
             $template = $_REQUEST['site_template'];
             $res = CSnippets::CreateCategory(array('template' => $template, 'name' => $_REQUEST['category_name'], 'parent' => $_REQUEST['category_parent']));
             if ($res) {
                 $result = array('result' => true, 'snippets' => array($template => self::GetSnippets($template)));
             } else {
                 $result = array('result' => false);
             }
             break;
         case "snippet_remove_category":
             if (!$USER->CanDoOperation('fileman_view_file_structure')) {
                 break;
             }
             CUtil::JSPostUnEscape();
             $template = $_REQUEST['site_template'];
             $res = CSnippets::RemoveCategory(array('template' => $template, 'path' => $_REQUEST['category_path']));
             if ($res) {
                 $result = array('result' => true, 'snippets' => array($template => self::GetSnippets($template)));
             } else {
                 $result = array('result' => false);
             }
             break;
         case "snippet_rename_category":
             if (!$USER->CanDoOperation('fileman_view_file_structure')) {
                 break;
             }
             CUtil::JSPostUnEscape();
             $template = $_REQUEST['site_template'];
             $res = CSnippets::RenameCategory(array('template' => $template, 'path' => $_REQUEST['category_path'], 'new_name' => $_REQUEST['category_new_name']));
             if ($res) {
                 $result = array('result' => true, 'snippets' => array($template => self::GetSnippets($template)));
             } else {
                 $result = array('result' => false);
             }
             break;
             // END *** Snippets actions
             // spellcheck
         // END *** Snippets actions
         // spellcheck
         case "spellcheck_words":
         case "spellcheck_add_word":
             CUtil::JSPostUnEscape();
             $spellChecker = new CSpellchecker(array("lang" => $_REQUEST['lang'], "skip_length" => 2, "use_pspell" => $_REQUEST['use_pspell'] !== "N", "use_custom_spell" => $_REQUEST['use_custom_spell'] !== "N", "mode" => PSPELL_FAST));
             if ($action == "spellcheck_words") {
                 $words = isset($_REQUEST['words']) && is_array($_REQUEST['words']) ? $_REQUEST['words'] : array();
                 $result = array('words' => $spellChecker->checkWords($words));
             } else {
                 $word = CFileMan::SecurePathVar($_REQUEST['word']);
                 $spellChecker->addWord($word);
             }
             break;
             // END *** spellcheck
         // END *** spellcheck
         case "load_file_dialogs":
             $editorId = $_REQUEST['editor_id'];
             $editorId = preg_replace("/[^a-zA-Z0-9_-]/is", "_", $editorId);
             CAdminFileDialog::ShowScript(array("event" => "BxOpenFileBrowserWindFile" . $editorId, "arResultDest" => array("FUNCTION_NAME" => "OnFileDialogSelect" . $editorId), "arPath" => array("SITE" => SITE_ID), "select" => 'F', "operation" => 'O', "showUploadTab" => true, "showAddToMenuTab" => false, "fileFilter" => 'image', "allowAllFiles" => true, "SaveConfig" => true));
             CMedialib::ShowBrowseButton(array('value' => '...', 'event' => "BxOpenFileBrowserWindFile" . $editorId, 'button_id' => "bx-open-file-link-medialib-but-" . $editorId, 'id' => "bx_open_file_link_medialib_button_" . $editorId, 'MedialibConfig' => array("event" => "BxOpenFileBrowserFileMl" . $editorId, "arResultDest" => array("FUNCTION_NAME" => "OnFileDialogSelect" . $editorId)), 'useMLDefault' => false));
             CMedialib::ShowBrowseButton(array('value' => '...', 'event' => "BxOpenFileBrowserWindFile" . $editorId, 'button_id' => "bx-open-file-medialib-but-" . $editorId, 'id' => "bx_open_file_medialib_button_" . $editorId, 'MedialibConfig' => array("event" => "BxOpenFileBrowserImgFileMl" . $editorId, "arResultDest" => array("FUNCTION_NAME" => "OnFileDialogImgSelect" . $editorId), "types" => array('image'))));
             $result = array('result' => true);
             break;
     }
     self::ShowResponse(intVal($_REQUEST['reqId']), $result);
 }
示例#5
0
	public static function GetSnippets($templateId, $bClearCache = false)
	{
		return array(
			'items' => CSnippets::LoadList(
				array(
					'template' => $templateId,
					'bClearCache' => $bClearCache,
					'returnArray' => true
				)
			),
			'groups' => CSnippets::GetGroupList(
				array(
					'template' => $templateId,
					'bClearCache' => $bClearCache
				)
			)
		);
	}
示例#6
0
 public static function RemoveCategory($params)
 {
     $res = false;
     if (is_array($params) && isset($params['path'])) {
         $path = CFileMan::SecurePathVar($params['path']);
         $template = isset($params['template']) && $params['template'] !== '' ? CFileMan::SecurePathVar($params['template']) : '.default';
         $basePath = $_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/" . $template . "/snippets";
         $categoryPath = $basePath . '/' . $path;
         $io = CBXVirtualIo::GetInstance();
         if ($io->DirectoryExists($categoryPath)) {
             $res = $io->Delete($categoryPath);
         }
         CSnippets::ClearCache();
     }
     return $res;
 }