Now all modules are in core modules folder

This commit is contained in:
Manuel Cillero 2017-08-08 12:14:45 +02:00
parent 5ba1cdfa0b
commit 05b6a91b0c
1907 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,77 @@
<?php
/**
* @file
* Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr>
* http://www.absyx.fr
*/
/**
* Implementation of hook_ckeditor_link_TYPE_autocomplete().
*/
function ckeditor_link_ckeditor_link_i18nmenu_autocomplete($string, $limit) {
// Currently, this function only supports MySQL.
// TODO: Add support for pgsql.
if (!in_array($GLOBALS['db_type'], array('mysql', 'mysqli'))) {
return array();
}
$matches = array();
$menus = array_keys(array_filter(variable_get('ckeditor_link_autocomplete_menus', array())));
if (count($menus)) {
$sql = "SELECT ml.link_path, CONVERT(lt.translation USING utf8) link_title, lt.language FROM {menu_links} ml
INNER JOIN {locales_source} ls ON ls.location = CONCAT('item:', ml.mlid, ':title')
INNER JOIN {locales_target} lt ON lt.lid = ls.lid
WHERE CONVERT(lt.translation USING utf8) LIKE '%%%s%%' AND ml.hidden = 0 AND ml.external = 0";
$args = array($string);
if (!in_array('- any -', $menus)) {
$sql .= ' AND ml.menu_name IN ('. db_placeholders($menus, 'text') .')';
$args = array_merge($args, $menus);
}
$sql .= ' ORDER BY link_title';
$result = db_query_range($sql, $args, 0, $limit);
while ($item = db_fetch_object($result)) {
if (_ckeditor_link_check_path($item->link_path)) {
$router_item = menu_get_item($item->link_path);
if ($router_item && $router_item['access']) {
$path = ckeditor_link_path_prefix_language($item->link_path, $item->language);
$matches[$path] = $item->link_title;
}
}
}
}
return $matches;
}
/**
* Implementation of hook_ckeditor_link_TYPE_revert().
*/
function ckeditor_link_ckeditor_link_i18nmenu_revert($path, &$langcode) {
$router_item = menu_get_item($path);
if ($router_item) {
if (!$router_item['access']) {
return FALSE;
}
$result = db_query("SELECT mlid, link_title, options FROM {menu_links} WHERE link_path = '%s' AND hidden = 0 ORDER BY customized DESC", $path);
$default_langcode = language_default('language');
$link_title = NULL;
while ($item = db_fetch_object($result)) {
$options = unserialize($item->options);
$item_langcode = (isset($options['langcode'])) ? $options['langcode'] : '';
if ($item_langcode == $langcode) {
$link_title = $item->link_title;
break;
}
elseif (($item_langcode == $default_langcode) && empty($langcode)) {
$langcode = $default_langcode;
$link_title = $item->link_title;
break;
}
elseif (!$link_title && empty($item_langcode)) {
$link_title = i18nstrings('menu:item:'. $item->mlid .':title', $item->link_title, $langcode);
}
}
return ($link_title) ? $link_title : NULL;
}
}

View file

@ -0,0 +1,63 @@
<?php
/**
* @file
* Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr>
* http://www.absyx.fr
*/
/**
* Implementation of hook_ckeditor_link_TYPE_autocomplete().
*/
function ckeditor_link_ckeditor_link_i18ntaxonomy_autocomplete($string, $limit) {
// Currently, this function only supports MySQL.
// TODO: Add support for pgsql.
if (!in_array($GLOBALS['db_type'], array('mysql', 'mysqli'))) {
return array();
}
$matches = array();
$vocabularies = array_keys(array_filter(variable_get('ckeditor_link_autocomplete_vocabularies', array())));
if (count($vocabularies)) {
$sql = "SELECT t.tid, CONVERT(lt.translation USING utf8) name, lt.language FROM {term_data} t
INNER JOIN {locales_source} ls ON ls.location = CONCAT('term:', t.tid, ':name')
INNER JOIN {locales_target} lt ON lt.lid = ls.lid
WHERE CONVERT(lt.translation USING utf8) LIKE '%%%s%%'";
$args = array($string);
if (!in_array('- any -', $vocabularies)) {
$sql .= ' AND t.vid IN ('. db_placeholders($vocabularies) .')';
$args = array_merge($args, $vocabularies);
}
$sql .= ' ORDER BY name';
$result = db_query_range(db_rewrite_sql($sql, 't', 'tid'), $args, 0, $limit);
while ($term = db_fetch_object($result)) {
$path = ckeditor_link_path_prefix_language('taxonomy/term/'. $term->tid, $term->language);
$matches[$path] = $term->name;
}
}
return $matches;
}
/**
* Implementation of hook_ckeditor_link_TYPE_revert().
*/
function ckeditor_link_ckeditor_link_i18ntaxonomy_revert($path, &$langcode) {
if (!preg_match('`^taxonomy/term/(\d+)$`', $path, $matches)) {
return;
}
$tid = $matches[1];
$result = db_query(db_rewrite_sql('SELECT t.tid, t.vid, t.name, t.language FROM {term_data} t WHERE t.tid = %d', 't', 'tid'), $tid);
if ($term = db_fetch_object($result)) {
if (empty($term->language)) {
return html_entity_decode(i18ntaxonomy_translate_term_name($term, '', $langcode), ENT_QUOTES);
}
else {
$langcode = '';
return $term->name;
}
}
return FALSE;
}

View file

@ -0,0 +1,80 @@
<?php
/**
* @file
* Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr>
* http://www.absyx.fr
*/
/**
* Implementation of hook_ckeditor_link_TYPE_autocomplete().
*/
function ckeditor_link_ckeditor_link_menu_autocomplete($string, $limit) {
$matches = array();
$menus = array_keys(array_filter(variable_get('ckeditor_link_autocomplete_menus', array())));
if (count($menus)) {
$sql = "SELECT link_path, link_title, options FROM {menu_links}
WHERE link_title LIKE '%%%s%%' AND hidden = 0 AND external = 0";
$args = array($string);
if (!in_array('- any -', $menus)) {
$sql .= ' AND menu_name IN ('. db_placeholders($menus, 'text') .')';
$args = array_merge($args, $menus);
}
$sql .= ' ORDER BY link_title';
$result = db_query_range($sql, $args, 0, $limit);
while ($item = db_fetch_object($result)) {
if (_ckeditor_link_check_path($item->link_path)) {
$router_item = menu_get_item($item->link_path);
if ($router_item && $router_item['access']) {
$options = unserialize($item->options);
$langcode = (isset($options['langcode'])) ? $options['langcode'] : '';
$path = ckeditor_link_path_prefix_language($item->link_path, $langcode);
$matches[$path] = $item->link_title;
}
}
}
}
return $matches;
}
/**
* Implementation of hook_ckeditor_link_TYPE_revert().
*/
function ckeditor_link_ckeditor_link_menu_revert($path, &$langcode) {
if (function_exists('ckeditor_link_ckeditor_link_i18nmenu_revert')) {
return;
}
$router_item = menu_get_item($path);
if ($router_item) {
if (!$router_item['access']) {
return FALSE;
}
$link_title = db_result(db_query("SELECT link_title FROM {menu_links} WHERE link_path = '%s' AND hidden = 0 ORDER BY customized DESC", $path));
return ($link_title) ? $link_title : NULL;
}
}
/**
* Implementation of hook_ckeditor_link_TYPE_settings().
*/
function ckeditor_link_ckeditor_link_menu_settings() {
$form = array();
if (module_exists('menu')) {
$form['menu'] = array(
'#type' => 'fieldset',
'#title' => t('Menu items'),
);
$form['menu']['ckeditor_link_autocomplete_menus'] = array(
'#type' => 'checkboxes',
'#title' => t('Menus'),
'#options' => array('- any -' => t('<em>Any menu</em>')) + array_map('check_plain', menu_get_menus()),
'#default_value' => variable_get('ckeditor_link_autocomplete_menus', array()),
'#description' => t('Select the menus to be available as autocomplete suggestions.'),
);
}
return $form;
}

View file

@ -0,0 +1,87 @@
<?php
/**
* @file
* Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr>
* http://www.absyx.fr
*/
/**
* Implementation of hook_ckeditor_link_TYPE_autocomplete().
*/
function ckeditor_link_ckeditor_link_node_autocomplete($string, $limit) {
$matches = array();
$node_types = array_keys(array_filter(variable_get('ckeditor_link_autocomplete_node_types', array('- any -' => '- any -'))));
if (count($node_types)) {
$sql = "SELECT n.nid, n.title FROM {node} n WHERE n.title LIKE '%%%s%%'";
$args = array($string);
if (!in_array('- any -', $node_types)) {
$sql .= ' AND n.type IN('. db_placeholders($node_types, 'text') .')';
$args = array_merge($args, $node_types);
}
$sql .= ' ORDER BY n.title, n.type';
$result = db_query_range(db_rewrite_sql($sql), $args, 0, $limit);
while ($node = db_fetch_object($result)) {
$matches['node/'. $node->nid] = $node->title;
}
}
return $matches;
}
/**
* Implementation of hook_ckeditor_link_TYPE_revert().
*/
function ckeditor_link_ckeditor_link_node_revert($path, &$langcode) {
if (!preg_match('`^node/(\d+)$`', $path, $matches)) {
return;
}
$nid = $matches[1];
$result = db_query(db_rewrite_sql('SELECT n.title, n.language FROM {node} n WHERE n.nid = %d'), $nid);
if ($node = db_fetch_object($result)) {
if (!empty($node->language)) {
$langcode = '';
}
return $node->title;
}
return FALSE;
}
/**
* Implementation of hook_ckeditor_link_TYPE_url().
*/
function ckeditor_link_ckeditor_link_node_url($path, $langcode) {
if (!preg_match('`^node/(\d+)$`', $path, $matches)) {
return;
}
$nid = $matches[1];
$languages = ckeditor_link_get_languages();
if ($languages && ($language = db_result(db_query('SELECT language FROM {node} WHERE nid = %d', $nid))) && isset($languages[$language])) {
$langcode = $language;
}
return ckeditor_link_url("node/$nid", $langcode);
}
/**
* Implementation of hook_ckeditor_link_TYPE_settings().
*/
function ckeditor_link_ckeditor_link_node_settings() {
$form['node'] = array(
'#type' => 'fieldset',
'#title' => t('Nodes'),
);
$form['node']['ckeditor_link_autocomplete_node_types'] = array(
'#type' => 'checkboxes',
'#title' => t('Content types'),
'#options' => array('- any -' => t('<em>Any content type</em>')) + array_map('check_plain', node_get_types('names')),
'#default_value' => variable_get('ckeditor_link_autocomplete_node_types', array('- any -' => '- any -')),
'#description' => t('Select the content types to be available as autocomplete suggestions.'),
);
return $form;
}

View file

@ -0,0 +1,90 @@
<?php
/**
* @file
* Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr>
* http://www.absyx.fr
*/
/**
* Implementation of hook_ckeditor_link_TYPE_autocomplete().
*/
function ckeditor_link_ckeditor_link_taxonomy_autocomplete($string, $limit) {
$matches = array();
$vocabularies = array_keys(array_filter(variable_get('ckeditor_link_autocomplete_vocabularies', array())));
if (count($vocabularies)) {
$sql = "SELECT t.tid, t.name FROM {term_data} t WHERE t.name LIKE '%%%s%%'";
$args = array($string);
if (!in_array('- any -', $vocabularies)) {
$sql .= ' AND t.vid IN ('. db_placeholders($vocabularies) .')';
$args = array_merge($args, $vocabularies);
}
$sql .= ' ORDER BY t.name';
$result = db_query_range(db_rewrite_sql($sql, 't', 'tid'), $args, 0, $limit);
while ($term = db_fetch_object($result)) {
$matches['taxonomy/term/'. $term->tid] = $term->name;
}
}
return $matches;
}
/**
* Implementation of hook_ckeditor_link_TYPE_revert().
*/
function ckeditor_link_ckeditor_link_taxonomy_revert($path, &$langcode) {
if (function_exists('ckeditor_link_ckeditor_link_i18ntaxonomy_revert')
|| !preg_match('`^taxonomy/term/(\d+)$`', $path, $matches)) {
return;
}
$tid = $matches[1];
$name = db_result(db_query(db_rewrite_sql('SELECT t.name FROM {term_data} t WHERE t.tid = %d', 't', 'tid'), $tid));
return ($name) ? $name : FALSE;
}
/**
* Implementation of hook_ckeditor_link_TYPE_url().
*/
function ckeditor_link_ckeditor_link_taxonomy_url($path, $langcode) {
if (!preg_match('`^taxonomy/term/(\d+)$`', $path, $matches)) {
return;
}
$tid = $matches[1];
$languages = ckeditor_link_get_languages();
if ($languages) {
$term = taxonomy_get_term($tid);
if ($term && ($language = @$term->language) && isset($languages[$language])) {
$langcode = $language;
}
}
return ckeditor_link_url("taxonomy/term/$tid", $langcode);
}
/**
* Implementation of hook_ckeditor_link_TYPE_settings().
*/
function ckeditor_link_ckeditor_link_taxonomy_settings() {
$form['taxonomy'] = array(
'#type' => 'fieldset',
'#title' => t('Taxonomy terms'),
);
$vocabularies = taxonomy_get_vocabularies();
$options = array('- any -' => t('<em>Any vocabulary</em>'));
foreach ($vocabularies as $vid => $vocabulary) {
$options[$vid] = check_plain($vocabulary->name);
}
$form['taxonomy']['ckeditor_link_autocomplete_vocabularies'] = array(
'#type' => 'checkboxes',
'#title' => t('Vocabularies'),
'#options' => $options,
'#default_value' => variable_get('ckeditor_link_autocomplete_vocabularies', array()),
'#description' => t('Select the vocabularies to be available as autocomplete suggestions.'),
);
return $form;
}