GUIEditor.php
changeset 0 640e15974415
child 1 960c1572df75
equal deleted inserted replaced
-1:000000000000 0:640e15974415
       
     1 <?php
       
     2 /**!info**
       
     3 {
       
     4   "Plugin Name"  : "GUI Editor",
       
     5   "Plugin URI"   : "http://enanocms.org/plugin/guieditor",
       
     6   "Description"  : "Adds a toolbar to the editor interface, allowing point-and-click insertion of most formatting elements",
       
     7   "Author"       : "Dan Fuhry",
       
     8   "Version"      : "0.1",
       
     9   "Author URI"   : "http://enanocms.org/",
       
    10   "Version list" : ['0.1']
       
    11 }
       
    12 **!*/
       
    13 
       
    14 $plugins->attachHook('compile_template', 'guied_attach_script();');
       
    15 
       
    16 function guied_attach_script()
       
    17 {
       
    18 	global $template;
       
    19 	$template->add_header_js('<script type="text/javascript" src="' . scriptPath . '/plugins/guieditor/editor.js"></script>');
       
    20 }
       
    21 
       
    22 //
       
    23 // Image search autofill
       
    24 //
       
    25 
       
    26 $plugins->attachHook('autofill_json_request', 'guied_image_autofill($dataset);');
       
    27 
       
    28 function guied_image_autofill(&$dataset)
       
    29 {
       
    30 	global $db, $session, $paths, $template, $plugins; // Common objects
       
    31 	if ( $_GET['type'] == 'guied_image' )
       
    32 	{
       
    33 		$results = perform_search($_GET['userinput'], $warnings, false, $word_list);
       
    34 		foreach ( $results as $i => $result )
       
    35 		{
       
    36 			if ( $result['namespace'] != 'File' )
       
    37 				unset($results[$i]);
       
    38 		}
       
    39 		if ( count($results) > 5 )
       
    40 		{
       
    41 			$results = array_slice($results, 0, 5);
       
    42 		}
       
    43 		foreach ( $results as $result )
       
    44 		{
       
    45 			$dataset[] = array(
       
    46 					0 => $result['page_id'],
       
    47 					'title' => str_replace(array('<highlight>', '</highlight>'), array('<b>', '</b>'), $result['page_name']),
       
    48 					'thumbnail' => makeUrlNS('Special', "DownloadFile/{$result['page_id']}", "preview&width=80&height=80"),
       
    49 					'score' => $result['score'],
       
    50 					'type' => isset($result['page_note']) ? $result['page_note'] : '',
       
    51 					'size' => $result['page_length'],
       
    52 				);
       
    53 		}
       
    54 	}
       
    55 }
       
    56 
       
    57 /**!language**
       
    58 <code>
       
    59 {
       
    60 	eng: {
       
    61 		categories: ['meta', 'guied'],
       
    62 		strings: {
       
    63 			meta: {
       
    64 				guied: 'GUI Editor',
       
    65 			},
       
    66 			guied: {
       
    67 				btn_bold: 'Bold',
       
    68 				btn_italic: 'Italic',
       
    69 				btn_underline: 'Underline',
       
    70 				btn_intlink: 'Internal link',
       
    71 				btn_extlink: 'External link',
       
    72 				btn_image: 'Image',
       
    73 				
       
    74 				sample_bold: 'Bold text',
       
    75 				sample_italic: 'Italic text',
       
    76 				sample_underline: 'Underlined text',
       
    77 				
       
    78 				intlink_title: 'Insert internal link',
       
    79 				intlink_lbl_page: 'Page:',
       
    80 				intlink_lbl_text: 'Link text:',
       
    81 				intlink_af_hint: 'Type a few letters to search.',
       
    82 				intlink_text_hint: 'If left blank, the title of the page linked to will be displayed.',
       
    83 				
       
    84 				extlink_title: 'Insert external link',
       
    85 				extlink_lbl_link: 'Link:',
       
    86 				extlink_lbl_text: 'Link text: ',
       
    87 				extlink_link_hint: 'Supported link types: http, https, irc, mailto, ftp',
       
    88 				extlink_text_hint: 'If left blank, the link URL will be displayed.',
       
    89 				
       
    90 				image_title: 'Insert image',
       
    91 				image_lbl_image: 'Image file:',
       
    92 				image_btn_upload: 'Upload a file',
       
    93 				image_lbl_caption: 'Caption:',
       
    94 				image_af_hint: 'Type a few letters to search.',
       
    95 				
       
    96 				btn_insert: 'Insert'
       
    97 			}
       
    98 		}
       
    99 	}
       
   100 }
       
   101 </code>
       
   102 **!*/