diff --git a/insertView/images/icon.gif b/insertView/images/icon.gif new file mode 100644 index 0000000..82e62b0 Binary files /dev/null and b/insertView/images/icon.gif differ diff --git a/insertView/lang/en.js b/insertView/lang/en.js new file mode 100644 index 0000000..dc574f1 --- /dev/null +++ b/insertView/lang/en.js @@ -0,0 +1,2 @@ +FCKLang.NodeEmbedooltip = 'Node Embed' ; +FCKLang.NodeEmbedTitle = 'Embed' ; \ No newline at end of file diff --git a/insertView/plugin.js b/insertView/plugin.js new file mode 100644 index 0000000..b235905 --- /dev/null +++ b/insertView/plugin.js @@ -0,0 +1,77 @@ +CKEDITOR.plugins.add( 'insertView', + { + requires : [ 'iframedialog', 'fakeobjects'], + //Initialize the plugin + init : function( editor ) { + //add the popup for the plugin + CKEDITOR.dialog.add( 'insertview', function () { + return { + title : 'Insert View', + minWidth : 700, + minHeight : 400, + //the contents of the dialog + contents : + [ + { + id : 'iframe', + label : 'Insert a view: ', + expand : true, + style: 'width:100%;height:100%;', + elements : + [ + { + type : 'iframe', + src : Drupal.settings.basePath + 'insert-views', + width : '100%', + height : '100%', + onContentLoad : function() {} + } + ] + } + ], + + //handles the 'ok' button being clicked + onOk : function() { + if(window.insert_view_selection) { + this._.editor.insertHtml(window.insert_view_selection); //insert the tag into the editor + } + } + }; + + } + + ); + //add the button to the menu + editor.ui.addButton( 'insertView', + { + label : 'Insert View', + icon : this.path + 'images/icon.gif', + command : 'insertView' + } + ); + + //add the command to open the window + editor.addCommand( 'insertView', {exec : function(e){ + e.openDialog('insertview'); + } + } + ); + + //if the "menu" plugin is loaded, register the menu items. + if ( editor.addMenuItems ) { + editor.addMenuItems( + { + insertmenu : + { + label : 'Insert View', + command : 'insertView', + group : 'insertView', + order : 1 + } + } + ); + } + + } + + } ); diff --git a/insert_view.admin.inc b/insert_view.admin.inc new file mode 100644 index 0000000..f2240f1 --- /dev/null +++ b/insert_view.admin.inc @@ -0,0 +1,22 @@ + t('Views that will appear in wysiwyg plugins.'), + '#type' => 'checkboxes', + '#options' => insert_view_view_selection_options(FALSE), + '#description' => t('If using a wysiwyg plugin to place the view, select which views should appear here.'), + '#default_value' => variable_get('insert_view_view_selection', array()), + ); + return system_settings_form($form); +} \ No newline at end of file diff --git a/insert_view.module b/insert_view.module index 8924757..32ac891 100644 --- a/insert_view.module +++ b/insert_view.module @@ -110,3 +110,121 @@ function insert_view($view_name, $display_id = 'default', $args = '') { return $output; } + +/** + * Implements hook_permission(). + */ +function insert_view_permission() { + return array( + 'administer insert view' => array( + 'title' => t('Administer insert view'), + 'description' => t('Configure insert view settings'), + ), + ); +} + +/** + * Implements hook_menu(). + */ +function insert_view_menu() { + $items = array(); + + $items['insert-views'] = array( + 'page callback' => 'insert_view_view_selection', + // @todo access callback that checks if any input formats has insert view + // allowed. + 'access arguments' => array('access content'), + ); + + $items['admin/config/content/insert-view'] = array( + 'page arguments' => array('insert_view_admin_form'), + 'page callback' => 'drupal_get_form', + 'access arguments' => array('administer insert view'), + 'file' => 'insert_view.admin.inc', + 'title' => 'Insert View', + 'description' => 'Configure insert view settings', + 'type' => MENU_NORMAL_ITEM, + ); + + return $items; +} + +/** + * View selection page. + */ +function insert_view_view_selection() { + $views = views_get_all_views(); + $page = array( + 'selection' => array( + '#type' => 'select', + '#options' => array('' => t('- View -')) + insert_view_view_selection_options(), + '#title' => t('View'), + ), + ); + drupal_add_js(drupal_get_path('module', 'insert_view') . '/insert_view_selection.js'); + return $page; +} + +/** + * Returns an array of tags for view selection. + */ +function insert_view_view_selection_options($filter = TRUE) { + $views = views_get_all_views(); + $options = array(); + foreach ($views as $name => $view) { + foreach ($view->display as $display_key => $display) { + $options['[view:' . $name . '=' . $display_key . ']'] = $view->human_name ? check_plain($view->human_name) : check_plain($name); + if ($display_key != 'default') { + $options['[view:' . $name . '=' . $display_key . ']'] .= ': ' . check_plain($display->display_title); + } + } + } + if ($filter && ($configured_options = array_filter(variable_get('insert_view_view_selection', array())))) { + $options = array_intersect_key($options, $configured_options); + } + return $options; + +} + +/** + * Implements hook_theme_registry_alter(). + */ +function insert_view_theme_registry_alter(&$theme_registry) { + + // Add 'html--insert-view.tpl.php' template file + $theme_registry['html__insert_views'] = array(); + $theme_registry['html__insert_views']['template'] = 'html--insert-views'; + $theme_registry['html__insert_views']['path'] = drupal_get_path('module', 'insert_view') . "/theme"; + $theme_registry['html__insert_views']['render element'] = 'page'; + $theme_registry['html__insert_views']['base hook'] = 'html'; + $theme_registry['html__insert_views']['type'] = 'theme_engine'; + $theme_registry['html__insert_views']['theme path'] = path_to_theme(); + $theme_registry['html__insert_views']['preprocess functions'] = array(); + $theme_registry['html__insert_views']['process functions'] = array(); + + // Add 'page--insert-view.tpl.php' template file + $theme_registry['page__insert_views'] = array(); + $theme_registry['page__insert_views']['template'] = 'page--insert-views'; + $theme_registry['page__insert_views']['path'] = drupal_get_path('module', 'insert_view') . "/theme"; + $theme_registry['page__insert_views']['render element'] = 'page'; + $theme_registry['page__insert_views']['base hook'] = 'page'; + $theme_registry['page__insert_views']['type'] = 'theme_engine'; + $theme_registry['page__insert_views']['theme path'] = path_to_theme(); + $theme_registry['page__insert_views']['preprocess functions'] = array(); + $theme_registry['page__insert_views']['process functions'] = array(); + +} + +/** + * Implements of hook_ckeditor_plugin(). + */ +function insert_view_ckeditor_plugin() { + return array( + 'insertView' => array( + 'name' => 'insertView', + 'desc' => t('Insert View - insert a view into content.'), + 'path' => drupal_get_path('module', 'insert_view') . '/insertView/', + ), + ); +} + diff --git a/insert_view_selection.js b/insert_view_selection.js new file mode 100644 index 0000000..4523e21 --- /dev/null +++ b/insert_view_selection.js @@ -0,0 +1,10 @@ +(function ($) { + Drupal.behaviors.insert_view = { + attach: function(context) { + $('select', context).change(function() { + console.log('here'); + window.parent.insert_view_selection = $(this).val(); + }); + } + } +})(jQuery); diff --git a/theme/html--insert-views.tpl.php b/theme/html--insert-views.tpl.php new file mode 100644 index 0000000..4cd5b89 --- /dev/null +++ b/theme/html--insert-views.tpl.php @@ -0,0 +1,72 @@ +language contains its textual representation. + * $language->dir contains the language direction. It will either be 'ltr' or 'rtl'. + * - $rdf_namespaces: All the RDF namespace prefixes used in the HTML document. + * - $grddl_profile: A GRDDL profile allowing agents to extract the RDF data. + * - $head_title: A modified version of the page title, for use in the TITLE + * tag. + * - $head_title_array: (array) An associative array containing the string parts + * that were used to generate the $head_title variable, already prepared to be + * output as TITLE tag. The key/value pairs may contain one or more of the + * following, depending on conditions: + * - title: The title of the current page, if any. + * - name: The name of the site. + * - slogan: The slogan of the site, if any, and if there is no title. + * - $head: Markup for the HEAD section (including meta tags, keyword tags, and + * so on). + * - $styles: Style tags necessary to import all CSS files for the page. + * - $scripts: Script tags necessary to load the JavaScript files and settings + * for the page. + * - $page_top: Initial markup from any modules that have altered the + * page. This variable should always be output first, before all other dynamic + * content. + * - $page: The rendered page content. + * - $page_bottom: Final closing markup from any modules that have altered the + * page. This variable should always be output last, after all other dynamic + * content. + * - $classes String of classes that can be used to style contextually through + * CSS. + * + * @see template_preprocess() + * @see template_preprocess_html() + * @see template_process() + */ +?> + + + + + + + + <?php print $head_title; ?> + + + + + + + + +
+ +
+ + + diff --git a/theme/page--insert-views.tpl.php b/theme/page--insert-views.tpl.php new file mode 100644 index 0000000..1092c0f --- /dev/null +++ b/theme/page--insert-views.tpl.php @@ -0,0 +1 @@ +