panels content type plugin declaration with comments

  1. /*
  2.  * There are seven types of panels plugins at present: context, relationships,
  3.  * arguments, content_types, styles, layouts, cache; Panels provides an API that
  4.  * allows any module to implement these, but there's a starter set that comes
  5.  * with Panels itself. They're found in the various subdirectories that live under
  6.  * the Panels directory.
  7.  *
  8.  * All of them (but for our purposes more importantly, content types) start with
  9.  * a 'plugin declaration' function like this one. ALL this function does is return
  10.  * an associative array with a bunch of information for the Panels API to process.
  11.  * The Panels API looks for certain keys in that array - exactly which keys depends
  12.  * on the plugin type - and essentially treats the value in that key as a directive
  13.  * governing how the plugin should behave. Here's what all that concretely means
  14.  * for content types:
  15.  *
  16.  * Yes, there is some unnecessary duplication with this set of callbacks; they were
  17.  * implemented in this way in order to keep from changing the Panels2 API. They will
  18.  * be made consistent & elegant in Panels3.
  19.  */
  20. function panels_SAMPLE_CT_panels_content_types() {
  21.   $items['SAMPLE_CT'] = array(
  22.     // title (string): SETTING. The title that will be used for this pane on the 'Add Content' modal
  23.     // form, and in the display content editor in general. This is a purely internal setting;
  24.     // normal users will never see it.  
  25.     'title' => t('Sample Content Type'),
  26.     // weight (int): SETTING. Standard drupal weighting concept at work here; all it determines is the
  27.     // position of this content type's icon relative to the other content type icons on the
  28.     // 'Add Content' modal form.
  29.     'weight' => -10,
  30.     // single (bool): SETTING. Indicates that this content type plugin provides only a single content
  31.     // type. This doesn't have to be included, it's almost more of a note to humans than to
  32.     // the Panels API. Check out panels_admin_content_types_block() to see how one callback
  33.     // can be used to define multiple content types (technically, types AND subtypes).
  34.     // Defaults to FALSE.
  35.     'single' => TRUE,
  36.     // content_types (string): CALLBACK. The Panels API calls this function to get
  37.     // basic information about the content types this plugin provides. See the callback
  38.     // for details.
  39.     'content_types' => 'panels_admin_content_types_SAMPLE_CT',
  40.     // render callback (string): CALLBACK. The Panels API calls this function when it's
  41.     // trying to render the pane for viewing. See the callback for details.
  42.     'render callback' => 'panels_content_SAMPLE_CT',
  43.     // add callback (string): CALLBACK. This function gets called when the user
  44.     // clicks an icon to add a new pane (from the 'Add Content' modal form).
  45.     // See the callback for details; note that it is often possible to use the
  46.     // same, or nearly the same, callback for this as for the 'edit callback.'  
  47.     'add callback' => 'panels_admin_add_SAMPLE_CT',
  48.     // edit callback (string): CALLBACK. This function gets called when the user
  49.     // clicks the 'Configure' button; it partially governs what appears on the
  50.     // configuration modal form that pops up.
  51.     'edit callback' => 'panels_admin_edit_SAMPLE_CT',
  52.     // (add|edit) validate callback (string): CALLBACK. Defines a callback to be
  53.     // used as a FAPI validator, but only for the $form_values set by form items
  54.     // defined in the 'add/edit callback'.
  55.     'add validate callback' => 'panels_admin_add_validate_SAMPLE_CT',
  56.     'edit validate callback' => 'panels_admin_edit_validate_SAMPLE_CT',
  57.     // (add|edit) submit callback (string): CALLBACK. Defines a callback to be
  58.     // used as a FAPI submit handler, but only for the $form_values set by form
  59.     // items defined in the 'add/edit callback'.
  60.     'add submit callback' => 'panels_admin_add_submit_SAMPLE_CT',
  61.     'edit submit callback' => 'panels_admin_edit_submit_SAMPLE_CT',  
  62.     // title callback (string): CALLBACK. This function determines the title that
  63.     // the pane will use, both in the admin interface and for general viewing. Note
  64.     // that this can almost always be overridden
  65.     'title callback' => 'panels_admin_title_SAMPLE_CT',
  66.     // visibility control (string): CALLBACK. This function gets called at the same
  67.     // time as the add/edit callbacks. Use it to create a form widget that allowing the
  68.     // user to select values that will make sense when passed to your 'visibility check'
  69.     // callback.
  70.     'visibility control' => 'panels_admin_visibility_control_SAMPLE_CT',
  71.     // visibility submit (string): CALLBACK. The custom submit handler you define
  72.     // for your content type's visibility settings. This function is passed
  73.     // whatever selection the user makes on the form widget defined by the
  74.     // 'visibility control' callback. Implement this if you need to wrangle that
  75.     // data before the Panels API's data storage routines kick in, or if the API's
  76.     // built-in routines are inadequate and you need to build a custom storage
  77.     // mechanism. See panels_content_config_form() and panels_content_config_form_submit()
  78.     // to grok the logic behind if/when/how this callback is triggered.
  79.     'visibility submit' => 'panels_admin_visibility_submit_SAMPLE_CT',
  80.     // visibility check (string): CALLBACK. The Panels API calls this function during
  81.     // the pane accessibility checking routine - that's done in panels_pane_access().
  82.     // Define the logic governing your content type's visibility here.
  83.     'visibility check' => 'panels_content_visibility_SAMPLE_CT',
  84.     // visibility serialize (bool): SETTING. Set this to 'true' if the contents of
  85.     // $pane->visibility need to be serialized before being written to the database.
  86.     // Set this to TRUE if, for example, your visibility form widget uses checkboxes
  87.     // (and therefore generates an array), as opposed to if your widget uses radios
  88.     // (and therefore generates an integer that can be stored directly). See
  89.     // panels_content_config_form_submit() and panels_save_display() to better
  90.     // understand how this works.
  91.     // Defaults to FALSE.
  92.     'visibility serialize' => TRUE,
  93.     // role-based access (bool): SETTING. Boolean setting to indicate whether you
  94.     // want the your content type to utilize the Panels API's built-in access
  95.     // system, which is based on drupal user roles. Set this to FALSE to disable
  96.     // role-based access. Note that this will automatically be set to FALSE if
  97.     // a 'visibility control' callback is defined.
  98.     // Defaults to TRUE.
  99.     'role-based access' => FALSE,
  100.     // roles and visibility (bool): SETTING. If you want your content type to use
  101.     // both your custom visibility logic and Panels' built-in roles-based access
  102.     // system, then set this to TRUE. Setting 'role-based access' to TRUE is not
  103.     // sufficient; see panels_ajax_ct_preconfigure() to understand how this works.
  104.     // If you use both systems, panels_pane_access() will AND the results together
  105.     // when determining pane visibility.
  106.     'roles and visibility' => TRUE,
  107.     // form control (string): CALLBACK. If the other callbacks governing the add/edit
  108.     // form ('add/edit callback', 'visibility control') aren't enough for your needs,
  109.     // then implement this callback. The callback will be passed a fully-built $form object
  110.     // by reference, and you can alter it as you see fit. Use with caution.
  111.     'form control' => 'panels_admin_form_control_node_content',
  112.   );
  113.   return $items;
  114. }