FINAL suepr merge step : added all modules to this super repos
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implementation of hook_drush_command().
|
||||
*/
|
||||
function entity_translation_create_drush_command() {
|
||||
$items['create-translations'] = array(
|
||||
'description' => 'Create translations.',
|
||||
'arguments' => array(
|
||||
'bundle' => 'Bundle (like node type)',
|
||||
),
|
||||
'options' => array(
|
||||
'limit' => 'limit.',
|
||||
),
|
||||
'aliases' => array('etcc'),
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Command callback. Generate a number of users.
|
||||
*/
|
||||
function drush_entity_translation_create_create_translations( $bundle = false) {
|
||||
if (!$bundle) {
|
||||
return drush_set_error(t('Invalid bundle.'));
|
||||
}
|
||||
$entity = 'node';
|
||||
$limit = 100; //drush_get_option('limit') ? drush_get_option('limit') : 0;
|
||||
|
||||
drush_log(t('limit : @lim', array('@lim' => $limit)), 'notice');
|
||||
|
||||
drush_log(t('Bundle : @bun', array('@bun' => $bundle)), 'notice');
|
||||
|
||||
|
||||
$query = db_select('entity_translation', 'et');
|
||||
$query->join('node', 'n', 'n.nid = et.entity_id');
|
||||
|
||||
$query->fields('et');
|
||||
|
||||
$query->condition('et.entity_type',$entity);
|
||||
$query->condition('et.source','');
|
||||
$query->condition('et.language','und', '<>');
|
||||
if($bundle){
|
||||
$query->condition('n.type',$bundle);
|
||||
}
|
||||
|
||||
$entities = $query->execute();
|
||||
|
||||
$num_translations = 0;
|
||||
$i = 0;
|
||||
foreach ($entities as $row) {
|
||||
|
||||
$trans = db_select('entity_translation', 'et')
|
||||
->fields('et')
|
||||
->condition('et.entity_id',$row->entity_id)
|
||||
->condition('et.entity_type',$entity)
|
||||
->condition('et.source',$row->language)
|
||||
->execute();
|
||||
|
||||
$translations = 0;
|
||||
foreach ($trans as $t) {
|
||||
$translations++;
|
||||
}
|
||||
|
||||
drush_log(t('count translations : @trans', array('@trans' => $translations)), 'notice');
|
||||
|
||||
if(!$translations){
|
||||
$nid = db_insert('entity_translation') // Table name no longer needs {}
|
||||
->fields(array(
|
||||
'entity_id' => $row->entity_id,
|
||||
'entity_type' => $row->entity_type,
|
||||
'language' => $row->language == 'en' ? 'fr' : 'en',
|
||||
'source' => $row->language,
|
||||
'uid' => $row->uid,
|
||||
'status' => $row->status,
|
||||
'translate' => $row->translate,
|
||||
'created' => $row->created,
|
||||
'changed' => $row->changed,
|
||||
))
|
||||
->execute();
|
||||
|
||||
$num_translations ++;
|
||||
|
||||
}else{
|
||||
drush_log(t('Entity id : @id already have a translation', array('@id' => $row->entity_id)), 'notice');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
drush_log(t('Created @number translations', array('@number' => $num_translations)), 'success');
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
name = Entity Translation Create
|
||||
description = "Entity Translation Create"
|
||||
|
||||
; Core version (required)
|
||||
core = 7.x
|
||||
|
||||
; Package name (see http://drupal.org/node/542202 for a list of names)
|
||||
package = Materio
|
||||
|
||||
; PHP version requirement (optional)
|
||||
; php = 5.2
|
||||
|
||||
; Loadable code files
|
||||
;files[] = materio_didactique.theme.inc
|
||||
;files[] = materio_didactique.forms.inc
|
||||
;files[] = materio_didactique.pages.inc
|
||||
;files[] = materio_didactique.admin.inc
|
||||
files[] = entity_Translation_create.module
|
||||
|
||||
; Module dependencies
|
||||
;dependencies[] = taxonomy
|
||||
;dependencies[] = search_api
|
||||
dependencies[] = entity_translation
|
||||
|
||||
; Configuration page
|
||||
; configure = admin/config/materiobasemod
|
||||
|
||||
; For further information about configuration options, see
|
||||
; - http://drupal.org/node/542202
|
Reference in New Issue
Block a user