Esempio n. 1
0
 function action_export_items($input)
 {
     TikiLib::lib('tiki')->allocate_extra('tracker_export_items', function () use($input) {
         $trackerId = $input->trackerId->int();
         $definition = Tracker_Definition::get($trackerId);
         if (!$definition) {
             throw new Services_Exception_NotFound();
         }
         $perms = Perms::get('tracker', $trackerId);
         if (!$perms->export_tracker) {
             throw new Services_Exception_Denied(tr('Not allowed to export'));
         }
         $fields = array();
         foreach ((array) $input->listfields->int() as $fieldId) {
             if ($f = $definition->getField($fieldId)) {
                 $fields[$fieldId] = $f;
             }
         }
         if (0 === count($fields)) {
             throw new Services_Exception(tr('No valid field selected for export'), 400);
         }
         $showItemId = $input->showItemId->int();
         $showStatus = $input->showStatus->int();
         $showCreated = $input->showCreated->int();
         $showLastModif = $input->showLastModif->int();
         $keepItemlinkId = $input->keepItemlinkId->int();
         $keepCountryId = $input->keepCountryId->int();
         $dateFormatUnixTimestamp = $input->dateFormatUnixTimestamp->int();
         $encoding = $input->encoding->text();
         if (!in_array($encoding, array('UTF-8', 'ISO-8859-1'))) {
             $encoding = 'UTF-8';
         }
         $separator = $input->separator->none();
         $delimitorR = $input->delimitorR->none();
         $delimitorL = $input->delimitorL->none();
         $cr = $input->CR->none();
         $recordsMax = $input->recordsMax->int();
         $recordsOffset = $input->recordsOffset->int() - 1;
         $writeCsv = function ($fields) use($separator, $delimitorL, $delimitorR, $encoding, $cr) {
             $values = array();
             foreach ($fields as $v) {
                 $values[] = "{$delimitorL}{$v}{$delimitorR}";
             }
             $line = implode($separator, $values);
             $line = str_replace(array("\r\n", "\n", "<br/>", "<br />"), $cr, $line);
             if ($encoding === 'ISO-8859-1') {
                 echo utf8_decode($line) . "\n";
             } else {
                 echo $line . "\n";
             }
         };
         session_write_close();
         $trklib = TikiLib::lib('trk');
         $trklib->write_export_header($encoding, $trackerId);
         $header = array();
         if ($showItemId) {
             $header[] = 'itemId';
         }
         if ($showStatus) {
             $header[] = 'status';
         }
         if ($showCreated) {
             $header[] = 'created';
         }
         if ($showLastModif) {
             $header[] = 'lastModif';
         }
         foreach ($fields as $f) {
             $header[] = $f['name'] . ' -- ' . $f['fieldId'];
         }
         $writeCsv($header);
         /** @noinspection PhpParamsInspection */
         $items = $trklib->list_items($trackerId, $recordsOffset, $recordsMax, 'itemId_asc', $fields);
         $smarty = TikiLib::lib('smarty');
         $smarty->loadPlugin('smarty_modifier_tiki_short_datetime');
         foreach ($items['data'] as $row) {
             $toDisplay = array();
             if ($showItemId) {
                 $toDisplay[] = $row['itemId'];
             }
             if ($showStatus) {
                 $toDisplay[] = $row['status'];
             }
             if ($showCreated) {
                 if ($dateFormatUnixTimestamp) {
                     $toDisplay[] = $row['created'];
                 } else {
                     $toDisplay[] = smarty_modifier_tiki_short_datetime($row['created'], '', 'n');
                 }
             }
             if ($showLastModif) {
                 if ($dateFormatUnixTimestamp) {
                     $toDisplay[] = $row['lastModif'];
                 } else {
                     $toDisplay[] = smarty_modifier_tiki_short_datetime($row['lastModif'], '', 'n');
                 }
             }
             foreach ($row['field_values'] as $val) {
                 if ($keepItemlinkId && $val['type'] == 'r') {
                     $toDisplay[] = $val['value'];
                 } elseif ($keepCountryId && $val['type'] == 'y') {
                     $toDisplay[] = $val['value'];
                 } elseif ($dateFormatUnixTimestamp && $val['type'] == 'f') {
                     $toDisplay[] = $val['value'];
                 } elseif ($dateFormatUnixTimestamp && $val['type'] == 'j') {
                     $toDisplay[] = $val['value'];
                 } else {
                     $toDisplay[] = $trklib->get_field_handler($val, $row)->renderOutput(array('list_mode' => 'csv', 'CR' => $cr, 'delimitorL' => $delimitorL, 'delimitorR' => $delimitorR));
                 }
             }
             $writeCsv($toDisplay);
         }
     });
     exit;
 }
	<td style="text-align:right;" class="<?php 
            echo smarty_function_cycle(array('advance' => false), $this);
            ?>
"><?php 
            echo $this->_tpl_vars['listpages'][$this->_sections['changes']['index']]['hits'];
            ?>
</td>
<?php 
        }
        if ($this->_tpl_vars['wiki_list_lastmodif'] == 'y') {
            ?>
	<td class="<?php 
            echo smarty_function_cycle(array('advance' => false), $this);
            ?>
"><?php 
            echo is_array($_tmp = $this->_tpl_vars['listpages'][$this->_sections['changes']['index']]['lastModif']) ? $this->_run_mod_handler('tiki_short_datetime', true, $_tmp) : smarty_modifier_tiki_short_datetime($_tmp);
            ?>
</td>
<?php 
        }
        if ($this->_tpl_vars['wiki_list_creator'] == 'y') {
            ?>
	<td class="<?php 
            echo smarty_function_cycle(array('advance' => false), $this);
            ?>
"><?php 
            echo is_array($_tmp = $this->_tpl_vars['listpages'][$this->_sections['changes']['index']]['creator']) ? $this->_run_mod_handler('userlink', true, $_tmp) : smarty_modifier_userlink($_tmp);
            ?>
</td>
<?php 
        }
"><?php 
            echo $this->_tpl_vars['msgs'][$this->_sections['ix']['index']]['subject'];
            ?>
</a>
  </td>
  <td class="<?php 
            echo smarty_function_cycle(array('advance' => false), $this);
            ?>
"><?php 
            echo $this->_tpl_vars['msgs'][$this->_sections['ix']['index']]['user_from'];
            ?>
</td><td class="<?php 
            echo smarty_function_cycle(array(), $this);
            ?>
"><?php 
            echo is_array($_tmp = $this->_tpl_vars['msgs'][$this->_sections['ix']['index']]['date']) ? $this->_run_mod_handler('tiki_short_datetime', true, $_tmp) : smarty_modifier_tiki_short_datetime($_tmp);
            ?>
</td></tr>
  <?php 
        }
    }
    ?>
  </table>
  </div>
</div>
<?php 
}
?>

<?php 
if ($this->_tpl_vars['feature_tasks'] == 'y' && $this->_tpl_vars['mytiki_tasks'] == 'y') {
Esempio n. 4
0
 function action_export_items($input)
 {
     @ini_set('max_execution_time', 0);
     //will not work in safe_mode is on
     $trackerId = $input->trackerId->int();
     $definition = Tracker_Definition::get($trackerId);
     if (!$definition) {
         throw new Services_Exception_NotFound();
     }
     $perms = Perms::get('tracker', $trackerId);
     if (!$perms->export_tracker) {
         throw new Services_Exception(tr('Not allowed to export'), 403);
     }
     $fields = array();
     foreach ((array) $input->listfields->int() as $fieldId) {
         if ($f = $definition->getField($fieldId)) {
             $fields[$fieldId] = $f;
         }
     }
     if (0 === count($fields)) {
         throw new Services_Exception(tr('No valid field selected for export'), 400);
     }
     $showItemId = $input->showItemId->int();
     $showStatus = $input->showStatus->int();
     $showCreated = $input->showCreated->int();
     $showLastModif = $input->showLastModif->int();
     $keepItemlinkId = $input->keepItemlinkId->int();
     $encoding = $input->encoding->text();
     if (!in_array($encoding, array('UTF-8', 'ISO-8859-1'))) {
         $encoding = 'UTF-8';
     }
     $separator = $input->separator->none();
     $delimitorR = $input->delimitorR->none();
     $delimitorL = $input->delimitorL->none();
     $cr = $input->CR->none();
     $recordsMax = $input->recordsMax->int();
     $recordsOffset = $input->recordsOffset->int() - 1;
     session_write_close();
     $trklib = TikiLib::lib('trk');
     $trklib->write_export_header($encoding, $trackerId);
     $header = array();
     if ($showItemId) {
         $header[] = 'itemId';
     }
     if ($showStatus) {
         $header[] = 'status';
     }
     if ($showCreated) {
         $header[] = 'created';
     }
     if ($showLastModif) {
         $header[] = 'lastModif';
     }
     foreach ($fields as $f) {
         $header[] = $f['name'] . ' -- ' . $f['fieldId'];
     }
     $this->writeCsv($header, $separator, $delimitorL, $delimitorR, $encoding);
     $items = $trklib->list_items($trackerId, $recordsOffset, $recordsMax, 'itemId_asc', $fields);
     $smarty = TikiLib::lib('smarty');
     $smarty->loadPlugin('smarty_modifier_tiki_short_datetime');
     foreach ($items['data'] as $row) {
         $toDisplay = array();
         if ($showItemId) {
             $toDisplay[] = $row['itemId'];
         }
         if ($showStatus) {
             $toDisplay[] = $row['status'];
         }
         if ($showCreated) {
             $toDisplay[] = smarty_modifier_tiki_short_datetime($row['created'], '', 'n');
         }
         if ($showLastModif) {
             $toDisplay[] = smarty_modifier_tiki_short_datetime($row['lastModif'], '', 'n');
         }
         foreach ($row['field_values'] as $val) {
             if ($keepItemlinkId && $val['type'] == 'r') {
                 $toDisplay[] = $val['value'];
             } else {
                 $toDisplay[] = $trklib->get_field_handler($val)->renderOutput(array('list_mode' => 'csv'));
             }
         }
         $this->writeCsv($toDisplay, $separator, $delimitorL, $delimitorR, $encoding, $cr);
     }
     exit;
 }
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'tiki_short_datetime', 'tiki-top_bar.tpl', 4, false), array('function', 'phplayers', 'tiki-top_bar.tpl', 12, false))), $this);
?>
This is TikiWiki 1.9.5 -Sirius- &#169; 2002&#8211;2006 by the <a href="http://tikiwiki.org" 
title="tikiwiki.org">Tiki community</a>
<?php 
if ($this->_tpl_vars['feature_calendar'] == 'y' && $this->_tpl_vars['tiki_p_view_calendar'] == 'y') {
    ?>
  <a href="tiki-calendar.php"><?php 
    echo is_array($_tmp = time()) ? $this->_run_mod_handler('tiki_short_datetime', true, $_tmp) : smarty_modifier_tiki_short_datetime($_tmp);
    ?>
</a>
<?php 
} else {
    ?>
  <?php 
    echo is_array($_tmp = time()) ? $this->_run_mod_handler('tiki_short_datetime', true, $_tmp) : smarty_modifier_tiki_short_datetime($_tmp);
    ?>

<?php 
}
if ($this->_tpl_vars['tiki_p_admin'] == 'y' && $this->_tpl_vars['feature_debug_console'] == 'y') {
    ?>
  &#160;//&#160;<a href="javascript:toggle('debugconsole');">debug</a>
<?php 
}
if ($this->_tpl_vars['feature_phplayers'] == 'y' && $this->_tpl_vars['feature_siteidentity'] == 'y' && $this->_tpl_vars['feature_sitemenu'] == 'y') {
    echo smarty_function_phplayers(array('id' => 42, 'type' => 'horiz'), $this);
    ?>

<?php 
}