manual1-lookup.inc 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <?php
  2. /* NOTE: If there is documentation for a new extension, the extension's
  3. classes, enums and flags will need to be added to the $classes array
  4. before this search script will work with it!! */
  5. /* set up the tools for the job - this array tests class and enum names
  6. in order to capitalize them correctly, throughout the search routines */
  7. $classes = array('GtkAccelGroup.', 'GtkAccelLabel.', 'GtkAdjustment.', 'GtkAlignment.', 'GtkArrow.', 'GtkAspectFrame.', 'GtkBin.', 'GtkBox.', 'GtkBoxChild.', 'GtkButton.', 'GtkButtonBox.', 'GtkCalendar.', 'GtkCheckButton.', 'GtkCheckMenuItem.', 'GtkCList.', 'GtkCListRow.', 'GtkColorSelection.', 'GtkColorSelectionDialog.', 'GtkCombo.', 'GtkContainer.', 'GtkCTree.', 'GtkCTreeNode.', 'GtkCurve.', 'GtkData.', 'GtkDialog.', 'GtkDrawingArea.', 'GtkEditable.', 'GtkEntry.', 'GtkEventBox.', 'GtkFileSelection.', 'GtkFixed.', 'GtkFixedChild.', 'GtkFontSelection.', 'GtkFontSelectionDialog.', 'GtkFrame.', 'GtkGammaCurve.', 'GtkHandleBox.', 'GtkHBox.', 'GtkHButtonBox.', 'GtkHPaned.', 'GtkHRuler.', 'GtkHScale.', 'GtkHScrollbar.', 'GtkHSeparator.', 'GtkImage.', 'GtkInputDialog.', 'GtkInvisible.', 'GtkItem.', 'GtkItemFactory.', 'GtkLabel.', 'GtkLayout.', 'GtkList.', 'GtkListItem.', 'GtkMenu.', 'GtkMenuBar.', 'GtkMenuItem.', 'GtkMenuShell.', 'GtkMisc.', 'GtkNotebook.', 'GtkObject.', 'GtkOptionMenu.', 'GtkPacker.', 'GtkPaned.', 'GtkPixmap.', 'GtkPlug.', 'GtkPreview.', 'GtkProgress.', 'GtkProgressbar.', 'GtkRadioButton.', 'GtkRadioMenuItem.', 'GtkRange.', 'GtkRuler.', 'GtkScale.', 'GtkScrollbar.', 'GtkScrolledWindow.', 'GtkSelectionData.', 'GtkSeparator.', 'GtkSocket.', 'GtkSpinButton.', 'GtkStatusBar.', 'GtkStyle.', 'GtkTable.', 'GtkTableChild.', 'GtkTearoffMenuItem.', 'GtkText.', 'GtkTipsQuery.', 'GtkToggleButton.', 'GtkToolBar.', 'GtkToolTips.', 'GtkTree.', 'GtkTreeItem.', 'GtkVBox.', 'GtkVButtonBox.', 'GtkViewport.', 'GtkVPaned.', 'GtkVRuler.', 'GtkVScale.', 'GtkVScrollbar.', 'GtkVSeparator.', 'GtkWidget.', 'GtkWindow.', 'GdkAtom.', 'GdkBitmap.', 'GdkColor.', 'GdkColormap.', 'GdkCursor.', 'GdkDragContext.', 'GdkEvent.', 'GdkEventAny.', 'GdkEventExpose.', 'GdkFont.', 'GdkGC.', 'GdkPixmap.', 'GdkVisual.', 'GdkWindow.', 'GdkCapStyle.', 'GdkCursorType.', 'GdkDragAction.', 'GdkEventMask.', 'GdkEventType.', 'GdkFill.', 'GdkFontType.', 'GdkFunction.', 'GdkInputCondition.', 'GdkJoinStyle.', 'GdkLineStyle.', 'GdkModifierType.', 'GdkRgbDither.', 'GdkSubwindowMode.', 'GdkVisualType.', 'GtkAccelFlags.', 'GtkAnchorType.', 'GtkArrowType.', 'GtkAttachOptions.', 'GtkButtonAction.', 'GtkButtonBoxStyle.', 'GtkCalendarDisplayOptions.', 'GtkCellType.', 'GtkCornerStyle.', 'GtkCTreeExpanderStyle.', 'GtkCTreeExpansionType.', 'GtkCTreeLineStyle.', 'GtkCurveType.', 'GtkDestDefaults.', 'GtkDirectionType.', 'GtkFontFilterType.', 'GtkFontType.', 'GtkJustification.', 'GtkObjectFlags.', 'GtkOrientation.', 'GtkPackerOptions.', 'GtkPackType.', 'GtkPolicyType.', 'GtkPositionType.', 'GtkPreviewType.', 'GtkProgressBarOrientation.', 'GtkProgressBarStyle.', 'GtkReliefStyle.', 'GtkResizeMode.', 'GtkScrollType.', 'GtkSelectionMode.', 'GtkShadowType.', 'GtkSideType.', 'GtkSortType.', 'GtkSpinButtonUpdatePolicy.', 'GtkSpinType.', 'GtkStateType.', 'GtkSubmenuPlacement.', 'GtkToolbarChildType.', 'GtkToolbarSpaceStyle.', 'GtkToolbarStyle.', 'GtkTreeViewMode.', 'GtkUpdateType.', 'GtkVisibility.', 'GtkWidgetFlags.', 'GtkWindowPosition.', 'GtkWindowType.', 'GtkScintilla.', 'GtkSQPane.', 'GladeXML.');
  8. function tryprefix($lang, $func, $prefix) {
  9. global $classes, $full_match;
  10. $full_match = (int)0;
  11. $types = array('method.', 'signal.', 'property.');
  12. $hit = array();
  13. $part = array();
  14. /* get the 'ext' element of gtk/gdk filenames */
  15. $first = substr($prefix, 0, 3);
  16. /* get the 'ext' element of non-gtk/gdk filenames */
  17. $ext = array();
  18. $dir = opendir("$_SERVER[DOCUMENT_ROOT]/manual1/$lang");
  19. while(($item = readdir($dir))!== false) {
  20. if(!is_dir($item)) {
  21. $part = explode('.', $item);
  22. if(strlen($part[0]) < 4 && $part[0] !== "gtk" && $part[0] !== "gdk" && !in_array($part[0], $ext))
  23. $ext[sizeof($ext)] = $part[0];
  24. }
  25. }
  26. closedir($dir);
  27. /* just so's we don't have to guess wildly at capitalisation in classes/enums */
  28. for($i = 0; $i < sizeof($classes); $i++) {
  29. if(stristr($classes[$i], "${func}.")) $pos = $i;
  30. }
  31. $realname = $classes[$pos];
  32. /* check for classes, enums and static functions */
  33. if(strstr($func, "gdk") || strstr($func, "gtk") || strstr($prefix, "method")) {
  34. /* check for full gtk/gdk function name (e.g. 'gtkwindow::set_title') */
  35. if(strstr($prefix, "method") && strlen($prefix) > 11) {
  36. $try = "/manual1/${lang}/${first}.${prefix}${func}.php";
  37. if (file_exists("$_SERVER[DOCUMENT_ROOT]$try")) {
  38. $full_match++;
  39. $hit[] = $try;
  40. }
  41. else {
  42. /* check for the same under other extensions */
  43. foreach($ext as $first) {
  44. $try = "/manual1/${lang}/${first}.${prefix}${func}.php";
  45. if (file_exists("$_SERVER[DOCUMENT_ROOT]$try")) {
  46. $full_match++;
  47. $hit[] = $try;
  48. }
  49. }
  50. }
  51. }
  52. else {
  53. /* check for a gtk/gdk static function, full class or enum name */
  54. $try = "/manual1/${lang}/${prefix}${func}.php";
  55. $constructor = "/manual1/${lang}/${prefix}${func}.constructor.php";
  56. if (file_exists("$_SERVER[DOCUMENT_ROOT]$constructor")) {
  57. $try = "/manual1/${lang}/${prefix}${realname}php";
  58. $constructor = "/manual1/${lang}/${prefix}${realname}constructor.php";
  59. $full_match = $full_match + 2;
  60. $hit = array($try, $constructor);
  61. }
  62. else if (file_exists("$_SERVER[DOCUMENT_ROOT]$try")) {
  63. $full_match++;
  64. $hit[] = $try;
  65. }
  66. else {
  67. $try = "/manual1/${lang}/${prefix}enum.${func}.php";
  68. if (file_exists("$_SERVER[DOCUMENT_ROOT]$try")) {
  69. $try = "/manual1/${lang}/${prefix}enum.${realname}php";
  70. $full_match++;
  71. $hit[] = $try;
  72. }
  73. }
  74. }
  75. }
  76. if(!$hit) {
  77. /* go through the extension classes */
  78. foreach($ext as $prefix) {
  79. $try = "/manual1/${lang}/${prefix}.${func}.php";
  80. $constructor = "/manual1/${lang}/${prefix}.${func}.constructor.php";
  81. if (file_exists("$_SERVER[DOCUMENT_ROOT]$constructor")) {
  82. $try = "/manual1/${lang}/${prefix}.${realname}php";
  83. $constructor = "/manual1/${lang}/${prefix}.${realname}constructor.php";
  84. $full_match = $full_match + 2;
  85. $hit = array($try, $constructor);
  86. }
  87. else if (file_exists("$_SERVER[DOCUMENT_ROOT]$try")) {
  88. $full_match++;
  89. $hit[] = $try;
  90. }
  91. else {
  92. /* cover against futureshock - non-g*k enums */
  93. $try = "/manual1/${lang}/${prefix}.enum.${func}.php";
  94. if (file_exists("$_SERVER[DOCUMENT_ROOT]$try")) {
  95. $try = "/manual1/${lang}/${prefix}.enum.${realname}php";
  96. $full_match++;
  97. $hit[] = $try;
  98. }
  99. }
  100. }
  101. }
  102. return $hit;
  103. }
  104. /**
  105. * 2006-10-27 FGM: this function needs to have the docs locally in order to work,
  106. * so for now I'm disabling it.
  107. *
  108. * @param unknown_type $lang
  109. * @param unknown_type $func
  110. * @param unknown_type $hit
  111. * @return unknown
  112. */
  113. function wildcard($lang, $func, $hit)
  114. {
  115. return null;
  116. global $classes, $full_match;
  117. $full_match = (int)0;
  118. $dir = opendir("$_SERVER[DOCUMENT_ROOT]/manual1/$lang");
  119. $dir = opendir("$_SERVER[DOCUMENT_ROOT]/manual1/$lang");
  120. while(($item = readdir($dir))!== false) {
  121. $part = explode('.', $item);
  122. $gtk = $part[0];
  123. $class = substr($part[1], 0, 3);
  124. $enum = substr($part[2], 0, 3);
  125. $method = substr($part[3], 0, 3);
  126. if($gtk == $class || $gtk == $enum || ($gtk !== "gtk" && $gtk !== "gdk")) {
  127. if(stristr($part[1], $func) || stristr($part[2], $func)) {
  128. if($part[2] !== "method" && $part[2] !== "property"
  129. && $part[2] !== "signal") {
  130. $try = "/manual1/${lang}/$item";
  131. if(file_exists("$_SERVER[DOCUMENT_ROOT]$try") &&
  132. !in_array($try, $hit)) {
  133. if(stristr($part[1], $func)) $uc = $part[1];
  134. else $uc = $part[2];
  135. for($i = 0; $i < sizeof($classes); $i++) {
  136. if(stristr($classes[$i], "$uc.")) $pos = $i;
  137. }
  138. $realname = $classes[$pos];
  139. if ($uc == $part[1]) {
  140. $try = "/manual1/${lang}/$part[0].$realname$part[2]";
  141. }
  142. else {
  143. $try = "/manual1/${lang}/$part[0].$part[1].$realname$part[3]";
  144. }
  145. similar_text(strtolower($func), strtolower($uc), $percent);
  146. if($percent == 100) $full_match++;
  147. if($percent > 50) $hit[] = $try;
  148. }
  149. }
  150. }
  151. }
  152. if($part[1] == "method") {
  153. if(strstr($part[2], $func)) {
  154. $try = "/manual1/${lang}/$item";
  155. if(file_exists("$_SERVER[DOCUMENT_ROOT]$try") && !in_array($try, $hit)) {
  156. similar_text(strtolower($func), strtolower($part[2]), $percent);
  157. if($percent == 100) $full_match++;
  158. if($percent > 50) $hit[] = $try;
  159. }
  160. }
  161. }
  162. if(($gtk == $class || ($gtk !== "gtk" && $gtk !== "gdk")) && strstr($part[3], $func)) {
  163. $try = "/manual1/${lang}/$item";
  164. if(file_exists("$_SERVER[DOCUMENT_ROOT]$try") && !in_array($try, $hit)) {
  165. for($i = 0; $i < sizeof($classes); $i++) {
  166. if(stristr($classes[$i], "$part[1].")) $pos = $i;
  167. }
  168. $realname = $classes[$pos];
  169. $try = "/manual1/${lang}/$part[0].$realname$part[2].$part[3].$part[4]";
  170. similar_text(strtolower($func), strtolower($part[3]), $percent);
  171. if($percent == 100) $full_match++;
  172. if($percent > 50) $hit[] = $try;
  173. }
  174. }
  175. }
  176. closedir($dir);
  177. return $hit;
  178. }
  179. function find_manual_page($lang, $function) {
  180. $tried = 0;
  181. $hit = array();
  182. /* fast track, single return :) */
  183. if(strstr($function, "::")) {
  184. list($funcpre, $funcpost) = split("::", $function);
  185. $try = tryprefix($lang, $funcpost, "$funcpre.method.");
  186. if($try) return $try;
  187. }
  188. elseif(strtolower(substr($function, 0, 3)) == "gtk" ||
  189. strtolower(substr($function, 0, 3 == "gdk"))) {
  190. $prefix = strtolower(substr($function, 0, 3));
  191. $try = tryprefix($lang, $function, "$prefix.");
  192. if($try) return $try;
  193. }
  194. else {
  195. /* if there's no :: or gtk in there we could be looking for anything */
  196. $try = wildcard($lang, $function, $hit);
  197. /* if($try) $result = array_merge($try, $result); */
  198. if ($try) return $try;
  199. }
  200. /*
  201. if($result) {
  202. return $result;
  203. }
  204. */
  205. return "";
  206. }
  207. ?>