public function action_SetSortDate() { $item = Model::factory('kwalbum_item')->load((int) $_POST['item']); $this->_testPermission($item); $date = Kwalbum_Helper::replaceBadDate($_POST['value']); $item->sort_date = $date; $item->save(); echo $item->sort_date; }
/** * Save file in proper location and save information to database * * Check if it has an acceptable file extension, determine the filetype * based on the extension, move the file into the necessary directory, * create thumbnail and resized versions if necessary, then insert into the * database if there have not been any errors. * * Return the id of the new item if successful * @since 3.0 */ private function save() { $item = $this->_item; $item->sort_date = Kwalbum_Helper::replaceBadDate($_POST['date'] . ' ' . $_POST['time']); $item->visible_date = $item->sort_date; // get exif data from jpeg files if ($item->type == 'jpeg') { $fullpath = $item->path . $item->filename; $import_caption = false; $import_keywords = false; if (isset($_POST['import_caption']) and $_POST['import_caption'] == 1) { $import_caption = true; } if (isset($_POST['import_keywords']) and $_POST['import_keywords'] == 1) { $import_keywords = true; } if ($import_caption || $import_keywords) { $info = null; $size = getimagesize($fullpath, $info); if (isset($info['APP13'])) { $iptc = iptcparse($info['APP13']); foreach ($iptc as $key => $data) { if ($key == '2#120' and $import_caption) { $item->description = trim($data[0]); } if ($key == '2#025' and $import_keywords) { if (!is_array($data)) { $data = array($data); } foreach ($data as $keyword) { $item->addTag(htmlspecialchars($keyword)); } } } } } $exif = @exif_read_data($fullpath); if ($exif) { //Kohana::$log->add('var', Kohana::debug($exif)); /* if ($irb = get_Photoshop_IRB($jpeg_header_data)) { $xmp = Read_XMP_array_from_text(get_XMP_text($jpeg_header_data)); $pinfo = get_photoshop_file_info($exif, $xmp, $irb); foreach ($pinfo['keywords'] as $keyword) { $item->addTag(trim($keyword)); } //echo '<pre>'.Kohana::debug( $pinfo );exit; }*/ // replace the set date if one is found in the picture's exif data if (isset($exif['DateTimeOriginal'])) { $item->sort_date = Kwalbum_Helper::replaceBadDate($exif['DateTimeOriginal']); $item->visible_date = $item->sort_date; } if (!empty($exif['GPSLatitude'])) { $latitude = $exif['GPSLatitude']; $sec = explode('/', $latitude[2]); $lat = @((int) $latitude[0] + (int) $latitude[1] / 60 + (int) $sec[0] / (int) $sec[1] / 3600); if (!empty($exif['GPSLatitudeRef']) && 'S' == $exif['GPSLatitudeRef']) { $lat = -$lat; } $item->latitude = $lat; } if (!empty($data['GPSLongitude'])) { $longitude = $data['GPSLongitude']; $sec = explode('/', $longitude[2]); $lon = @((int) $longitude[0] + (int) $longitude[1] / 60 + (int) $sec[0] / (int) $sec[1] / 3600); if (!empty($data['GPSLongitudeRef']) && 'W' == $data['GPSLongitudeRef']) { $lon = -$lon; } $item->longitude = $lon; } } } if ($item->type == 'jpeg' or $item->type == 'png' or $item->type == 'gif') { $this->resizeImage($item->path, $item->filename); if (!empty($exif['Orientation'])) { switch ($exif['Orientation']) { case 8: $item->rotate(270); break; case 3: $item->rotate(180); break; case 6: $item->rotate(90); break; } } } if (isset($_POST['group_option']) and $_POST['group_option'] == 'existing') { $result = DB::query(Database::SELECT, "SELECT update_dt\n\t\t\tFROM kwalbum_items\n\t\t\tORDER BY id DESC\n\t\t\tLIMIT 1")->execute(); $item->update_date = $result[0]['update_dt']; $item->save(false); } else { $item->save(); } return $item->id; }