Exemplo n.º 1
0
 /**
  * Return view for configuring preprocessing.
  */
 public function getConfigure()
 {
     $URI = Input::get('URI');
     if ($document = File::where('_id', $URI)->first()) {
         // Load which functions are available for display
         $functions = $this->getAvailableFunctions();
         $newLine = "\n";
         $docPreview = $document['content'];
         $project = $document['project'];
         $docPreview = explode($newLine, $docPreview);
         $docPreview = array_slice($docPreview, 0, $this->nLines);
         $docPreview = implode($newLine, $docPreview);
         $docTypes = Unit::select('documentType')->where('project', $document->project)->distinct()->get()->toArray();
         // default preview of files
         $previewTable = $this->doPreviewTable($document, '"', ',', false);
         return View::make('media.preprocess.text.pages.configure')->with('URI', $URI)->with('docTitle', $document['title'])->with('docPreview', $docPreview)->with('functions', $functions)->with('project', $project)->with('previewTable', $previewTable)->with('docTypes', $docTypes);
     } else {
         return Redirect::back()->with('flashError', 'No valid URI given: ' . $URI);
     }
 }
Exemplo n.º 2
0
 /**
  * get keys for (a set of) selected document types
  */
 public function postKeys()
 {
     // get the document types
     $documents = explode("|", Input::get('documents'));
     $searchComponent = new MediaSearchComponent();
     // store all keys in this array
     $docKeys = [];
     // go through each selected document type and get the keys
     foreach ($documents as $type) {
         // skip if value is empty
         if ($type == "") {
             continue;
         } elseif ($type == "all") {
             $units = Unit::select('content')->get();
         } else {
             // split the document type string so that we can get the project name from it.
             $type = explode('__', $type);
             // get the content of the units for this document type in this project
             // if the load on the system is too high limit this to e.g. 100 random units.
             $units = Unit::select('content')->where('project', $type[0])->where('documentType', $type[1])->get();
         }
         // get the keys for the units in this document type
         foreach ($units as $unit) {
             $unit->attributesToArray();
             $keys = $searchComponent->getKeys($unit['attributes']);
             $docKeys = array_unique(array_merge($docKeys, $keys));
         }
     }
     //		asort($keys);
     return $docKeys;
 }