From 4a94da62427ff337fbe8b801fa594e7317a812cb Mon Sep 17 00:00:00 2001 From: Code Review Date: Sun, 11 Oct 2015 18:00:14 -0400 Subject: [PATCH] Fixing issue(s): 1:1 Missing file doc comment 423:1 Expected 1 newline at end of file; 2 found 2:1 Whitespace found at end of line 4:4 Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for xyz_bar().",, "* Implements hook_foo_BAR_ID_bar() for xyz-bar.html.twig.", or "* Implements hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.". 23:76 Whitespace found at end of line 31:117 Whitespace found at end of line 32:91 Whitespace found at end of line 35:78 Whitespace found at end of line 62:86 Whitespace found at end of line 71:94 Whitespace found at end of line 73:91 Whitespace found at end of line 87:33 Whitespace found at end of line 116:4 Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for xyz_bar().",, "* Implements hook_foo_BAR_ID_bar() for xyz-bar.html.twig.", or "* Implements hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.". 121:7 Case breaking statements must be followed by a single blank line 123:7 Case breaking statements must be followed by a single blank line 125:7 Case breaking statements must be followed by a single blank line 137:3 Expected 1 space after SWITCH keyword; 0 found 137:15 Expected 1 space after closing parenthesis; found "" 142:7 Case breaking statements must be followed by a single blank line 147:7 Case breaking statements must be followed by a single blank line 151:7 Case breaking statements must be followed by a single blank line 155:7 Case breaking statements must be followed by a single blank line 160:7 Case breaking statements must be followed by a single blank line 160:13 Whitespace found at end of line 164:7 Case breaking statements must be followed by a single blank line 168:7 Case breaking statements must be followed by a single blank line 172:7 Case breaking statements must be followed by a single blank line 177:7 Case breaking statements must be followed by a single blank line 181:7 Case breaking statements must be followed by a single blank line 186:7 Case breaking statements must be followed by a single blank line 191:7 Case breaking statements must be followed by a single blank line 195:7 Case breaking statements must be followed by a single blank line 199:7 Case breaking statements must be followed by a single blank line 203:7 Case breaking statements must be followed by a single blank line 207:7 Case breaking statements must be followed by a single blank line 140:7 "include_once" is a statement not a function; no parentheses are required 140:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 140:63 Concat operator must be surrounded by a single space 145:7 "include_once" is a statement not a function; no parentheses are required 145:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 145:63 Concat operator must be surrounded by a single space 149:7 "include_once" is a statement not a function; no parentheses are required 149:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 149:63 Concat operator must be surrounded by a single space 153:7 "include_once" is a statement not a function; no parentheses are required 153:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 153:63 Concat operator must be surrounded by a single space 157:7 "include_once" is a statement not a function; no parentheses are required 157:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 157:63 Concat operator must be surrounded by a single space 158:7 "include_once" is a statement not a function; no parentheses are required 158:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 158:54 Concat operator must be surrounded by a single space 162:7 "include_once" is a statement not a function; no parentheses are required 162:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 162:63 Concat operator must be surrounded by a single space 166:7 "include_once" is a statement not a function; no parentheses are required 166:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 166:63 Concat operator must be surrounded by a single space 170:7 "include_once" is a statement not a function; no parentheses are required 170:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 170:63 Concat operator must be surrounded by a single space 174:7 "include_once" is a statement not a function; no parentheses are required 174:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 174:54 Concat operator must be surrounded by a single space 175:7 "include_once" is a statement not a function; no parentheses are required 175:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 175:63 Concat operator must be surrounded by a single space 179:7 "include_once" is a statement not a function; no parentheses are required 179:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 179:63 Concat operator must be surrounded by a single space 183:7 "include_once" is a statement not a function; no parentheses are required 183:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 183:54 Concat operator must be surrounded by a single space 184:7 "include_once" is a statement not a function; no parentheses are required 184:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 184:63 Concat operator must be surrounded by a single space 188:7 "include_once" is a statement not a function; no parentheses are required 188:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 189:7 "include_once" is a statement not a function; no parentheses are required 189:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 189:63 Concat operator must be surrounded by a single space 193:7 "include_once" is a statement not a function; no parentheses are required 193:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 193:63 Concat operator must be surrounded by a single space 197:7 "include_once" is a statement not a function; no parentheses are required 197:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 197:63 Concat operator must be surrounded by a single space 201:7 "include_once" is a statement not a function; no parentheses are required 201:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 201:63 Concat operator must be surrounded by a single space 205:7 "include_once" is a statement not a function; no parentheses are required 205:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 205:63 Concat operator must be surrounded by a single space 209:7 Expected 1 space after IF keyword; 0 found 210:53 Concat operator must be surrounded by a single space 210:65 Concat operator must be surrounded by a single space 211:9 "include_once" is a statement not a function; no parentheses are required 211:9 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 213:9 Expected 1 space after IF keyword; 0 found 213:39 Expected 1 space after closing parenthesis; found "" 215:1 Whitespace found at end of line 217:11 Expected 1 space after IF keyword; 0 found 217:50 Expected 1 space after closing parenthesis; found "" 222:12 Expected 1 space after ELSE keyword; 0 found 222:11 Expected newline after closing brace 238:3 Expected 1 space after SWITCH keyword; 0 found 238:15 Expected 1 space after closing parenthesis; found "" 243:7 Case breaking statements must be followed by a single blank line 248:7 Case breaking statements must be followed by a single blank line 248:13 Whitespace found at end of line 252:7 Case breaking statements must be followed by a single blank line 252:13 Whitespace found at end of line 256:7 Case breaking statements must be followed by a single blank line 261:7 Case breaking statements must be followed by a single blank line 265:7 Case breaking statements must be followed by a single blank line 269:7 Case breaking statements must be followed by a single blank line 273:7 Case breaking statements must be followed by a single blank line 273:13 Whitespace found at end of line 277:7 Case breaking statements must be followed by a single blank line 281:7 Case breaking statements must be followed by a single blank line 285:7 Case breaking statements must be followed by a single blank line 290:7 Case breaking statements must be followed by a single blank line 294:7 Case breaking statements must be followed by a single blank line 298:7 Case breaking statements must be followed by a single blank line 302:7 Case breaking statements must be followed by a single blank line 302:13 Whitespace found at end of line 306:7 Case breaking statements must be followed by a single blank line 241:7 "include_once" is a statement not a function; no parentheses are required 241:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 241:63 Concat operator must be surrounded by a single space 246:7 "include_once" is a statement not a function; no parentheses are required 246:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 246:63 Concat operator must be surrounded by a single space 250:7 "include_once" is a statement not a function; no parentheses are required 250:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 250:63 Concat operator must be surrounded by a single space 254:7 "include_once" is a statement not a function; no parentheses are required 254:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 254:63 Concat operator must be surrounded by a single space 258:7 "include_once" is a statement not a function; no parentheses are required 258:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 258:63 Concat operator must be surrounded by a single space 259:7 "include_once" is a statement not a function; no parentheses are required 259:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 259:54 Concat operator must be surrounded by a single space 263:7 "include_once" is a statement not a function; no parentheses are required 263:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 263:63 Concat operator must be surrounded by a single space 267:7 "include_once" is a statement not a function; no parentheses are required 267:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 267:63 Concat operator must be surrounded by a single space 271:7 "include_once" is a statement not a function; no parentheses are required 271:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 271:63 Concat operator must be surrounded by a single space 275:7 "include_once" is a statement not a function; no parentheses are required 275:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 275:63 Concat operator must be surrounded by a single space 279:7 "include_once" is a statement not a function; no parentheses are required 279:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 279:63 Concat operator must be surrounded by a single space 283:7 "include_once" is a statement not a function; no parentheses are required 283:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 283:63 Concat operator must be surrounded by a single space 287:7 "include_once" is a statement not a function; no parentheses are required 287:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 287:43 Whitespace found at end of line 288:7 "include_once" is a statement not a function; no parentheses are required 288:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 288:63 Concat operator must be surrounded by a single space 292:7 "include_once" is a statement not a function; no parentheses are required 292:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 292:63 Concat operator must be surrounded by a single space 296:7 "include_once" is a statement not a function; no parentheses are required 296:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 296:63 Concat operator must be surrounded by a single space 300:7 "include_once" is a statement not a function; no parentheses are required 300:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 300:63 Concat operator must be surrounded by a single space 304:7 "include_once" is a statement not a function; no parentheses are required 304:7 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 304:63 Concat operator must be surrounded by a single space 308:7 Expected 1 space after IF keyword; 0 found 309:53 Concat operator must be surrounded by a single space 309:65 Concat operator must be surrounded by a single space 310:9 "include_once" is a statement not a function; no parentheses are required 310:9 Language constructs must be followed by a single space; expected "include_once (" but found "include_once(" 312:9 Expected 1 space after IF keyword; 0 found 312:39 Expected 1 space after closing parenthesis; found "" 313:11 Expected 1 space after IF keyword; 0 found 313:30 Expected 1 space after closing parenthesis; found "" 316:11 Expected 1 space after IF keyword; 0 found 316:33 Expected 1 space after closing parenthesis; found "" 321:11 Expected 1 space after IF keyword; 0 found 321:47 Expected 1 space after closing parenthesis; found "" 325:11 Expected 1 space after IF keyword; 0 found 325:59 Expected 1 space after closing parenthesis; found "" 353:36 Expected 1 space after closing parenthesis; found 0 356:3 Expected 1 space after IF keyword; 0 found 356:20 Expected 1 space after closing parenthesis; found "" 358:5 Expected 1 space after IF keyword; 0 found 358:31 Expected 1 space after closing parenthesis; found "" 361:1 Whitespace found at end of line 364:1 Whitespace found at end of line 365:5 Expected 1 space after FOREACH keyword; 0 found 365:28 Expected 1 space after closing parenthesis; found "" 366:7 Expected 1 space after IF keyword; 0 found 366:34 Expected 1 space after closing parenthesis; found "" 367:1 Whitespace found at end of line 368:9 Expected 1 space after IF keyword; 0 found 368:98 Expected 1 space after closing parenthesis; found "" 368:71 Expected one space after the comma, 0 found 370:10 Expected 1 space after ELSE keyword; 0 found 370:9 Expected newline after closing brace 373:1 Whitespace found at end of line 375:9 Expected 1 space after IF keyword; 0 found 375:37 Expected 1 space after closing parenthesis; found "" 376:47 Whitespace found at end of line 378:1 Whitespace found at end of line 382:82 Expected one space after the comma, 0 found 383:8 Expected 1 space after ELSE keyword; 0 found 383:7 Expected newline after closing brace 394:44 Expected 1 space after closing parenthesis; found 0 397:3 Expected 1 space after IF keyword; 0 found 397:19 Expected 1 space after closing parenthesis; found "" 398:82 Expected one space after the comma, 0 found 402:3 Expected 1 space after FOREACH keyword; 0 found 402:26 Expected 1 space after closing parenthesis; found "" 404:5 Expected 1 space after IF keyword; 0 found 404:111 Expected 1 space after closing parenthesis; found "" 408:6 Expected 1 space after ELSE keyword; 0 found 408:5 Expected newline after closing brace 410:7 Expected 1 space after IF keyword; 0 found 410:35 Expected 1 space after closing parenthesis; found "" 412:45 Whitespace found at end of line 414:70 Concat operator must be surrounded by a single space 415:23 Concat operator must be surrounded by a single space 416:1 Whitespace found at end of line 419:1 Whitespace found at end of line --- drupal_deploy.drush.inc | 238 +++++++++++++++++++++++----------------- 1 file changed, 140 insertions(+), 98 deletions(-) diff --git a/drupal_deploy.drush.inc b/drupal_deploy.drush.inc index a46f87c..96f7eca 100644 --- a/drupal_deploy.drush.inc +++ b/drupal_deploy.drush.inc @@ -1,5 +1,9 @@ dt('Export cck fields.'), 'drush dde users' => dt('Export users.'), 'drush dde users --uid=1,2,3' => dt('Export users with uid=1,2,3.'), - 'drush dde users --rid=1,2,3' => dt('Export users roles rid=1,2,3.'), + 'drush dde users --rid=1,2,3' => dt('Export users roles rid=1,2,3.'), 'drush dde imagecache' => dt('Export imagecache presets.'), 'drush dde nodes --nid=1,2,3' => dt('Export nodes 1,2,3 with comments and revisions.'), 'drush dde nodes --type=forum' => dt('Export forum nodes with comments and revisions.'), @@ -28,11 +32,11 @@ function drupal_deploy_drush_command() { 'drush dde language --name=ru --group=default' => dt('Export RU language translation.'), 'drush dde comment_notify' => dt('Export comment_notify settings.'), 'drush dde variables --name=superfish_%' => dt('Export superfish variables settings.'), - 'drush dde variables --name=comment_notify_%,node_notify_%' => dt('Export comment_notify variable settings.'), - 'drush dde variables --name=pathauto_%' => dt('Export pathauto variable settings.'), + 'drush dde variables --name=comment_notify_%,node_notify_%' => dt('Export comment_notify variable settings.'), + 'drush dde variables --name=pathauto_%' => dt('Export pathauto variable settings.'), 'drush dde aggregator' => dt('Export aggregator feed only.'), 'drush dde rules' => dt('Export all rules.'), - 'drush dde book --nid=10' => dt('Export book with root node 10 menu.'), + 'drush dde book --nid=10' => dt('Export book with root node 10 menu.'), ), 'aliases' => array('dde'), 'arguments' => array( @@ -59,7 +63,7 @@ function drupal_deploy_drush_command() { 'drush ddi filters' => dt('Import filters.'), 'drush ddi roles' => dt('Import roles.'), 'drush ddi node_types --type=blog' => dt('Import node type blog.'), - 'drush ddi taxonomy --name=Forums' => dt('Import taxonomy vocabulary Forums.'), + 'drush ddi taxonomy --name=Forums' => dt('Import taxonomy vocabulary Forums.'), 'drush ddi forum' => dt('Import forum container links to taxonomy tid.'), 'drush ddi cck' => dt('Import cck fields.'), 'drush ddi users' => dt('Import users.'), @@ -68,9 +72,9 @@ function drupal_deploy_drush_command() { 'drush ddi language --name=ru --mode=replace' => dt('Import RU language translation. Replace existing ones, new ones are added.'), 'drush ddi language --name=ru --set-default=true' => dt('Import RU language translation. Replace existing ones, new ones are added.'), 'drush ddi comment_notify' => dt('Export comment_notify settings.'), - 'drush ddi variables --name=superfish_%' => dt('Import superfish variables settings.'), + 'drush ddi variables --name=superfish_%' => dt('Import superfish variables settings.'), 'drush ddi variables --name=comment_notify_%,node_notify_%' => dt('Import comment_notify variable settings.'), - 'drush ddi variables --name=pathauto_%' => dt('Import pathauto variable settings.'), + 'drush ddi variables --name=pathauto_%' => dt('Import pathauto variable settings.'), 'drush ddi aggregator' => dt('Import aggregator feed only.'), 'drush ddi rules' => dt('Import rules from file.'), 'drush ddi book' => dt('Import book.'), @@ -84,7 +88,7 @@ function drupal_deploy_drush_command() { 'name' => 'Variable, Language, Menu or Vocabulary name', 'theme' => 'Theme name', 'type' => 'Node type', - 'nid' => 'Node id or ids', + 'nid' => 'Node id or ids', 'mode' => 'Import language mode. Values: add, replace', 'group' => 'Translation group name', 'set-default' => 'Set language as default', @@ -119,10 +123,13 @@ function drupal_deploy_drush_help($section) { switch ($section) { case 'drush:deploy-export': return dt('Export data from database.'); + case 'drush:deploy-import': return dt('Import navigation menu to database.'); + case 'drush:deploy-sync': return dt('Sync database state from files.'); + case 'drush:deploy-revert': return dt('Sync database state from files.'); } @@ -134,92 +141,109 @@ function drupal_deploy_drush_help($section) { function drupal_deploy_export($type = '') { $filename = drush_get_option('file'); ini_set('memory_limit', '1G'); - switch($type){ + switch ($type) { case 'menu': $menu_name = drush_get_option('name'); - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_menu.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_menu.inc'; drupal_deploy_export_menu($menu_name, $filename); break; + case 'blocks': $theme_name = drush_get_option('theme'); - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_blocks.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_blocks.inc'; drupal_deploy_export_blocks($theme_name, $filename); break; + case 'filters': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_filters.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_filters.inc'; drupal_deploy_export_filters($filename); break; + case 'roles': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_roles.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_roles.inc'; drupal_deploy_export_roles($filename); break; + case 'node_types': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_node_types.inc'); - include_once(drupal_get_path('module', 'node') .'/content_types.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_node_types.inc'; + include_once drupal_get_path('module', 'node') . '/content_types.inc'; drupal_deploy_export_node_types($filename); - break; + break; + case 'taxonomy': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_taxonomy.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_taxonomy.inc'; drupal_deploy_export_taxonomy($filename); break; + case 'forum': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_forum.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_forum.inc'; drupal_deploy_export_forum($filename); break; + case 'cck': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_cck.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_cck.inc'; drupal_deploy_export_cck($filename); break; + case 'users': - include_once(drupal_get_path('module', 'user') .'/user.pages.inc'); - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_users.inc'); + include_once drupal_get_path('module', 'user') . '/user.pages.inc'; + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_users.inc'; drupal_deploy_export_users($filename); break; + case 'imagecache': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_imagecache.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_imagecache.inc'; drupal_deploy_export_imagecache($filename); break; + case 'nodes': - include_once(drupal_get_path('module', 'node') .'/node.pages.inc'); - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_nodes.inc'); + include_once drupal_get_path('module', 'node') . '/node.pages.inc'; + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_nodes.inc'; drupal_deploy_export_nodes($filename); break; + case 'language': - include_once('includes/locale.inc'); - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_language.inc'); + include_once 'includes/locale.inc'; + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_language.inc'; drupal_deploy_export_language($filename); break; + case 'variables': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_variables.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_variables.inc'; drupal_deploy_export_variables($filename); break; + case 'aggregator': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_aggregator.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_aggregator.inc'; drupal_deploy_export_aggregator($filename); break; + case 'rules': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_rules.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_rules.inc'; drupal_deploy_export_rules($filename); break; + case 'book': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_book.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_book.inc'; drupal_deploy_export_book($filename); break; + default: - if(module_exists($type)) { - $fileinc = drupal_get_path('module', $type) .'/' . $type. '.dde.inc'; - include_once($fileinc); + if (module_exists($type)) { + $fileinc = drupal_get_path('module', $type) . '/' . $type . '.dde.inc'; + include_once $fileinc; $func_name = $type . '_dde_fetch_data'; - if(function_exists($func_name)){ + if (function_exists($func_name)) { $type_items = $func_name(); - + $filename = $type . '.export'; - if($files = dde_export_files($filename)){ + if ($files = dde_export_files($filename)) { $items = array( 'data' => $type_items, 'files' => $files, ); - }else{ + } + else { $items = $type_items; } @@ -235,94 +259,110 @@ function drupal_deploy_export($type = '') { function drupal_deploy_import($type = '', $option = '') { $filename = drush_get_option('file'); ini_set('memory_limit', '1G'); - switch($type){ + switch ($type) { case 'menu': $menu_name = drush_get_option('name'); - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_menu.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_menu.inc'; drupal_deploy_import_menu($filename, $menu_name); break; + case 'blocks': $theme_name = drush_get_option('theme'); - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_blocks.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_blocks.inc'; drupal_deploy_import_blocks($filename, $theme_name); - break; + break; + case 'filters': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_filters.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_filters.inc'; drupal_deploy_import_filters($filename); - break; + break; + case 'roles': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_roles.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_roles.inc'; drupal_deploy_import_roles($filename); break; + case 'node_types': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_node_types.inc'); - include_once(drupal_get_path('module', 'node') .'/content_types.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_node_types.inc'; + include_once drupal_get_path('module', 'node') . '/content_types.inc'; drupal_deploy_import_node_types($filename); break; + case 'taxonomy': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_taxonomy.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_taxonomy.inc'; drupal_deploy_import_taxonomy($filename); break; + case 'forum': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_forum.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_forum.inc'; drupal_deploy_import_forum($filename); break; + case 'cck': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_cck.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_cck.inc'; drupal_deploy_import_cck($filename); - break; + break; + case 'users': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_users.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_users.inc'; drupal_deploy_import_users($filename); break; + case 'imagecache': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_imagecache.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_imagecache.inc'; drupal_deploy_import_imagecache($filename); break; + case 'nodes': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_nodes.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_nodes.inc'; drupal_deploy_import_nodes($filename); break; + case 'language': - include_once('includes/locale.inc'); - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_language.inc'); + include_once 'includes/locale.inc'; + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_language.inc'; drupal_deploy_import_language($filename); break; + case 'variables': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_variables.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_variables.inc'; drupal_deploy_import_variables($filename); break; + case 'aggregator': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_aggregator.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_aggregator.inc'; drupal_deploy_import_aggregator($filename); break; + case 'rules': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_rules.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_rules.inc'; drupal_deploy_import_rules($filename); - break; + break; + case 'book': - include_once(drupal_get_path('module', 'drupal_deploy') .'/includes/drupal_deploy_book.inc'); + include_once drupal_get_path('module', 'drupal_deploy') . '/includes/drupal_deploy_book.inc'; drupal_deploy_import_book($filename); break; + default: - if(module_exists($type)) { - $fileinc = drupal_get_path('module', $type) .'/' . $type. '.ddi.inc'; - include_once($fileinc); + if (module_exists($type)) { + $fileinc = drupal_get_path('module', $type) . '/' . $type . '.ddi.inc'; + include_once $fileinc; $func_name = $type . '_ddi_data'; - if(function_exists($func_name)){ - if(empty($filename)){ + if (function_exists($func_name)) { + if (empty($filename)) { $filename = $type . '.export'; } - if(!is_file($filename)){ + if (!is_file($filename)) { drush_log(dt('File !filename does not exists', array('!filename' => $filename)), 'error'); return FALSE; } $data = file_get_contents($filename); - if(!$data = json_decode($data, TRUE)){ + if (!$data = json_decode($data, TRUE)) { drush_log(dt('Json decode error!'), 'error'); return FALSE; } - if(isset($data['data']) && isset($data['files'])){ + if (isset($data['data']) && isset($data['files'])) { ddi_import_files($data['files'], $filename); $data = $data['data']; } @@ -350,37 +390,39 @@ function drupal_deploy_revert() { /** * Export files to folder, if provided. */ -function dde_export_files($filename){ +function dde_export_files($filename) { $items = array(); $files = dde_files_to_export('get'); - if(!empty($files)){ + if (!empty($files)) { $export_folder = $filename . '.files'; - if(!is_dir($export_folder)){ + if (!is_dir($export_folder)) { mkdir($export_folder); } - + $file_directory_path = variable_get('file_directory_path', conf_path() . '/files'); $file_directory_path_len = strlen($file_directory_path); - - foreach($files as $file){ - if(is_file($file->filepath)){ - - if(0 == strcmp($file_directory_path, substr($file->filepath, 0,$file_directory_path_len))){ + + foreach ($files as $file) { + if (is_file($file->filepath)) { + + if (0 == strcmp($file_directory_path, substr($file->filepath, 0, $file_directory_path_len))) { $store_filepath = $export_folder . '/' . substr($file->filepath, $file_directory_path_len + 1); - }else{ + } + else { $store_filepath = $export_folder . '/' . basename($file->filepath); } - + $info = pathinfo($store_filepath); - if(!is_dir($info['dirname'])){ - mkdir($info['dirname'], 0750, TRUE); + if (!is_dir($info['dirname'])) { + mkdir($info['dirname'], 0750, TRUE); } - + copy($file->filepath, $store_filepath); $file->stored_filepath = $store_filepath; $items[] = $file; - drush_log(dt('!filename exported', array('!filename' => $file->filename)),'notice'); - }else{ + drush_log(dt('!filename exported', array('!filename' => $file->filename)), 'notice'); + } + else { drush_log(dt('!filename does not exists', array('!filename' => $file->filename)), 'warning'); } } @@ -391,34 +433,34 @@ function dde_export_files($filename){ /** * Import files to database, if provided. */ -function ddi_import_files($files, $filename){ +function ddi_import_files($files, $filename) { $info = pathinfo($filename); $dir = $info['dirname']; - if(!is_dir($dir)){ - drush_log(dt('File folder !folder does not exists', array('!folder' => $dir)),'error'); + if (!is_dir($dir)) { + drush_log(dt('File folder !folder does not exists', array('!folder' => $dir)), 'error'); return FALSE; } - foreach($files as $file){ + foreach ($files as $file) { $file['uid'] = ddi_get_user_id($file['username']); - if($stored_file = db_fetch_array(db_query("SELECT * FROM {files} WHERE filepath='%s'", $file['filepath']))){ + if ($stored_file = db_fetch_array(db_query("SELECT * FROM {files} WHERE filepath='%s'", $file['filepath']))) { print_r($stored_file); drush_log(dt('!filename already stored. No changes', array('!filename' => $stored_file['filename']))); dde_files_imported('set', $stored_file); - }else{ + } + else { $info = pathinfo($file['filepath']); - if(!is_dir($info['dirname'])){ + if (!is_dir($info['dirname'])) { drush_log(dt('Create dir !dirname.', array('!dirname' => $info['dirname']))); - mkdir($info['dirname'], 0751, TRUE); + mkdir($info['dirname'], 0751, TRUE); } - drush_log(dt('Copy !from to !to.', array('!from' => $dir . '/' .$file['stored_filepath'], '!to' => $file['filepath']))); - copy($dir . '/' .$file['stored_filepath'], $file['filepath']); - + drush_log(dt('Copy !from to !to.', array('!from' => $dir . '/' . $file['stored_filepath'], '!to' => $file['filepath']))); + copy($dir . '/' . $file['stored_filepath'], $file['filepath']); + drupal_write_record('files', $file); dde_files_imported('set', $file); - + drush_log(dt('!filename imported.', array('!filename' => $file['filename'])), 'notice'); } } } -