/** * @see FWS_Module::run() */ public function run() { $tpl = FWS_Props::get()->tpl(); $input = FWS_Props::get()->input(); $cookies = FWS_Props::get()->cookies(); $file = $input->get_var('file', -1, FWS_Input::STRING); $class = $input->get_var('class', -1, FWS_Input::STRING); $function = $input->get_var('function', -1, FWS_Input::STRING); $url = PC_URL::get_mod_url(); $url->set('file', $file); $url->set('class', $class); $url->set('function', $function); $surl = clone $url; $typecon = new PC_Engine_TypeContainer(new PC_Engine_Options()); $pagination = new PC_Pagination(PC_ENTRIES_PER_PAGE, PC_DAO::get_calls()->get_count_for($file, $class, $function)); $pagination->populate_tpl($url); $start = $pagination->get_start(); $calls = array(); foreach (PC_DAO::get_calls()->get_list($start, PC_ENTRIES_PER_PAGE, $file, $class, $function) as $call) { /* @var $call PC_Obj_Call */ $url = PC_URL::get_mod_url('file'); $url->set('path', $call->get_file()); $url->set('line', $call->get_line()); $url->set_anchor('l' . $call->get_line()); $func = $typecon->get_method_or_func($call->get_class(), $call->get_function()); $calls[] = array('id' => $call->get_id(), 'call' => $this->get_call($call, $typecon), 'file' => $call->get_file(), 'line' => $call->get_line(), 'url' => $url->to_url(), 'since' => $func ? implode(', ', $func->get_version()->get_min()) : '', 'till' => $func ? implode(', ', $func->get_version()->get_max()) : ''); } $callurl = PC_URL::get_mod_url('filepart'); $callurl->set('id', '__ID__'); $callurl->set('type', 'call'); $this->request_formular(); $tpl->add_variables(array('calls' => $calls, 'get_code_url' => $callurl->to_url(), 'file' => $file, 'class' => $class, 'function' => $function, 'search_target' => $surl->to_url(), 'display_search' => $cookies->get_cookie('calls_search') ? 'block' : 'none', 'cookie_name' => $cookies->get_prefix() . 'calls_search')); }
/** * @see FWS_Module::run() */ public function run() { $input = FWS_Props::get()->input(); $doc = FWS_Props::get()->doc(); $id = $input->get_var('id', 'get', FWS_Input::INTEGER); $type = $input->correct_var('type', 'get', FWS_Input::STRING, array('call', 'var', 'func', 'const', 'error'), 'call'); if ($id === null) { $this->report_error(); return; } $loc = null; switch ($type) { case 'call': $loc = PC_DAO::get_calls()->get_by_id($id); break; case 'var': $loc = PC_DAO::get_vars()->get_by_id($id); break; case 'func': $loc = PC_DAO::get_functions()->get_by_id($id); break; case 'const': $loc = PC_DAO::get_constants()->get_by_id($id); break; case 'error': $loc = PC_DAO::get_errors()->get_by_id($id); if ($loc === null) { $this->report_error(); return; } $loc = $loc->get_loc(); break; } if (!is_file($loc->get_file())) { $this->report_error(); return; } $lines = explode("\n", file_get_contents($loc->get_file())); $start_line = max(1, $loc->get_line() - 4); $end_line = min(count($lines), $loc->get_line() + 2); $code = ''; for ($i = $start_line; $i <= $end_line; $i++) { $code .= $lines[$i - 1] . "\n"; } $code = PC_Utils::highlight_string($code, $start_line, $loc->get_line(), false); $renderer = $doc->use_raw_renderer(); $renderer->set_content($code); }
public function run($args) { $project = FWS_Props::get()->project(); $options = new PC_Engine_Options(); $options->set_report_unused(true); $options->set_report_argret_strictly($project->get_report_argret_strictly()); $options->add_project($project->get_id()); foreach ($project->get_project_deps() as $pid) { $options->add_project($pid); } foreach ($project->get_req() as $r) { if ($r['type'] == 'min') { $options->add_min_req($r['name'], $r['version']); } else { $options->add_max_req($r['name'], $r['version']); } } $env = new PC_Engine_Env($options); $ascanner = new PC_Engine_StmtScannerFrontend($env); $msgs = array(); foreach ($args as $file) { try { $ascanner->scan_file($file); } catch (PC_Engine_Exception $e) { $msgs[] = $e->__toString(); } } if (count($env->get_types()->get_calls())) { PC_DAO::get_calls()->create_bulk($env->get_types()->get_calls()); } foreach ($env->get_errors()->get() as $err) { PC_DAO::get_errors()->create($err); } foreach ($ascanner->get_vars() as $vars) { foreach ($vars as $var) { PC_DAO::get_vars()->create($var); } } // write messages to shared data $mutex = new FWS_MutexFile(PC_CLI_MUTEX_FILE); $mutex->aquire(); $data = unserialize($mutex->read()); /* @var $data PC_JobData */ $data->add_errors($msgs); $mutex->write(serialize($data)); $mutex->close(); }
/** * @see FWS_Module::run() */ public function run() { $tpl = FWS_Props::get()->tpl(); $input = FWS_Props::get()->input(); $line = $input->get_var('line', 'get', FWS_Input::INTEGER); if (!isset($_GET['path'])) { $this->report_error(); return; } $path = urldecode($_GET['path']); if (PC_DAO::get_classes()->get_count_for_file($path) == 0 && PC_DAO::get_calls()->get_count_for($path) == 0) { $this->report_error(); return; } $source = PC_Utils::highlight_file($path, $line); $tpl->add_variables(array('source' => $source)); }
public function perform_action() { $input = FWS_Props::get()->input(); $user = FWS_Props::get()->user(); $folderstr = $input->get_var('folders', 'post', FWS_Input::STRING); $exclstr = $input->get_var('exclude', 'post', FWS_Input::STRING); $files = array(); $folders = FWS_Array_Utils::advanced_explode("\n", $folderstr); $excl = FWS_Array_Utils::advanced_explode("\n", $exclstr); FWS_Array_Utils::trim($excl); // determine files to scan foreach ($folders as $folder) { $folder = trim($folder); if (is_file($folder)) { $files[] = $folder; } else { foreach (FWS_FileUtils::get_list($folder, true, true) as $item) { if (!$this->is_excluded($item, $excl)) { $files[] = $item; } } } } // clear position, just to be sure $storage = new FWS_Progress_Storage_Session('pstmtscan_'); $storage->clear(); // store in session $user->set_session_data('stmtscan_files', $files); // store in project $project = FWS_Props::get()->project(); $project->set_stmt_folders($folderstr); $project->set_stmt_exclude($exclstr); PC_DAO::get_projects()->update($project); // clear previous data in the db PC_DAO::get_vars()->delete_by_project($project->get_id()); PC_DAO::get_calls()->delete_by_project($project->get_id()); PC_DAO::get_errors()->delete_by_type(PC_Obj_Error::get_types_of(PC_Obj_Error::R_STMTSCANNER), $project->get_id()); $this->set_redirect(true, PC_URL::get_submod_url(0, 'cliscan')); $this->set_show_status_page(false); $this->set_action_performed(true); return ''; }
public function perform_action() { $input = FWS_Props::get()->input(); $id = $input->get_var('id', 'get', FWS_Input::STRING); if (!FWS_Helper::is_integer($id) || $id <= 0) { return 'The id is invalid'; } PC_DAO::get_calls()->delete_by_project($id); PC_DAO::get_classes()->delete_by_project($id); PC_DAO::get_classfields()->delete_by_project($id); PC_DAO::get_constants()->delete_by_project($id); PC_DAO::get_errors()->delete_by_project($id); PC_DAO::get_functions()->delete_by_project($id); PC_DAO::get_vars()->delete_by_project($id); $this->set_redirect(false); $this->set_success_msg('The project has been cleaned successfully'); $this->set_show_status_page(true); $this->set_action_performed(true); return ''; }
public function perform_action() { $input = FWS_Props::get()->input(); $idstr = $input->get_var('ids', 'get', FWS_Input::STRING); $ids = FWS_Array_Utils::advanced_explode(',', $idstr); if (!FWS_Array_Utils::is_numeric($ids)) { return 'Got an invalid id-string'; } PC_DAO::get_projects()->delete($ids); foreach ($ids as $id) { PC_DAO::get_calls()->delete_by_project($id); PC_DAO::get_classes()->delete_by_project($id); PC_DAO::get_classfields()->delete_by_project($id); PC_DAO::get_constants()->delete_by_project($id); PC_DAO::get_errors()->delete_by_project($id); PC_DAO::get_functions()->delete_by_project($id); PC_DAO::get_vars()->delete_by_project($id); } $this->set_redirect(false); $this->set_show_status_page(false); $this->set_action_performed(true); return ''; }