Advertisement
adriweb

WikiArticle_MakerAppDelegate.m

Jul 8th, 2011
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  WikiArticle_MakerAppDelegate.m
  3. //  WikiArticle Maker
  4. //
  5. //  Created by Adrien Bertrand on 08/07/11.
  6. //  Copyright 2011 __MyCompanyName__. All rights reserved.
  7. //
  8.  
  9. #import "WikiArticle_MakerAppDelegate.h"
  10.  
  11. @implementation WikiArticle_MakerAppDelegate
  12.  
  13. @synthesize window, title, partof, sinceversion, description, arg1name, arg1type, arg1desc, arg2name, arg2type, arg2desc, arg3name, arg3type, arg3desc, arg4name, arg4type, arg4desc, example, link1, link2, link3, link4, categ1, categ2, resultat, copyButton, resetButton;
  14.  
  15. - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
  16. {
  17.     pasteBoard = [NSPasteboard generalPasteboard];
  18. }
  19.  
  20. - (IBAction) copy:(id)sender {
  21.     [self writeToPasteBoard:[[resultat textStorage] string]];
  22. }
  23.  
  24. - (BOOL) writeToPasteBoard:(NSString *)stringToWrite
  25. {
  26.     [pasteBoard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
  27.     return [pasteBoard setString:stringToWrite forType:NSStringPboardType];
  28. }
  29.  
  30. - (IBAction) reset:(id)sender {
  31.     NSLog(@"not yet implemented");
  32. }
  33.  
  34. - (IBAction) combine:(id)sender {
  35.     NSString *finalString;
  36.     NSString *arguments;
  37.     NSString *argDesc;
  38.     NSString *table;
  39.    
  40.     argDesc = @"";
  41.    
  42.     if ([[arg1name stringValue] length] != 0)
  43.         argDesc = [NSString stringWithFormat:@"\n| <u><center>%@</center></u> || %@ || %@ \n|-", [arg1name stringValue], [arg1type stringValue], [arg1desc stringValue]];
  44.    
  45.     if ([[arg2name stringValue] length] != 0)
  46.         argDesc = [NSString stringWithFormat:@"%@\n| <u><center>%@</center></u> || %@ || %@ \n|-", argDesc, [arg2name stringValue], [arg2type stringValue], [arg2desc stringValue]];
  47.  
  48.     if ([[arg3name stringValue] length] != 0)
  49.         argDesc = [NSString stringWithFormat:@"%@\n| <u><center>%@</center></u> || %@ || %@ \n|-", argDesc, [arg3name stringValue], [arg3type stringValue], [arg3desc stringValue]];
  50.    
  51.     if ([[arg4name stringValue] length] != 0)
  52.         argDesc = [NSString stringWithFormat:@"%@\n| <u><center>%@</center></u> || %@ || %@ \n|-", argDesc, [arg4name stringValue], [arg4type stringValue], [arg4desc stringValue]];
  53.  
  54.     arguments = [NSString stringWithFormat:@"%@, %@, %@, %@",[arg1name stringValue], [arg2name stringValue], [arg3name stringValue], [arg4name stringValue]];
  55.    
  56.     if ([argDesc length] == 0) {
  57.         arguments = @"";
  58.         table = @"";
  59.     } else {
  60.         table = [NSString stringWithFormat:@"{| class=\"wikitable\"\n|-\n! Parameter !! Type !! Description\n|-%@\n|}\n",argDesc];
  61.     }
  62.    
  63.     finalString = [NSString stringWithFormat:@"'''%@''' is a function that is part of [[:Category:%@|%@]].\n\n%@\n\n<br /> {{Since|%@}}\n\n==Syntax==\n%@:'''%@'''(%@)\n\n%@\n== Example == \n<syntaxhighlight>%@</syntaxhighlight>\n\n<br /><br />\n[[Category:%@]]\n[[Category:%@]]",[title stringValue], [partof stringValue], [partof stringValue], [description stringValue], [sinceversion stringValue], [partof stringValue], [title stringValue], arguments, table, [example stringValue], [categ1 stringValue], [categ2 stringValue]];
  64.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  65.     [resultat setString:finalString];
  66. }
  67.  
  68. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement