XarayaTranslationMemory  1.6
CodingStyle.php
Go to the documentation of this file.
1 <?
11 /* BSD style "{ }" handling. 4 tabs. */
12 
13 class TranslationWordList implements Iterator
14 {
15  private $DB;
16  private $Tables;
18  function __construct()
19  {
20  }
21 
22  private function SplitToWords($text)
23  {
24  // Clear previous items
25  unset($this->AllWords);
26  $this->SetFakeLength(0);
27 
28  // Split to words
29  $wordList = split('[ \.,()!\?:;=|*]', $text);
30 
31  foreach($wordList as $word)
32  {
33  // Remove trash remained with split
34  $word = trim($word, " \t\n\r:[]#'\"$+-_<>/");
35 
36  // Nonempty, nonnumbers
37  if($word != "" && !is_numeric($word))
38  {
39  $this->AddWord(strtolower($word));
40  }
41  }
42 
43 
44 /* FUNCTION DEFINITION */
45 
46 /* Function and class names names are UpperCamelCase */
47 
48  private function SplitToWords($text)
49 
50 
51 /* VARIABLE NAMES */
52 
53 /* Function parameters (as being local variables) are camelCase */
54 
55  private function SplitToWords($text)
56  public function CreateProject($parentID, $name, $localeID, $document = '', $skeleton = '')
57 
58 /* Function parameters must have type-hint for objects. */
59 
60  function ProcessDir(RecursiveDirectoryIterator $dirIterator, TranslationProject $parentProject)
61 
62 /* Local variables are camelCase (like the function parameters) */
63 
64  $wordList = split('[ \.,()!\?:;=|*]', $text);
65  $word = trim($word, " \t\n\r:[]#'\"$+-_<>/");
66  $points = 0;
67 
68 /* Class member variables and functions are UpperCamelCase */
69 
70  private $AllWords;
71  private $CurrentIndex;
72 
73 /* Reference to class member variables and functions starts with $this-> */
74 /* (This is a requirement in PHP, but would be optional in C#) */
75 
76  $this->SetFakeLength(0);
77  $this->ParentID = $parentID;
78  $this->Name = $name;
79 
80 /* No meaningless variable names */
81 
82  $CardIsValid = $this->CheckCreditCard($CardNumber);
83 
84 /* Bad: $valid = IsValid($number) */
85 
86 /* Event handles based on the event sender control name and the event type */
87 
88  public btnNext_Clicked()
89  {
90  }
91 
92 
93 /* CODE SPACNIG */
94 
95 /* No space next to parenthesis (unless it gets very messy). */
96 
97  foreach($wordList as $word)
98  if($word != "" && !is_numeric($word))
99  $this->AddWord(strtolower($word));
100 
101 /* No single line "if" and "if" without curly bracket. Good: */
102 
103  if($w->GetID() == $id)
104  {
105  return $w;
106  }
107 /*
108 Bad: if($w->GetID() == $id) { return $w }
109 
110 Bad: if($w->GetID() == $id)
111  return $w;
112 */
113 
114 /* Qt WIDGETnotations */
115 
116  $vboxNameHere = new QVBoxLayout();
117  $hboxNameHere = new QHBoxLayout();
118  $gridNameHere = new QGridLayout();
119 
120  $btnNameHere = new QButton();
121  $txtNameHere = new QTextEdit();
122  $txtNameHere = new QLineEdit();
123  $lblNameHere = new QLabel();
124  $tblNameHere = new QTableWidget();
125 
126  $wNameHere = new QWidget(); // for window-building dummy widgets
127 ?>
AddWord($word, $count=1)