/** * Get a database explain statement. * * @param string $query The query to explain. * * @return string Formatted output * * @since 1.0 */ public function getExplain($query) { $db = $this->database; $db->setDebug(false); // Run an EXPLAIN EXTENDED query on the SQL query if possible: $explain = ''; $tableFormat = new TableFormat(); if (in_array($db->name, ['mysqli', 'mysql', 'postgresql'])) { $dbVersion56 = strncmp($db->name, 'mysql', 5) == 0 && version_compare($db->getVersion(), '5.6', '>='); if (stripos($query, 'select') === 0 || $dbVersion56 && (stripos($query, 'delete') === 0 || stripos($query, 'update') === 0)) { $db->setQuery('EXPLAIN ' . ($dbVersion56 ? 'EXTENDED ' : '') . $query); if ($db->execute()) { $explain = $tableFormat->fromArray($db->loadAssocList()); } else { $explain = sprintf(g11n3t('Failed EXPLAIN on query: %s'), htmlspecialchars($query)); } } } $db->setDebug(true); return $explain; }
/** * Prints out translated and untranslated strings. * * @return string HTML markup for language debug * * @since 1.0 */ protected function renderLanguageStrings() { $html = array(); $items = g11n::get('processedItems'); $html[] = '<table class="table table-hover table-condensed">'; $html[] = '<tr>'; $html[] = '<th>' . g11n3t('String') . '</th><th>' . g11n3t('File (line)') . '</th><th></th>'; $html[] = '</tr>'; $tableFormat = new TableFormat(); $i = 0; foreach ($items as $string => $item) { $color = '-' == $item->status ? '#ffb2b2;' : '#e5ff99;'; $html[] = '<tr>'; $html[] = '<td style="border-left: 7px solid ' . $color . '">' . htmlentities($string) . '</td>'; $html[] = '<td>' . str_replace(JPATH_ROOT, 'ROOT', $item->file) . ' (' . $item->line . ')</td>'; $html[] = '<td><span class="btn btn-mini" onclick="$(\'#langStringTrace' . $i . '\').slideToggle();">Trace</span></td>'; $html[] = '</tr>'; $html[] = '<tr><td colspan="4" id="langStringTrace' . $i . '" style="display: none;">' . $tableFormat->fromTrace($item->trace) . '</td></tr>'; $i++; } $html[] = '</table>'; return implode("\n", $html); }