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 ''; }
/** * Builds the message * * @param PC_Obj_Error $err the error * @return string the message */ private function get_msg($err) { $msg = $err->get_msg(); return preg_replace_callback('/#(#?[a-zA-Z0-9_:]+?)#/', function ($match) { $func = ''; if (strstr($match[1], '::')) { list($class, $func) = explode('::', $match[1]); $func = '::' . $func; } else { if ($match[1] == PC_Obj_Variable::SCOPE_GLOBAL) { return '<i>Global</i>'; } else { $class = $match[1]; } } $url = PC_URL::get_mod_url('class')->set('name', $class)->to_url(); return "<a href=\"" . $url . "\">" . $class . "</a>" . $func; }, $msg); }
/** * Builds a PC_Obj_Error from the given row * * @param array $row the row from db * @return PC_Obj_Error the error */ private function build_error($row) { $err = new PC_Obj_Error(new PC_Obj_Location($row['file'], $row['line']), $row['message'], $row['type']); $err->set_id($row['id']); return $err; }