edit modul tes online digilib in progress..
Untuk jumlah soal lebih dari 5 masih ada eror.
membenahi login user dan form test online digilib
progress:
navigation user sudah bisa, tetapi untuk child tab belum berfungsi
form test online sudah muncul, tetapi masih berantakan di tampilan
Progress Login Box Admin dan Member DIgilib
Pilihan Login
Form Login Admin:
Form Login Member:
Form Registrasi Member
Belajar migrasi tampilan di code igniter
dari tampilan
menjadi
progress –> baru bisa edit link header
Memperbaiki footer yang bandel
Mengapa footer tersebut tidak terletak di bawah tapi malah disamping kanan ?, ternyata permasalahannya ada sidebar yang tidak di load.
function index(){
if ($this->session->userdata('id_member') == '') {
$this->session->set_flashdata('error','<p style="color:red;">Silahkan login untuk bisa melakukan review paper online. </p>');
redirect('frontend/login');
} else {
$this->form_validation->set_rules('judul_paper', 'judul_paper', 'Wajib Di isi');
if ( $this->form_validation->run() == TRUE ) {
$this->load->library('paperrater');
//print_r($_POST);
$judul = $this->input->post('judul_paper');
$isi = $this->input->post('isi_paper');
$tempat = $this->input->post('kota_paper');
$level = $this->input->post('level_edukasi');
$tipe = $this->input->post('tipe_paper');
$opsi = $this->input->post('opsi_pilihan');
print_r(json_decode($this->paperrater->get($judul,$isi,$tempat,$level,$tipe,$opsi)));
}
$data['page'] = "frontend/paper/paper-1";
$data['sidebar'] = "frontend/theme/sidebar";
$this->load->view('frontend/template', $data);
}
ket:
bagian yang diberi label kuning bila tidak di load menyebabkan footer tidak tampil di tempat semestinya. Oleh karena itu, sidebar juga perlu ditampilkan.
Bila tidak ingin menampilkan sidebar dan footer tetap di posisi bawah, saya belum tau caranya..mungkin teman2 yang tau bisa memberi saran/masukan
terima kasih
Sebelumnya telah kita bahas mengupload file ke folder tertentu di google drive dengan php dan google drive API. Sekarang kita lanjutkan agar pdf yang sudah diupload bisa dilihat oleh orang banyak
<?php
session_start();
$url_array = explode('?', 'http://'.$_SERVER ['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$url = $url_array[0];
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_DriveService.php';
$client = new Google_Client();
$client->setClientId('your client id');
$client->setClientSecret('your client secret');
$client->setRedirectUri($url);
$client->setScopes(array('https://www.googleapis.com/auth/drive'));
if (isset($_GET['code'])) {
$_SESSION['accessToken'] = $client->authenticate($_GET['code']);
header('location:'.$url);exit;
} elseif (!isset($_SESSION['accessToken'])) {
$client->authenticate();
}
if (!empty($_POST)) {
$fileName = $_FILES['dokumen']['name'];
if (move_uploaded_file($_FILES['dokumen']['tmp_name'], $fileName)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
$client->setAccessToken($_SESSION['accessToken']);
$service = new Google_DriveService($client);
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$file_path = str_replace('/','\\',dirname($_SERVER['SCRIPT_FILENAME'])).'/'.$fileName;
$parentId="0Bx3dFOUzrPOidEMwY2Y1d1hGRVE";
$mime_type = finfo_file($finfo, $file_path);
$file = new Google_DriveFile();
$file->setTitle($fileName);
$file->setDescription('This is a '.$mime_type.' document');
$file->setMimeType($mime_type);
// Set the parent folder.
if ($parentId != null) {
$parent = new Google_ParentReference();
$parent->setId($parentId);
$file->setParents(array($parent));
}
try {
$data = file_get_contents($fileName);
$createdFile = $service->files->insert($file, array(
'data' => file_get_contents($file_path),
'mimeType' => $mime_type,
));
//Uncomment the following line to print the File ID
//print 'File ID: %s' % $createdFile->getId();
if ($createdFile != null) {
echo "<a href='https://drive.google.com/file/d/".$createdFile[id]."'>open file</a>";
}
return $createdFile;
} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
}
finfo_close($finfo);
//unlink($fileName);
header('location:'.$url);exit;
}
include 'index.phtml';
?>
Hasil
Upload dokumen ke folder terntentu di google drive. Bagaimana caranya ?, terlebih dahulu login ke akun google drive masing-masing –> drive.google.com
1. Setelah itu, buat sebuah folder di google drive. Klik tanda centang –> Pilih More –> Share –> Share..Pada bagian Who has Access, Pilih Sharing Settings yang diinginkan, misalnya memilih Public on The Web. Copy link share dan simpan di notepad
2. Download google api php client library di –> https://code.google.com/p/google-api-php-client/ . Pilih latest release
3. Buat susunan file seperti ini, kumpulkan dalam satu folder proyek
4. isi file index.php dengan code berikut
<?php
session_start();
$url_array = explode('?', 'http://'.$_SERVER ['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$url = $url_array[0];
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_DriveService.php';
$client = new Google_Client();
$client->setClientId('Client Id Anda');
$client->setClientSecret('Client Secret Anda');
$client->setRedirectUri($url);
$client->setScopes(array('https://www.googleapis.com/auth/drive'));
if (isset($_GET['code'])) {
$_SESSION['accessToken'] = $client->authenticate($_GET['code']);
header('location:'.$url);exit;
} elseif (!isset($_SESSION['accessToken'])) {
$client->authenticate();
}
if (!empty($_POST)) {
$fileName = $_FILES['dokumen']['name'];
if (move_uploaded_file($_FILES['dokumen']['tmp_name'], $fileName)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
$client->setAccessToken($_SESSION['accessToken']);
$service = new Google_DriveService($client);
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$parentId="Id Folder Anda di Google Drive";
$file_path = str_replace('/','\\',dirname($_SERVER['SCRIPT_FILENAME'])).'/'.$fileName;
$mime_type = finfo_file($finfo, $file_path);
//function insertFile($service, $title, $description, $parentId, $mimeType, $filename) {
$file = new Google_DriveFile();
$file->setTitle($fileName);
$file->setDescription('This is a '.$mime_type.' document');
$file->setMimeType($mime_type);
// Set the parent folder.
if ($parentId != null) {
$parent = new Google_ParentReference();
$parent->setId($parentId);
$file->setParents(array($parent));
}
try {
$data = file_get_contents($fileName);
$createdFile = $service->files->insert($file, array(
'data' => file_get_contents($file_path),
'mimeType' => $mime_type,
));
// Uncomment the following line to print the File ID
// print 'File ID: %s' % $createdFile->getId();
return $createdFile;
} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
}
//}
finfo_close($finfo);
unlink($fileName);
header('location:'.$url);exit;
}
include 'index.phtml';
?>
5. isi file index.phtml dengan form upload
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Google Drive Example App</title>
</head>
<body>
<form method="post" action="<?php echo $url; ?>">
<input type="submit" value="enviar" name="submit">
</form>
</body>
</html>
Selesai
Bila mengalami kendala dalam pembuatan, bisa tengok google drive API Reference –> https://developers.google.com/drive/v2/reference/
Tugas membuat modul pdf online yang hanya dapat dibaca tapi tidak bisa didownload..
Status: in Progress
Belum mendapatkan tutorial yang sesuai. Baru mendapatkan contoh code untuk otentikasi di google drive.
Tutorial dapat diilhat di –> http://www.eduardocasas.com/blog/05-12-2012/subiendo-archivos-a-google-drive-con-php
Source code dapat didownload di –> https://codeload.github.com/eduardocasas/Google-Drive-PHP-API-Simple-App-Example/zip/master
Contoh Hasil Aplikasi yang dijalankan:
nb:
Ada juga tutorial dasar dari google developer –> https://developers.google.com/drive/quickstart-php
Menyelesaikan modul customer service untuk fashion store
Backend:
Frontend:
notes:
browser itu memiliki cache untuk menyimpan data sementara. Celakanya kalau kita sedang editing web, terkadang ketika terjadi kesalahan seperti salah ketik atau melakukan perubahan, website masih tampil normal-normal saja. Akan tetapi ketika kita jalankan di online, ternyata eror..Misal Tampilan di online menjadi blank, padahal di offline tampilan normal (kemungkinan karena cache browser yang aktif).
Bila sudah terlanjur, coba lakukan tracing dengan menambahkan syntax sederhana, misal <?php echo “ok” ?>..Lakukan tracing secara berurutan dan berpindah-pindah bagian hingga eror ditemukan.
Aktifkan display_errors di php.ini , sehingga bila terjadi error ada error message-nya. Bila sudah final, atau diserah terima ke end-user, baru error message di nonaktifkan kembali agar tidak menggangu pemandangan.
Membuat Widget Customer Service Statis
<div class="box">
<h4>Customer Service</h4>
<table border="0" cellpadding="4" cellspacing="0">
<tr><td>sen-Jum<td>8:00-16:30</td>
<tr><td>sabtu<td>8:00-15:00</td></tr>
<tr><td>admin</td><td><a href="ymsgr:sendIM?fashionstore">
<img src="http://opi.yahoo.com/online?u=fashionstore&m=g&t=1&rand=5292d14262f86" width=64 height=16 border=0 align="absmiddle"></a></td></tr>
<tr><td>telp<td>021-6621291/92</td></tr>
<tr><td>HP<td>021-6621282</td></tr>
<tr><td>BB<td>021-6621282</td></tr>
<tr><td>fax<td>021-6621282</td></tr>
<tr>
<td colspan="2"><a href="mailto:admin@fashionstore.com">admin@fashionstore.com</a></td>
</tr>
</table>
</div>
Result: