Example #1
0
 function storeFileForIndexing($file_path)
 {
     $FileInstance = new File();
     $file_details = array('path' => $file_path, 'body' => file_get_contents($this->base_dir . DS . $file_path), 'hash' => md5_file($this->base_dir . DS . $file_path), 'has_been_analyzed' => false);
     if ($SourceFile =& $FileInstance->findFirstBy('path', $file_path)) {
         if (!$file_details['has_been_analyzed']) {
             $this->log('File ' . $file_details['path'] . ' is stored but not indexed.');
         }
         $file_details['has_been_analyzed'] = $SourceFile->hash == $file_details['hash'] && $SourceFile->get('has_been_analyzed');
         if (!$file_details['has_been_analyzed']) {
             $this->log('File ' . $file_details['path'] . ' marked for reanalizing');
             $SourceFile->setAttributes($file_details);
             $SourceFile->save();
         } else {
             $this->log('File ' . $file_details['path'] . ' is up to date');
         }
     } else {
         $this->log('Storing file ' . $file_details['path']);
         $SourceFile = new File($file_details);
         $SourceFile->save();
     }
 }
Example #2
0
 public function indexFile($file_path)
 {
     $file_path = trim($file_path, '/');
     $FileInstance = new File(array('init' => false));
     if ($this->db) {
         $FileInstance->setConnection($this->db);
     }
     $FileInstance->init();
     if ($UnIndexedPage = $FileInstance->findFirstBy('path AND has_been_analyzed', $file_path, false)) {
         $ComponentInstance = new Component(array('init' => false));
         if ($this->db) {
             $ComponentInstance->setConnection($this->db);
         }
         $ComponentInstance->init();
         $ClassInstance = new Klass(array('init' => false));
         if ($this->db) {
             $ClassInstance->setConnection($this->db);
         }
         $ClassInstance->init();
         $this->log('Analyzing file ' . $UnIndexedPage->path);
         $Component = $ComponentInstance->updateComponentDetails($UnIndexedPage, $this);
         $Classes = $ClassInstance->updateClassDetails($UnIndexedPage, $Component, $this);
         if (!empty($Classes)) {
             //AkDebug::debug($Classes);
         }
         $UnIndexedPage->set('has_been_analyzed', true);
         $UnIndexedPage->save();
     }
 }