/** * @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); $func = $input->get_var('func', -1, FWS_Input::STRING); $url = PC_URL::get_submod_url(); $url->set('file', $file); $url->set('func', $func); $surl = clone $url; $pagination = new PC_Pagination(PC_ENTRIES_PER_PAGE, PC_DAO::get_functions()->get_count(0, PC_Project::CURRENT_ID, $file, $func)); $pagination->populate_tpl($url); $start = $pagination->get_start(); $funcs = array(); foreach (PC_DAO::get_functions()->get_list(array(0), $start, PC_ENTRIES_PER_PAGE, $file, $func) as $f) { $url = PC_URL::get_mod_url('file'); $url->set('path', $f->get_file()); $url->set('line', $f->get_line()); $url->set_anchor('l' . $f->get_line()); $funcs[] = array('id' => $f->get_id(), 'url' => $url->to_url(), 'func' => (string) $f, 'file' => $f->get_file(), 'line' => $f->get_line(), 'since' => implode(', ', $f->get_version()->get_min()), 'till' => implode(', ', $f->get_version()->get_max())); } $callurl = PC_URL::get_mod_url('filepart'); $callurl->set('id', '__ID__'); $callurl->set('type', 'func'); $this->request_formular(); $tpl->add_variables(array('get_code_url' => $callurl->to_url(), 'funcs' => $funcs, 'file' => $file, 'func' => $func, 'search_target' => $surl->to_url(), 'display_search' => $cookies->get_cookie('funcs_search') ? 'block' : 'none', 'cookie_name' => $cookies->get_prefix() . 'funcs_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 ''; }
public function perform_action() { $user = FWS_Props::get()->user(); $files = array(); foreach (FWS_FileUtils::get_list('phpman', false, false) as $file) { if (preg_match('/\\.html$/', $file)) { $files[] = 'phpman/' . $file; } } // store in session $user->set_session_data('phpref_files', $files); $user->set_session_data('phpref_aliases', array()); $user->set_session_data('phpref_versions', array()); // clear position, just to be sure $storage = new FWS_Progress_Storage_Session('pphprefscan_'); $storage->clear(); // clear previous data in the db PC_DAO::get_functions()->delete_by_project(PC_Project::PHPREF_ID); PC_DAO::get_classes()->delete_by_project(PC_Project::PHPREF_ID); $this->set_redirect(true, PC_URL::get_submod_url(0, 'cliscan')); $this->set_show_status_page(false); $this->set_action_performed(true); return ''; }
/** * Returns the method with given name. Will fetch it from db if not already present * * @param string $class the class-name * @param string $method the method-name * @return PC_Obj_Method the function or null if not found */ public function get_method($class, $method) { $lclass = strtolower($class); $lmethod = strtolower($method); if (!isset($this->missing['methods'][$lclass . '::' . $lmethod])) { // move the method over from the class, if necessary if (!isset($this->methods[$lclass . '::' . $lmethod])) { $cobj = $this->get_class($lclass); if ($cobj && $cobj->contains_method($lmethod)) { $this->methods[$lclass . '::' . $lmethod] = $cobj->get_method($lmethod); } } if (!isset($this->methods[$lclass . '::' . $lmethod])) { foreach ($this->options->get_projects() as $pid) { $f = PC_DAO::get_functions()->get_by_name($method, $pid, $class); if ($f) { $this->methods[$lclass . '::' . $lmethod] = $f; break; } } } } if (isset($this->methods[$lclass . '::' . $lmethod])) { return $this->methods[$lclass . '::' . $lmethod]; } $this->missing['methods'][$lclass . '::' . $lmethod] = true; return null; }
/** * Loads the fields from db, if not already done */ private function load_methods() { if ($this->methods === null) { $this->methods = array(); foreach (PC_DAO::get_functions()->get_list(array($this->id), 0, 0, '', '', $this->pid) as $method) { $this->methods[strtolower($method->get_name())] = $method; } } }
/** * Grabs a function from the given file * * @param string $file the file */ private function grab_function($file) { $func = new PC_PHPRef_Function($file); $res = $func->get_method(); if (count($res) == 0) { return; } if ($res[0] == 'alias') { list(, $funcname, $aliasclass, $aliasfunc) = $res; $this->aliases[] = array($funcname, $aliasclass, $aliasfunc); } else { if ($res[0] != 'deprecated') { list(, $classname, $method) = $res; // save method-version-information for later use if ($classname) { $this->versions[] = array($classname, $method->get_name(), $method->get_version()); } else { PC_DAO::get_functions()->create($method, 0, PC_Project::PHPREF_ID); } } } }
public function update_function($method, $classid) { PC_DAO::get_functions()->update($method, $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())); }
/** * Fetches the page from the specified file and parses it for information about the function */ public function finalize() { $options = new PC_Engine_Options(); $options->add_project(PC_Project::PHPREF_ID); $typecon = new PC_Engine_TypeContainer($options); $typecon->prefetch(); foreach ($this->versions as $vinfo) { list($classname, $funcname, $version) = $vinfo; $class = $typecon->get_class($classname); if ($class !== null) { $func = $class->get_method($funcname); if ($func !== null) { if ($func->get_version()->is_empty()) { $func->get_version()->set($version->get_min(), $version->get_max()); } PC_DAO::get_functions()->update($func, $class->get_id()); } } } // inherit version info to methods, if still empty foreach ($typecon->get_classes() as $c) { $version = $c->get_version(); foreach ($c->get_methods() as $m) { if ($m->get_version()->is_empty()) { $m->get_version()->set($version->get_min(), $version->get_max()); PC_DAO::get_functions()->update($m, $c->get_id()); } } } foreach ($this->aliases as $alias) { list($funcname, $aliasclass, $aliasfunc) = $alias; $aliasf = null; if ($aliasclass) { $class = $typecon->get_class($aliasclass); if ($class !== null) { $aliasf = $class->get_method($aliasfunc); } } else { $aliasf = $typecon->get_function($aliasfunc); } if ($aliasf !== null) { $aliasf->set_name($funcname); PC_DAO::get_functions()->create($aliasf, 0, PC_Project::PHPREF_ID); } } }
/** * 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; }