本文整理匯總了PHP中ImageManager::dbstore方法的典型用法代碼示例。如果您正苦於以下問題:PHP ImageManager::dbstore方法的具體用法?PHP ImageManager::dbstore怎麽用?PHP ImageManager::dbstore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ImageManager
的用法示例。
在下文中一共展示了ImageManager::dbstore方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: handlePostData
/**
* Méthode callback qui gère la soumission du formulaire add/edit.
* Elle est appelée via callback par la méthode process() de HTML_QuickForm
*
* @access public
* @param array $values les données du formulaire.
* @return void
*/
public function handlePostData($values)
{
if (!$this->innerForm) {
Database::connection()->startTrans();
}
$this->onBeforeHandlePostData($values);
if ($this->object->getId() == 0) {
$this->object->generateId();
$this->objID = $this->object->getId();
}
// gestion des propriétés et des fkeys
foreach ($this->attrs as $property => $class) {
$setter = 'set' . $property;
$getter = 'get' . $property;
if (!method_exists($this->object, $setter)) {
continue;
}
$eltname = $this->clsname . '_' . $property;
if (!is_string($class) && isset($values[$eltname])) {
// propriétés simples
$data = $values[$eltname];
} else {
if (isset($values[$eltname . '_ID'])) {
// on a une fkey
$data = $values[$eltname . '_ID'];
$getter .= 'Id';
} else {
if (isset($_FILES[$eltname])) {
$data = $_FILES[$eltname];
}
}
}
if (isset($data)) {
$custom = 'handle' . $property;
if (method_exists($this, $custom)) {
call_user_func(array($this, $custom), $data);
continue;
}
if ($class == Object::TYPE_PASSWORD) {
if ($data != $values[$eltname . '_Again']) {
Template::errorDialog(E_PASSWD_MISMATCH, $this->url);
exit(1);
}
if ($data != self::PW_NOCHG) {
$this->object->{$setter}($data);
}
} elseif ($class == Object::TYPE_FILE_UPLOAD) {
if (isset($_FILES[$eltname]['name']) && !empty($_FILES[$eltname]['name'])) {
try {
$uploader = new Upload($eltname);
if (UPLOAD_STORAGE == 'db') {
// stock l'image ou le fichier en bd
$uploader->dbstore();
$this->object->{$setter}($_FILES[$eltname]['name']);
} else {
// stock l'image ou le fichier en dur et écrit le chemin en bd
$uploader->store(UPLOAD_STORAGE);
$this->object->{$setter}($data);
}
} catch (Exception $exc) {
Template::errorDialog($exc->getMessage(), $this->guessReturnURL());
exit;
}
}
} else {
if ($class == Object::TYPE_IMAGE) {
if (isset($_FILES[$eltname]['name']) && !empty($_FILES[$eltname]['name'])) {
try {
$manager = new ImageManager($eltname);
$manager->dbstore();
$this->object->{$setter}($_FILES[$eltname]['name']);
} catch (Exception $exc) {
Template::errorDialog($exc->getMessage(), $this->guessReturnURL());
exit;
}
}
} elseif ($class == Object::TYPE_DATETIME) {
$this->object->{$setter}($data . ':00');
/*$datetime = explode(' ', $data);
if (count($datetime) == 2) {
list($date, $time) = $datetime;
$date = explode('/', $date);
if (count($date) == 3) {
list($d, $m, $y) = $date;
$data = sprintf('%04d-%02d-%02d %s:00', $y, $m, $d, $time);
$this->object->$setter($data);
}
}*/
} elseif (in_array($class, array(Object::TYPE_FLOAT, Object::TYPE_DECIMAL))) {
$this->object->{$setter}(I18N::extractNumber($data));
} elseif (is_string($class)) {
if ($this->innerForm && $this->innerForm->clsname == $class) {
//.........這裏部分代碼省略.........