Extracts main text

@param   string  $file
@param   mixed   $callback
@return  string
@throws  \Exception
978033
public function getMainText($file, $callback = null)
    {
        if(!is_null($callback))
        {
            $this->setCallback($callback);
        }

        return $this->request('text-main', $file);
    }
546179
private function getFileContents($file) {
    if (file_exists($file) === FALSE) {
      return NULL;
    }

    $contents = file_get_contents($file);
    if ($contents === FALSE) {
      return NULL;
    }

    return $contents;
  }
775084
public static function parse($file)
    {
        $config_path = self::$config_path == '' ? APP_PATH . '/config/' : self::$config_path;
        if($file == null){
            $file = scandir($config_path);
            foreach ($file as $k => $v)
            {
                unset($file[0], $file[1]);
                if($v == 'routes.php' )
                {
                    unset($file[$k]);
                }
            }
            foreach ($file as $k => $v)
            {
                $name = str_replace('.php', '', $v);
                $file = $config_path . $v;
                $data[$name] = include $file;
            }
        }else{
            $type = $file;
            if(strpos($type, '.')){
                $type = explode('.', $type);
                $file = $config_path . $type[0] . '.php';
                if(!array_key_exists($type[1], self::load($file)))
                {
                    throw new Exception('This configuration [' . self::$config . '] is not supported!');
                }
                $data = self::load($file)[$type[1]];
            }else{
                $file = $config_path . $file . '.php';
                $data = self::load($file);
            }

        }
        return $data;
    }
972050
protected function getFileContents($file, $line){
        if(!is_string($file) || !is_int($line)
            || !is_file($file) || !is_readable($file)
        ){
            return null;
        }

        $file       = new \SplFileObject($file, "r");
        $current    = 1;
        $contents   = [];
        $min        = $line - 3;
        $max        = $line + 3;

        foreach($file as $row){
            if($min <= $current && $current <= $max){
                $contents[$current] = $row;
            }

            $current++;
        }

        if(empty($contents)){
            return null;
        }

        return $contents;
    }
1349869
public function fetch($file=null)
    {
        if (!$file) {
            $file = $this->_file;
        }

        // Extract the vars to local namespace
        extract($this->_vars);

        // Start output buffering
        ob_start();

        include(PSI_APP_ROOT.$file);

        // Get the contents of the buffer
        $contents = ob_get_contents();

        // End buffering and discard
        ob_end_clean();

        return $contents;
    }
547714
public static function extractChecks($file)
    {
        $returnValue = null;

        if (is_readable($file)){
        	$manifestPath = $file;
	    	$content = file_get_contents($manifestPath);
	    	$matches = array();
	    	preg_match_all("/(?:\"|')\s*checks\s*(?:\"|')\s*=>(\s*array\s*\((\s*array\((?:.*)\s*\)\)\s*,{0,1})*\s*\))/", $content, $matches);
	    	
	    	if (!empty($matches[1][0])){
	    		$returnValue = eval('return ' . $matches[1][0] . ';');
	    		
	    		foreach ($returnValue as &$component){
		    		if (strpos($component['type'], 'FileSystemComponent') !== false){
		    			$root = realpath(dirname(__FILE__) . '/../../../');
	        			$component['value']['location'] = $root . '/' . $component['value']['location'];
	        		}	
	    		}
	    	}
	    	else{
	    		$returnValue = array();	
	    	}
        }
        else{
        	$msg = "Extension Manifest file could not be found in '${file}'.";
        	throw new common_ext_ManifestNotFoundException($msg);
        }

        return $returnValue;
    }
1053637
public function getContent($file)
    {
        /** @var \TeaminmediasPluswerk\KeSearch\Utility\OoxmlConversion $reader */
        $reader = GeneralUtility::makeInstance(\TeaminmediasPluswerk\KeSearch\Utility\OoxmlConversion::class, $file);

        try {
            return trim($reader->convertToText());
        } catch (\Exception $e) {
            $this->pObj->logger->error($e->getMessage());
        }
    }
900933
function extractText( filePath, options, cb ) {
  var result = ''
    , error = null
    , textutil = spawn( 'textutil', ['-convert', 'txt', '-stdout', filePath] )
    ;

  textutil.stdout.on( 'data', function( buffer ) {
    result += buffer.toString();
  });

  textutil.stderr.on( 'error', function( buffer ) {
    if ( !error ) {
      error = '';
    }
    error += buffer.toString();
  });

  textutil.on( 'close', function( /* code */ ) {
    if ( error ) {
      error = new Error( 'textutil read of file named [[ ' +
        path.basename( filePath ) + ' ]] failed: ' + error );
      cb( error, null );
      return;
    }
    cb( null, result.trim() );
  });
}
194926
public static function get($file, $data = [])
    {
        $path = self::load('views.' . $file);

        extract($data, EXTR_SKIP);

        include $path;
    }
937584
public function extract(callable $callback = null)
    {

        if ($callback === null) {
            $result = $this->result->serialize();
        }
        else {
            $result = $callback($this->result->serialize());
        }

        return $result;

    }
271910
public function render($file, array $data = array(), callable $callback = null) {
        $content = $this->setAttribute($data)
            ->getView($file)->render($callback);
        $layout = $this->findLayoutFile();
        if (empty($layout)) {
            return $content;
        }
        return $this->getView($layout)
            ->renderWithData(['content' => $content]);
    }
299086
public function extractMeaning($file, Context $context = null, array $queryParams = [])
    {
        if (!$file || (!is_resource($file) && !is_readable($file))) {
            throw new \InvalidArgumentException('$file argument must be a readable file path or a valid resource');
        }

        if (null !== $context && !$context->isEmpty()) {
            $queryParams['context'] = json_encode($context);
        }

        $file = is_resource($file) ? $file : fopen($file, 'r');
        $response = $this->client->send('POST', '/speech', $file, $queryParams);

        return $this->decodeResponse($response);
    }
11928
public function get($file)
    {
        $basepath = $this->config['basepath'];
        $suffix = $this->config['suffix'];
        $target = "$basepath/$file{$suffix}";

        if (!is_readable($target)) {
            throw new \Exception(t("No such file content: @FILENAME", ["@FILENAME" => $target]));
        }

        $filter  = $this->config['textfilter'];
        $content = file_get_contents($target);
        $content = $this->di->textFilter->doFilter($content, $filter);

        return $content;
    }
1370420
public function read($file)
    {
        $document = new \DOMDocument();
        $errorToExceptionContext = new ErrorToExceptionContext(E_WARNING, function () use ($file, $document) {
            $document->load($file);
        });
        $errorToExceptionContext->invoke();

        return $this->readDocument($document, pathinfo($file, PATHINFO_FILENAME));
    }
27007
private function parseFile($file)
    {
        $data = sscanf($file, '@%[^:]:%[^?]');

        if (empty($data[0])) {
            throw new \InvalidArgumentException(sprintf('File "%s" has invalid syntax', $file));
        }

        return $data;
    }
623966
public function parseFile($file)
    {
        $str = @\file_get_contents($file);
        if (false === $str) {
            throw new Exception('Can\'t read file.');
        }

        return $this->parse($str);
    }
1312682
protected function getRawOutput($file)
    {
        if (!$this->isAvailable()) {
            throw new Exception("getRawOutput called on unavailable extractor");
        }

        $path = $file instanceof File ? $this->getPathFromFile($file) : $file;
        exec(sprintf('%s %s - 2>&1', $this->bin('pdftotext'), escapeshellarg($path)), $content, $err);
        if ($err) {
            if (!is_array($err) && $err == 1) {
                // For Windows compatibility
                $err = $content;
            }

            throw new Exception(sprintf(
                'PDFTextExtractor->getContent() failed for %s: %s',
                $path,
                implode(PHP_EOL, $err)
            ));
        }

        return implode(PHP_EOL, $content);
    }