protected function addPost($status) { global $app; $post = $app->request()->post(); // add post $post['dated'] = date($app->view()->getData('dateFormat')); $post['slug'] = getSlugName($post['title']); $post['categoryslug'] = getSlugName($post['category']); $post['status'] = $status; $post['summary'] = $this->getSummary($post['body'], 300); MetaDataWriter::updateFileData($this->metaFile, $post, true); // update categories $array[] = MetaDataWriter::getFileData($this->categoriesFile); $array[] = $post['category']; $array = arrayFlatten($array); $array = array_unique($array); MetaDataWriter::writeData($this->categoriesFile, $array); // also write tags file $array[] = MetaDataWriter::getFileData($this->tagsFile); $array[] = $post['tags']; $array = arrayFlatten($array); $array = array_unique($array); MetaDataWriter::writeData($this->tagsFile, $array); $app->flash('info', 'Saved Successfully'); $app->redirect($_SERVER['HTTP_REFERER']); }
public function add() { global $app; $message = ''; $image = $_FILES['image']; if ($image['name']) { if (!$image['error']) { $file_name = basename($image['name']); $ext = pathinfo($file_name, PATHINFO_EXTENSION); $file_name = time() . uniqid() . '.' . $ext; $valid_file = true; if ($image['size'] > 5242880) { $valid_file = false; $message = 'Oops! Your file\'s size is to large.'; } if ($valid_file) { move_uploaded_file($image['tmp_name'], $this->imagesDir . $file_name); $data = array('image' => $this->imagesDir . $file_name); MetaDataWriter::updateFileData($this->metaFile, $data, true); $message = 'File uploaded successfully!'; } } else { //set that to be the returned message $message = 'Ooops! Your upload triggered the following error: ' . $image['error']; } } $app->flash('info', $message); $app->redirect($_SERVER['HTTP_REFERER']); }
public function addCustomValue() { global $app; $post = $app->request()->post(); $post['id'] = time(); MetaDataWriter::updateFileData($this->customValuesFile, $post, true); $app->flash('info', 'Saved Successfully'); $app->redirect($_SERVER['HTTP_REFERER']); }
public function add() { global $app; $post = $app->request()->post(); // add post $post['slug'] = getSlugName($post['title']); MetaDataWriter::updateFileData($this->metaFile, $post, true); $app->flash('info', 'Saved Successfully'); $app->redirect($_SERVER['HTTP_REFERER']); }