/** * Cleans all the generated fields of the data obkects */ public function clean() { $this->comment->clean(); if ($this->media !== null) { $this->media->clean(); } }
echo $page; ?> /" class="btn btn-success btn-block">Return</a> </div> <div class="col-lg-offset-7 col-lg-2 col-sm-offset-6 col-sm-3"> <button type="submit" class="btn btn-primary btn-block pull-right dirtyOK">Save Page</button> </div> </div> </form> </div> </div> <br><br> <!-- Modal --> <?php $mediaData = new MediaData(); $dataImages = $mediaData->getData(); ?> <div class="modal fade" id="imageSelectModal" tabindex="-1" role="dialog" aria-labelledby="imageSelectModal"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel">Select Image</h4> </div> <div class="modal-body" style="height: 400px; overflow: scroll;"> <?php foreach ($dataImages['images'] as $key => $datum) { ?> <img src="<?php echo $datum['location'];
function post() { $users = new UsersData(); if ($users->checkPass() && !$users->authNeeded()) { $media = new MediaData(); if (isset($_POST['delete'])) { $media->deleteImage('images', $_POST['delete']); } if (!empty($_FILES)) { $media->uploadFiles('media'); } header('Location: /admin/media/?updated=true'); } else { include_once '401.html'; } }
public function __construct($filename) { $data = $this->extractDataFromFilename($filename); parent::__construct($data); }
public function actionGetImage($id) { if (!($file = \MediaData::model()->findByPk($id))) { throw new CHttpException(404, 'File not found'); } $filepath = $file->getPath(); if (!file_exists($file->getPath())) { throw new CException('File not found on filesystem: ' . $file->getPath()); } //var_dump($file); //die; header('Content-Type: ' . \MediaType::model()->findByPk($file->media_type_id)->type_mime); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Content-Length: ' . $file->original_file_size); ob_clean(); flush(); readfile($filepath); }
function post($page = null, $key = null) { $users = new UsersData(); if (is_null($page) || is_null($key)) { include_once '404.html'; } else { if (!is_null($page) && $users->checkPass() && !$users->authNeeded()) { PagesData::updatePage($page, $_POST); $media = new MediaData(); $media->uploadFiles($page); header('Location: /admin/page/' . $page . '/repeat/' . $key . '/?updated=true'); } else { include_once '401.html'; } } }
function post($post_id = null, $action = null) { $users = new UsersData(); if (is_null($post_id)) { include_once '404.html'; } else { if ($users->checkPass() && !$users->authNeeded()) { $blogData = new BlogData(); if ($action == 'update') { $blogData->updateBlogPost($post_id, $_POST, isset($_POST['publish'])); $media = new MediaData(); $media->uploadFiles($post_id, true); } $blogData->orderBlog(); header('Location: /admin/blog/?updated=true'); } else { include_once '401.html'; } } }
function uploadImage($name, $class = 'default') { $obj = new stdClass(); $_FILES["Filedata"] = $_FILES[$name]; $filename = $_FILES["Filedata"]["name"]; /* $md = new MediaData(); $md->setClass($class); $md->url_data = $_REQUEST; */ $data_array = array(); $data_array['currentType'] = $class; $md = new MediaData(); $md->setClass($class); $md->url_data = $data_array; // $this->url_data['currentType']='product'; $class = "Media" . ucfirst($md->_getFileTypesByExtension($filename)); $md = new $class(); $md->url_data = $data_array; $obj = $md->Upload($filename); if ($obj->success == 1) { $status = array(); $status['code'] = '0'; $status['message'] = 'OK'; $status['file_name'] = $_FILES["Filedata"]["name"]; return $this->statusXMLTag($status); } else { $status = array(); $status['code'] = '-1'; $status['message'] = 'UPLOAD FAILED'; $status['file_name'] = $_FILES["Filedata"]["name"]; return $this->statusXMLTag($status); } }
function makeImageBGImage(&$edit, &$dataArr, $dataFile, $fieldID, $desc, $isBG = false, $count = null, $repeatFieldID = null) { if (isset($edit->autocms)) { $desc = $edit->autocms; } $tag = null; $source = null; if ($isBG) { $source = $edit->style; preg_match('~\\bbackground(-image)?\\s*:(.*?)\\(\\s*(\'|")?(?<image>.*?)\\3?\\s*\\)~i', $source, $matches); $source = $matches[4]; $tag = $matches[0]; } else { $source = $edit->src; } if ($source[0] != '/') { $source = '/' . $source; } if ($source[0] == '/') { $source = $_SERVER['DOCUMENT_ROOT'] . $source; } $fileExt = pathinfo(parse_url($edit->src, PHP_URL_PATH), PATHINFO_EXTENSION); $fileExt = MediaData::getImageType($fileExt, $source); if ($fileExt != 'error') { $media = new MediaData(); if (!$media->checkMediaLibrary('images', $source)) { $imgFileName = $media->makeDateFolders() . uniqid() . '.' . $fileExt; if (file_exists($source)) { copy($source, $_SERVER['DOCUMENT_ROOT'] . $imgFileName); } $media->addToMediaLibrary('images', $imgFileName, $source); } else { $imgFileName = $media->getFromMediaLibrary('images', $source); } if (!is_null($repeatFieldID)) { $dataArr[$fieldID]['repeat'][$count][$repeatFieldID] = array('image' => $imgFileName, 'description' => $desc, 'type' => 'image'); } else { $dataArr[$fieldID] = array('image' => $imgFileName, 'description' => $desc, 'type' => 'image'); } if ($isBG) { if (!is_null($repeatFieldID)) { $edit->style = str_replace($tag, '', $edit->style) . "background-image: url('<?=get('{$dataFile}', '{$fieldID}', " . '$x' . ", '{$repeatFieldID}')?>');"; } else { $edit->style = str_replace($tag, '', $edit->style) . "background-image: url('<?=get('{$dataFile}', '{$fieldID}')?>');"; } $edit->class = str_replace('auto-edit-bg-img', '', $edit->class); } else { $altText = $edit->alt; if ($altText === false) { $altText = ''; } $altFieldID = uniqid(); if (!is_null($repeatFieldID)) { $edit->src = "<?=get('{$dataFile}', '{$fieldID}', " . '$x' . ", '{$repeatFieldID}')?>"; $dataArr[$fieldID]['repeat'][$count][$altFieldID] = array('text' => $altText, 'description' => 'image alt text', 'type' => 'text', 'parent' => $fieldID); } else { $edit->src = "<?=get('{$dataFile}', '{$fieldID}')?>"; $dataArr[$altFieldID] = array('text' => $altText, 'description' => 'image alt text', 'type' => 'text', 'parent' => $fieldID); } if (!is_null($repeatFieldID)) { $edit->alt = "<?=get('{$dataFile}', '{$fieldID}', " . '$x' . ", '{$altFieldID}')?>"; } else { $edit->alt = "<?=get('{$dataFile}', '{$altFieldID}')?>"; } $edit->class = str_replace('auto-edit-img', '', $edit->class); } if (trim($edit->class) === '') { $edit->class = null; } $edit->autocms = null; } }
<?php include_once 'header.php'; $mediaData = new MediaData(); $data = $mediaData->getData(); ?> <div class="container"> <div class="row"> <div class="col-lg-12"> <h2 class="page-header">Media Library</h2> </div> </div> <div class="row"> <div class="col-lg-12"> <div> <ul class="nav nav-tabs" role="tablist"> <?php $count = 0; foreach ($data as $key => $datum) { ?> <?php if (!empty($datum)) { ?> <li role="presentation"<?php if ($count == 0) { ?> class="active"<?php } ?> ><a href="#<?php