/** *the imported data doesn't match the tables * Ask what the user wants to do * */ function csvChooseElementTypes($elementTypes) { FabrikViewImport::setcsvChooseElementTypesToolbar(); ?> <form action="index.php" method="post" name="adminForm"> <?php if (!empty($this->newHeadings)) { echo "<H3>" . JText::_('NEW HEADINGS FOUND') . "</h3>"; echo str_replace('{table}', $this->table->label, JText::_('NEWHEADINGSFOUNDDESC')); ?> <table class="adminlist"> <thead> <tr> <th class="title"><?php echo JText::_('CREATE ELEMENT'); ?> </th> <th class="title"><?php echo JText::_('LABEL'); ?> </th> <th class="title"><?php echo JText::_('ELEMENT TYPE'); ?> </th> <?php if ($this->table->db_primary_key == '') { ?> <th class="title"><?php echo JText::_('PRIMARY KEY'); ?> </th> <?php } ?> <th><?php echo JText::_('SAMPLE DATA'); ?> </th> </tr> </thead> <tbody> <?php for ($i = 0; $i < count($this->newHeadings); $i++) { $heading = trim($this->newHeadings[$i]); foreach ($this->headings as $sKey => $sVal) { if (strtolower($heading) == strtolower($sVal)) { $sample = $this->data[0][$sKey]; } } ?> <tr> <td> <label> <input type="radio" name="createElements[<?php echo $heading; ?> ]" value="0" checked="checked"> <?php echo JText::_('NO'); ?> </label> <label> <input type="radio" name="createElements[<?php echo $heading; ?> ]" value="1"> <?php echo JText::_('YES'); ?> </label> </td> <td><?php echo $heading; ?> </td> <td><?php echo $elementTypes; ?> </td> <?php if ($this->table->db_primary_key == '') { ?> <td><input type="checkbox" name="key[<?php echo $heading; ?> ]" value="1" /></td> <?php } ?> <td><?php echo $sample; ?> </td> </tr> <?php } ?> </tbody> </table> <?php } ?> <?php echo "<H3>" . JText::_('EXISTING HEADINGS FOUND') . "</h3>"; ?> <table class="adminlist"> <thead> <tr> <th class="title"><?php echo JText::_('LABEL'); ?> </th> <?php if ($this->table->db_primary_key == '') { ?> <th class="title"><?php echo JText::_('PRIMARY KEY'); ?> </th> <?php } ?> <th><?php echo JText::_('SAMPLE DATA'); ?> </th> </tr> </thead> <tbody> <?php foreach ($this->matchedHeadings as $heading) { foreach ($this->headings as $sKey => $sVal) { if (strtolower($heading) == strtolower($sVal)) { $sample = $this->data[0][$sKey]; } } ?> <tr> <td><?php echo $heading; ?> </td> <?php if ($this->table->db_primary_key == '') { ?> <td> <input type="checkbox" name="key[<?php echo $heading; ?> ]" value="1" /> </td> <?php } ?> <td><?php echo $sample; ?> </td> </tr> <?php } ?> </tbody> </table> <input type="hidden" name="option" value="com_fabrik" /> <?php //@TODO not sure about this value: ?> <input type="hidden" name="table" value="<?php echo $this->table->db_table_name; ?> " /> <input type="hidden" name="fabrik_list" value="<?php echo $this->table->id; ?> " /> <input type="hidden" name="task" value="makeTableFromCSV" /> <input type="hidden" name="c" value="import" /> <input type="hidden" name="boxchecked" value="" /> <input type="hidden" name="drop_data" value="<?php echo JRequest::getVar('drop_data'); ?> " /> <input type="hidden" name="overwrite" value="<?php echo JRequest::getVar('overwrite'); ?> " /> <?php echo JHTML::_('form.token'); ?> </form> <?php }
/** * display the import CSV file form */ function display() { $this->tableid = JRequest::getVar('tableid', 0); $tableModel =& JModel::getInstance('Table', 'FabrikModel'); $tableModel->setId($this->tableid); $this->table =& $tableModel->getTable(); FabrikViewImport::import(); }