first import

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-08 11:40:19 +02:00
commit 1bc61b12ad
8435 changed files with 1582817 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
name = Skinr Panels
description = Provides Skinr integration with Panels.
package = Skinr
core = 7.x
dependencies[] = panels
files[] = tests/skinr_panels.test
; Information added by drupal.org packaging script on 2012-01-20
version = "7.x-2.0-alpha1"
core = "7.x"
project = "skinr"
datestamp = "1327086045"

View File

@@ -0,0 +1,115 @@
<?php
/**
* @file
* Provides Skinr integration with Panels.
*
* NOTE: When panels are stored in code, rather than DB, we run into lack of
* context problems. See the below link for a workaround. This is a limitation
* with the Panels module.
*
* @link http://drupal.org/node/1160924 Undefined property: stdClass::$did in panels_skinr_preprocess_index_handler() @endlink
* @link http://drupal.org/node/1292662 Workaround for undefined property: stdClass::$did in panels_skinr_preprocess_index_handler() @endlink
*/
/**
* Implements hook_skinr_api().
*/
function skinr_panels_skinr_api_2() {
return array();
}
/**
* Implements hook_theme_registry_alter().
*
* Re-order preprocess functions to prioritize skinr_ui_preprocess, which adds
* contextual links, over template_preprocess_HOOK functions. This fixes a
* problem with the way panels handles contextual links.
*/
function skinr_panels_theme_registry_alter(&$theme_registry) {
$preprocess_functions = array();
foreach ($theme_registry['panels_pane']['preprocess functions'] as $function) {
if ($function == 'skinr_ui_preprocess' || $function == 'skinr_panels_preprocess') {
continue;
}
$preprocess_functions[] = $function;
if ($function == 'template_preprocess') {
// Insert our preprocess function right after template_preprocess to give it priority over template_preprocess_HOOK functions.
$preprocess_functions[] = 'skinr_panels_preprocess';
$preprocess_functions[] = 'skinr_ui_preprocess';
}
}
$theme_registry['panels_pane']['preprocess functions'] = $preprocess_functions;
// Add a preprocess function to theme_links(). This is a total hack.
$theme_registry['links']['preprocess functions'][] = 'skinr_panels_preprocess_links';
}
/**
* Implements hook_preprocess().
*/
function skinr_panels_preprocess(&$variables, $hook) {
if ($hook == 'panels_pane' && user_access('edit skin settings')) {
// Get contextual links.
$contextual_links = array();
$counter = 0;
$array_elements = skinr_invoke_all('skinr_elements', $variables, $hook, 'contextual_links');
$module = 'panels';
$elements = $array_elements[$module];
foreach ($elements as $element) {
$contextual_links['skinr-' . $module . '-' . $counter++] = array(
'admin/structure/skinr/edit/nojs', array($module, $element),
);
}
if (!empty($contextual_links)) {
// Need to set contextual links through Skinr API so we have a valid, and
// consistent, link title. It's also used in our hook_preprocess_links()
// hack.
_skinr_ui_set_contextual_links($hook, $contextual_links);
// Render links.
$element = array(
'#type' => 'contextual_links',
'#contextual_links' => $contextual_links,
);
$element = contextual_pre_render_links($element);
// Add in the Skinr links.
if (isset($variables['content']->admin_links) && is_array($variables['content']->admin_links)) {
$variables['content']->admin_links += $element['#links'];
}
else {
$variables['content']->admin_links = $element['#links'];
}
}
}
}
/**
* Implements hook_preprocess_links().
*
* This hack is panels on panel pages only.
*/
function skinr_panels_preprocess_links(&$variables, $hook) {
if (isset($variables['links'][0]['title']) && $variables['links'][0]['title'] == t('Edit @type', array('@type' => 'Panel')) && user_access('edit skin settings')) {
// Get contextual links.
$contextual_links = skinr_ui_get_contextual_links();
if (isset($contextual_links['panels_pane'])) {
$contextual_links = $contextual_links['panels_pane'];
// Render links.
$element = array(
'#type' => 'contextual_links',
'#contextual_links' => $contextual_links,
);
$element = contextual_pre_render_links($element);
// Hack in the Skinr links.
$variables['links'] += $element['#links'];
}
}
}

View File

@@ -0,0 +1,44 @@
<?php
/**
* @file
* Implements Skinr hooks for panels.module.
*/
/**
* Implements hook_skinr_config_info().
*/
function skinr_panels_skinr_config_info() {
return array('panels');
}
/**
* Implements hook_skinr_theme_hooks().
*/
function skinr_panels_skinr_theme_hooks($module, $element) {
$theme_hooks = array();
if ($module == 'panels') {
if (strpos($element, 'region') === 0) {
$theme_hooks[] = 'panels_region';
}
elseif (strpos($element, 'pane') === 0) {
$theme_hooks[] = 'panels_pane';
}
else {
$theme_hooks[] = 'panels_display';
}
}
return $theme_hooks;
}
/**
* Implements hook_skinr_elements().
*/
function skinr_panels_skinr_elements($variables, $hook) {
$elements = array();
if ($hook == 'panels_pane') {
$elements['panels'] = array('pane__' . $variables['pane']->did . '__' . $variables['pane']->pid);
}
return $elements;
}

View File

@@ -0,0 +1,153 @@
<?php
/**
* @file
* Tests for the Skinr Panels module.
*/
/**
* Tests UI functionality for Panels plugin.
*/
class SkinrPanelsTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Plugins UI - Panels',
'description' => 'Tests Skinr UI functionality for functionality plugin from Panels.',
'dependencies' => array('ctools', 'page_manager', 'panels', 'panels_node', 'panels_mini'),
'group' => 'Skinr',
);
}
function setUp() {
parent::setUp(array('block', 'page_manager', 'panels_node', 'panels_mini', 'skinr_panels_test'));
$this->admin_user = $this->drupalCreateUser(array(
'administer blocks',
'use page manager',
'administer page manager',
'create mini panels',
'administer mini panels',
'access contextual links',
'administer skinr',
'edit skin settings',
'edit advanced skin settings',
'bypass node access',
));
$this->drupalLogin($this->admin_user);
}
/**
* Tests panels plugin.
*
* @todo The below test doesn't work due to CTools/Panels not passing along
* enough data to create unique element ids when panels are in code. Skinr
* currently doesn't support panels in code.
*/
function xtestPanelsDefault() {
// Test panels pages.
// Go to panel page.
$this->drupalGet('skinr-panels-test-panel');
// Make sure our contextual link appears on the page.
$this->assertLinkByHref('admin/structure/skinr/edit/nojs/panels/pane__1__1/configure', 0, "Contexual link to edit pane's skin configuration on panel page (stored in code) was found.");
$this->drupalGet('admin/structure/mini-panels');
// Test mini panels.
// Add the mini block to the sidebar.
$default_theme = variable_get('theme_default', 'bartik');
db_merge('block')
->key(array(
'theme' => $default_theme,
'module' => 'panels_mini',
'delta' => 'skinr_panels_test_mini_panel',
))
->fields(array(
'status' => 1,
'region' => 'sidebar_first',
'pages' => '',
))
->execute();
// Go front page.
$this->drupalGet('');
// Make sure our contextual link appears on the page.
// @todo Is there a better way to determine did and pid used for this panel?
$this->assertLinkByHref('admin/structure/skinr/edit/nojs/panels/pane__2__2/configure', 0, 'Contexual link to edit pane\'s skin configuration on mini panel (stored in code) was found.');
}
/**
* Tests panels plugin.
*/
function testPanelsDatabase() {
// Create a simple panel node.
$node = $this->drupalCreateNode(array(
'type' => 'panel',
'panels_node' => array(
'layout' => 'onecol',
'css_id' => '',
'pipeline' => 'standard',
),
));
// Add a block to our panel node.
$display = panels_load_display($node->panels_node['did']);
$pane = panels_new_pane('block', 'system-user-menu', TRUE);
$display->add_pane($pane, 'middle');
$this->assertTrue(panels_save_display($display), 'Block was successfully added to panel node.');
// Go to node.
$uri = entity_uri('node', $node);
$this->drupalGet($uri['path']);
// Make sure our contextual link appears on the page.
// @todo Is there a better way to determine did and pid used for this panel?
$this->assertLinkByHref('admin/structure/skinr/edit/nojs/panels/pane__1__1/configure', 0, 'Contexual link to edit pane\'s skin configuration on panel node was found.');
// Test panels pages.
// Save page to DB.
$task = page_manager_get_task('page');
$handler = page_manager_load_task_handler($task, 'skinr_panels_test', 'page_skinr_panels_test_panel_context');
page_manager_save_task_handler($handler);
// Go to panel page.
$this->drupalGet('skinr-panels-test-panel');
// Make sure our contextual link appears on the page.
$this->assertLinkByHref('admin/structure/skinr/edit/nojs/panels/pane__2__2/configure', 0, "Contexual link to edit pane's skin configuration on panel page (stored in DB) was found.");
// Test mini panels.
// Save mini panel to DB.
$mini = panels_mini_load('skinr_panels_test_mini_panel');
panels_mini_save($mini);
// Add the mini block to the sidebar.
$default_theme = variable_get('theme_default', 'bartik');
db_merge('block')
->key(array(
'theme' => $default_theme,
'module' => 'panels_mini',
'delta' => 'skinr_panels_test_mini_panel',
))
->fields(array(
'status' => 1,
'region' => 'sidebar_first',
'pages' => '',
))
->execute();
// Go front page.
$this->drupalGet('');
// Make sure our contextual link appears on the page.
// @todo Is there a better way to determine did and pid used for this panel?
$this->assertLinkByHref('admin/structure/skinr/edit/nojs/panels/pane__3__3/configure', 0, 'Contexual link to edit pane\'s skin configuration on mini panel (stored in DB) was found.');
}
}

View File

@@ -0,0 +1,71 @@
<?php
$page = new stdClass;
$page->disabled = FALSE; /* Edit this to true to make a default page disabled initially */
$page->api_version = 1;
$page->name = 'skinr_panels_test';
$page->task = 'page';
$page->admin_title = 'Skinr Panels Test';
$page->admin_description = 'Skinr Panels Test panels page.';
$page->path = 'skinr-panels-test-panel';
$page->access = array();
$page->menu = array();
$page->arguments = array();
$page->conf = array(
'admin_paths' => FALSE,
);
$page->default_handlers = array();
$handler = new stdClass;
$handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */
$handler->api_version = 1;
$handler->name = 'page_skinr_panels_test_panel_context';
$handler->task = 'page';
$handler->subtask = 'skinr_panels_test';
$handler->handler = 'panel_context';
$handler->weight = 0;
$handler->conf = array(
'title' => 'Panel',
'no_blocks' => 0,
'pipeline' => 'standard',
'css_id' => '',
'css' => '',
'contexts' => array(),
'relationships' => array(),
);
$display = new panels_display;
$display->layout = 'onecol';
$display->layout_settings = array();
$display->panel_settings = array(
'style_settings' => array(
'default' => NULL,
'middle' => NULL,
),
);
$display->cache = array();
$display->title = '';
$display->content = array();
$display->panels = array();
$pane = new stdClass;
$pane->pid = 'new-1';
$pane->panel = 'middle';
$pane->type = 'block';
$pane->subtype = 'system-user-menu';
$pane->shown = TRUE;
$pane->access = array();
$pane->configuration = array(
'override_title' => 0,
'override_title_text' => '',
);
$pane->cache = array();
$pane->style = array(
'settings' => NULL,
);
$pane->css = array();
$pane->extras = array();
$pane->position = 0;
$display->content['new-1'] = $pane;
$display->panels['middle'][0] = 'new-1';
$display->hide_title = PANELS_TITLE_FIXED;
$display->title_pane = 'new-1';
$handler->conf['display'] = $display;
$page->default_handlers[$handler->name] = $handler;

View File

@@ -0,0 +1,48 @@
<?php
$mini = new stdClass;
$mini->disabled = FALSE;
$mini->api_version = 1;
$mini->name = 'skinr_panels_test_mini_panel';
$mini->category = '';
$mini->admin_title = 'Skinr Panels Test mini panel';
$mini->admin_description = 'Skinr Panels Test mini panel.';
$mini->requiredcontexts = array();
$mini->contexts = array();
$mini->relationships = array();
$display = new panels_display;
$display->layout = 'onecol';
$display->layout_settings = array();
$display->panel_settings = array(
'style_settings' => array(
'default' => NULL,
'middle' => NULL,
),
);
$display->cache = array();
$display->title = '';
$display->content = array();
$display->panels = array();
$pane = new stdClass;
$pane->pid = 'new-1';
$pane->panel = 'middle';
$pane->type = 'block';
$pane->subtype = 'system-user-menu';
$pane->shown = TRUE;
$pane->access = array();
$pane->configuration = array(
'override_title' => 0,
'override_title_text' => '',
);
$pane->cache = array();
$pane->style = array(
'settings' => NULL,
);
$pane->css = array();
$pane->extras = array();
$pane->position = 0;
$display->content['new-1'] = $pane;
$display->panels['middle'][0] = 'new-1';
$display->hide_title = PANELS_TITLE_FIXED;
$display->title_pane = '0';
$mini->display = $display;

View File

@@ -0,0 +1,14 @@
name = Skinr Panels Testing
description = A test module used for testing Skinr Panels.
package = Testing
core = 7.x
hidden = TRUE
dependencies[] = skinr_panels
dependencies[] = skinr_ui
; Information added by drupal.org packaging script on 2012-01-20
version = "7.x-2.0-alpha1"
core = "7.x"
project = "skinr"
datestamp = "1327086045"

View File

@@ -0,0 +1,15 @@
<?php
/**
* @file
* Skinr Panels testing module.
*/
/**
* Implementation of hook_ctools_plugin_api().
*/
function skinr_panels_test_ctools_plugin_api($module, $api) {
if (($module == 'page_manager' && $api == 'pages_default') || ($module == 'panels_mini' && $api == 'panels_default')) {
return array('version' => 1);
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* @file
* Default pages.
*/
/**
* Implementation of hook_default_page_manager_pages().
*/
function skinr_panels_test_default_page_manager_pages() {
static $pages;
if (isset($pages)) {
return $pages;
}
$files = file_scan_directory(drupal_get_path('module', 'skinr_panels_test') . '/pages_default', '/\.inc$/');
foreach ($files as $filepath => $file) {
include $filepath;
if (isset($page)) {
$pages[$page->name] = $page;
}
}
return $pages;
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* @file
* skinr_panels_test.panels_default.inc
*/
/**
* Implementation of hook_default_panels_mini().
*/
function skinr_panels_test_default_panels_mini() {
static $minis;
if (isset($minis)) {
return $minis;
}
$files = file_scan_directory(drupal_get_path('module', 'skinr_panels_test') . '/panels_default', '/\.inc$/');
foreach ($files as $filepath => $file) {
include $filepath;
if (isset($mini)) {
$minis[$mini->name] = $mini;
}
}
return $minis;
}