1: <?php
2: class Examples {
3: public static $Categories = array();
4: public static $AdditionalCode = array();
5: public static $PluginExamples = array();
6: public static $PluginAdditions = array();
7:
8: public static function Init() {
9: $intIndex = -1;
10:
11: $intIndex++;
12: Examples::$Categories[$intIndex] = array();
13: Examples::$Categories[$intIndex]['name'] = 'Basic CodeGen';
14: Examples::$Categories[$intIndex]['description'] = 'An introduction to the QCubed Code Generator';
15: self::AddCoreExampleFile($intIndex, '/code_generator/about.php (About Sections 1 - 3)');
16: self::AddCoreExampleFile($intIndex, '/code_generator/intro.php About the Database');
17: self::AddCoreExampleFile($intIndex, '/code_generator/objects.php * Object Relational Model');
18: self::AddCoreExampleFile($intIndex, '/code_generator/indexes.php * Loading Objects');
19: self::AddCoreExampleFile($intIndex, '/code_generator/save_delete.php * Saving and Deleting');
20: self::AddCoreExampleFile($intIndex, '/code_generator/relationships.php * Relationships (Foreign Keys)');
21: self::AddCoreExampleFile($intIndex, '/code_generator/reverse_relationships.php * Reverse Relationships (One-to-One and One-to-Many)');
22: self::AddCoreExampleFile($intIndex, '/code_generator/relationships_many.php * Many-to-Many Relationships');
23: self::AddCoreExampleFile($intIndex, '/code_generator/script_path.php Defining Relationships without Foreign Keys');
24: self::AddCoreExampleFile($intIndex, '/code_generator/primary_keys.php Explanation of QCubed Primary Key Requirement');
25: Examples::$AdditionalCode[__VIRTUAL_DIRECTORY__ . __EXAMPLES__ . '/code_generator/intro.php'] = array('mysql_innodb.sql','sql_server.sql');
26: Examples::$AdditionalCode[__VIRTUAL_DIRECTORY__ . __EXAMPLES__ . '/code_generator/script_path.php'] = array('mysql_myisam.sql', 'relationships.txt');
27:
28: $intIndex++;
29: Examples::$Categories[$intIndex] = array();
30: Examples::$Categories[$intIndex]['name'] = 'More About the Object Relational Model';
31: Examples::$Categories[$intIndex]['description'] = 'Looking more in depth at the functionality of the generated ORM';
32: self::AddCoreExampleFile($intIndex, '/more_codegen/sort_limit.php * Sorting and Limiting Array Results');
33: self::AddCoreExampleFile($intIndex, '/more_codegen/late_bind.php * Late Binding of Related Objects');
34: self::AddCoreExampleFile($intIndex, '/more_codegen/early_bind.php * Early Binding of Related Objects');
35: self::AddCoreExampleFile($intIndex, '/more_codegen/virtual_attributes.php * Virtual Attributes');
36: self::AddCoreExampleFile($intIndex, '/more_codegen/type_tables.php * Type Tables');
37: self::AddCoreExampleFile($intIndex, '/more_codegen/custom.php * Customized Business Logic');
38: self::AddCoreExampleFile($intIndex, '/more_codegen/custom_load.php * Customized Load Methods');
39: self::AddCoreExampleFile($intIndex, '/more_codegen/optimistic_locking.php * Optimistic Locking');
40:
41: $intIndex++;
42: Examples::$Categories[$intIndex] = array();
43: Examples::$Categories[$intIndex]['name'] = 'Querying in QCubed';
44: Examples::$Categories[$intIndex]['description'] = 'Ad Hoc Queries, Custom Load Methods, and QCubed Query';
45: self::AddCoreExampleFile($intIndex, '/qcubed_query/qq.php * QCubed Query: Object Oriented Database Querying');
46: self::AddCoreExampleFile($intIndex, '/qcubed_query/qqnode.php * QCubed Query: The QQ Node Classes');
47: self::AddCoreExampleFile($intIndex, '/qcubed_query/qqcondition.php * QCubed Query: The QQ Condition Classes');
48: self::AddCoreExampleFile($intIndex, '/qcubed_query/qqclause.php * QCubed Query: The QQ Clause Classes');
49: self::AddCoreExampleFile($intIndex, '/qcubed_query/conditional_expand.php * QCubed Query: Conditional Joins');
50: self::AddCoreExampleFile($intIndex, '/qcubed_query/association.php * QCubed Query: Handling Association Tables');
51: self::AddCoreExampleFile($intIndex, '/qcubed_query/reverse.php * QCubed Query: Handling Reverse Relationships');
52: self::AddCoreExampleFile($intIndex, '/qcubed_query/expandasarray.php * ExpandAsArray: Multiple related tables in one swift query');
53: self::AddCoreExampleFile($intIndex, '/qcubed_query/alias.php * SQL Aliases for QQuery');
54: self::AddCoreExampleFile($intIndex, '/qcubed_query/qqselect.php * Picking database columns for QQuery');
55: self::AddCoreExampleFile($intIndex, '/qcubed_query/qqfuncnmath.php * SQL functions and math operations for QQuery');
56: self::AddCoreExampleFile($intIndex, '/qcubed_query/subsql.php * Custom SQL Subqueries for QQuery');
57: self::AddCoreExampleFile($intIndex, '/qcubed_query/intro.php * Performing Custom SQL Queries');
58: self::AddCoreExampleFile($intIndex, '/qcubed_query/qcache.php * Caching Query Results with QueryArrayCached');
59:
60: $intIndex++;
61: Examples::$Categories[$intIndex] = array();
62: Examples::$Categories[$intIndex]['name'] = 'Basic QForms';
63: Examples::$Categories[$intIndex]['description'] = 'An introduction to QForms and QControls';
64: self::AddCoreExampleFile($intIndex, '/basic_qform/about.php (About Sections 4 - 10)');
65: self::AddCoreExampleFile($intIndex, '/basic_qform/intro.php Hello World Example');
66: self::AddCoreExampleFile($intIndex, '/basic_qform/state.php QForms: Stateful, Event-Driven Objects');
67: self::AddCoreExampleFile($intIndex, '/basic_qform/process_flow.php Understanding Process Flow');
68: self::AddCoreExampleFile($intIndex, '/basic_qform/calculator.php Calculator Example');
69: self::AddCoreExampleFile($intIndex, '/basic_qform/calculator_2.php Calculator Example with Validation');
70: self::AddCoreExampleFile($intIndex, '/basic_qform/calculator_3.php Calculator Example with "Design"');
71: self::AddCoreExampleFile($intIndex, '/basic_qform/listbox.php * Introduction to QListControl');
72: self::AddCoreExampleFile($intIndex, '/basic_qform/hlist.php * Generating Html Lists');
73: self::AddCoreExampleFile($intIndex, '/basic_qform/textbox.php * Introduction to QTextBoxControls');
74:
75: $intIndex++;
76: Examples::$Categories[$intIndex] = array();
77: Examples::$Categories[$intIndex]['name'] = 'Basic AJAX in QForms';
78: Examples::$Categories[$intIndex]['description'] = 'A look at how to AJAX-enable your QForms';
79: self::AddCoreExampleFile($intIndex, '/basic_ajax/intro.php Hello World Example using AJAX');
80: self::AddCoreExampleFile($intIndex, '/basic_ajax/calculator_2.php Calculator Example using AJAX');
81: self::AddCoreExampleFile($intIndex, '/basic_ajax/wait_icon.php Adding a Wait Icon');
82:
83: $intIndex++;
84: Examples::$Categories[$intIndex] = array();
85: Examples::$Categories[$intIndex]['name'] = 'More About Events and Actions';
86: Examples::$Categories[$intIndex]['description'] = 'Looking more in depth at the capabilities of the QEvent and QAction libraries';
87: self::AddCoreExampleFile($intIndex, '/events_actions/editable_listbox.php Editable ListBox');
88: self::AddCoreExampleFile($intIndex, '/events_actions/editable_listbox_2.php Conditional Events');
89: self::AddCoreExampleFile($intIndex, '/events_actions/delayed.php Trigger-Delayed Events');
90: self::AddCoreExampleFile($intIndex, '/events_actions/javascript_alerts.php Javascript Actions, Alerts and Confirmations');
91: self::AddCoreExampleFile($intIndex, '/events_actions/other_actions.php Other Client-Side QActions');
92: self::AddCoreExampleFile($intIndex, '/events_actions/event_propagation.php Controlling Event Bubbling');
93: self::AddCoreExampleFile($intIndex, '/events_actions/event_delegation.php Event Delegation');
94: self::AddCoreExampleFile($intIndex, '/events_actions/low_priority_js.php JavaScript priorities');
95: self::AddCoreExampleFile($intIndex, '/events_actions/watcher.php Automatic Refreshing of Controls');
96: self::AddCoreExampleFile($intIndex, '/events_actions/control_proxy.php Using QControlProxies to have Non-QControls Trigger Events');
97:
98: $intIndex++;
99: Examples::$Categories[$intIndex] = array();
100: Examples::$Categories[$intIndex]['name'] = 'Paginated Controls';
101: Examples::$Categories[$intIndex]['description'] = 'The QHtmlTable, QDataGrid and QDataRepeater controls';
102: self::AddCoreExampleFile($intIndex, '/datagrid/intro.php * QHtmlTable');
103: self::AddCoreExampleFile($intIndex, '/datagrid/columns.php * QHtmlTable Columns');
104: self::AddCoreExampleFile($intIndex, '/datagrid/column_values.php * QHtmlTable Formatting and Styling');
105: self::AddCoreExampleFile($intIndex, '/datagrid/link_column.php * QHtmlTable Link Column');
106: self::AddCoreExampleFile($intIndex, '/datagrid/links_images.php * Dynamically adding Controls to QHtmlTable');
107: self::AddCoreExampleFile($intIndex, '/datagrid/sorting.php * The QDataGrid Class and Sorting');
108: self::AddCoreExampleFile($intIndex, '/datagrid/pagination.php * QDataGrid Pagination');
109: self::AddCoreExampleFile($intIndex, '/datagrid/rowactions.php * Detecting Row and Cell Clicks');
110:
111: self::AddCoreExampleFile($intIndex, '/datagrid/qcheckboxcolumn.php * The Easy Way to Add a Checkbox Column to a Datagrid');
112: self::AddCoreExampleFile($intIndex, '/dynamic/inline_editing.php * Datagrid with Inline Editing');
113:
114: self::AddCoreExampleFile($intIndex, '/master_detail/project_list.php * Nested QDataGrid');
115: Examples::$AdditionalCode[__VIRTUAL_DIRECTORY__ . __EXAMPLES__ . '/master_detail/project_list.php'] = array(
116: 'records.summary.php',
117: 'records.summary.tpl.php',
118: 'styles.css');
119: self::AddCoreExampleFile($intIndex, '/datarepeater/ajax.php * Simple QDataRepeater using AJAX-triggered Pagination');
120: Examples::$AdditionalCode[__VIRTUAL_DIRECTORY__ . __EXAMPLES__ . '/datarepeater/ajax.php'] = array('dtr_persons.tpl.php');
121:
122:
123: $intIndex++;
124: Examples::$Categories[$intIndex] = array();
125: Examples::$Categories[$intIndex]['name'] = 'Advanced Controls Manipulation';
126: Examples::$Categories[$intIndex]['description'] = 'Dynamically creating controls, Implementing custom controls';
127: self::AddCoreExampleFile($intIndex, '/dynamic/qpanel.php Introduction to QBlockControls');
128: self::AddCoreExampleFile($intIndex, '/dynamic/qpanel_2.php Dynamically Changing a Control\'s Parent');
129: self::AddCoreExampleFile($intIndex, '/other_controls/persist.php Persistent Controls: Performance for Reusable Components');
130: self::AddCoreExampleFile($intIndex, '/other_controls/sample.php Creating Your Own Control');
131: self::AddCoreExampleFile($intIndex, '/composite/intro.php Creating a Composite Control');
132: self::AddCoreExampleFile($intIndex, '/multiple_qform/intro.php "Multiple QForms" Functionality via Custom QPanels');
133: self::AddCoreReferencedFile('/dynamic/qpanel.php', 'pnl_panel.tpl.php');
134: self::AddCoreReferencedFile('/other_controls/sample.php', '__CORE_CONTROL__QSampleControl.class.php');
135: self::AddCoreReferencedFile('/composite/intro.php', 'SampleComposite.class.php');
136: self::AddCoreReferencedFile('/multiple_qform/intro.php', array(
137: 'ProjectViewPanel.class.php', 'ProjectViewPanel.tpl.php',
138: 'ProjectEditPanel.class.php', 'ProjectEditPanel.tpl.php',
139: 'PersonEditPanel.class.php', 'PersonEditPanel.tpl.php'));
140:
141: $intIndex++;
142: Examples::$Categories[$intIndex] = array();
143: Examples::$Categories[$intIndex]['name'] = 'Advanced AJAX';
144: Examples::$Categories[$intIndex]['description'] = 'Advanced AJAX functionality like drag and drop, selection and cinematic effects';
145: self::AddCoreExampleFile($intIndex, '/advanced_ajax/renamer.php Renameable Labels');
146: self::AddCoreExampleFile($intIndex, '/advanced_ajax/renamer_2.php Porting Code to the Client Side');
147: self::AddCoreExampleFile($intIndex, '/advanced_ajax/move.php Moveable Controls (a.k.a. Drag and Drop)');
148: self::AddCoreExampleFile($intIndex, '/advanced_ajax/scrolling.php Automatic Scrolling');
149: self::AddCoreExampleFile($intIndex, '/advanced_ajax/move_target.php Move Handle: Specifying Which Controls to Move');
150: self::AddCoreExampleFile($intIndex, '/advanced_ajax/drop_zone.php Move Handle: Defining Drop Zones');
151: self::AddCoreExampleFile($intIndex, '/advanced_ajax/resize_jquery.php Resizing Block Controls');
152: self::AddCoreExampleFile($intIndex, '/advanced_ajax/dialog_box.php Modal "Dialog Boxes"');
153: self::AddCoreExampleFile($intIndex, '/other_controls/jq_example.php * Server-side wrappers for all jQuery UI Controls');
154: self::AddCoreExampleFile($intIndex, '/other_controls/js_return_param_example.php Post data back to the server from jQuery UI controls');
155: self::AddCoreExampleFile($intIndex, '/advanced_ajax/jquery_effects.php JQuery Effects');
156:
157: Examples::$AdditionalCode[__VIRTUAL_DIRECTORY__ . __EXAMPLES__ . '/advanced_ajax/dialog_box.php'] = array('CalculatorWidget.class.php','CalculatorWidget.tpl.php');
158:
159: $intIndex++;
160: Examples::$Categories[$intIndex] = array();
161: Examples::$Categories[$intIndex]['name'] = 'Other Advanced Controls';
162: Examples::$Categories[$intIndex]['description'] = 'A collection of examples for some of the more advanced/complex QControls';
163: self::AddCoreExampleFile($intIndex, '/image_label/intro.php Introduction to QImageLabel');
164: self::AddCoreExampleFile($intIndex, '/image_rollover/intro.php Image rollovers using QImageRollover');
165: self::AddCoreExampleFile($intIndex, '/treenav/treenav.php Introduction to QTreeNav');
166: self::AddCoreExampleFile($intIndex, '/other_controls/image.php Introduction to QImageControl');
167: self::AddCoreExampleFile($intIndex, '/other_controls/datetime.php Date and DateTime-based QControls');
168: self::AddCoreExampleFile($intIndex, '/other_controls/file_asset.php Combining Controls, Ex. 1: A Better Way to Upload Files');
169: self::AddCoreExampleFile($intIndex, '/image_browser/test_image_browser.php Combining Controls, Ex. 2: Browsing Image Files');
170: self::AddCoreExampleFile($intIndex, '/other_controls/image_file_asset.php Upload Control Just for Images');
171: self::AddCoreExampleFile($intIndex, '/other_controls/timer_js.php JavaScript Timer');
172: self::AddCoreReferencedFile('/image_browser/test_image_browser.php', array('image_browser.tpl.php', 'imagebrowser.css'));
173:
174: $intIndex++;
175: Examples::$Categories[$intIndex] = array();
176: Examples::$Categories[$intIndex]['name'] = 'Model Connectors, DataGrid Connectors, and the Drafts';
177: Examples::$Categories[$intIndex]['description'] = 'Combining the Code Generator with the QForm Library';
178: self::AddCoreExampleFile($intIndex, '/other/formgen.php QForm and CodeGen, a Winning Combination to RAD');
179: self::AddCoreExampleFile($intIndex, '/other/model_connectors.php * Introduction to Model Connectors');
180: self::AddCoreExampleFile($intIndex, '/other/datagrid_connectors.php * Introduction to DataGrid Connectors');
181: self::AddCoreExampleFile($intIndex, '/other/form_drafts.php * Introduction to the Drafts');
182:
183: $intIndex++;
184: Examples::$Categories[$intIndex] = array();
185: Examples::$Categories[$intIndex]['name'] = 'Beyond HTML';
186: Examples::$Categories[$intIndex]['description'] = 'Other libraries in QCubed, including support for Email and RSS';
187: self::AddCoreExampleFile($intIndex, '/communication/email.php Introduction to QEmailServer');
188: self::AddCoreExampleFile($intIndex, '/communication/rss.php * Introduction to QRssFeed');
189: self::AddCoreExampleFile($intIndex, '/other/parsing.php Introduction to parsing with QLexer and QRegex');
190: self::AddCoreExampleFile($intIndex, '/communication/crypto.php Introduction to QCryptography');
191: self::AddCoreExampleFile($intIndex, '/communication/i18n.php Introduction to QI18n (Internationalization)');
192: self::AddCoreExampleFile($intIndex, '/communication/advanced_intl.php Advanced Internationalization techniques');
193: self::AddCoreExampleFile($intIndex, '/communication/soap.php * Introduction to QSoapService');
194: self::AddCoreExampleFile($intIndex, '/other/timer.php * Measuring Performance using QTimer');
195: self::AddCoreReferencedFile('/communication/rss.php', 'rss_feed.php');
196: self::AddCoreReferencedFile('/communication/i18n.php', array('en.po', 'es.po'));
197: self::AddCoreReferencedFile('/communication/soap.php', 'example_service.php');
198: self::AddCoreReferencedFile('/other/parsing.php', 'bb_parser.php');
199: self::AddCoreReferencedFile('/communication/advanced_intl.php', 'sample_translator.class.php');
200:
201:
202: $intIndex++;
203: Examples::$Categories[$intIndex] = array();
204: Examples::$Categories[$intIndex]['name'] = 'Other Tidbits';
205: Examples::$Categories[$intIndex]['description'] = 'Other random examples, samples and tutorials';
206: self::AddCoreExampleFile($intIndex, '/basic_qform/xss.php * Security: Preventing Cross-Site Scripting');
207: self::AddCoreExampleFile($intIndex, '/other/optimistic_locking.php * Optimistic Locking and QForms');
208: self::AddCoreExampleFile($intIndex, '/other/attribute_overriding.php Attribute Overriding');
209: self::AddCoreExampleFile($intIndex, '/other/alternate_template.php Specifying a Template Filepath');
210: self::AddCoreExampleFile($intIndex, '/other/single.php Single File QForms');
211: self::AddCoreExampleFile($intIndex, '/other/form_state.php Working with FormState Handlers');
212: self::AddCoreExampleFile($intIndex, '/other/print.php PHP Print Command Shortcuts');
213: self::AddCoreExampleFile($intIndex, '/other/includes_outside.php Includes outside of the __DOCROOT__ for Security and Shared Installs');
214: self::AddCoreReferencedFile('/other/alternate_template.php', 'some_template_file.tpl.php');
215:
216: $intIndex++;
217: Examples::$Categories[$intIndex] = array();
218: Examples::$Categories[$intIndex]['name'] = 'Plugin System';
219: Examples::$Categories[$intIndex]['description'] = 'Infrastructure that lets the community extend QCubed';
220: self::AddCoreExampleFile($intIndex, '/plugins/about.php Plugin Ecosystem: Introduction');
221: self::AddCoreExampleFile($intIndex, '/plugins/components.php Writing your own plugins, Part 1: components of a plugin');
222: self::AddCoreExampleFile($intIndex, '/plugins/packaging.php Writing your own plugins, Part 2: packaging a plugin');
223:
224: self::AddCoreReferencedFile('/plugins/components.php', '__CORE_FRAMEWORK__QPluginInterface.class.php');
225:
226:
227: if (defined ('__PLUGINS__') &&
228: is_dir(__PLUGINS__)) {
229: $plugins = scandir(__PLUGINS__);
230:
231: if (count($plugins) > 0) {
232:
233:
234:
235:
236:
237: foreach ($plugins as $dirName) {
238: if ($dirName != '.' && $dirName != '..' && file_exists(__PLUGINS__ . '/' . $dirName . '/composer.json')) {
239:
240: $composerDetails = json_decode(file_get_contents(__PLUGINS__ . '/' . $dirName . '/composer.json' ), true);
241: if (!empty($composerDetails['extra']['examples'])) {
242: foreach ($composerDetails['extra']['examples'] as $strExample) {
243: $strExamplePath = __PLUGINS__ . '/' . $dirName . '/examples/' . $strExample;
244: if (file_exists ($strExamplePath)) {
245: self::AddPluginExampleFile($dirName, $strExample);
246: if (!empty($composerDetails['extra']['exampleExtras'][$strExample])) {
247: self::AddPluginExtraFile($dirName, $strExample, $composerDetails['extra']['exampleExtras'][$strExample]);
248: }
249: }
250: }
251: }
252: }
253: }
254: }
255: }
256: }
257:
258: public static function AddPluginExampleFile($strPluginName, $strExampleFileName) {
259: Examples::$PluginExamples[$strPluginName][] = $strExampleFileName;
260: }
261:
262: public static function AddPluginExtraFile($strPluginName, $strExampleFileName, $extras) {
263: Examples::$PluginAdditions[$strPluginName][$strExampleFileName] = $extras;
264: }
265:
266: private static function AddCoreExampleFile($intIndex, $strExampleFileName) {
267: array_push(Examples::$Categories[$intIndex], __VIRTUAL_DIRECTORY__ . __EXAMPLES__ . $strExampleFileName);
268: }
269:
270: private static function AddCoreReferencedFile($strExampleFileName, $mixReferencedFile) {
271: if (!is_array($mixReferencedFile)) {
272: $mixReferencedFile = array($mixReferencedFile);
273: }
274: Examples::$AdditionalCode[__VIRTUAL_DIRECTORY__ . __EXAMPLES__ . $strExampleFileName] = $mixReferencedFile;
275: }
276:
277: public static function GetCategoryId() {
278: $numCategories = count(Examples::$Categories);
279: $categories = Examples::$Categories;
280: for ($intCategoryIndex = 0; $intCategoryIndex < count(Examples::$Categories); $intCategoryIndex++) {
281: $objExampleCategory = Examples::$Categories[$intCategoryIndex];
282:
283: for ($intExampleIndex = 0; $intExampleIndex < count($objExampleCategory); $intExampleIndex++) {
284: if (array_key_exists($intExampleIndex, $objExampleCategory)) {
285: $strExample = $objExampleCategory[$intExampleIndex];
286: $intPosition = strpos($strExample, ' ');
287: $strScriptPath = substr($strExample, 0, $intPosition);
288:
289: if (substr_count($strScriptPath, QApplicationBase::$ScriptName) > 0) {
290: return $intCategoryIndex;
291: }
292: }
293: }
294: }
295:
296:
297: $strScript = QApplicationBase::$ScriptName;
298: if ($offset = strpos (QApplicationBase::$ScriptFilename, '/plugin/')) {
299: return 'plugin';
300: }
301:
302: return null;
303: }
304:
305: public static function GetExampleId() {
306: for ($intCategoryIndex = 0; $intCategoryIndex < count(Examples::$Categories); $intCategoryIndex++) {
307: $objExampleCategory = Examples::$Categories[$intCategoryIndex];
308:
309: for ($intExampleIndex = 0; $intExampleIndex < count($objExampleCategory); $intExampleIndex++) {
310: if (array_key_exists($intExampleIndex, $objExampleCategory)) {
311: $strExample = $objExampleCategory[$intExampleIndex];
312: $intPosition = strpos($strExample, ' ');
313: $strScriptPath = strtolower(substr($strExample, 0, $intPosition));
314: $strName = substr($strExample, $intPosition + 1);
315:
316: $scriptName = QApplicationBase::$ScriptName;
317: $portionOfScriptName = strtolower(substr($scriptName, strlen(QApplicationBase::$ScriptName) - strlen($strScriptPath)));
318:
319: if ($portionOfScriptName == $strScriptPath) {
320: return $intExampleIndex;
321: }
322: }
323: }
324: }
325:
326:
327: if ($offset = strpos (QApplicationBase::$ScriptFilename, '/plugin/')) {
328: $offset += strlen ('/plugin/');
329: $endoffset = strpos (QApplicationBase::$ScriptFilename, '/', $offset);
330: $strCat = substr (QApplicationBase::$ScriptFilename, $offset, $endoffset - $offset);
331:
332:
333: if (!empty(Examples::$PluginExamples[$strCat])) {
334: return $strCat;
335: }
336: }
337:
338: return null;
339: }
340:
341: public static function GetPluginFile() {
342: if ($offset = strpos (QApplicationBase::$ScriptFilename, '/plugin/')) {
343: $offset += strlen ('/plugin/');
344: $endoffset = strpos (QApplicationBase::$ScriptFilename, '/', $offset);
345: $strCat = substr (QApplicationBase::$ScriptFilename, $offset, $endoffset - $offset);
346:
347:
348: if (!empty(Examples::$PluginExamples[$strCat])) {
349: $endoffset = strrpos (QApplicationBase::$ScriptFilename, '/', $offset);
350: $strCurFile = substr(QApplicationBase::$ScriptFilename, $endoffset + 1);
351: for ($intExampleIndex = 0; $intExampleIndex < count(Examples::$PluginExamples[$strCat]); $intExampleIndex++) {
352: if (Examples::$PluginExamples[$strCat][$intExampleIndex] == $strCurFile) {
353: return $strCurFile;
354: }
355: }
356: }
357: }
358: return null;
359: }
360:
361: public static function GetExampleName($mixCategoryId, $mixExampleId) {
362: if ($mixCategoryId == 'plugin') {
363: $strExample = Examples::$PluginExamples[$mixExampleId][0];
364: return $strExample;
365: }
366: $strExample = Examples::$Categories[$mixCategoryId][$mixExampleId];
367: $intPosition = strpos($strExample, ' ');
368: $strScriptPath = substr($strExample, 0, $intPosition);
369: $strName = substr($strExample, $intPosition + 1);
370: return $strName;
371: }
372:
373: public static function GetExampleScriptPath($mixCategoryId, $mixExampleId, $mixSubId = null) {
374: if ($mixCategoryId == 'plugin') {
375: $strScriptPath = __PLUGIN_ASSETS__ . "/{$mixExampleId}/examples/{$mixSubId}";
376: return $strScriptPath;
377: }
378: $strExample = Examples::$Categories[$mixCategoryId][$mixExampleId];
379: $intPosition = strpos($strExample, ' ');
380: $strScriptPath = substr($strExample, 0, $intPosition);
381: return $strScriptPath;
382: }
383:
384: public static function PageName($strReference = null) {
385: if (is_null($strReference))
386: $strReference = QApplication::$ScriptName;
387:
388: foreach (Examples::$Categories as $objExampleCategory)
389: foreach ($objExampleCategory as $strKey => $strExample)
390: if (is_numeric($strKey)) {
391:
392: $intPosition = strpos($strExample, ' ');
393: $strScriptName = substr($strExample, 0, $intPosition);
394:
395: if (strpos($strReference, $strScriptName) !== false)
396: return(substr($strExample, $intPosition + 1));
397: }
398:
399: return 'Main Page';
400: }
401:
402: public static function PageLinkName($strReference = null) {
403: if (is_null($strReference))
404: $strReference = QApplication::$ScriptName;
405:
406: foreach (Examples::$Categories as $objExampleCategory)
407: foreach ($objExampleCategory as $strKey => $strExample)
408: if (is_numeric($strKey)) {
409:
410: $intPosition = strpos($strExample, ' ');
411: $strScriptName = substr($strExample, 0, $intPosition);
412:
413: if (strpos($strReference, $strScriptName) !== false)
414: return($strScriptName);
415: }
416: }
417:
418: public static function CodeLinks($strCategoryId, $strExampleId, $strSubId, $strCurrentScript) {
419: $blnIsScript = false;
420:
421: $strReference = Examples::GetExampleScriptPath($strCategoryId, $strExampleId, $strSubId);
422:
423: if ($strCurrentScript == 'header.inc.php') {
424: $strToReturn = '<span class="headerGray">header.inc.php</span>';
425: $blnIsScript = true;
426: } else {
427: $strToReturn = sprintf('<a href="%s/../header.inc.php" class="headerLink">header.inc.php</a>', QApplication::$RequestUri);
428: }
429:
430: $strToReturn .= ' | ';
431:
432: if ($strCurrentScript == 'footer.inc.php') {
433: $strToReturn .= '<span class="headerGray">footer.inc.php</span>';
434: $blnIsScript = true;
435: } else {
436: $strToReturn .= sprintf('<a href="%s/../footer.inc.php" class="headerLink">footer.inc.php</a>', QApplication::$RequestUri);
437: }
438:
439: $strToReturn .= ' | ';
440: if ($strCurrentScript == 'examples.css') {
441: $strToReturn .= '<span class="headerGray">examples.css</span>';
442: $blnIsScript = true;
443: } else
444: $strToReturn .= sprintf('<a href="%s/../examples.css" class="headerLink">examples.css</a>', QApplication::$RequestUri);
445:
446: $strToReturn .= ' | ';
447:
448: $strScriptname = substr($strReference, strrpos($strReference, '/') + 1);
449: if ($strCurrentScript == $strScriptname) {
450: $strToReturn .= sprintf('<span class="headerGray">%s</span>', $strScriptname);
451: $blnIsScript = true;
452: } else
453: $strToReturn .= sprintf('<a href="%s/../%s" class="headerLink">%s</a>', QApplication::$RequestUri, $strScriptname, $strScriptname);
454:
455:
456:
457: $intCount = 4;
458:
459: if (file_exists(__DOCROOT__ . str_replace('.php', '.tpl.php', $strReference))) {
460: $strToReturn .= ' | ';
461:
462: $strScriptname = substr(str_replace('.php', '.tpl.php', $strReference), strrpos(str_replace('.php', '.tpl.php', $strReference), '/') + 1);
463: if ($strCurrentScript == $strScriptname) {
464: $strToReturn .= sprintf('<span class="headerGray">%s</span>', $strScriptname);
465: $blnIsScript = true;
466: } else {
467: $strToReturn .= sprintf('<a href="%s/../%s" class="headerLink">%s</a>', QApplication::$RequestUri, $strScriptname, $strScriptname);
468: }
469:
470: $intCount++;
471: }
472:
473: if ($strCategoryId == 'plugin') {
474: if (!empty(Examples::$PluginAdditions[$strExampleId][$strSubId])) {
475: $extraFiles = Examples::$PluginAdditions[$strExampleId][$strSubId];
476: }
477: }
478: if(array_key_exists($strReference, Examples::$AdditionalCode)) {
479: $extraFiles = Examples::$AdditionalCode[$strReference];
480: }
481:
482: if (!empty($extraFiles)) {
483: foreach ($extraFiles as $strCode) {
484: if (($intCount % 7) == 0)
485: $strToReturn .= '<br/>';
486: else
487: $strToReturn .= ' | ';
488:
489: $strScriptname = $strCode;
490: if ($strCurrentScript == $strScriptname) {
491: $strToReturn .= sprintf('<span class="headerGray">%s</span>', preg_replace('/__.*__/', '', $strScriptname));
492: $blnIsScript = true;
493: } else {
494: $strToReturn .= sprintf('<a href="%s/../%s" class="headerLink">%s</a>', QApplication::$RequestUri, $strScriptname, preg_replace('/__.*__/', '', $strScriptname));
495: }
496:
497: $intCount++;
498: }
499: }
500:
501: if ($blnIsScript) {
502: return $strToReturn;
503: }
504: else {
505: QApplication::CloseWindow();
506: }
507: }
508:
509: public static function PageLinks() {
510: $strPrevious = null;
511: $strNext = null;
512: $blnFound = false;
513:
514: $strScript = QApplication::$ScriptName;
515:
516: if (strpos($strScript, "plugin") !== false &&
517: strpos($strScript, "vendor") !== false) {
518:
519: $strLink = QHtml::RenderLink(QHtml::MakeUrl(__DEVTOOLS_ASSETS__ . '/plugin_manager.php'), "Plugin Manager", ["class"=>"headerLink"]);
520: return $strLink;
521: }
522:
523: foreach (Examples::$Categories as $objExampleCategory) {
524: if (!$blnFound) {
525: $strPrevious = null;
526: $strNext = null;
527:
528: foreach ($objExampleCategory as $strKey => $strExample) {
529: if (is_numeric($strKey)) {
530:
531: $intPosition = strpos($strExample, ' ');
532: $strScriptName = substr($strExample, 0, $intPosition);
533: $strDescription = substr($strExample, $intPosition + 1);
534: $qapp = QApplication::$ScriptName;
535:
536: if (!$blnFound) {
537: if (strpos(QApplication::$ScriptName, $strScriptName) !== false ||
538: strpos($strScriptName, QApplication::$ScriptName) !== false) {
539: $blnFound = true;
540: } else {
541: $strPrevious = sprintf('<strong><a href="%s" class="headerLink"><< %s</a></strong>',
542: $strScriptName, $strDescription);
543: }
544: } else if (!$strNext) {
545: $strNext = sprintf('<strong><a href="%s" class="headerLink">%s >></a></strong>',
546: $strScriptName, $strDescription);
547: }
548: }
549: }
550: }
551: }
552:
553: $strToReturn = '';
554:
555: if ($strPrevious)
556: $strToReturn = $strPrevious;
557: else
558: $strToReturn = '<span class="headerGray"><< Previous</span>';
559:
560: $intCategoryId = Examples::GetCategoryId();
561: if ($intCategoryId < 3)
562: $intPartId = 1;
563: else if ($intCategoryId < 10)
564: $intPartId = 2;
565: else
566: $intPartId = 3;
567:
568: $strToReturn .= ' | ';
569: $strToReturn .= sprintf('<strong><a href="%s/index.php%s" class="headerLink">Back to Main</a></strong>',
570: __VIRTUAL_DIRECTORY__ . __EXAMPLES__, $intPartId == 1 ? "" : "/" . $intPartId);
571: $strToReturn .= ' | ';
572:
573: if ($strNext)
574: $strToReturn .= $strNext;
575: else
576: $strToReturn .= '<span class="headerGray">Next >></span>';
577:
578: return $strToReturn;
579: }
580: }
581:
582:
583:
584: Examples::Init();
585: ?>
586: