diff --git a/includes/display-edit.inc b/includes/display-edit.inc index ecb5fa4d46942f101b6a3e962728cd9d15ad6a09..dd5f21ec820f8d8b6c213a1a4ecb8164113cb18d 100644 --- a/includes/display-edit.inc +++ b/includes/display-edit.inc @@ -150,7 +150,7 @@ function panels_edit_display_form(&$form_state) { drupal_add_css(panels_get_path('css/panels_admin.css')); $css = array(); - $js = array(); + $js = array(drupal_get_path('module', 'ctools') . '/js/dependent.js' => TRUE); foreach ($form_state['content_types'] as $type_name => $subtypes) { if (is_array($subtypes)) { foreach ($subtypes as $subtype) { diff --git a/includes/display-render.inc b/includes/display-render.inc index bdd3f19024e2ce487448dde8926290f522c94c3d..3456880c59f3bc2278c427d61f22e42065a689ce 100644 --- a/includes/display-render.inc +++ b/includes/display-render.inc @@ -101,6 +101,9 @@ function panels_render_layout($layout, $content, $css_id = NULL, $settings = arr /** * Render the administrative layout of a display. + * + * This is used for the edit version, so that layouts can have different + * modes, such as the flexible layout designer mode. */ function panels_render_layout_admin($layout, $content, $display) { // @todo This should be abstracted. @@ -310,9 +313,6 @@ function panels_render_panel($display, $panel, $panes) { * $content->more -- An optional 'more' link (destination only) * $content->admin_links -- Administrative links associated with the content * $content->feeds -- Any feed icons or associated with the content - * $content->subject -- A legacy setting for block compatibility - * $content->module -- A legacy setting for block compatibility - * $content->delta -- A legacy setting for block compatibility */ function theme_panels_pane($content, $pane, $display) { if (!empty($content->content)) { diff --git a/includes/plugins.inc b/includes/plugins.inc index db8d462cd740635dbcd8a11de4d28d70ef58eb8a..ccd4329962beeb66dfb6c8ccffaf4e3cb64349ae 100644 --- a/includes/plugins.inc +++ b/includes/plugins.inc @@ -7,12 +7,6 @@ * Contains helper code for plugins and contexts. */ - -/** - * @defgroup panels_content Panels content and pane helper/info functions - * @{ - */ - /** * Determine if a pane is visible. * @@ -26,212 +20,6 @@ function panels_pane_access($pane, $display) { return ctools_access($pane->access, $display->context); } -/** - * Get the content from a given content type. - * - * @param $type - * The content type. May be the name or an already loaded content type object. - * @param $conf - * The configuration for the content type. - * @param $args - * The arguments to the content type. - * @param $context - * The panels_context object. - * @param $incoming_content - * Any incoming content, if this display is a wrapper. - */ -function panels_ct_get_content($type, $subtype, $conf, $args, $context, $incoming_content) { - if ($function = panels_plugin_get_function('content_types', $type, 'render callback')) { - $content = $function($subtype, $conf, $args, $context, $incoming_content); - if (empty($content->title) && !empty($content->subject)) { - $content->title = $content->subject; - } - - if (!empty($content->title) && empty($content->subject)) { - $content->subject = $content->title; - } - - return $content; - } -} - -/** - * Get the title from a given content type. - * - * @param $type - * The content type. May be the name or an already loaded content type object. - * @param $conf - * The configuration for the content type. - * @param $context - * The panels_context object. - * @param $incoming_content - * Any incoming content, if this display is a wrapper. - */ -function panels_ct_get_title($type, $subtype, $conf, $context = NULL, $incoming_content = NULL) { - if ($function = panels_plugin_get_function('content_types', $type, 'title callback')) { - return $function($subtype, $conf, $context, $incoming_content); - } - return t('Deleted/missing content type @type', array('@type' => $type)); -} - -/** - * Add the default FAPI elements to the content type configuration form - */ -function panels_ct_conf_form($content_type, $subtype, $contexts, $conf) { - ctools_include('context'); - if (!empty($subtype['required context']) && is_array($contexts)) { - $form['context'] = ctools_context_selector($contexts, $subtype['required context'], isset($conf['context']) ? $conf['context'] : array()); - } - - // Unless we're not allowed to overide the title on this content type, add this - // gadget to all panes. - if (empty($content_type['no title override'])) { - $form['aligner_start'] = array( - '#value' => '
', - ); - $form['override_title'] = array( - '#type' => 'checkbox', - '#default_value' => isset($conf['override_title']) ? $conf['override_title'] : '', - '#title' => t('Override title'), - '#id' => 'override-title-checkbox', - ); - $form['override_title_text'] = array( - '#type' => 'textfield', - '#default_value' => isset($conf['override_title_text']) ? $conf['override_title_text'] : '', - '#size' => 35, - '#id' => 'override-title-textfield', - ); - $form['aligner_stop'] = array( - '#value' => '
', - ); - $form['override_title_markup'] = array( - '#prefix' => '
', - '#suffix' => '
', - '#value' => t('You may use %keywords from contexts, as well as %title to contain the original title.'), - ); - } - - return $form; -} - -/** - * Call any content type-defined add/edit callbacks so that additions - * to $form['configuration'] can be made. - * - * @see panels_content_config_form() - * - * @param object $pane - * The $pane object currently being edited. - * @param $contexts - * A list of possible contexts. - * @param $parents - * The #parents to be used on the form, because some form gadgets need to - * know where they live. - * @param string $op - * Either 'add' or 'edit' depending on the operation being performed. - * @param mixed $content_type - * This variable should only be passed if the calling function already has access to the - * relevant content_type data and wants to save a little on performance. If so, then the - * fully-loaded content type plugin declaration array should be passed. - */ -function panels_ct_pane_config_form($pane, $contexts, $parents, $op, $content_type = 'content_types') { - if ($function = panels_plugin_get_function($content_type, $pane->type, "$op callback")) { - return $function($pane->subtype, $parents, $pane->configuration); - } -} - -/** - * Call any add/edit validators defined by the content type. - * - * @see panels_content_config_form_validate() - * - * @param $type - * The content type. May be the name or an already loaded content type object. - * @param $form - * The actual Forms API form that is being validated. - * @param $form_values - * The actual Forms API values being validated. - * @param string $op - * Either 'add' or 'edit' depending on the operation being performed. - */ -function panels_ct_pane_validate_form($content_type, $form, &$form_state, $op) { - if ($function = panels_plugin_get_function('content_types', $content_type, "$op validate callback")) { - return $function($form, $form_state); - } -} - -/** - * Call any add/edit submit handlers defined by the content type. - * - * @param string $content_type - * A string value containing the name of the content type. - * @param $form_values - * The $form_values['configuration'] sub-array generated by FAPI for the - * overall ct add/edit submit handler. - * @param string $op - * Either 'add' or 'edit' depending on the operation being performed. - */ -function panels_ct_pane_submit_form($content_type, &$form_values, $op) { - if ($function = panels_plugin_get_function('content_types', $content_type, "$op submit callback")) { - return $function($form_values); - } -} - -/** - * Get all of the individual subtypes provided by a given content type. This - * would be all of the blocks for the block type, or all of the views for - * the view type. - * - * @param $type - * The content type to load. - */ -function panels_ct_get_subtypes($type) { - if (is_array($type)) { - $content_type = $type; - } - else { - $content_type = panels_get_content_type($type); - } - - // Leave this in to maintain a little backward compatibility. We can take - // this out later. - if (isset($content_type['content types'])) { - $function = $content_type['content types']; - } - else { - $function = $content_type['content_types']; - } - - if (is_array($function)) { - return (array) $function; - } - - if (function_exists($function)) { - return (array) $function(); - } - return array(); -} - -/** - * Given a content type and a subtype id, return the information about that - * content subtype. - * - * @param $type - * @param $subtype_id - */ -function panels_ct_get_subtype($type, $subtype_id) { - $function = panels_plugin_get_function('content_types', $type, 'content_type'); - if ($function) { - return $function($subtype_id); - } - else { - $subtypes = panels_ct_get_subtypes($type); - if (isset($subtypes[$subtype_id])) { - return $subtypes[$subtype_id]; - } - } -} - /** * Get a list of panels available in the layout. */ @@ -245,79 +33,6 @@ function panels_get_panels($layout, $display) { return array(); } -/** - * Get an array of all available content types that can be fed into the - * display editor for the add content list. - * - * @param $context - * If a context is provided, content that requires that context can apepar. - * @param $has_content - * Whether or not the display will have incoming content - * @param $allowed_types - * An array of allowed content types (pane types) keyed by content_type . '-' . sub_type - * @param $default_types - * A default allowed/denied status for content that isn't known about - */ -function panels_get_available_content_types($contexts = NULL, $has_content = FALSE, $allowed_types = NULL, $default_types = NULL) { - $content_types = panels_get_content_types(); - $available = array(); - - ctools_include('context'); - foreach ($content_types as $id => $type) { - foreach (panels_ct_get_subtypes($type) as $cid => $cinfo) { - // exclude items that require content if we're saying we don't - // provide it. - if (!empty($cinfo['requires content']) && !$has_content) { - continue; - } - - // Check to see if the content type can be used in this context. - if (!empty($cinfo['required context'])) { - if (!ctools_context_filter($contexts, $cinfo['required context'])) { - continue; - } - } - - // Check to see if the passed-in allowed types allows this content. - if ($allowed_types) { - $key = $id . '-' . $cid; - if (!isset($allowed_types[$key])) { - $allowed_types[$key] = isset($default_types[$id]) ? $default_types[$id] : $default_types['other']; - } - if (!$allowed_types[$key]) { - continue; - } - } - - // If we made it through all the tests, then we can use this content. - $available[$id][$cid] = $cinfo; - } - } - return $available; -} - -/** - * Get an array of all content types that can be fed into the - * display editor for the add content list, regardless of - * availability. - * - */ -function panels_get_all_content_types() { - $content_types = panels_get_content_types(); - $available = array(); - - foreach ($content_types as $id => $type) { - foreach (panels_ct_get_subtypes($type) as $cid => $cinfo) { - // If we made it through all the tests, then we can use this content. - $available[$id][$cid] = $cinfo; - } - } - return $available; -} - -// ------------------------------------------------------------------ -// Functions to provide information about a panel or part of a panel. - /** * Get the content from a given pane. * @@ -552,10 +267,6 @@ function panels_get_pane_title(&$pane, $context = array(), $incoming_content = N return ctools_content_admin_title($pane->type, $pane->subtype, $pane->configuration, $context); } -/** - * @} End of "defgroup panels_content". - */ - /** * Select a context for a pane. * @@ -622,34 +333,6 @@ function panels_get_styles() { return ctools_get_plugins('panels', 'styles'); } - -/** - * Fetch metadata on a specific content_type plugin. - * - * @param $content type - * Name of a panel content type. - * - * @return - * An array with information about the requested panel content type. - */ -function panels_get_content_type($content_type) { - ctools_include('context'); - ctools_include('plugins'); - return ctools_get_plugins('panels', 'content_types', $content_type); -} - -/** - * Fetch metadata for all content_type plugins. - * - * @return - * An array of arrays with information about all available panel content types. - */ -function panels_get_content_types() { - ctools_include('context'); - ctools_include('plugins'); - return ctools_get_plugins('panels', 'content_types'); -} - /** * Fetch metadata on a specific caching plugin. * @@ -702,9 +385,5 @@ function panels_plugin_get_function($plugin, $which, $function_name) { } // These are placeholders to prevent crashes from the former plugins - -class panels_required_context { - function filter() { } -}; - +class panels_required_context { function filter() { } }; class panels_optional_context extends panels_required_context {};