This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
// This is dangerous, I would never do this. | |
// Just for testing purposes: | |
$_SESSION['loggedin'] = true; | |
use Imanager\Category; | |
use Imanager\Field; | |
use Imanager\FieldConfigs; | |
use Imanager\FieldFileupload; | |
use Imanager\Item; | |
include '../framework/imanager.php'; | |
$gallery = $imanager->getCategory('name=Gallery'); | |
$timestamp = time(); | |
$item = $gallery->getItem(1); | |
if(!$item) { | |
$item = new Item($gallery->id); | |
} | |
if($imanager->input->post->action == 'save') { | |
$item->save(); | |
$dataSent = array( | |
'file' => $imanager->input->post->position_images, | |
'title' => $imanager->input->post->title_images, | |
'timestamp' => $imanager->input->get->timestamp | |
); | |
// Set input value | |
if($item->set('images', $dataSent)) { | |
$item->save(); | |
} else { | |
echo 'Error: The field value could not be set'; | |
} | |
} | |
?> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Backend</title> | |
<meta name="description" content="Just a simple login Form"> | |
<!-- Mobile-friendly viewport --> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" | |
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> | |
<meta name="author" content="J.E"> | |
</head> | |
<body> | |
<main role="main"> | |
<?php | |
$imanager->fieldMapper->init($gallery->id, true); | |
$field = $gallery->getField('name=images'); | |
$widget = new FieldFileupload; | |
// Action should point to the processing script, | |
// in our case it is the same file "index.php": | |
echo '<form action="./" method="post">'; | |
// The widget's parameter "url" points to the IM root, | |
// in our case "../framework/" (Note trailing slash): | |
$widget->set('url', '../framework/'); | |
// The widget's action points to the upload processor: | |
$widget->set('action', "../framework/imanager/upload/server/php/index.php"); | |
$widget->set('id', $field->name); | |
$widget->set('categoryid', $field->categoryid); | |
$widget->set('itemid', isset($item->id) ? $item->id : null); | |
$widget->set('timestamp', $timestamp); | |
$widget->set('fieldid', $field->id); | |
$widget->set('configs', $field->configs, false); | |
$widget->set('name', $field->name); | |
echo $widget->render(); | |
echo '<input type="hidden" name="action" value="save">'; | |
echo '<button type="submit">Save</button>'; | |
echo '</form>'; | |
?> | |
</main> | |
<footer role="contentinfo"> | |
<small>Copyright © | |
<time datetime="<?php echo date('Y'); ?>"><?php echo date('Y'); ?></time> Ehret Studio</small> | |
</footer> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script> | |
<?php echo $widget->renderJsBlock(); ?> | |
<?php echo $widget->renderJsLibs(); ?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment