-
cahyonegoro
-
-
OFFLINE
-
Warga Joomla
-
- Posts: 2
-
Karma: 0
-
|
Pagi gan, ane mau tanya tentang programming joomla nih
Ane kan mau buat WEB tentang lowongan gitu pake j1.5, terus ane bikin komponen sendiri untuk login user(jadi loginya ga pake joomla) ini script registrasinya
function viewformregjob($rid){
JHTML::_('behavior.formvalidation');
?>
<style type="text/css">
/* form validation */
.invalid { border-color: #ff0000; background-color:#ffd;}
label.invalid { color: #ff0000; }
</style>
<script language="javascript" type="text/javascript">
<!--
function checksubmit() {
var form = document.adminForm;
if (document.formvalidator.isValid(form)) {
form.check.value='<?php echo JUtility::getToken(); ?>';
form.submit();
}else {
alert('<?php echo JText::_('Isi field yang berwarna merah dengan benar!'); ?>');
return false;
}
}
Window.onDomReady(function(){
document.formvalidator.setHandler('passverify', function (value) { return ($('fpassword').value == value); } );
});
//-->
</script>
<form action="index.php" method="post" class="form-validate" name="adminForm" onsubmit="return checksubmit()">
<table class="admintable">
<tr>
<td class="key">
<label for="message">
<?php echo JText::_( 'Username' ); ?>:
</label>
</td>
<td >
<input type="text" name="fusername" id="fusername" size="25" maxlength="255" class="text_area required">
</td>
</tr>
<tr>
<td class="key">
<label for="message">
<?php echo JText::_( 'Password' ); ?>:
</label>
</td>
<td >
<input class="text_area required validate-password" type="password" name="fpassword" id="fpassword" size="25" maxlength="150">
</td>
</tr>
<tr>
<td class="key">
<label for="message">
<?php echo JText::_( 'Re-enter password' ); ?>:
</label>
</td>
<td >
<input class="text_area required validate-passverify" type="password" name="fpassword2" id="password2" size="25" maxlength="150">
</td>
</tr>
<tr>
<td class="key">
<label for="message">
<?php echo JText::_( 'Nama Lengkap' ); ?>:
</label>
</td>
<td >
<input class="text_area required" type="text" name="fnama" id="fnama" size="25" maxlength="150">
</td>
</tr>
<tr>
<td class="key">
<label for="message">
<?php echo JText::_( 'Email' ); ?>:
</label>
</td>
<td >
<input class="text_area required validate-email" type="text" name="femail" id="femail" size="25" maxlength="150">
</td>
</tr>
<tr>
<td class="key">
<label for="message">
<?php echo JText::_( 'No HP' ); ?>:
</label>
</td>
<td >
<input class="text_area required" type="text" name="fhp" id="fhp" size="25" maxlength="150">
</td>
</tr>
<tr>
<td>
</td>
<td >
<input type="submit" value="Daftarkan" class="button" name="daftar" onclick />
</td>
</tr>
</table>
<input type="hidden" name="option" value="com_acc" />
<input type="hidden" name="task" value="doregistrasi" />
<input type="hidden" name="check" value="post" />
<input type="hidden" name="rid" value="<?php echo $rid;?>" />
</form>
<?php
}
terus ane kan bikin script upload foto dan cv gan
//just for jobseeker
function saveProfil(){
global $mainframe;
$session =& JFactory::getSession();
$status = $session->get('accsebagai','');
if($status != 'mhs'):
$mainframe->redirect('member.html', 'Menu khusus untuk jobseeker','error');
exit();
endif;
$doSave = true;
$row = new stdClass();
$row->kode_anggota = $session->get('kodeanggota','');
$row->no = JRequest::getVar( 'fnomhs', '','post', 'string', JREQUEST_ALLOWRAW );
$row->nama = JRequest::getVar( 'fnama', '','post', 'string', JREQUEST_ALLOWRAW );
if($row->nama == ''):
$doSave = false;
endif;
$row->alamat = JRequest::getVar( 'falamat', '','post', 'string', JREQUEST_ALLOWRAW );
$row->tempat_lahir = JRequest::getVar( 'ftmpt', '','post', 'string', JREQUEST_ALLOWRAW );
$tmpTanggal = JRequest::getVar( 'ftgl', '','post', 'string', JREQUEST_ALLOWRAW );
if(ereg("^([0-9]{2})-([0-9]{2})-([0-9]){4}$",$tmpTanggal)):
$tgl = explode('-',$tmpTanggal);
if(count($tgl) == 3):
$row->tgl = $tgl[0];
$row->bulan = $tgl[1];
$row->tahun = $tgl[2];
else:
$doSave = false;
endif;
else:
$doSave = false;
endif;
$row->kuliah = JRequest::getVar( 'fpt', '','post', 'string', JREQUEST_ALLOWRAW );
$row->jurusan = JRequest::getInt( 'fjurusan', 0, 'post');
$row->ipk = JRequest::getVar( 'fipk', '','post', 'string', JREQUEST_ALLOWRAW );
$row->hp = JRequest::getVar( 'fhp', '','post', 'string', JREQUEST_ALLOWRAW );
$row->lulus = JRequest::getVar( 'flulus', '','post', 'string', JREQUEST_ALLOWRAW );
$row->skripsi = JRequest::getVar( 'fta', '','post', 'string', JREQUEST_ALLOWRAW );
$row->email = JRequest::getVar( 'femail', '','post', 'string', JREQUEST_ALLOWRAW );
$tmpKel = JRequest::getVar( 'fsex', '','post', 'string', JREQUEST_ALLOWRAW );
$row->kelamin = ($tmpKel == '1')?'laki-laki':'perempuan';
$almt = JRoute::_( 'index.php?option=com_acc&task=update');
if($doSave):
$db = JFactory::getDBO();
if (!$db->updateObject( '#__anggota', $row, 'kode_anggota' )) {
$mainframe->redirect($almt,'Gagal update profil','error');
return false;
}
//try upload
$file = JRequest::getVar('fphoto', null, 'files', 'array');
if(isset($file) && !empty($file['tmp_name'])):
jimport('joomla.filesystem.file');
$filename = JFile::makeSafe($file['name']);
$newFileName = str_replace(array('-',',','.'),'',$row->kode_anggota);
$src = $file['tmp_name'];
$dest = JPATH_COMPONENT."/foto/".$newFileName.".jpg";
if(strtolower(JFile::getExt($filename)) == 'jpg'):
JFile::upload($src, $dest);
list($width, $height) = getimagesize($dest);
$tmp1 = imagecreatetruecolor(100,150);
$source = imagecreatefromjpeg($dest);
imagecopyresampled($tmp1,$source,0,0,0,0,100,150,$width,$height);
imagejpeg($tmp1,$dest);
imagedestroy($tmp1);
imagedestroy($source);
else:
$mainframe->redirect($almt,'foto yang diupload haruslah JPG','error');
endif;
endif;
$fileCv = JRequest::getVar('fupcv', null, 'files', 'array');
if(isset($fileCv) && !empty($fileCv['tmp_name'])):
jimport('joomla.filesystem.file');
$filename = JFile::makeSafe($fileCv['name']);
$newFileName = str_replace(array('-',',','.'),'',$row->kode_anggota);
$src = $fileCv['tmp_name'];
$dest = JPATH_COMPONENT."/cv/".$newFileName.".doc";
if(strtolower(JFile::getExt($filename)) == 'doc'):
JFile::upload($src, $dest);
else:
$mainframe->redirect($almt,'CV yang diupload berekstensi .doc','error');
endif;
endif;
//end try
$mainframe->redirect($almt,'Member berhasil diupdate');
else:
$mainframe->redirect($almt,'Isi form dengan benar','error');
endif;
}
terus yang berhasil ane tampilin cuma fotonya, ini script nampilin fotonya
<table id="low">
<thead>
<tr>
<th colspan="2">BIODATA</td>
</tr>
</thead>
<tbody>
<tr>
<td colspan=2 align="right">
<?php
if($row->foto == ''):
$newFileName = "foto/".str_replace(array('-',',','.'),'',$row->kode_anggota).".jpg";
else:
$newFileName = $row->kode_anggota;
endif;
?>
<img src="<?php echo "components/com_acc/".$newFileName?>"/>
</td>
</tr>
<tr>
<td><?php echo JText::_( 'Nama' ); ?>:</td>
<td><?php echo $row->nama;?></td>
</tr>
<tr>
<td><?php echo JText::_( 'TTL' ); ?>:</td>
<td><?php echo $row->tempat_lahir.','.$row->tgl_lahir;?></td>
</tr>
<tr>
<td><?php echo JText::_( 'Kuliah' ); ?>:</td>
<td><?php echo $row->kuliah;?></td>
</tr>
<tr>
<td><?php echo JText::_( 'Jurusan' ); ?>:</td>
<td><?php echo $row->jurusan;?></td>
</tr>
<tr>
<td><?php echo JText::_( 'IPK' ); ?>:</td>
<td><?php echo $row->ipk;?></td>
</tr>
<tr>
<td><?php echo JText::_( 'Kelamin' ); ?>:</td>
<td><?php echo $row->kelamin;?></td>
</tr>
<tr>
<td><?php echo JText::_( 'Alamat' ); ?>:</td>
<td><?php echo $row->alamat;?></td>
</tr>
<tr>
<td><?php echo JText::_( 'E-mail' ); ?>:</td>
<td><?php echo $row->email;?></td>
</tr>
<tr>
<td><?php echo JText::_( 'HP' ); ?>:</td>
<td><?php echo $row->hp;?></td>
</tr>
<tr>
<td><?php echo JText::_( 'Skripsi' ); ?>:</td>
<td><?php echo $row->skripsi;?></td>
</tr>
</tbody>
</table>
khusus bagian ini :
<tr>
<td colspan=2 align="right">
<?php
if($row->foto == ''):
$newFileName = "foto/".str_replace(array('-',',','.'),'',$row->kode_anggota).".jpg";
else:
$newFileName = $row->kode_anggota;
endif;
?>
<img src="<?php echo "components/com_acc/".$newFileName?>"/>
</td>
</tr>
bisa keluar foto anggota,..
pertanyaan ane:
terus bagaimana nampilin(bisa download) cvnya,
FYI:
CV dan foto sama sama di folder com_acc
satu anggota nama file cv dan fotonya sama cuma nama extensionya aja beda (*.jpg & *.doc)
thanks for your help
|