Loading...
 
Skip to main content
 Note
This page is to document "what Tiki should do". For feature documentation (what Tiki does), please see corresponding page on doc site

Tracker Tabular

Tracker Tabular is built as an API to import and export tracker information as lists. While the API is used within Tiki, it can also be used to create custom import/export interfaces when appropriate.

Defining a Schema

While building the schema, the process will make sure the field and mode selected exist within the specified tracker definition. The final validation call will make sure that there are no conflicting fields.

Sample schema assembly
Copy to clipboard
$tracker = \Tracker_Definition::get(4); $schema = new \Tracker\Tabular\Schema($tracker); $schema->addColumn('itemId', 'id'); $schema->addColumn('sku', 'default'); $schema->addColumn('division', 'text'); $schema->addColumn('supplier', 'lookup-simple'); $schema->addColumn('price', 'formatted'); $schema->addColumn('name', 'default'); $schema->addColumn('introductionDate', 'yyyy-mm-dd'); $schema->addColumn('introductionDate', 'unix') ->setReadOnly(true); $schema->setPrimaryKey('itemId'); $schema->validate();

Importing


The process of importing data implies reading the data from a source, and writing it into tracker storage. The following example provides a generic example importing anything into a specific tracker.

You could also use a CsvSource instead of an AutoDetectCsvSource if you want to allow the operation over only a select collection of fields. In this case, you would need to provide the schema to the source. For example, you could have employees only able to update the price of items and a specific category while importing, creating limited privilege imports.

Simplest import
Copy to clipboard
$tracker = \Tracker_Definition::get(4); $source = new \Tracker\Tabular\Source\AutoDetectCsvSource($tracker, '/tmp/import'); $writer = new \Tracker\Tabular\Writer\TrackerWriter; $writer->write($source);

Exporting


Data Export can be performed on a full tracker directly from the tracker data, or based on a query result. Both sources work using PHP's generators to avoid loading too much data into memory at one time and reduce required memory usage.

Performance of the query-based export will depend on the used engine. Lucene would be the slowest as all data needs to be re-fetched. MySQL will only re-fetch multi-value fields when they are needed. ElasticSearch will rarely need to re-fetch anything.

Full Tracker Export
Copy to clipboard
$schema = $this->getSchema(); $source = new \Tracker\Tabular\Source\TrackerSource($schema); $writer = new \Tracker\Tabular\Writer\CsvWriter('php://output'); $writer->sendHeaders(); $writer->write($source); exit;

Query-based export
Copy to clipboard
$schema = $this->getSchema(); $query = \TikiLib::lib('unifiedsearch')->buildQuery([ 'type' => "trackeritem", 'tracker_id' => "4", ]); $query->filterCategories("1 or 2 or 3"); // Anything from the Search_Query class $source = new \Tracker\Tabular\Source\QuerySource($schema, $query); $writer = new \Tracker\Tabular\Writer\CsvWriter('php://output'); $writer->sendHeaders(); $writer->write($source); exit;

Adding Modes


To be exportable, a field must support the Tracker_Field_Exportable interface. The only requirement is to support the getTabularSchema() method. Here is a sample method from the Drop Down field type.

Copy to clipboard
function getTabularSchema() { $schema = new Tracker\Tabular\Schema($this->getTrackerDefinition()); $permName = $this->getConfiguration('permName'); $name = $this->getConfiguration('name'); $possibilities = $this->getPossibilities(); $invert = array_flip($possibilities); $schema->addNew($permName, 'code') ->setLabel($name) ->setRenderTransform(function ($value) { return $value; }) ->setParseIntoTransform(function (& $info, $value) use ($permName) { $info['fields'][$permName] = $value; }) ; $schema->addNew($permName, 'text') ->setLabel($name) ->addIncompatibility($permName, 'code') ->addQuerySource('text', "tracker_field_{$permName}_text") ->setRenderTransform(function ($value, $extra) use ($possibilities) { if (isset($possibilities[$value])) { return $possibilities[$value]; } }) ->setParseIntoTransform(function (& $info, $value) use ($permName, $invert) { if (isset($invert[$value])) { $info['fields'][$permName] = $invert[$value]; } }) ; return $schema; }


The defined schema above defines two modes for the same field: code and text. Note that the second one is marked as incompatible with the first one, as when importing they would fight each other.

Each field defines setRenderTransform and "parseIntoTransform". The first one takes the value from the source and serializes it. The second one takes the serialized version and converts it to the actual value. The functions are defined as closures, giving them access to the parent scope and the entire field data.

The render transform can receive data from the tracker source or the query source.

  • The tracker source will always only provide the $value for the field. $extra will contain the itemId and status keys.
  • The query source will provide the exact match key from the result array as $value. $extra will be populated with what is specified by addQuerySource calls, allowing to make some values to simpler names. In this case, it is not really required as the text is obtained from a static list. However, in other cases, such as item links, it can avoid making an extra query to fetch it.


Because these functions will be called multiple times, it is worth it to do some of the work up-front, like obtaining the possibilities, and generating the invert map, which will be made available through the **use** statement.

Quite often, the same values will need to be fetched over and over again. Item links often point to a small set of items. However, it is impossible assume that this will always be the case. The Tracker\Tabular\Schema\CachedLookupHelper is available to help with the caching process.

  • A function can be specified to load a base set of items on demand
  • A function can be provided to load each item individually
  • Static methods are available to quickly generate lookups and invert lookups from tracker data


The component allows to initialize the behavior from within the getTabularSchema() function, supporting both the small set and large set scenarios, without paying any initial costs. The data will only begin loading when needed the first time, hence the lookups needed for export will not be loaded on imports.

Keywords

The following is a list of keywords that should serve as hubs for navigation within the Tiki development and should correspond to documentation keywords.

Each feature in Tiki has a wiki page which regroups all the bugs, requests for enhancements, etc. It is somewhat a form of wiki-based project management. You can also express your interest in a feature by adding it to your profile. You can also try out the Dynamic filter.

Accessibility (WAI & 50😎
Accounting
Administration
Ajax
Articles & Submissions
Backlinks
Banner
Batch
BigBlueButton audio/video/chat/screensharing
Blog
Bookmark
Browser Compatibility
Calendar
Category
Chat
Comment
Communication Center
Consistency
Contacts Address book
Contact us
Content template
Contribution
Cookie
Copyright
Credits
Custom Home (and Group Home Page)
Database MySQL - MyISAM
Database MySQL - InnoDB
Date and Time
Debugger Console
Diagram
Directory (of hyperlinks)
Documentation link from Tiki to doc.tiki.org (Help System)
Docs
DogFood
Draw -superseded by Diagram
Dynamic Content
Preferences
Dynamic Variable
External Authentication
FAQ
Featured links
Feeds (RSS)
File Gallery
Forum
Friendship Network (Community)
Gantt
Group
Groupmail
Help
History
Hotword
HTML Page
i18n (Multilingual, l10n, Babelfish)
Image Gallery
Import-Export
Install
Integrator
Interoperability
Inter-User Messages
InterTiki
jQuery
Kaltura video management
Kanban
Karma
Live Support
Logs (system & action)
Lost edit protection
Mail-in
Map
Menu
Meta Tag
Missing features
Visual Mapping
Mobile
Mods
Modules
MultiTiki
MyTiki
Newsletter
Notepad
OS independence (Non-Linux, Windows/IIS, Mac, BSD)
Organic Groups (Self-managed Teams)
Packages
Payment
PDF
Performance Speed / Load / Compression / Cache
Permission
Poll
Profiles
Quiz
Rating
Realname
Report
Revision Approval
Scheduler
Score
Search engine optimization (SEO)
Search
Security
Semantic links
Share
Shopping Cart
Shoutbox
Site Identity
Slideshow
Smarty Template
Social Networking
Spam protection (Anti-bot CATPCHA)
Spellcheck
Spreadsheet
Staging and Approval
Stats
Survey
Syntax Highlighter (Codemirror)
Tablesorter
Tags
Task
Tell a Friend
Terms and Conditions
Theme
TikiTests
Federated Timesheets
Token Access
Toolbar (Quicktags)
Tours
Trackers
TRIM
User Administration
User Files
User Menu
Watch
Webmail and Groupmail
WebServices
Wiki History, page rename, etc
Wiki plugins extends basic syntax
Wiki syntax text area, parser, etc
Wiki structure (book and table of content)
Workspace and perspectives
WYSIWTSN
WYSIWYCA
WYSIWYG
XMLRPC
XMPP




Useful Tools