Ejemplo n.º 1
0
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Contributors:
 *     Pierre-Gildas MILLON <*****@*****.**>
 */
require_once '../vendor/autoload.php';
$documents = null;
$client = new \Nuxeo\Client\Api\NuxeoClient('http://nuxeo:8080/nuxeo', 'Administrator', 'Administrator');
$blobTempStorage = __DIR__ . DIRECTORY_SEPARATOR . 'blobs';
if (!@mkdir($blobTempStorage) && !is_dir($blobTempStorage)) {
    throw new \Symfony\Component\HttpFoundation\File\Exception\FileException(sprintf('Could not create %s: ', $blobTempStorage));
}
/** @var \Nuxeo\Client\Api\Objects\Documents $availablePaths */
$availablePaths = $client->automation('Document.Query')->param('query', 'SELECT * FROM Workspace')->execute(\Nuxeo\Client\Api\Objects\Documents::className);
$httpRequest = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
$document = null;
if ($httpRequest->files->has('blob') && $httpRequest->request->has('path')) {
    $path = $httpRequest->get('path');
    $uploadedBlob = $httpRequest->files->get('blob');
    /** @var \Symfony\Component\HttpFoundation\File\UploadedFile $uploadedBlob */
    $blob = $uploadedBlob->move($blobTempStorage, $uploadedBlob->getClientOriginalName());
    try {
        /** @var \Nuxeo\Client\Api\Objects\Document $document */
        $document = $client->automation('Document.Create')->input('doc:' . $path)->params(array('type' => 'File', 'name' => $blob->getFilename(), 'properties' => 'dc:title=' . $blob->getFilename()))->execute(\Nuxeo\Client\Api\Objects\Document::className);
    } catch (\Nuxeo\Client\Internals\Spi\NuxeoClientException $ex) {
        throw new RuntimeException(sprintf('Could not create Document %s: ' . $ex->getMessage(), $blob->getFilename()));
    }
    try {
        if (null !== $document) {
Ejemplo n.º 2
0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Contributors:
 *     Pierre-Gildas MILLON <*****@*****.**>
 */
require_once '../vendor/autoload.php';
$documents = null;
$client = new \Nuxeo\Client\Api\NuxeoClient('http://nuxeo:8080/nuxeo', 'Administrator', 'Administrator');
if (!empty($_POST['q'])) {
    $query = $_POST['q'];
    /** @var \Nuxeo\Client\Api\Objects\Documents $documents */
    $documents = $client->automation('Document.Query')->param('query', sprintf('SELECT * FROM Document WHERE ecm:fulltext = "%s"', $query))->execute(\Nuxeo\Client\Api\Objects\Documents::className);
}
?>
<!DOCTYPE html>

<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>B2 test php Client</title>
  <!-- Latest compiled and minified CSS -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

  <!-- Optional theme -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

  <!-- Latest compiled and minified JavaScript -->
Ejemplo n.º 3
0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Contributors:
 *     Pierre-Gildas MILLON <*****@*****.**>
 */
require_once '../vendor/autoload.php';
$documents = null;
$client = new \Nuxeo\Client\Api\NuxeoClient('http://nuxeo:8080/nuxeo', 'Administrator', 'Administrator');
if (!empty($_POST['date'])) {
    $date = DateTime::createFromFormat('Y/m/d', $_POST['date']);
    /** @var \Nuxeo\Client\Api\Objects\Documents $documents */
    $documents = $client->automation('Document.Query')->param('query', sprintf('SELECT * FROM Document WHERE dc:created >= DATE "%s"', date_format($date, 'Y-m-d')))->execute(\Nuxeo\Client\Api\Objects\Documents::className);
}
?>
<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>B3 test php Client</title>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

    <!-- Latest compiled and minified JavaScript -->
Ejemplo n.º 4
0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Contributors:
 *     Pierre-Gildas MILLON <*****@*****.**>
 */
require_once '../vendor/autoload.php';
$client = new \Nuxeo\Client\Api\NuxeoClient('http://nuxeo:8080/nuxeo', 'Administrator', 'Administrator');
if (!empty($_POST['path'])) {
    $path = $_POST['path'];
    try {
        /** @var \Nuxeo\Client\Api\Objects\Blob $blob */
        $blob = $client->automation('Blob.Get')->input('doc:' . $path)->execute(\Nuxeo\Client\Api\Objects\Blob::className);
        $response = new \Symfony\Component\HttpFoundation\BinaryFileResponse($blob->getFile());
        $response->setContentDisposition(\Symfony\Component\HttpFoundation\ResponseHeaderBag::DISPOSITION_ATTACHMENT, $blob->getFilename());
        $response->prepare(\Symfony\Component\HttpFoundation\Request::createFromGlobals())->send();
    } catch (\Nuxeo\Client\Internals\Spi\NuxeoClientException $ex) {
        throw new RuntimeException(sprintf('Could not fetch blob of %s: ', $path) . $ex->getMessage());
    }
}
?>
<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>B5 test php Client</title>
    <!-- Latest compiled and minified CSS -->