[4f375e3] | 1 | <?php |
---|
| 2 | |
---|
| 3 | /** |
---|
| 4 | * Implementation of hook_ctools_plugin_directory(). |
---|
| 5 | */ |
---|
| 6 | function panels_ipe_ctools_plugin_directory($module, $plugin) { |
---|
| 7 | if ($module == 'panels' && $plugin == 'display_renderers') { |
---|
| 8 | return 'plugins/' . $plugin; |
---|
| 9 | } |
---|
| 10 | } |
---|
| 11 | |
---|
| 12 | /** |
---|
| 13 | * Implementation of hook_ctools_plugin_api(). |
---|
| 14 | * |
---|
| 15 | * Inform CTools about version information for various plugins implemented by |
---|
| 16 | * Panels. |
---|
| 17 | * |
---|
| 18 | * @param string $owner |
---|
| 19 | * The system name of the module owning the API about which information is |
---|
| 20 | * being requested. |
---|
| 21 | * @param string $api |
---|
| 22 | * The name of the API about which information is being requested. |
---|
| 23 | */ |
---|
| 24 | function panels_ipe_ctools_plugin_api($owner, $api) { |
---|
| 25 | if ($owner == 'panels' && $api == 'pipelines') { |
---|
| 26 | return array( |
---|
| 27 | 'version' => 1, |
---|
| 28 | 'path' => drupal_get_path('module', 'panels_ipe') . '/includes', |
---|
| 29 | ); |
---|
| 30 | } |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | /** |
---|
| 34 | * Implementation of hook_theme(). |
---|
| 35 | */ |
---|
| 36 | function panels_ipe_theme() { |
---|
| 37 | return array( |
---|
| 38 | 'panels_ipe_pane_wrapper' => array( |
---|
| 39 | 'arguments' => array('output' => NULL, 'pane' => NULL, 'display' => NULL), |
---|
| 40 | ), |
---|
| 41 | 'panels_ipe_region_wrapper' => array( |
---|
| 42 | 'arguments' => array('output' => NULL, 'region_id' => NULL, 'display' => NULL, 'renderer' => NULL), |
---|
| 43 | ), |
---|
| 44 | 'panels_ipe_add_pane_button' => array( |
---|
| 45 | 'arguments' => array('region_id' => NULL, 'display' => NULL, 'renderer' => NULL), |
---|
| 46 | ), |
---|
| 47 | 'panels_ipe_placeholder_pane' => array( |
---|
| 48 | 'arguments' => array('region_id' => NULL, 'region_title' => NULL), |
---|
| 49 | ), |
---|
| 50 | 'panels_ipe_dnd_form_container' => array( |
---|
| 51 | 'arguments' => array('link' => NULL, 'cache_key' => NULL, 'display' => NULL), |
---|
| 52 | ), |
---|
| 53 | ); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | /** |
---|
| 57 | * Theme the 'placeholder' pane, which is shown on an active IPE when no panes |
---|
| 58 | * live in that region. |
---|
| 59 | * |
---|
| 60 | * @param string $region_id |
---|
| 61 | * @param string $region_title |
---|
| 62 | */ |
---|
| 63 | function theme_panels_ipe_placeholder_pane($region_id, $region_title) { |
---|
| 64 | $output = '<div class="panels-ipe-placeholder-content">'; |
---|
| 65 | $output .= "<h3>$region_title</h3>"; |
---|
| 66 | $output .= '</div>'; |
---|
| 67 | return $output; |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | function theme_panels_ipe_pane_wrapper($output, $pane, $display, $renderer) { |
---|
| 71 | $content_type = ctools_get_content_type($pane->type); |
---|
| 72 | $subtype = ctools_content_get_subtype($content_type, $pane->subtype); |
---|
| 73 | $links = array(); |
---|
| 74 | |
---|
| 75 | if (ctools_content_editable($content_type, $subtype, $pane->configuration)) { |
---|
| 76 | $links['edit'] = array( |
---|
| 77 | 'title' => isset($content_type['edit text']) ? $content_type['edit text'] : t('Settings'), |
---|
| 78 | 'href' => $renderer->get_url('edit-pane', $pane->pid), |
---|
| 79 | 'attributes' => array( |
---|
| 80 | 'class' => 'ctools-use-modal', |
---|
| 81 | // 'id' => "pane-edit-panel-pane-$pane->pid", |
---|
| 82 | ), |
---|
| 83 | ); |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | // Deleting is managed entirely in the js; this is just an attachment point |
---|
| 87 | // for it |
---|
| 88 | $links['delete'] = array( |
---|
| 89 | 'title' => t('Delete'), |
---|
| 90 | 'href' => '#', |
---|
| 91 | 'attributes' => array( |
---|
| 92 | 'class' => 'pane-delete', |
---|
| 93 | 'id' => "pane-delete-panel-pane-$pane->pid", |
---|
| 94 | ), |
---|
| 95 | ); |
---|
| 96 | |
---|
| 97 | $attr = array( |
---|
| 98 | 'class' => 'panels-ipe-linkbar', |
---|
| 99 | ); |
---|
| 100 | |
---|
| 101 | $links = theme('links', $links, $attr); |
---|
| 102 | $links .= '<div class="panels-ipe-draghandle"> </div>'; |
---|
| 103 | $handlebar = '<div class="panels-ipe-handlebar-wrapper panels-ipe-on clear-block">' . $links . '</div>'; |
---|
| 104 | return $handlebar . $output; |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | function theme_panels_ipe_region_wrapper($output, $region_id, $display) { |
---|
| 108 | return $output; |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | function theme_panels_ipe_add_pane_button($region_id, $display, $renderer) { |
---|
| 112 | $attr = array('class' => 'ctools-use-modal'); |
---|
| 113 | $link = l(t('Add new pane'), $renderer->get_url('select-content', $region_id), array('attributes' => $attr)); |
---|
| 114 | return '<div class="panels-ipe-newblock panels-ipe-on panels-ipe-portlet-static">' . $link . '</div>'; |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | function panels_ipe_get_cache_key($key = NULL) { |
---|
| 118 | static $cache; |
---|
| 119 | if (isset($key)) { |
---|
| 120 | $cache = $key; |
---|
| 121 | } |
---|
| 122 | return $cache; |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | /** |
---|
| 126 | * Implementation of hook_footer() |
---|
| 127 | * |
---|
| 128 | * Adds the IPE control container. |
---|
| 129 | * |
---|
| 130 | * @param unknown_type $main |
---|
| 131 | */ |
---|
| 132 | function panels_ipe_footer($main = 0) { |
---|
| 133 | $key = panels_ipe_get_cache_key(); |
---|
| 134 | if (!isset($key)) { |
---|
| 135 | return; |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | // TODO should be moved into the IPE plugin - WAAAY too hardcoded right now |
---|
| 139 | $output = "<div id='panels-ipe-control-container' class='clear-block'>"; |
---|
| 140 | $output .= "<div id='panels-ipe-control-$key' class='panels-ipe-control'>"; |
---|
| 141 | $output .= "<div class='panels-ipe-startedit panels-ipe-pseudobutton panels-ipe-off'>"; |
---|
| 142 | $output .= "<span>" . t('Customize this page') . "</span>"; |
---|
| 143 | $output .= "</div>"; |
---|
| 144 | $output .= "<div class='panels-ipe-form-container panels-ipe-on clear-block'></div>"; |
---|
| 145 | $output .= "</div></div>"; |
---|
| 146 | return $output; |
---|
| 147 | } |
---|