本文整理汇总了PHP中BackendModel类的典型用法代码示例。如果您正苦于以下问题:PHP BackendModel类的具体用法?PHP BackendModel怎么用?PHP BackendModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BackendModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
BackendAuthentication::logout();
// redirect to login-screen
$this->redirect(BackendModel::createUrlForAction('index', $this->getModule()));
}
示例2: execute
/**
* Execute the action
*
* @return void
*/
public function execute()
{
// get parameters
$this->id = $this->getParameter('id', 'int');
// does the item exist
if ($this->id !== null && BackendBlogModel::exists($this->id)) {
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// set category id
$this->categoryId = SpoonFilter::getGetValue('category', null, null, 'int');
if ($this->categoryId == 0) {
$this->categoryId = null;
}
// get data
$this->record = (array) BackendBlogModel::get($this->id);
// delete item
BackendBlogModel::delete($this->id);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id));
// delete search indexes
if (is_callable(array('BackendSearchModel', 'removeIndex'))) {
BackendSearchModel::removeIndex($this->getModule(), $this->id);
}
// build redirect URL
$redirectUrl = BackendModel::createURLForAction('index') . '&report=deleted&var=' . urlencode($this->record['title']);
// append to redirect URL
if ($this->categoryId != null) {
$redirectUrl .= '&category=' . $this->categoryId;
}
// item was deleted, so redirect
$this->redirect($redirectUrl);
} else {
$this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing');
}
}
示例3: validateForm
/**
* Validates the settings form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
if ($this->frm->isCorrect()) {
// set the base values
$width = (int) $this->frm->getField('width_widget')->getValue();
$height = (int) $this->frm->getField('height_widget')->getValue();
if ($width > 800) {
$width = 800;
} elseif ($width < 300) {
$width = BackendModel::getModuleSetting('location', 'width_widget');
}
if ($height < 150) {
$height = BackendModel::getModuleSetting('location', 'height_widget');
}
// set our settings (widgets)
BackendModel::setModuleSetting($this->URL->getModule(), 'zoom_level_widget', (string) $this->frm->getField('zoom_level_widget')->getValue());
BackendModel::setModuleSetting($this->URL->getModule(), 'width_widget', $width);
BackendModel::setModuleSetting($this->URL->getModule(), 'height_widget', $height);
BackendModel::setModuleSetting($this->URL->getModule(), 'map_type_widget', (string) $this->frm->getField('map_type_widget')->getValue());
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_saved_settings');
// redirect to the settings page
$this->redirect(BackendModel::createURLForAction('settings') . '&report=saved');
}
}
}
示例4: validateForm
/**
* Validate the form.
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// get field
$txtName = $this->frm->getField('name');
// name filled in?
if ($txtName->isFilled(BL::getError('NameIsRequired'))) {
// name exists?
if (BackendProfilesModel::existsGroupName($txtName->getValue())) {
// set error
$txtName->addError(BL::getError('GroupNameExists'));
}
}
// no errors?
if ($this->frm->isCorrect()) {
// build item
$values['name'] = $txtName->getValue();
// insert values
$id = BackendProfilesModel::insertGroup($values);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_group', array('item' => $values));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('groups') . '&report=group-added&var=' . urlencode($values['name']) . '&highlight=row-' . $id);
}
}
}
示例5: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// action to execute
$action = SpoonFilter::getGetValue('action', array('delete', 'export'), '');
$this->groupId = SpoonFilter::getGetValue('group_id', null, '');
// no id's provided
if (!$action) {
$this->redirect(BackendModel::createURLForAction('addresses') . '&error=no-action-selected');
}
if (!isset($_GET['emails'])) {
$this->redirect(BackendModel::createURLForAction('addresses') . '&error=no-items-selected');
} else {
// redefine id's
$this->emails = (array) $_GET['emails'];
// evaluate $action, see what action was triggered
switch ($action) {
case 'delete':
$this->deleteAddresses();
break;
case 'export':
$this->exportAddresses();
break;
}
}
}
示例6: execute
/**
* Execute the action
*
* @return void
*/
public function execute()
{
// get parameters
$this->id = $this->getParameter('id', 'int');
// does the item exist
if ($this->id !== null && BackendBlogModel::existsCategory($this->id)) {
// get data
$this->record = (array) BackendBlogModel::getCategory($this->id);
// allowed to delete the category?
if (BackendBlogModel::deleteCategoryAllowed($this->id)) {
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// delete item
BackendBlogModel::deleteCategory($this->id);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_delete_category', array('id' => $this->id));
// category was deleted, so redirect
$this->redirect(BackendModel::createURLForAction('categories') . '&report=deleted-category&var=' . urlencode($this->record['title']));
} else {
$this->redirect(BackendModel::createURLForAction('categories') . '&error=delete-category-not-allowed&var=' . urlencode($this->record['title']));
}
} else {
$this->redirect(BackendModel::createURLForAction('categories') . '&error=non-existing');
}
}
示例7: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// get parameters
$mailingId = SpoonFilter::getPostValue('mailing_id', null, '', 'int');
$sendOnDate = SpoonFilter::getPostValue('send_on_date', null, BackendModel::getUTCDate('d/m/Y'));
$sendOnTime = SpoonFilter::getPostValue('send_on_time', null, BackendModel::getUTCDate('H:i'));
$messageDate = $sendOnDate;
// validate mailing ID
if ($mailingId == '') {
$this->output(self::BAD_REQUEST, null, 'Provide a valid mailing ID');
}
if ($sendOnDate == '' || $sendOnTime == '') {
$this->output(self::BAD_REQUEST, null, 'Provide a valid send date date provided');
}
// record is empty
if (!BackendMailmotorModel::existsMailing($mailingId)) {
$this->output(self::BAD_REQUEST, null, BL::err('MailingDoesNotExist', 'mailmotor'));
}
// reverse the date and make it a proper
$explodedDate = explode('/', $sendOnDate);
$sendOnDate = $explodedDate[2] . '-' . $explodedDate[1] . '-' . $explodedDate[0];
// calc full send timestamp
$sendTimestamp = strtotime($sendOnDate . ' ' . $sendOnTime);
// build data
$item['id'] = $mailingId;
$item['send_on'] = BackendModel::getUTCDate('Y-m-d H:i:s', $sendTimestamp);
$item['edited_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
// update mailing
BackendMailmotorModel::updateMailing($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_edit_mailing_step4', array('item' => $item));
// output
$this->output(self::OK, array('mailing_id' => $mailingId, 'timestamp' => $sendTimestamp), sprintf(BL::msg('SendOn', $this->getModule()), $messageDate, $sendOnTime));
}
示例8: loadDatagrids
/**
* Loads the dataGrids
*/
private function loadDatagrids()
{
// load all categories
$categories = BackendFaqModel::getCategories(true);
// loop categories and create a dataGrid for each one
foreach ($categories as $categoryId => $categoryTitle) {
$dataGrid = new BackendDataGridDB(BackendFaqModel::QRY_DATAGRID_BROWSE, array(BL::getWorkingLanguage(), $categoryId));
$dataGrid->setAttributes(array('class' => 'dataGrid sequenceByDragAndDrop'));
$dataGrid->setColumnsHidden(array('category_id', 'sequence'));
$dataGrid->addColumn('dragAndDropHandle', null, '<span>' . BL::lbl('Move') . '</span>');
$dataGrid->setColumnsSequence('dragAndDropHandle');
$dataGrid->setColumnAttributes('question', array('class' => 'title'));
$dataGrid->setColumnAttributes('dragAndDropHandle', array('class' => 'dragAndDropHandle'));
$dataGrid->setRowAttributes(array('id' => '[id]'));
// check if this action is allowed
if (BackendAuthentication::isAllowedAction('edit')) {
$dataGrid->setColumnURL('question', BackendModel::createURLForAction('edit') . '&id=[id]');
$dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]', BL::lbl('Edit'));
}
// add dataGrid to list
$this->dataGrids[] = array('id' => $categoryId, 'title' => $categoryTitle, 'content' => $dataGrid->getContent());
}
// set empty datagrid
$this->emptyDatagrid = new BackendDataGridArray(array(array('dragAndDropHandle' => '', 'question' => BL::msg('NoQuestionInCategory'), 'edit' => '')));
$this->emptyDatagrid->setAttributes(array('class' => 'dataGrid sequenceByDragAndDrop emptyGrid'));
$this->emptyDatagrid->setHeaderLabels(array('edit' => null, 'dragAndDropHandle' => null));
}
示例9: execute
/**
* Execute the action.
*/
public function execute()
{
// get parameters
$this->id = $this->getParameter('id', 'int');
// does the item exist
if ($this->id !== null && BackendProfilesModel::exists($this->id)) {
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// get item
$profile = BackendProfilesModel::get($this->id);
// already blocked? Prolly want to unblock then
if ($profile['status'] === 'blocked') {
// set profile status to active
BackendProfilesModel::update($this->id, array('status' => 'active'));
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_unblock', array('id' => $this->id));
// redirect
$this->redirect(BackendModel::createURLForAction('index') . '&report=profile-unblocked&var=' . urlencode($profile['email']) . '&highlight=row-' . $this->id);
} else {
// delete profile session that may be active
BackendProfilesModel::deleteSession($this->id);
// set profile status to blocked
BackendProfilesModel::update($this->id, array('status' => 'blocked'));
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_block', array('id' => $this->id));
// redirect
$this->redirect(BackendModel::createURLForAction('index') . '&report=profile-blocked&var=' . urlencode($profile['email']) . '&highlight=row-' . $this->id);
}
} else {
$this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing');
}
}
示例10: execute
/**
* Execute the widget
*
* @return void
*/
public function execute()
{
// analytics session token and analytics table id
if (BackendModel::getModuleSetting('analytics', 'session_token', null) == '') {
return;
}
if (BackendModel::getModuleSetting('analytics', 'table_id', null) == '') {
return;
}
// settings are ok, set option
$this->tpl->assign('analyticsValidSettings', true);
// set column
$this->setColumn('right');
// set position
$this->setPosition(0);
// add css
$this->header->addCSS('widgets.css', 'analytics');
// add highchart javascript
$this->header->addJS('highcharts.js', 'analytics');
$this->header->addJS('analytics.js', 'analytics');
// parse
$this->parse();
// display
$this->display();
}
示例11: loadDataGrid
/**
* Loads the datagrid with the groups
*
* @return void
*/
private function loadDataGrid()
{
// create datagrid
$this->dataGrid = new BackendDataGridDB(BackendMailmotorModel::QRY_DATAGRID_BROWSE_GROUPS);
$this->dataGrid->setColumnsHidden(array('language', 'is_default'));
// sorting columns
$this->dataGrid->setSortingColumns(array('name', 'created_on'), 'created_on');
$this->dataGrid->setSortParameter('desc');
// set colum URLs
$this->dataGrid->setColumnURL('name', BackendModel::createURLForAction('addresses') . '&group_id=[id]');
// set the datagrid ID so we don't run into trouble with multiple datagrids that use mass actions
$this->dataGrid->setAttributes(array('id' => 'dgGroups'));
// add the multicheckbox column
$this->dataGrid->setMassActionCheckboxes('checkbox', '[id]', BackendMailmotorModel::getDefaultGroupIds());
$this->dataGrid->setColumnsSequence('checkbox', 'name', 'created_on', 'language');
// add mass action dropdown
$ddmMassAction = new SpoonFormDropdown('action', array('delete' => BL::lbl('Delete')), 'delete');
$this->dataGrid->setMassAction($ddmMassAction);
// set column functions
$this->dataGrid->setColumnFunction(array('BackendDataGridFunctions', 'getTimeAgo'), array('[created_on]'), 'created_on', true);
// add delete column
$this->dataGrid->addColumnAction('custom_fields', null, BL::lbl('CustomFields'), BackendModel::createURLForAction('custom_fields') . '&group_id=[id]', BL::lbl('CustomFields'), array('class' => 'button icon iconEdit linkButton'));
$this->dataGrid->addColumnAction('export', null, BL::lbl('Export'), BackendModel::createURLForAction('export_addresses') . '&id=[id]', BL::lbl('Export'), array('class' => 'button icon iconExport linkButton'));
$this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit_group') . '&id=[id]', BL::lbl('Edit'));
// add styles
$this->dataGrid->setColumnAttributes('name', array('class' => 'title'));
// set paging limit
$this->dataGrid->setPagingLimit(self::PAGING_LIMIT);
}
示例12: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
BackendBlogModel::deleteSpamComments();
// item was deleted, so redirect
$this->redirect(BackendModel::createURLForAction('comments') . '&report=deleted-spam#tabSpam');
}
示例13: execute
/**
* Execute the action
*/
public function execute()
{
// get parameters
$this->id = $this->getParameter('mailing_id', 'int');
// does the item exist
if (BackendMailmotorModel::existsMailing($this->id)) {
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// fetch the mailing
$mailing = BackendMailmotorModel::getMailing($this->id);
// get all data for the user we want to edit
$records = (array) BackendMailmotorCMHelper::getCM()->getCampaignBounces($mailing['cm_id']);
// reset some data
if (!empty($records)) {
// loop the records
foreach ($records as $record) {
// only remove the hard bounces
if ($record['bounce_type'] == 'Hard') {
// remove the address
BackendMailmotorModel::deleteAddresses($record['email']);
}
}
}
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_delete_bounces');
// user was deleted, so redirect
$this->redirect(BackendModel::createURLForAction('statistics') . '&id=' . $mailing['id'] . '&report=deleted-bounces');
} else {
$this->redirect(BackendModel::createURLForAction('statistics') . '&error=no-bounces');
}
}
示例14: execute
/**
* Execute the action
*/
public function execute()
{
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// init vars
$templates = array();
$theme = BackendModel::getModuleSetting('core', 'theme');
$files[] = BACKEND_PATH . '/core/layout/editor_templates/templates.js';
$themePath = FRONTEND_PATH . '/themes/' . $theme . '/core/layout/editor_templates/templates.js';
if (SpoonFile::exists($themePath)) {
$files[] = $themePath;
}
// loop all files
foreach ($files as $file) {
// process file
$templates = array_merge($templates, $this->processFile($file));
}
// set headers
SpoonHTTP::setHeaders('Content-type: text/javascript');
// output the templates
if (!empty($templates)) {
echo 'CKEDITOR.addTemplates(\'default\', { imagesPath: \'/\', templates:' . "\n";
echo json_encode($templates) . "\n";
echo '});';
}
exit;
}
示例15: validateForm
/**
* Validate the form
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// shorten fields
$txtName = $this->frm->getField('name');
$rbtDefaultForLanguage = $this->frm->getField('default');
// validate fields
if ($txtName->isFilled(BL::err('NameIsRequired'))) {
// check if the group exists by name
if (BackendMailmotorModel::existsGroupByName($txtName->getValue())) {
$txtName->addError(BL::err('GroupAlreadyExists'));
}
}
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item['name'] = $txtName->getValue();
$item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
$item['language'] = $rbtDefaultForLanguage->getValue() === '0' ? null : $rbtDefaultForLanguage->getValue();
$item['is_default'] = $rbtDefaultForLanguage->getChecked() ? 'Y' : 'N';
// insert the item
$item['id'] = BackendMailmotorCMHelper::insertGroup($item);
// check if all default groups were set
BackendMailmotorModel::checkDefaultGroups();
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_group', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('groups') . '&report=added&var=' . urlencode($item['name']) . '&highlight=id-' . $item['id']);
}
}
}