/** * {@inheritdoc} */ public function searchFor($strPattern) { // Base implementation, do a simple search on given column. $objQuery = \Database::getInstance()->prepare(sprintf('SELECT id FROM %s WHERE %s IN (SELECT uuid FROM %s WHERE path LIKE ?)', $this->getMetaModel()->getTableName(), $this->getColName(), \FilesModel::getTable()))->execute(str_replace(array('*', '?'), array('%', '_'), $strPattern)); $arrIds = $objQuery->fetchEach('id'); return $arrIds; }
/** * Walks the list of pending folders via ToolboxFile::addPath(). * * @return void */ protected function collectFiles() { $table = \FilesModel::getTable(); $conditions = array(); $parameters = array(); if (count($this->pendingIds)) { $conditions[] = $table . '.uuid IN(' . implode(',', array_fill(0, count($this->pendingIds), 'UNHEX(?)')) . ')'; $parameters = array_map('bin2hex', $this->pendingIds); $this->pendingIds = array(); } if (count($this->pendingPaths)) { $slug = $table . '.path LIKE ?'; foreach ($this->pendingPaths as $pendingPath) { $conditions[] = $slug; $parameters[] = $pendingPath . '%'; } $this->pendingPaths = array(); } if (!count($conditions)) { return; } if ($files = \FilesModel::findBy(array(implode(' OR ', $conditions)), $parameters)) { $this->addFileModels($files); } if (count($this->pendingPaths)) { // Run again. $this->collectFiles(); } }