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,12 @@
name = Custom content panes
description = Create custom, exportable, reusable content panes for applications like Panels.
core = 7.x
package = Chaos tool suite
dependencies[] = ctools
; Information added by drupal.org packaging script on 2013-02-02
version = "7.x-1.2+31-dev"
core = "7.x"
project = "ctools"
datestamp = "1359766341"

View File

@ -0,0 +1,67 @@
<?php
/**
* Schema for CTools custom content.
*/
function ctools_custom_content_schema() {
return ctools_custom_content_schema_1();
}
function ctools_custom_content_schema_1() {
$schema = array();
$schema['ctools_custom_content'] = array(
'description' => 'Contains exportable customized content for this site.',
'export' => array(
'identifier' => 'content',
'bulk export' => TRUE,
'primary key' => 'cid',
'api' => array(
'owner' => 'ctools_custom_content',
'api' => 'ctools_content',
'minimum_version' => 1,
'current_version' => 1,
),
'create callback' => 'ctools_content_type_new',
),
'fields' => array(
'cid' => array(
'type' => 'serial',
'description' => 'A database primary key to ensure uniqueness',
'not null' => TRUE,
'no export' => TRUE,
),
'name' => array(
'type' => 'varchar',
'length' => '255',
'description' => 'Unique ID for this content. Used to identify it programmatically.',
),
'admin_title' => array(
'type' => 'varchar',
'length' => '255',
'description' => 'Administrative title for this content.',
),
'admin_description' => array(
'type' => 'text',
'size' => 'big',
'description' => 'Administrative description for this content.',
'object default' => '',
),
'category' => array(
'type' => 'varchar',
'length' => '255',
'description' => 'Administrative category for this content.',
),
'settings' => array(
'type' => 'text',
'size' => 'big',
'description' => 'Serialized settings for the actual content to be used',
'serialize' => TRUE,
'object default' => array(),
),
),
'primary key' => array('cid'),
);
return $schema;
}

View File

@ -0,0 +1,98 @@
<?php
/**
* @file
* ctools_custom_content module
*
* This module allows styles to be created and managed on behalf of modules
* that implement styles.
*
* The ctools_custom_content tool allows recolorable styles to be created via a miniature
* scripting language. Panels utilizes this to allow administrators to add
* styles directly to any panel display.
*/
/**
* Implementation of hook_permission()
*/
function ctools_custom_content_permission() {
return array(
'administer custom content' => array(
'title' => t('Administer custom content'),
'description' => t('Add, edit and delete CTools custom stored custom content'),
),
);
}
/**
* Implementation of hook_ctools_plugin_directory() to let the system know
* we implement task and task_handler plugins.
*/
function ctools_custom_content_ctools_plugin_directory($module, $plugin) {
// Most of this module is implemented as an export ui plugin, and the
// rest is in ctools/includes/ctools_custom_content.inc
if ($module == 'ctools' && $plugin == 'export_ui') {
return 'plugins/' . $plugin;
}
}
/**
* Create callback for creating a new CTools custom content type.
*
* This ensures we get proper defaults from the plugin for its settings.
*/
function ctools_content_type_new($set_defaults) {
$item = ctools_export_new_object('ctools_custom_content', $set_defaults);
ctools_include('content');
$plugin = ctools_get_content_type('custom');
$item->settings = ctools_content_get_defaults($plugin, array());
return $item;
}
/**
* Implementation of hook_panels_dashboard_blocks().
*
* Adds page information to the Panels dashboard.
*/
function ctools_custom_content_panels_dashboard_blocks(&$vars) {
$vars['links']['ctools_custom_content'] = array(
'title' => l(t('Custom content'), 'admin/structure/ctools-content/add'),
'description' => t('Custom content panes are basic HTML you enter that can be reused in all of your panels.'),
);
// Load all mini panels and their displays.
ctools_include('export');
$items = ctools_export_crud_load_all('ctools_custom_content');
$count = 0;
$rows = array();
foreach ($items as $item) {
$rows[] = array(
check_plain($item->admin_title),
array(
'data' => l(t('Edit'), "admin/structure/ctools-content/list/$item->name/edit"),
'class' => 'links',
),
);
// Only show 10.
if (++$count >= 10) {
break;
}
}
if ($rows) {
$content = theme('table', array('rows' => $rows, 'attributes' => array('class' => 'panels-manage')));
}
else {
$content = '<p>' . t('There are no custom content panes.') . '</p>';
}
$vars['blocks']['ctools_custom_content'] = array(
'title' => t('Manage custom content'),
'link' => l(t('Go to list'), 'admin/structure/ctools-content'),
'content' => $content,
'class' => 'dashboard-content',
'section' => 'right',
);
}

View File

@ -0,0 +1,20 @@
<?php
$plugin = array(
'schema' => 'ctools_custom_content',
'access' => 'administer custom content',
'menu' => array(
'menu item' => 'ctools-content',
'menu title' => 'Custom content panes',
'menu description' => 'Add, edit or delete custom content panes.',
),
'title singular' => t('content pane'),
'title singular proper' => t('Content pane'),
'title plural' => t('content panes'),
'title plural proper' => t('Content panes'),
'handler' => 'ctools_custom_content_ui',
);

View File

@ -0,0 +1,129 @@
<?php
class ctools_custom_content_ui extends ctools_export_ui {
function edit_form(&$form, &$form_state) {
// Correct for an error that came in because filter format changed.
if (is_array($form_state['item']->settings['body'])) {
$form_state['item']->settings['format'] = $form_state['item']->settings['body']['format'];
$form_state['item']->settings['body'] = $form_state['item']->settings['body']['value'];
}
parent::edit_form($form, $form_state);
$form['category'] = array(
'#type' => 'textfield',
'#title' => t('Category'),
'#description' => t('What category this content should appear in. If left blank the category will be "Miscellaneous".'),
'#default_value' => $form_state['item']->category,
);
$form['title'] = array(
'#type' => 'textfield',
'#default_value' => $form_state['item']->settings['title'],
'#title' => t('Title'),
);
$form['body'] = array(
'#type' => 'text_format',
'#title' => t('Body'),
'#default_value' => $form_state['item']->settings['body'],
'#format' => $form_state['item']->settings['format'],
);
$form['substitute'] = array(
'#type' => 'checkbox',
'#title' => t('Use context keywords'),
'#description' => t('If checked, context keywords will be substituted in this content.'),
'#default_value' => !empty($form_state['item']->settings['substitute']),
);
}
function edit_form_submit(&$form, &$form_state) {
parent::edit_form_submit($form, $form_state);
// Since items in our settings are not in the schema, we have to do these manually:
$form_state['item']->settings['title'] = $form_state['values']['title'];
$form_state['item']->settings['body'] = $form_state['values']['body']['value'];
$form_state['item']->settings['format'] = $form_state['values']['body']['format'];
$form_state['item']->settings['substitute'] = $form_state['values']['substitute'];
}
function list_form(&$form, &$form_state) {
parent::list_form($form, $form_state);
$options = array('all' => t('- All -'));
foreach ($this->items as $item) {
$options[$item->category] = $item->category;
}
$form['top row']['category'] = array(
'#type' => 'select',
'#title' => t('Category'),
'#options' => $options,
'#default_value' => 'all',
'#weight' => -10,
);
}
function list_filter($form_state, $item) {
if ($form_state['values']['category'] != 'all' && $form_state['values']['category'] != $item->category) {
return TRUE;
}
return parent::list_filter($form_state, $item);
}
function list_sort_options() {
return array(
'disabled' => t('Enabled, title'),
'title' => t('Title'),
'name' => t('Name'),
'category' => t('Category'),
'storage' => t('Storage'),
);
}
function list_build_row($item, &$form_state, $operations) {
// Set up sorting
switch ($form_state['values']['order']) {
case 'disabled':
$this->sorts[$item->name] = empty($item->disabled) . $item->admin_title;
break;
case 'title':
$this->sorts[$item->name] = $item->admin_title;
break;
case 'name':
$this->sorts[$item->name] = $item->name;
break;
case 'category':
$this->sorts[$item->name] = $item->category;
break;
case 'storage':
$this->sorts[$item->name] = $item->type . $item->admin_title;
break;
}
$ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
$this->rows[$item->name] = array(
'data' => array(
array('data' => check_plain($item->name), 'class' => array('ctools-export-ui-name')),
array('data' => check_plain($item->admin_title), 'class' => array('ctools-export-ui-title')),
array('data' => check_plain($item->category), 'class' => array('ctools-export-ui-category')),
array('data' => $ops, 'class' => array('ctools-export-ui-operations')),
),
'title' => check_plain($item->admin_description),
'class' => array(!empty($item->disabled) ? 'ctools-export-ui-disabled' : 'ctools-export-ui-enabled'),
);
}
function list_table_header() {
return array(
array('data' => t('Name'), 'class' => array('ctools-export-ui-name')),
array('data' => t('Title'), 'class' => array('ctools-export-ui-title')),
array('data' => t('Category'), 'class' => array('ctools-export-ui-category')),
array('data' => t('Operations'), 'class' => array('ctools-export-ui-operations')),
);
}
}