Exemplo n.º 1
0
 /**
  * Bearbeiten eines Dokuments (metadaten)
  * 
  * @param string $id
  * @return \yii\web\View
  * @author KAS <*****@*****.**> 06.08.2015
  */
 public function actionEdit($id = NULL)
 {
     Yii::$app->view->params['headline'] = 'Dokument bearbeiten';
     // Wir laden das gewählte Document
     $model = Documents::findOne(new \MongoId($id));
     // Wir machen aus dem Array ein Object ---------------------------------
     #$model->metadata = new Metadata($model->metadata);
     // Nur wenn auch ein POST gesendet wurde -------------------------------
     if (\Yii::$app->request->isPost) {
         $post = \Yii::$app->request->post();
         $meta = new Metadata($post['Documents']['metadata']);
         // Hier werden die Daten für Mongo angepasst(convertiert) ----------
         $meta->load($post['Documents']['metadata']);
         //------------------------------------------------------------------
         // wir belassen die originalen Metadaten
         $model->metadata = $model->metadata->toArray();
         // Änderungen werden in metadatanew abgelegt
         $model->metadatanew = $meta->toArray();
         #var_dump($model);
         // Speichern der Daten
         $model->update();
         // daten refreshen und neu zuordnen --------------------------------
         $model->refresh();
         $model->metadata = new Metadata($model->metadata);
     }
     //----------------------------------------------------------------------
     // Wenn bereits neue Daten vorhanden sind,
     // laden wir diese für die Anzeige
     if ($model->metadatanew !== NULL) {
         #$model->metadata = new Metadata($model->metadatanew);
     }
     return $this->render('edit', ['model' => $model]);
 }
Exemplo n.º 2
0
    die("The database has not been correctly configured.");
}
Database::initialize(DATABASE_NAME);
// Make sure a connection to the database was created
if (!Database::$database) {
    // If we're installing the system, we acknowledge that errors with the database will exist.
    if (!$url[0] == "install") {
        die("There was an issue connecting to the database. Likely issues: wrong user/pass credentials or the table is missing.");
    }
}
/****** Setup Custom Error Handler ******/
require SYS_PATH . "/error-handler.php";
/****** Process Security Functions ******/
Security_Fingerprint::run();
/****** Metadata Handler ******/
Metadata::load();
/****** Identify the Device (1 = mobile, 2 = tablet, 3 = device) ******/
if (!isset($_SESSION['device'])) {
    $device = new DetectDevice();
    if ($device->isMobile()) {
        $_SESSION['device'] = 1;
    } else {
        if ($device->isTablet()) {
            $_SESSION['device'] = 2;
        } else {
            $_SESSION['device'] = 3;
        }
    }
}
// Load the routing system
require SYS_PATH . "/routes.php";