Guest User

Untitled

a guest
May 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. #!/usr/bin/env php
  2. <?php
  3.  
  4. $dialog = str_replace('Application Support', 'Application\ Support', $_ENV['DIALOG']);
  5. $dir = $_ENV['TM_PROJECT_DIRECTORY'];
  6. $charlist = "\t\n\r\0\x0B";
  7. $models = glob("{$dir}/models/*Model.php");
  8.  
  9. foreach($models as $model):
  10. $file = basename($model);
  11. $file = str_replace('Model.php', '',$file);
  12. $ret[] = " { title = '$file'; } ";
  13. endforeach;
  14.  
  15. $time = time();
  16. exec("touch /path/to/tmp/.vardump/{$time}");
  17. exec("{$dialog} -up '{ menuItems = ( ".implode(',', $ret)." ); }' > /path/to/tmp/.vardump/{$time}");
  18.  
  19. $tmp_file = file_get_contents("/path/to/tmp/.vardump/{$time}");
  20. $tmp_file = strip_tags($tmp_file);
  21. $tmp_file = str_replace(str_split($charlist), '', $tmp_file);
  22. $tmp_file = preg_replace('#selectedIndex[0-9+]selectedMenuItemtitle#', '', $tmp_file);
  23. echo '\$this->'.$tmp_file.'->';
  24. unlink("/path/to/tmp/.vardump/{$time}");
  25.  
  26. $contents = file_get_contents($dir.'/models/'.$tmp_file.'Model.php');
  27. preg_match_all('#function ([^(]+)#i', $contents, $results);
  28.  
  29. foreach($results[1] as $func)
  30. $ret2[] = " { title = '$func'; } ";
  31.  
  32. $time = time() + 1;
  33.  
  34. exec("touch /path/to/tmp/.vardump/{$time}");
  35. exec("{$dialog} -up '{ menuItems = ( ".implode(',', $ret2)." ); }' > /path/to/tmp/.vardump/{$time}");
  36.  
  37. $tmp_file = file_get_contents("/path/to/tmp/.vardump/{$time}");
  38. $tmp_file = strip_tags($tmp_file);
  39. $tmp_file = str_replace(str_split($charlist), '', $tmp_file);
  40. $tmp_file = preg_replace('#selectedIndex[0-9+]selectedMenuItemtitle#', '', $tmp_file);
  41. echo $tmp_file.'(${1:vars});';
  42. unlink("/path/to/tmp/.vardump/{$time}");
  43.  
  44. ?>
Add Comment
Please, Sign In to add comment