本文整理汇总了PHP中Banner::store方法的典型用法代码示例。如果您正苦于以下问题:PHP Banner::store方法的具体用法?PHP Banner::store怎么用?PHP Banner::store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Banner
的用法示例。
在下文中一共展示了Banner::store方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Banner
}
}
//echo fRequest::encode('id_zone','integer');
//echo fRequest::encode('id_section','integer');
/*
* Add Article
*/
$banner = new Banner();
$banner->setId_zone(fRequest::encode('id_zone', 'integer'));
$banner->setLink(fRequest::encode('link', 'string'));
$banner->setOrder(fRequest::encode('order', 'integer'));
$banner->setId_section(fRequest::encode('id_section', 'integer'));
/* Limited By User Permissions */
$banner->setStatus(fRequest::get('id_state', 'integer'));
try {
$banner->store();
} catch (Exception $e) {
exit("Ha ocurrido un error.");
}
$lastId = $banner->prepareIdBanner();
/*
* Add Region
* Limited By User Permissions
*/
/*
* Add Files to Server
*/
if (!empty($_FILES)) {
$uploader = new fUpload();
$uploader->setOptional();
$uploader->setMIMETypes($acceptedFiles, 'El tipo de archivo es incorrecto');
示例2: new_action
/**
* Create a new banner
*/
public function new_action()
{
// add new banner input
if (Request::submitted('anlegen')) {
$description = Request::get('description');
$alttext = Request::get('alttext');
$target_type = Request::option('target_type');
//add the right target
if ($target_type == 'url') {
$target = Request::get('target');
} else {
if ($target_type == 'inst') {
$target = Request::option('institut');
} else {
if ($target_type == 'user') {
$target = Request::username('user');
} else {
if ($target_type == 'seminar') {
$target = Request::option('seminar');
} else {
$target = Request::get('target');
}
}
}
}
$priority = Request::int('priority');
$errors = array();
$upload = $_FILES['imgfile'];
if (!$upload['name']) {
$errors[] = _('Es wurde kein Bild ausgewählt.');
} else {
$banner_path = $this->bannerupload($upload['tmp_name'], $upload['size'], $upload['name'], $errors);
}
$startDate = explode('.', Request::get('start_date'));
if (($x = $this->valid_date(Request::int('start_hour'), Request::int('start_minute'), $startDate[0], $startDate[1], $startDate[2])) == -1) {
$errors[] = _('Bitte geben Sie einen gültiges Startdatum ein.');
} else {
$startdate = $x;
}
$endDate = explode('.', Request::get('end_date'));
if (($x = $this->valid_date(Request::int('end_hour'), Request::int('end_minute'), $endDate[0], $endDate[1], $endDate[2])) == -1) {
$errors[] = _('Bitte geben Sie einen gültiges Enddatum ein.');
} else {
$enddate = $x;
}
if (!$target && $target_type != 'none') {
$errors[] = _('Es wurde kein Verweisziel angegeben.');
} else {
switch ($target_type) {
case 'url':
if (!preg_match('~^(https?|ftp)://~i', $target)) {
$errors[] = _('Das Verweisziel muss eine gültige URL sein (incl. http://).');
}
break;
case 'inst':
if (Institute::find($target) === null) {
$errors[] = _('Die angegebene Einrichtung existiert nicht. ' . 'Bitte geben Sie eine gültige Einrichtungs-ID ein.');
}
break;
case 'user':
if (User::findByUsername($target) === null) {
$errors[] = _('Der angegebene Benutzername existiert nicht.');
}
break;
case 'seminar':
try {
Seminar::getInstance($target);
} catch (Exception $e) {
$errors[] = _('Die angegebene Veranstaltung existiert nicht. ' . 'Bitte geben Sie eine gültige Veranstaltungs-ID ein.');
}
break;
case 'none':
$target = '';
break;
}
}
if (count($errors) > 0) {
PageLayout::postMessage(MessageBox::error(_('Es sind folgende Fehler aufgetreten:'), $errors));
} else {
$banner = new Banner();
$banner->banner_path = $banner_path;
$banner->description = $description;
$banner->alttext = $alttext;
$banner->target_type = $target_type;
$banner->target = $target;
$banner->startdate = $startdate;
$banner->enddate = $enddate;
$banner->priority = $priority;
$banner->store();
PageLayout::postMessage(MessageBox::success(_('Der Banner wurde erfolgreich gespeichert.')));
$this->redirect('admin/banner');
}
}
}