/** * @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)); }
/** * Deletes all class-fields from the project with given id * * @param int $id the project-id * @return int the number of affected rows */ public function delete_by_project($id) { $db = FWS_Props::get()->db(); if (!PC_Utils::is_valid_project_id($id)) { FWS_Helper::def_error('intge0', 'id', $id); } $stmt = $db->get_prepared_statement('DELETE FROM ' . PC_TB_CLASS_FIELDS . ' WHERE project_id = :id'); $stmt->bind(':id', $id); $db->execute($stmt->get_statement()); return $db->get_affected_rows(); }
/** * @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); }
private function get_call($call, $types) { if ($call->get_class() && $call->get_class() == PC_Obj_Class::UNKNOWN) { $classname = '<i>UNKNOWN</i>'; } else { $classname = $call->get_class(); } $url = PC_URL::get_mod_url('class'); $url->set('name', $classname); $str = ''; if ($classname) { $str .= '<a href="' . $url->to_url() . '">' . $classname . '</a>'; $str .= $call->is_static() ? '::' : '->'; } $func = $types->get_method_or_func($call->get_class(), $call->get_function()); if ($func && $func->get_line()) { $str .= '<a href="' . PC_Utils::get_code_url($func) . '">' . $call->get_function() . '</a>('; } else { $str .= $call->get_function() . '('; } $str .= implode(', ', $call->get_arguments()); $str .= ')'; return $str; }
/** * Sets the project with given id to the current one * * @param int $id the project-id */ public function set_current($id) { if (!PC_Utils::is_valid_project_id($id)) { FWS_Helper::def_error('intge0', 'id', $id); } $db = FWS_Props::get()->db(); $db->update(PC_TB_PROJECTS, '', array('current' => 0)); $db->update(PC_TB_PROJECTS, 'WHERE id = ' . $id, array('current' => 1)); }
/** * Builds an URL to the given location * * @param string $classfile the file of the class * @param PC_Obj_Location $loc the location of the item * @return string the URL */ private function get_url($classfile, $loc) { if ($loc->get_line() == 0) { return $loc->get_file(); } if ($loc->get_file() == $classfile) { return '#l' . $loc->get_line(); } return PC_Utils::get_code_url($loc); }