Projet

Général

Profil

Révision 7e72b748

Ajouté par Assos Assos il y a plus de 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/ctools/drush/ctools.drush.inc
140 140
  switch ($section) {
141 141
    case 'meta:ctools:title':
142 142
      return dt('CTools commands');
143

  
143 144
    case 'meta:entity:summary':
144 145
      return dt('CTools drush commands.');
145 146
  }
146 147
}
147 148

  
148 149
/**
149
 * Drush callback: export
150
 * Drush callback: export.
150 151
 */
151 152
function ctools_drush_export($module = 'foo') {
152 153
  $error = FALSE;
......
338 339
      $build[$table_choice]['count'] = count($multi_select);
339 340
      $selections[$table_choice] = array();
340 341
      foreach ($multi_select as $key) {
341
         $selections[$table_choice][$key] = $key;
342
        $selections[$table_choice][$key] = $key;
342 343
      }
343 344
    }
344 345
  }
......
445 446
    }
446 447
  }
447 448
}
449

  
448 450
/**
449 451
 * Drush callback: Acts as the hub for all op commands to keep
450 452
 * all arg handling etc in one place.
......
457 459
  switch ($command['command']) {
458 460
    case 'ctools-export-view':
459 461
      $op = 'view';
460
    break;
462
      break;
463

  
461 464
    case 'ctools-export-revert':
462 465
      // Revert is same as deleting. As any objects in the db are deleted.
463 466
      $op = 'delete';
464
    break;
467
      break;
468

  
465 469
    case 'ctools-export-enable':
466 470
      $op = 'enable';
467
    break;
471
      break;
472

  
468 473
    case 'ctools-export-disable':
469 474
      $op = 'disable';
470
    break;
475
      break;
471 476
  }
472 477

  
473 478
  if (!$op) {
......
475 480
  }
476 481

  
477 482
  if (drush_get_option('all', FALSE)) {
478
    $info = _ctools_drush_export_info('', TRUE);
483
    $info = _ctools_drush_export_info(array(), TRUE);
479 484
    $exportable_info = $info['exportables'];
480 485

  
481 486
    $all = drush_confirm(dt('Are you sure you would like to !op all exportables on the system?',
......
512 517
 * @param $op
513 518
 * @param $table_name
514 519
 * @param $exportables
515
 *
516 520
 */
517 521
function ctools_drush_export_op($op = '', $table_name = '', $exportables = NULL) {
518 522
  $objects = ctools_export_crud_load_multiple($table_name, array_keys($exportables));
......
538 542
 * @param $object_names
539 543
 *
540 544
 * @return
541
 *    Array of exportable objects (filtered if necessary, by name etc..) or FALSE if not.
545
 *   Array of exportable objects (filtered if necessary, by name etc..) or FALSE if not.
542 546
 */
543 547
function _ctools_drush_export_op_command_logic($op = '', $table_name = NULL, array $object_names = array()) {
544 548
  if (!$table_name) {
......
644 648
  return array('exportables' => $exportables, 'schemas' => $schemas);
645 649
}
646 650

  
647
/*
651
/**
648 652
 * View a single object.
649 653
 *
650 654
 * @param $table_name
......
662 666
  }
663 667
}
664 668

  
665
/*
669
/**
666 670
 * Revert a single object.
667 671
 *
668 672
 * @param $table_name
......
681 685
  }
682 686
}
683 687

  
684
/*
688
/**
685 689
 * Enable a single object.
686 690
 *
687 691
 * @param $table_name
......
701 705
  }
702 706
}
703 707

  
704
/*
708
/**
705 709
 * Disable a single object.
706 710
 *
707 711
 * @param $table_name
......
723 727
/**
724 728
 * Filter a nested array of exportables by export module.
725 729
 *
726
 * @param $exportables array
730
 * @param array $exportables
727 731
 *   Passed by reference. A nested array of exportables, keyed by table name.
728
 * @param $export_module string
732
 * @param string $export_module
729 733
 *   The name of the export module providing the exportable.
730 734
 */
731 735
function _ctools_drush_export_module_filter($exportables, $export_module) {
......
778 782
/**
779 783
 * Determine if an object is enabled.
780 784
 *
781
 * @see _ctools_drush_object_is_disabled.
785
 * @see _ctools_drush_object_is_disabled()
782 786
 */
783 787
function _ctools_drush_object_is_enabled($object) {
784 788
  return (empty($object->disabled)) ? TRUE : FALSE;
......
835 839
 *   Array of exportables to count.
836 840
 *
837 841
 * @return
838
 *    Array of count data containing the following:
842
 *   Array of count data containing the following:
839 843
 *     'total' - A total count of all exportables.
840 844
 *     'exportables' - An array of exportable counts per table.
841 845
 */
......
867 871
      // Show enabled exportables only.
868 872
      case 'enabled':
869 873
        $eval = '_ctools_drush_object_is_disabled';
870
      break;
874
        break;
875

  
871 876
      // Show disabled exportables only.
872 877
      case 'disabled':
873 878
        $eval = '_ctools_drush_object_is_enabled';
874
      break;
879
        break;
880

  
875 881
      // Show overridden exportables only.
876 882
      case 'overridden':
877 883
        $eval = '_ctools_drush_object_is_not_overridden';
878
      break;
884
        break;
885

  
879 886
      // Show database only exportables.
880 887
      case 'database':
881 888
        $eval = '_ctools_drush_object_is_not_db_only';
882
      break;
889
        break;
890

  
883 891
      // Show code only exportables.
884 892
      case 'code':
885 893
        $eval = '_ctools_drush_object_is_not_code_only';
886
      break;
894
        break;
895

  
887 896
      // Do nothing.
888 897
      case 'all':
889 898
        break;
899

  
890 900
      default:
891 901
        drush_log(dt('Invalid filter option. Available options are: enabled, disabled, overridden, database, and code.'), 'error');
892 902
        return;
......
983 993
    'light_gray' => '47',
984 994
  );
985 995

  
996
  /**
997
   *
998
   */
986 999
  private function __construct() {}
987 1000

  
988
  // Returns coloured string
1001
  /**
1002
   * Returns coloured string.
1003
   */
989 1004
  public static function getColouredOutput($string, $foreground_colour = NULL, $background_colour = NULL) {
990 1005
    $coloured_string = "";
991 1006

  
992
    // Check if given foreground colour found
1007
    // Check if given foreground colour found.
993 1008
    if ($foreground_colour) {
994 1009
      $coloured_string .= "\033[" . self::$foreground_colours[$foreground_colour] . "m";
995 1010
    }
996
    // Check if given background colour found
1011
    // Check if given background colour found.
997 1012
    if ($background_colour) {
998 1013
      $coloured_string .= "\033[" . self::$background_colours[$background_colour] . "m";
999 1014
    }
1000 1015

  
1001
    // Add string and end colouring
1002
    $coloured_string .=  $string . "\033[0m";
1016
    // Add string and end colouring.
1017
    $coloured_string .= $string . "\033[0m";
1003 1018

  
1004 1019
    return $coloured_string;
1005 1020
  }
1006 1021

  
1007
  // Returns all foreground colour names
1022
  /**
1023
   * Returns all foreground colour names.
1024
   */
1008 1025
  public static function getForegroundColours() {
1009 1026
    return array_keys(self::$foreground_colours);
1010 1027
  }
1011 1028

  
1012
  // Returns all background colour names
1029
  /**
1030
   * Returns all background colour names.
1031
   */
1013 1032
  public static function getBackgroundColours() {
1014 1033
    return array_keys(self::$background_colours);
1015 1034
  }

Formats disponibles : Unified diff