<?php /** * @package EasyCreator * @subpackage Views * @author Nikolai Plath * @author Created on 28-Sep-2009 * @license GNU/GPL, see JROOT/LICENSE.php */ //-- No direct access defined('_JEXEC') || die('=;)'); $phpcpd = new EcrPearHelperPhpcpd(); if (!$phpcpd->checkEnv()) { echo 'Env check failed.. cannot continue :('; return; } ?> <div class="ecr_floatbox"> Min-Lines:<br /> <input type="text" id="phpcpd_min_lines" size="5" value="5" /> <br /> Min-Tokens:<br /> <input type="text" id="phpcpd_min_tokens" size="5" value="70" /> <br /><br /> <!-- @todo activate when phpcpd supports multiple dirs <div class="ecr_button" onclick="doPHPCPD('<?php echo $this->ecr_project; ?> ');">Find duplicated Code</div>
/** * Runs PHP Copy & Paste detector. * * @return void */ public function phpcpd() { $input = JFactory::getApplication()->input; $path = $input->getPath('path'); $arguments = array(); $arguments['min-lines'] = $input->getInt('min-lines', 5); $arguments['min-tokens'] = $input->getInt('min-tokens', 70); $response = array(); if (!$path) { $response['status'] = 0; $response['text'] = jgettext('No path set'); $response['console'] = ''; echo json_encode($response); return; } ob_start(); $phpcpd = new EcrPearHelperPhpcpd(); $results = $phpcpd->detect($arguments, $path); $response['text'] = ob_get_contents(); ob_end_clean(); $response['console'] = htmlentities($results); $response['status'] = 1; echo json_encode($response); jexit(); }