/** * @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); $name = $input->get_var('name', -1, FWS_Input::STRING); $url = PC_URL::get_submod_url(); $url->set('file', $file); $url->set('name', $name); $surl = clone $url; $pagination = new PC_Pagination(PC_ENTRIES_PER_PAGE, PC_DAO::get_constants()->get_count_for(0, $file, $name)); $pagination->populate_tpl($url); $start = $pagination->get_start(); $consts = array(); $constants = PC_DAO::get_constants()->get_list(array(0), $file, $name, PC_Project::CURRENT_ID, $start, PC_ENTRIES_PER_PAGE); foreach ($constants as $const) { $url = PC_URL::get_mod_url('file'); $url->set('path', $const->get_file()); $url->set('line', $const->get_line()); $url->set_anchor('l' . $const->get_line()); $consts[] = array('id' => $const->get_id(), 'name' => $const->get_name(), 'type' => (string) $const->get_type(), 'file' => $const->get_file(), 'line' => $const->get_line(), 'url' => $url->to_url()); } $callurl = PC_URL::get_mod_url('filepart'); $callurl->set('id', '__ID__'); $callurl->set('type', 'const'); $this->request_formular(); $tpl->add_variables(array('consts' => $consts, 'get_code_url' => $callurl->to_url(), 'file' => $file, 'name' => $name, 'search_target' => $surl->to_url(), 'display_search' => $cookies->get_cookie('consts_search') ? 'block' : 'none', 'cookie_name' => $cookies->get_prefix() . 'consts_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 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('ptypescan_'); $storage->clear(); // store in session $user->set_session_data('typescan_files', $files); // store in project $project = FWS_Props::get()->project(); $project->set_type_folders($folderstr); $project->set_type_exclude($exclstr); PC_DAO::get_projects()->update($project); // clear previous data in the db PC_DAO::get_classes()->delete_by_project($project->get_id()); PC_DAO::get_functions()->delete_by_project($project->get_id()); PC_DAO::get_constants()->delete_by_project($project->get_id()); PC_DAO::get_classfields()->delete_by_project($project->get_id()); PC_DAO::get_errors()->delete_by_type(PC_Obj_Error::get_types_of(PC_Obj_Error::R_TYPESCANNER), $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 run($args) { $project = FWS_Props::get()->project(); $options = new PC_Engine_Options(); foreach ($project->get_project_deps() as $pid) { $options->add_project($pid); } $env = new PC_Engine_Env($options); $tscanner = new PC_Engine_TypeScannerFrontend($env); $msgs = array(); foreach ($args as $file) { try { $tscanner->scan_file($file); } catch (PC_Engine_Exception $e) { $msgs[] = $e->__toString(); } } foreach ($env->get_types()->get_classes() as $class) { PC_DAO::get_classes()->create($class); } foreach ($env->get_types()->get_constants() as $const) { PC_DAO::get_constants()->create($const); } foreach ($env->get_types()->get_functions() as $func) { PC_DAO::get_functions()->create($func); } foreach ($env->get_errors()->get() as $err) { PC_DAO::get_errors()->create($err); } // write msgs 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(); }
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 ''; }
/** * Returns the (free) constant with given name. Will fetch it from db if not already present * * @param string $name the constant-name * @return PC_Obj_Constant the constant or null if not found */ public function get_constant($name) { if (empty($name)) { return null; } $lname = strtolower($name); if (!isset($this->missing['consts'][$lname])) { if (!isset($this->constants[$lname])) { foreach ($this->options->get_projects() as $pid) { $c = PC_DAO::get_constants()->get_by_name($name, $pid); if ($c) { $this->constants[$lname] = $c; break; } } } } if (isset($this->constants[$lname])) { return $this->constants[$lname]; } $this->missing['consts'][$lname] = true; return null; }
/** * Loads the constants from db, if not already done */ private function load_constants() { if ($this->constants === null) { $this->constants = array(); foreach (PC_DAO::get_constants()->get_list(array($this->id), '', '', $this->pid) as $const) { $this->constants[strtolower($const->get_name())] = $const; } } }
public function create_constant($const, $classid) { return PC_DAO::get_constants()->create($const, $classid); }
/** * @see FWS_Module::run() */ public function run() { $tpl = FWS_Props::get()->tpl(); $tpl->add_variables(array('classcount' => PC_DAO::get_classes()->get_count(), 'funccount' => PC_DAO::get_functions()->get_count(), 'constcount' => PC_DAO::get_constants()->get_count())); }
/** * Builds the classes from given rows completely, i.e. without lazy-loading * * @param array $rows the rows * @param int $pid the project-id * @return array the class-objects */ private function build_complete_classes($rows, $pid) { $classes = array(); foreach ($rows as $row) { $classes[$row['id']] = $this->build_class($row, $pid, false); } $cids = array_keys($classes); foreach (PC_DAO::get_constants()->get_list($cids, '', '', $pid) as $const) { $classes[$const->get_class()]->add_constant($const); } foreach (PC_DAO::get_classfields()->get_all($cids, $pid) as $field) { $classes[$field->get_class()]->add_field($field); } foreach (PC_DAO::get_functions()->get_list($cids, 0, 0, '', '', $pid) as $method) { $classes[$method->get_class()]->add_method($method); } return $classes; }