예제 #1
0
 /**
  * @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'));
 }
예제 #2
0
 /**
  * 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 '#';
 }
예제 #3
0
 /**
  * @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));
 }
예제 #4
0
 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 '';
 }
예제 #5
0
 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 '';
 }
예제 #6
0
 /**
  * @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());
 }
예제 #7
0
 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();
 }
예제 #8
0
 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 '';
 }
예제 #9
0
 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 '';
 }
예제 #10
0
 /**
  * Returns the class with given name. Will fetch it from db if not already present
  *
  * @param string $name the class-name
  * @return PC_Obj_Class the class or null if not found
  */
 public function get_class($name)
 {
     if (empty($name)) {
         return null;
     }
     $lname = strtolower($name);
     if (!isset($this->missing['classes'][$lname])) {
         if (!isset($this->classes[$lname])) {
             foreach ($this->options->get_projects() as $pid) {
                 $c = PC_DAO::get_classes()->get_by_name($name, $pid);
                 if ($c) {
                     $this->classes[$lname] = $c;
                     break;
                 }
             }
         }
     }
     if (isset($this->classes[$lname])) {
         return $this->classes[$lname];
     }
     $this->missing['classes'][$lname] = true;
     return null;
 }
예제 #11
0
 /**
  * Grabs a class from the given file
  * 
  * @param string $file the file
  */
 private function grab_class($file)
 {
     $classp = new PC_PHPRef_Class($file);
     PC_DAO::get_classes()->create($classp->get_class(), PC_Project::PHPREF_ID);
 }
예제 #12
0
 /**
  * @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()));
 }