本文整理汇总了PHP中Contacts::getAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP Contacts::getAdapter方法的具体用法?PHP Contacts::getAdapter怎么用?PHP Contacts::getAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contacts
的用法示例。
在下文中一共展示了Contacts::getAdapter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteprofileimageAction
public function deleteprofileimageAction()
{
$staff = new Contacts();
$staffs = $staff->getImage($this->_getParam('id'));
foreach ($staffs as $staff) {
$filename = $staff['image'];
}
$updateData = array();
$updateData['image'] = NULL;
$updateData['updated'] = $this->getTimeForForms();
$updateData['updatedBy'] = $this->getIdentityForForms();
$stafflist = new Contacts();
$where = $stafflist->getAdapter()->quoteInto('id = ?', (int) $this->_getParam('id'));
$stafflist->update($updateData, $where);
$name = substr($filename, 0, strrpos($filename, '.'));
$ext = '.jpg';
$converted = $name . $ext;
unlink('./images/staffphotos/' . $filename);
unlink('./images/staffphotos/resized/' . $converted);
unlink('./images/staffphotos/thumbnails/' . $converted);
}
示例2: imageAction
/** Change your staff profile image
*/
public function imageAction()
{
$people = $this->_contacts->fetchRow($this->_contacts->select()->where('dbaseID = ' . $this->getIdentityForForms()));
if (is_null($people)) {
throw new Pas_Exception('Admin has not yet set up a profile for you');
}
$this->view->contacts = $people->toArray();
$currentimage = $people->image;
$form = new AddStaffPhotoForm();
$this->view->form = $form;
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
if ($form->isValid($formData)) {
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->addValidator('NotExists', true, array('./assets/staffphotos/'));
if ($upload->isValid()) {
$filename = $form->getValue('image');
$largepath = self::PROFILEPATH;
$original = $largepath . $filename;
$name = substr($filename, 0, strrpos($filename, '.'));
$ext = '.jpg';
$converted = $name . $ext;
$insertData = array();
$insertData['image'] = $converted;
$insertData['updated'] = $this->getTimeForForms();
$insertData['updatedBy'] = $this->getIdentityForForms();
foreach ($insertData as $key => $value) {
if (is_null($value) || $value == "") {
unset($insertData[$key]);
}
}
$smallpath = self::PROFILEPATH . 'thumbnails/' . $converted;
$mediumpath = self::PROFILEPATH . 'resized/' . $converted;
//create medium size
$phMagick = new phMagick($original, $mediumpath);
$phMagick->resize(400, 0);
$phMagick->convert();
/* Zend_Debug::dump($convertsmall);
Zend_Debug::dump($phMagick);
exit; */
$phMagick = new phMagick($original, $smallpath);
$phMagick->resize(80, 0);
$phMagick->convert();
$staffs = new Contacts();
$where = array();
$where[] = $staffs->getAdapter()->quoteInto('dbaseID = ?', $this->getIdentityForForms());
$staffs->update($insertData, $where);
$upload->receive();
unlink(self::PROFILEPATH . 'thumbnails/' . $currentimage);
unlink(self::PROFILEPATH . $currentimage);
unlink(self::PROFILEPATH . 'resized/' . $currentimage);
$this->getFlash()->addMessage('The image has been resized and added to your profile.');
$this->redirect('/users/account/');
} else {
$this->getFlash()->addMessage('There is a problem with your upload. Probably that image exists.');
$this->view->errors = $upload->getMessages();
}
} else {
$form->populate($formData);
$this->getFlash()->addMessage('Check your form for errors');
}
}
}
示例3: avatarAction
/** provide an avatar for a contact
*/
public function avatarAction()
{
$form = new AddStaffPhotoForm();
$this->view->form = $form;
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
if ($form->isValid($formData)) {
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->addValidator('NotExists', true, array(self::STAFFPATH));
if ($upload->isValid()) {
$filename = $form->getValue('image');
$insertData = array();
$insertData['image'] = $filename;
$insertData['updated'] = $this->getTimeForForms();
$insertData['updatedBy'] = $this->getIdentityForForms();
foreach ($insertData as $key => $value) {
if (is_null($value) || $value == "") {
unset($insertData[$key]);
}
}
$original = self::STAFFPATH . $filename;
$name = substr($filename, 0, strrpos($filename, '.'));
$ext = '.jpg';
$converted = $name . $ext;
$smallpath = self::STAFFPATH . 'thumbnails/' . $converted;
$mediumpath = self::STAFFPATH . 'resized/' . $converted;
//create medium size
$phMagick = new phMagick($original, $mediumpath);
$phMagick->resize(300, 0);
$phMagick->convert();
/* Zend_Debug::dump($convertsmall);
Zend_Debug::dump($phMagick);
exit; */
$phMagick = new phMagick($original, $smallpath);
$phMagick->resize(100, 0);
$phMagick->convert();
$staffs = new Contacts();
$where = array();
$where[] = $staffs->getAdapter()->quoteInto('id = ?', $this->_getParam('id'));
$staffs->update($insertData, $where);
$upload->receive();
$this->_flashMessenger->addMessage('The image has been resized and zoomified!');
$this->_redirect('/admin/contacts/contact/id/' . $this->_getParam('id'));
} else {
$this->_flashMessenger->addMessage('There is a problem with your upload.
Probably that image exists.');
$this->view->errors = $upload->getMessages();
}
} else {
$form->populate($formData);
$this->_flashMessenger->addMessage('Check your form for errors dude');
}
}
}