Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentTorregrosa committed Apr 1, 2016
2 parents 1ade411 + c2493a5 commit 5538dd6
Show file tree
Hide file tree
Showing 35 changed files with 320 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ class ScaldAtomController extends DrupalDefaultEntityController {
field_update_instance($instance);
}

// Instantiate the Scald Authors field.
// Instantiate the Scald Authors field, if the vocabulary exists, and if
// the field exists for us to instantiate. Otherwise, assume that one or
// both were intentionally deleted and don't re-create.
$vocabulary_name = variable_get('scald_author_vocabulary', 'scald_authors');
$vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary_name);
$instance = array(
'field_name' => 'scald_authors',
'entity_type' => 'scald_atom',
Expand All @@ -126,11 +130,14 @@ class ScaldAtomController extends DrupalDefaultEntityController {
'type' => 'taxonomy_autocomplete',
),
);
if (!field_read_instance($instance['entity_type'], $instance['field_name'], $instance['bundle'])) {
if ($vocabulary && field_read_field($instance['field_name']) && !field_read_instance($instance['entity_type'], $instance['field_name'], $instance['bundle'])) {
field_create_instance($instance);
}

// Instantiate the Scald Tags field.
// Instantiate the Scald Tags field. As with Scald Authors above, only do
// this if the vocabulary and the field already exist.
$vocabulary_name = variable_get('scald_tags_vocabulary', 'scald_tags');
$vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary_name);
$instance = array(
'field_name' => 'scald_tags',
'entity_type' => 'scald_atom',
Expand All @@ -141,7 +148,7 @@ class ScaldAtomController extends DrupalDefaultEntityController {
'type' => 'taxonomy_autocomplete',
),
);
if (!field_read_instance($instance['entity_type'], $instance['field_name'], $instance['bundle'])) {
if ($vocabulary && field_read_field($instance['field_name']) && !field_read_instance($instance['entity_type'], $instance['field_name'], $instance['bundle'])) {
field_create_instance($instance);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function scald_admin_dashboard() {

// Display a context listing.
$content .= '<h3>' . t('Scald Contexts') . '</h3>';
$content .= '<p>' . t('List of all Scald Contexts, thoses created through the UI and even those hidden or defined by other modules.') . '</p>';
$content .= '<p>' . t('List of all Scald Contexts, those created through the UI and even those hidden or defined by other modules.') . '</p>';
$content .= '<ul class="action-links"><li>' . l(t('Add context'), 'admin/structure/scald/context/add') . '</li></ul>';

$list = array('type' => 'ul', 'items' => array());
Expand Down
7 changes: 7 additions & 0 deletions www7/sites/all/modules/contrib/scald/includes/scald.pages.inc
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,14 @@ function scald_atom_add_form_add_submit(&$form, &$form_state) {
else {
$function($atoms[0], $form, $form_state);
}

$context = array(
'form' => $form,
'form_state' => $form_state,
);
drupal_alter('scald_add_form_fill', $atoms, $context);
}

// And put it in the form_state.
$form_state['scald']['atoms'] = $atoms;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,39 @@
* Provides a field containing the actions allowed for the current user on an atom
*/
class scald_views_handler_field_actions extends views_handler_field {
function option_definition() {
$options = parent::option_definition();
$options['end_user_links'] = array('default' => TRUE);
return $options;
}

function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);

$form['end_user_links'] = array(
'#type' => 'checkbox',
'#title' => t('Display links for end users'),
'#description' => t('If this is checked, a list of action links targeted towards end users is shown. If this is unchecked, then the raw labels of the actions checked on the atom will be displayed instead.'),
'#default_value' => $this->options['end_user_links'],
);
}

/**
* Renders the atom according in the context specified in the option form.
*/
function render($values) {
$atom = scald_fetch($values->sid);
$links = scald_atom_user_build_actions_links($atom, drupal_get_destination());
if ($this->options['end_user_links']) {
$links = scald_atom_user_build_actions_links($atom, drupal_get_destination());
}
else {
$links = [];
foreach (scald_actions() as $action) {
if ($atom->actions & $action['bitmask']) {
$links[] = array('title' => $action['title']);
}
}
}
$content = array(
'#theme' => 'links',
'#links' => $links,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,41 @@
*/

class scald_views_handler_filter_actions extends views_handler_filter {
/**
* Overrides operator_form.
*
* Hardcode our bitwise AND, and tells Views that this filter doesn't
* expose an operator.
*/
public function operator_form(&$form, &$form_state) {
$this->no_operator = TRUE;
$form['operator'] = array(
'#type' => 'value',
'#value' => '&',
public function option_definition() {
$options = parent::option_definition();

$options['operator']['default'] = '&';
$options['value']['default'] = array();

return $options;
}

public function operators() {
$operators = array(
'&' => array(
'title' => t('Is all of'),
'short' => t('is'),
),
'in' => array(
'title' => t('Is one of'),
'short' => t('in'),
),
'not in' => array(
'title' => t('Is not one of'),
'short' => t('not in'),
),
);

return $operators;
}

function operator_options($which = 'title') {
$options = array();
foreach ($this->operators() as $id => $info) {
$options[$id] = $info[$which];
}

return $options;
}

/**
Expand Down Expand Up @@ -49,19 +72,35 @@ class scald_views_handler_filter_actions extends views_handler_filter {
* Change the operator before querying.
*/
public function query() {
if (is_array($this->options['value'])) {
$this->value = 0;
if (is_array($this->value)) {
$values = drupal_map_assoc($this->value);
$bitmask = 0;
$actions = scald_actions();
foreach ($actions as $name => $action) {
if (!empty($this->options['value'][$name])) {
$this->value |= $action['bitmask'];
if (!empty($values[$name])) {
$bitmask |= $action['bitmask'];
}
}
}
else {
$this->value = $this->options['value'];
$bitmask = $this->value;
}
$this->operator = ' & ' . $this->value . ' = ';

switch ($this->operator) {
case '&':
$this->operator = ' & ' . $bitmask . ' = ';
$this->value = $bitmask;
break;
case 'in':
$this->operator = ' & ' . $bitmask . ' >';
$this->value = 0;
break;
case 'not in':
$this->operator = ' & ' . $bitmask . ' = ';
$this->value = 0;
break;
}

parent::query();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ files[] = atom_reference.test
files[] = atom_reference.migrate.inc


; Information added by Drupal.org packaging script on 2015-10-19
version = "7.x-1.6"
; Information added by Drupal.org packaging script on 2016-03-30
version = "7.x-1.7"
core = "7.x"
project = "scald"
datestamp = "1445262856"
datestamp = "1459346951"

Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Drupal.behaviors.atom_reference = {
// Permission granted for edit

$edit_link_model.clone()
.attr('href', settings.basePath + 'atom/' + atom_id + '/edit/nojs')
.attr('href', settings.basePath + settings.pathPrefix + 'atom/' + atom_id + '/edit/nojs')
.appendTo($operation_buttons.find('li.edit'));
Drupal.behaviors.ZZCToolsModal.attach($operation_buttons);
$operation_buttons.addClass('ctools-dropbutton');
Expand All @@ -95,7 +95,7 @@ Drupal.behaviors.atom_reference = {
// Permission granted for view

$view_link_model.clone()
.attr('href', settings.basePath + 'atom/' + atom_id)
.attr('href', settings.basePath + settings.pathPrefix + 'atom/' + atom_id)
.appendTo($operation_buttons.find('li.view'));
$operation_buttons.addClass('ctools-dropbutton');
}
Expand Down Expand Up @@ -156,7 +156,7 @@ Drupal.behaviors.atom_reference = {
if ($.grep(Drupal.dnd.Atoms[resource_id].actions, function(e){ return e == 'edit'; }).length > 0) {
// Permission granted for edit

var atom_edit_link = Drupal.settings.basePath + 'atom/' + resource_id + '/edit/nojs';
var atom_edit_link = settings.basePath + settings.pathPrefix + 'atom/' + resource_id + '/edit/nojs';
$edit_link_model.clone()
.attr('href', atom_edit_link)
.appendTo($operation_buttons.find('li.edit'));
Expand All @@ -168,7 +168,7 @@ Drupal.behaviors.atom_reference = {
if ($.grep(Drupal.dnd.Atoms[resource_id].actions, function(e){ return e == 'view'; }).length > 0) {
// Permission granted for view

var atom_view_link = Drupal.settings.basePath + 'atom/' + resource_id;
var atom_view_link = settings.basePath + settings.pathPrefix + 'atom/' + resource_id;
$view_link_model.clone()
.attr('href', atom_view_link)
.appendTo($operation_buttons.find('li.view'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function atom_reference_field_instance_settings_form($field, $instance) {
function atom_reference_field_views_data($field) {
$data = field_views_field_default_views_data($field);
$current_table = _field_sql_storage_tablename($field);
$revision_table = _field_sql_storage_revision_tablename($field);
$column = _field_sql_storage_columnname($field['field_name'], 'sid');

// Relationship: add a relationship for related atom.
Expand All @@ -91,6 +92,15 @@ function atom_reference_field_views_data($field) {
'field_name' => $field['field_name'],
);

// Relationship: add a relationship for revisions.
$data[$revision_table][$column]['relationship'] = array(
'base' => 'scald_atoms',
'field' => $column,
'handler' => 'views_handler_relationship',
'label' => t('Atom reference item revision from !field_name', array('!field_name' => $field['field_name'])),
'field_name' => $field['field_name'],
);

return $data;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ core = 7.x

stylesheets[all][] = css/editor-global.css

; Information added by Drupal.org packaging script on 2015-10-19
version = "7.x-1.6"
; Information added by Drupal.org packaging script on 2016-03-30
version = "7.x-1.7"
core = "7.x"
project = "scald"
datestamp = "1445262856"
datestamp = "1459346951"

18 changes: 14 additions & 4 deletions www7/sites/all/modules/contrib/scald/modules/fields/mee/mee.module
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,25 @@ function mee_ckeditor_plugin() {
'name' => 'dnd',
'desc' => t('Scald Drag and Drop integration'),
'path' => drupal_get_path('module', 'mee') . '/plugins/ckeditor/',
'buttons' => array(),
'buttons' => array(
'ScaldAtom' => array(
'icon' => 'icons/atom.png',
'label' => t('Edit atom properties'),
),
),
);
}
elseif ($mee_store_format == 'embed_div' && version_compare(ckeditor_get_version(), '4.3.0') >= 0) {
$plugins['dndck4'] = array(
'name' => 'dndck4',
'desc' => t('Scald Drag and Drop integration - CKEditor 4 widgets'),
'path' => drupal_get_path('module', 'mee') . '/plugins/dndck4/',
'buttons' => array(),
'buttons' => array(
'ScaldAtom' => array(
'icon' => 'icons/atom.png',
'label' => t('Edit atom properties'),
),
),
);
}

Expand Down Expand Up @@ -921,7 +931,7 @@ function _mee_extract_widget_embed_info($dom) {

// Collect the DOM nodes and the corresponding embed data.
$xpath = new DOMXPath($dom);
$nodes = $xpath->query("//div[@class='dnd-atom-wrapper']");
$nodes = $xpath->query("//div[@class='dnd-atom-wrapper']|//figure[@class='dnd-atom-wrapper']|//span[@class='dnd-atom-wrapper']");
foreach ($nodes as $node) {
$info = array(
'node' => $node,
Expand All @@ -932,7 +942,7 @@ function _mee_extract_widget_embed_info($dom) {
'caption' => '',
);
// Extract the caption if present.
$result = $xpath->query("div[@class='dnd-caption-wrapper']", $node);
$result = $xpath->query("div[@class='dnd-caption-wrapper']|figcaption[@class='dnd-caption-wrapper']", $node);
if ($result->length) {
foreach ($result->item(0)->childNodes as $child) {
$info['caption'] .= $dom->saveXML($child);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ CKEDITOR.dialog.add('atomProperties', function(editor) {
Drupal.dnd.Atoms[atom.sid].meta.align = this.getValueOf('info', 'cmbAlign');
var context = this.getValueOf('info', 'cmbContext');
atom.options.link = this.getValueOf('info', 'txtLink');
atom.options.linkTarget = this.getValueOf('info', 'cmbLinkTarget');
Drupal.dnd.fetchAtom(context, atom.sid, function() {
var html = Drupal.theme('scaldEmbed', Drupal.dnd.Atoms[atom.sid], context, atom.options);
CKEDITOR.dom.element.createFromHtml(html).replace(Drupal.dnd.atomCurrent);
Expand Down Expand Up @@ -105,7 +106,7 @@ CKEDITOR.dialog.add('atomProperties', function(editor) {
{
id: 'txtLink',
type: 'text',
label: 'Link',
label: lang.properties_link,
setup: function(atom) {
if (Drupal.dnd.Atoms[atom.sid].meta.type === 'image') {
this.setValue(atom.options.link);
Expand All @@ -117,6 +118,23 @@ CKEDITOR.dialog.add('atomProperties', function(editor) {
this.getElement().hide();
}
}
},
{
id: 'cmbLinkTarget',
type: 'select',
label: lang.properties_link_target,
items: [[lang.link_target_none, '_self'], [lang.link_target_blank, '_blank'], [lang.link_target_parent, '_parent']],
setup: function (atom) {
if (Drupal.dnd.Atoms[atom.sid].meta.type === 'image') {
this.setValue(atom.options.linkTarget);
this.enable();
this.getElement().show();
}
else {
this.disable();
this.getElement().hide();
}
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ if (typeof CKEDITOR !== 'undefined' && typeof CKEDITOR.plugins !== 'undefined')
properties_legend: Drupal.t('Legend'),
properties_context: Drupal.t('Context'),
properties_alignment: Drupal.t('Alignment'),
properties_link: Drupal.t('Link'),
properties_link_target: Drupal.t('Link Target'),
alignment_none: Drupal.t('None'),
alignment_left: Drupal.t('Left'),
alignment_right: Drupal.t('Right'),
alignment_center: Drupal.t('Center'),
link_target_none: Drupal.t('None'),
link_target_blank: Drupal.t('Blank'),
link_target_parent: Drupal.t('Parent'),
link_image_only: Drupal.t('This option is currently available for Image Atoms only.')
});
}
Loading

0 comments on commit 5538dd6

Please sign in to comment.