initial commit of starter install drupal 7

This commit is contained in:
Bachir Soussi Chiadmi
2015-02-21 17:21:40 +01:00
commit eeba51cea6
6113 changed files with 1249218 additions and 0 deletions
@@ -0,0 +1,102 @@
<?php
/**
* @file
* Linkit Profile class.
*/
/**
* Linkit Profile class implementation.
*/
class LinkitProfile {
/**
* The profile data (settings).
*
* @var array
*/
public $data;
/**
* All enabled attributes for this profile.
*
* @var array
*/
protected $enabled_attribute_plugins;
/**
* All enabled search plugins for this profile.
*
* @var array
*/
protected $enabled_search_plugins;
/**
* Set all enabled attribure plugins.
*/
public function setEnabledAttributePlugins() {
foreach ($this->data['attribute_plugins'] as $attribute_name => $attribute) {
if ($attribute['enabled']) {
// Load the attribute plugin.
$attribute_plugin = linkit_attribute_plugin_load($attribute_name);
// Call the callback to get the FAPI element.
if (isset($attribute_plugin['callback']) && function_exists($attribute_plugin['callback'])) {
$attribute_html = $attribute_plugin['callback']($attribute_plugin, $attribute);
// Add Linkit specific class, this is used by the editor JS scripts.
$attribute_html['#attributes']['class'][] = 'linkit-attribute';
$this->enabled_attribute_plugins[$attribute_name] = $attribute_html;
}
}
}
}
/**
* Set all enabled search plugins.
*/
public function setEnabledsearchPlugins() {
// Sort plugins by weight.
uasort($this->data['search_plugins'], 'linkit_sort_plugins_by_weight');
foreach ($this->data['search_plugins'] as $plugin_name => $plugin) {
if ($plugin['enabled']) {
// Load plugin definition.
$plugin_definition = linkit_search_plugin_load($plugin_name);
// Get a Linkit search plugin object.
$search_plugin = LinkitSearchPlugin::factory($plugin_definition, $this);
// Only register none broken plugins.
if ($search_plugin->broken() !== TRUE) {
$this->enabled_search_plugins[$plugin_name] = $search_plugin;
}
}
}
}
/**
* Construct an array with all the enabled attribute plugins for this profile.
*
* @return
* An array with all enabled attribute plugins for this profile.
*/
public function getEnabledAttributePlugins() {
if (!isset($this->enabled_attribute_plugins)) {
$this->setEnabledAttributePlugins();
}
return $this->enabled_attribute_plugins;
}
/**
* Construct an array with all enabled search plugins for this profile.
*
* @return
* An array with all enabled search plugins for this profile.
*/
public function getEnabledsearchPlugins() {
if (!isset($this->enabled_search_plugins)) {
$this->setEnabledsearchPlugins();
}
return $this->enabled_search_plugins;
}
}
@@ -0,0 +1,171 @@
<?php
/**
* @file
* Linkit Search plugin interface.
*
* Provides an interface and classes to implement Linkit search plugins.
*/
/**
* Defines a common interface for a Linkit search plugin.
*/
interface LinkitSearchPluginInterface {
/**
* Search plugin factory method.
*
* @param $plugin
* A search plugin object.
*
* @param LinkitProfile $profile
* (optional) A LinkitProfile object.
*
* @return
* An instance of the search plugin class or an instance of the
* LinkitSearchPluginBroken class.
*/
public static function factory($plugin, LinkitProfile $profile);
/**
* Return a string representing this handler's name in the UI.
*/
public function ui_title();
/**
* Return a string representing this handler's description in the UI.
*/
public function ui_description();
/**
* Fetch search results based on the $search_string.
*
* @param $search_string
* A string that contains the text to search for.
*
* @return
* An associative array whose values are an
* associative array containing:
* - title: A string to use as the search result label.
* - description: (optional) A string with additional information about the
* result item.
* - path: The URL to the item.
* - group: (optional) A string with the group name for the result item.
* Best practice is to use the plugin name as group name.
* - addClass: (optional) A string with classes to add to the result row..
*/
public function fetchResults($search_string);
}
/**
* Base class for Linkit search plugins.
*/
abstract class LinkitSearchPlugin implements LinkitSearchPluginInterface {
/**
* The plugin definition for this instance.
*
* @var array
*/
protected $plugin;
/**
* The profile instance for this instance.
*
* @var LinkitProfile object
*/
protected $profile;
/**
* Initialize this search plugin with the search plugin and the profile.
*
* @param $plugin
* A search plugin object.
*
* @param LinkitProfile $profile
* A LinkitProfile object.
*/
public function __construct($plugin, LinkitProfile $profile) {
$this->plugin = $plugin;
$this->profile = $profile;
}
/**
* Implements LinkitSearchPluginInterface::factory().
*/
public static function factory($plugin, LinkitProfile $profile) {
ctools_include('plugins');
// Make sure that the handler class exists and that it has this class as one
// of its parents.
if (class_exists($plugin['handler']['class']) && is_subclass_of($plugin['handler']['class'], __CLASS__)) {
return new $plugin['handler']['class']($plugin, $profile);
}
else {
// The plugin handler class is defined but it cannot be found, so lets
// instantiate the LinkitSearchPluginBroken instead.
return new LinkitSearchPluginBroken($plugin, $profile);
}
}
/**
* Implements LinkitSearchPluginInterface::ui_title().
*/
public function ui_title() {
if (!isset($this->plugin['ui_title'])) {
return check_plain($this->plugin['module'] . ':' . $this->plugin['name']);
}
return check_plain($this->plugin['ui_title']);
}
/**
* Implements LinkitSearchPluginInterface::ui_description().
*/
public function ui_description() {
if (isset($this->plugin['ui_description'])) {
return check_plain($this->plugin['ui_description']);
}
}
/**
* Generate a settings form for this handler.
* Uses the standard Drupal FAPI.
*
* @return
* An array containing any custom form elements to be displayed in the
* profile editing form
*/
public function buildSettingsForm() {}
/**
* Determine if the handler is considered 'broken', meaning it's a
* a placeholder used when a handler can't be found.
*/
public function broken() { }
}
/**
* A special handler to take the place of missing or broken Linkit search
* plugin handlers.
*/
class LinkitSearchPluginBroken extends LinkitSearchPlugin {
/**
* Overrides LinkitSearchPlugin::ui_title().
*/
public function ui_title() { return t('Broken/missing handler'); }
/**
* Overrides LinkitSearchPlugin::ui_description().
*/
public function ui_description() {}
/**
* Implements LinkitSearchPluginInterface::fetchResults().
*/
public function fetchResults($search_string) {}
/**
* Overrides LinkitSearchPlugin::broken().
*/
public function broken() { return TRUE; }
}
@@ -0,0 +1,46 @@
<?php
/**
* @file
* Linkit theme functions.
*/
/**
* Theme callback for the search/attribute plugins in linkit_profiles_form.
*/
function theme_linkit_plugin_form_table($variables) {
$form = $variables['form'];
$has_description = FALSE;
$rows = array();
// Iterate over each element.
foreach (element_children($form) as $id) {
$form[$id]['weight']['#attributes']['class'] = array('weight');
$fields = array(
drupal_render($form[$id]['name']),
drupal_render($form[$id]['weight']),
drupal_render($form[$id]['enabled']),
);
if (isset($form[$id]['description'])) {
$has_description = TRUE;
$fields[] = drupal_render($form[$id]['description']);
}
$rows[$id]['data'] = $fields;
$rows[$id]['class'] = array('draggable');
}
drupal_add_tabledrag('linkit-search-plugins', 'order', 'sibling', 'weight');
$header = array(
t('Name'),
t('Weight'),
t('Enabled'),
);
if ($has_description) {
$header[] = t('Description');
}
return theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'linkit-search-plugins'), 'sticky' => FALSE));
}