/** * @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() { $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); $url = PC_URL::get_submod_url(); $url->set('file', $file); $url->set('class', $class); $surl = clone $url; $pagination = new PC_Pagination(PC_ENTRIES_PER_PAGE, PC_DAO::get_classes()->get_count_for($class, $file)); $pagination->populate_tpl($url); $start = $pagination->get_start(); $classes = array(); foreach (PC_DAO::get_classes()->get_list($start, PC_ENTRIES_PER_PAGE, $class, $file) as $c) { $sig = $c->get_signature(true); $sig = preg_replace_callback('/#(.+?)#/', function ($match) { return "<a href=\"" . PC_URL::get_mod_url('class')->set('name', $match[1])->to_url() . "\">" . $match[1] . "</a>"; }, $sig); $classes[] = array('name' => $sig, 'file' => $c->get_file(), 'line' => $c->get_line(), 'since' => implode(', ', $c->get_version()->get_min()), 'till' => implode(', ', $c->get_version()->get_max())); } $this->request_formular(); $tpl->add_variables(array('classes' => $classes, 'file' => $file, 'class' => $class, 'search_target' => $surl->to_url(), 'display_search' => $cookies->get_cookie('classes_search') ? 'block' : 'none', 'cookie_name' => $cookies->get_prefix() . 'classes_search')); }
/** * @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() { $tpl = FWS_Props::get()->tpl(); $input = FWS_Props::get()->input(); $cookies = FWS_Props::get()->cookies(); $scope = $input->get_var('scope', -1, FWS_Input::STRING); $name = $input->get_var('name', -1, FWS_Input::STRING); $url = PC_URL::get_mod_url(); $url->set('scope', $scope); $url->set('name', $name); $surl = clone $url; $total = PC_DAO::get_vars()->get_count_for($scope, $name); $pagination = new PC_Pagination(PC_ENTRIES_PER_PAGE, $total); $pagination->populate_tpl($url); $start = $pagination->get_start(); $vars = array(); foreach (PC_DAO::get_vars()->get_list($start, PC_ENTRIES_PER_PAGE, $scope, $name) as $var) { /* @var $var PC_Obj_Variable */ $url = PC_URL::get_mod_url('file'); $url->set('path', $var->get_file()); $url->set('line', $var->get_line()); $url->set_anchor('l' . $var->get_line()); $vscope = $var->get_scope(); if ($vscope == PC_Obj_Variable::SCOPE_GLOBAL) { $vscope = '<i>Global</i>'; } $vars[] = array('id' => $var->get_id(), 'scope' => $vscope, 'name' => '$' . $var->get_name(), 'type' => $var->get_type(), 'file' => $var->get_file(), 'line' => $var->get_line(), 'url' => $url->to_url()); } $callurl = PC_URL::get_mod_url('filepart'); $callurl->set('id', '__ID__'); $callurl->set('type', 'var'); $this->request_formular(); $tpl->add_variables(array('vars' => $vars, 'get_code_url' => $callurl->to_url(), 'scope' => $scope, 'name' => $name, 'search_target' => $surl->to_url(), 'display_search' => $cookies->get_cookie('vars_search') ? 'block' : 'none', 'cookie_name' => $cookies->get_prefix() . 'vars_search')); }
public function perform_action() { PC_DAO::get_projects()->create(new PC_Project(1, '', time(), '', '', '', '', false)); $this->set_redirect(false); $this->set_show_status_page(false); $this->set_action_performed(true); return ''; }
public function perform_action() { $input = FWS_Props::get()->input(); $pid = $input->get_var('id', 'get', FWS_Input::INTEGER); if ($pid == null) { return ''; } if ($input->isset_var('add', 'post')) { $type = $input->correct_var('add_type', 'post', FWS_Input::STRING, array('min', 'max'), 'min'); $name = $input->get_var('add_name', 'post', FWS_Input::STRING); $version = $input->get_var('add_version', 'post', FWS_Input::STRING); if ($name == '') { return 'Please specify the name of the component'; } if ($version == '') { return 'Please specify the version'; } PC_DAO::get_projects()->add_req($pid, $type, $name, $version); } else { $name = $input->get_var('name', 'post', FWS_Input::STRING); $start_day = $input->get_var('start_day', 'post', FWS_Input::INTEGER); $start_month = $input->get_var('start_month', 'post', FWS_Input::INTEGER); $start_year = $input->get_var('start_year', 'post', FWS_Input::INTEGER); $start = mktime(0, 0, 0, $start_month, $start_day, $start_year); $projdeps = $input->get_var('projdeps', 'post'); $report_argret_strictly = $input->isset_var('report_argret_strictly', 'post'); $edit_type = $input->get_var('edit_type', 'post'); $edit_name = $input->get_var('edit_name', 'post'); $edit_version = $input->get_var('edit_version', 'post'); $proj = PC_DAO::get_projects()->get_by_id($pid); if (!$proj) { return ''; } if ($name == '') { return 'Please specify the project name'; } $proj->set_name($name); $proj->set_created($start); $proj->set_report_argret_strictly($report_argret_strictly); $proj->set_project_deps(is_array($projdeps) ? array_keys($projdeps) : array()); $req = $proj->get_req(); foreach ($req as &$r) { $r['type'] = $edit_type[$r['id']]; $r['name'] = $edit_name[$r['id']]; $r['version'] = $edit_version[$r['id']]; } $proj->set_req($req); PC_DAO::get_projects()->update($proj); } $this->set_success_msg('The version has been added'); $this->set_redirect(true, PC_URL::get_mod_url('edit_project')->set('id', $pid)); $this->set_show_status_page(false); $this->set_action_performed(true); return ''; }
/** * @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); $msg = $input->get_var('msg', -1, FWS_Input::STRING); $types = $input->get_var('types', -1); if (!FWS_Array_Utils::is_numeric($types)) { $types = array(); } $url = PC_URL::get_mod_url(); $url->set('file', $file); $url->set('msg', $msg); if (count($types)) { $url->set('types', $types); } $surl = clone $url; $pagination = new PC_Pagination(PC_ENTRIES_PER_PAGE, PC_DAO::get_errors()->get_count_with($file, $msg, $types)); $pagination->populate_tpl($url); $start = $pagination->get_start(); $errs = array(); $errors = PC_DAO::get_errors()->get_list(PC_Project::CURRENT_ID, $start, PC_ENTRIES_PER_PAGE, $file, $msg, $types); foreach ($errors as $err) { /* @var $err PC_Obj_Error */ $url = PC_URL::get_mod_url('file'); $url->set('path', $err->get_loc()->get_file()); $url->set('line', $err->get_loc()->get_line()); $url->set_anchor('l' . $err->get_loc()->get_line()); $errs[] = array('id' => $err->get_id(), 'type' => PC_Obj_Error::get_type_name($err->get_type()), 'message' => $this->get_msg($err), 'file' => $err->get_loc()->get_file(), 'line' => $err->get_loc()->get_line(), 'fileurl' => $url->to_url(), 'typeurl' => PC_URL::get_mod_url()->set('types', array($err->get_type()))->to_url()); } $this->request_formular(); $typecbs = array(); $row = -1; $i = 0; $error_types = PC_Obj_Error::get_types(); asort($error_types); foreach ($error_types as $type => $name) { if ($i % 4 == 0) { $typecbs[++$row] = array(); } $typecbs[$row][] = array('name' => 'types[' . $type . ']', 'selected' => count($types) == 0 || in_array($type, $types), 'value' => $type, 'text' => $name); $i++; } for ($i = $i % 4; $i < 4; $i++) { $typecbs[$row][] = array('name' => ''); } $callurl = PC_URL::get_mod_url('filepart'); $callurl->set('id', '__ID__'); $callurl->set('type', 'error'); $tpl->add_variables(array('errors' => $errs, 'search_target' => $surl->to_url(), 'display_search' => $cookies->get_cookie('error_search') ? 'block' : 'none', 'cookie_name' => $cookies->get_prefix() . 'error_search', 'file' => $file, 'msg' => $msg, 'typecbs' => $typecbs, 'get_code_url' => $callurl->to_url())); }
public function perform_action() { $input = FWS_Props::get()->input(); $pid = $input->get_var('project', 'post', FWS_Input::INTEGER); if ($pid < 0) { return 'Invalid project-id'; } PC_DAO::get_projects()->set_current($pid); $this->set_action_performed(true); $this->set_show_status_page(false); $this->set_redirect(false); return ''; }
public function perform_action() { $input = FWS_Props::get()->input(); $pid = $input->get_var('id', 'get', FWS_Input::INTEGER); $vid = $input->get_var('vid', 'get', FWS_Input::INTEGER); if ($pid == null || $vid == null) { return TDL_GENERAL_ERROR; } PC_DAO::get_projects()->del_req($vid); $this->set_success_msg('The requirement has been deleted'); $this->set_redirect(true, PC_URL::get_mod_url('edit_project')->set('id', $pid)); $this->set_show_status_page(false); $this->set_action_performed(true); return ''; }
/** * @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); }
/** * Builds an URL to the code for given location. * * @param PC_Obj_Location $loc the location * @return string the URL */ public static function get_code_url($loc) { $file = $loc->get_file(); $line = $loc->get_line(); if ($file) { $classes = PC_DAO::get_classes()->get_by_file($file); if (count($classes) == 1) { $url = PC_URL::get_mod_url('class')->set('name', $classes[0]->get_name()); } else { $url = PC_URL::get_mod_url('file')->set('path', $file); } $url->set_anchor('l' . $line); return $url->to_url(); } return '#'; }
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('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 ''; }
/** * @see FWS_Module::init() * * @param FWS_Document $doc */ public function init($doc) { $input = FWS_Props::get()->input(); $project = FWS_Props::get()->project(); $renderer = $doc->use_default_renderer(); $name = $input->get_var('name', 'get', FWS_Input::STRING); $pid = $project ? $project->get_id() : PC_Project::PHPREF_ID; $pids = array($pid); if ($project) { $pids = array_merge($pids, $project->get_project_deps()); } foreach ($pids as $pid) { $this->class = PC_DAO::get_classes()->get_by_name($name, $pid); if ($this->class !== null) { break; } } $renderer->add_breadcrumb('Types', PC_URL::build_submod_url('types')); $renderer->add_breadcrumb('Classes', PC_URL::build_submod_url('types', 'classes')); $renderer->add_breadcrumb($name, PC_URL::get_mod_url()->set('name', $name)->to_url()); }
/** * @see FWS_Module::run() */ public function run() { $input = FWS_Props::get()->input(); $tpl = FWS_Props::get()->tpl(); $id = $input->get_var('id', 'get', FWS_Input::INTEGER); if ($id === null) { $this->report_error(); return; } $add_type = $input->correct_var('add_type', 'post', FWS_Input::STRING, array('min', 'max'), 'min'); $add_name = $input->get_var('add_name', 'post', FWS_Input::STRING); $add_version = $input->get_var('add_version', 'post', FWS_Input::STRING); $proj = PC_DAO::get_projects()->get_by_id($id); if ($proj === null) { $this->report_error(); return; } $target_url = PC_URL::get_mod_url(); $target_url->set('id', $id); $this->request_formular(); $req = $proj->get_req(); if (!is_array($req)) { $req = array(); } foreach ($req as &$r) { $del_url = clone $target_url; $del_url->set('vid', $r['id']); $del_url->set('aid', PC_ACTION_DELETE_REQ); $r['del_url'] = $del_url->to_url(); } $projects = array(); foreach (PC_DAO::get_projects()->get_all() as $p) { if ($p->get_id() == $proj->get_id()) { continue; } $projects[] = array('id' => $p->get_id(), 'value' => in_array($p->get_id(), $proj->get_project_deps()), 'name' => $p->get_name()); } $tpl->add_variables(array('target_url' => $target_url->to_url(), 'action_type' => PC_ACTION_EDIT_PROJECT, 'def_name' => $proj->get_name(), 'def_start' => $proj->get_created(), 'projects' => $projects, 'report_argret_strictly' => $proj->get_report_argret_strictly(), 'req' => $req, 'add_type' => $add_type, 'add_name' => $add_name, 'add_version' => $add_version, 'types' => array('min' => '>=', 'max' => '<'), 'add_req_url' => $target_url->set('aid', PC_ACTION_ADD_REQ)->to_url())); }
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 ''; }
/** * 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); } } }
/** * @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())); }
/** * 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 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; } } }
public function create_constant($const, $classid) { return PC_DAO::get_constants()->create($const, $classid); }
/** * @see FWS_Document_Renderer_HTML_Default::header() */ protected function header() { $tpl = FWS_Props::get()->tpl(); $this->get_action_performer()->add_action(new PC_Action_chgproject(PC_ACTION_CHG_PROJECT)); $this->perform_action(); $projects = PC_DAO::get_projects()->get_all(); $pronames = array(); $pronames[0] = 'PHP builtins'; foreach ($projects as $project) { $pronames[$project->get_id()] = $project->get_name(); } $form = new FWS_HTML_Formular(); $tpl->set_template('inc_header.htm'); $tpl->add_allowed_method('form', '*'); $tpl->add_variables(array('location' => $this->get_breadcrumb_links(), 'form' => $form, 'projects' => $pronames, 'chg_project_aid' => PC_ACTION_CHG_PROJECT, 'project' => FWS_Props::get()->project() !== null ? FWS_Props::get()->project()->get_id() : 0)); $tpl->restore_template(); }
/** * 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; }
/** * 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); } } } }
/** * @return PC_Project the current project */ protected function project() { return PC_DAO::get_projects()->get_current(); }