本文整理匯總了PHP中Backend\Core\Engine\Model類的典型用法代碼示例。如果您正苦於以下問題:PHP Model類的具體用法?PHP Model怎麽用?PHP Model使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Model類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: execute
/**
* Execute the action
*/
public function execute()
{
// If step 1 isn't entered, redirect back to the first step of the wizard
$this->record = \SpoonSession::get('module');
if (!$this->record || !array_key_exists('title', $this->record)) {
$this->redirect(Model::createURLForAction('Add'));
}
// If there are no fields added, redirect back to the second step of the wizard
if (!array_key_exists('fields', $this->record) || empty($this->record['fields'])) {
$this->redirect(Model::createURLForAction('AddStep2'));
}
parent::execute();
// initialize some variables
$this->backendPath = BACKEND_MODULES_PATH . '/' . $this->record['camel_case_name'] . '/';
$this->frontendPath = FRONTEND_MODULES_PATH . '/' . $this->record['camel_case_name'] . '/';
$this->variables = (array) $this->record;
unset($this->variables['fields']);
$this->generateFolders();
$this->generateBaseFiles();
$this->generateInstallerFiles();
// Backend
$this->generateBackendFiles();
$this->generateBackendModel();
$this->generateBackendActions();
$this->generateBackendCategoryActions();
// Frontend
$this->generateFrontendFiles();
$this->generateFrontendModel();
$this->generateFrontendActions();
$this->generateFrontendCategoryActions();
$this->generateFrontendCategoryWidget();
$this->parse();
$this->display();
}
示例2: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
BackendAuthentication::logout();
// redirect to login-screen
$this->redirect(BackendModel::createURLForAction('Index', $this->getModule()));
}
示例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 = $this->get('fork.settings')->get('Location', 'width_widget');
}
if ($height < 150) {
$height = $this->get('fork.settings')->get('Location', 'height_widget');
}
// set our settings (widgets)
$this->get('fork.settings')->set($this->URL->getModule(), 'zoom_level_widget', (string) $this->frm->getField('zoom_level_widget')->getValue());
$this->get('fork.settings')->set($this->URL->getModule(), 'width_widget', $width);
$this->get('fork.settings')->set($this->URL->getModule(), 'height_widget', $height);
$this->get('fork.settings')->set($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: loadModules
/**
* Loops all backend modules, and builds a list of those that have an
* api.php file in their engine.
*/
protected function loadModules()
{
$modules = BackendModel::getModules();
foreach ($modules as &$module) {
// class names of the API file are always based on the name o/t module
$className = 'Backend\\Modules\\' . $module . '\\Engine\\Api';
if ($module == 'Core') {
$className = 'Backend\\Core\\Engine\\Api';
}
/*
* check if the api.php file exists for this module, and load it so our methods are
* accessible by the Reflection API.
*/
if (!class_exists($className)) {
continue;
}
$methods = get_class_methods($className);
// we will need the parameters + PHPDoc to generate our text fields
foreach ($methods as $key => $method) {
$methods[$key] = array('name' => $method, 'parameters' => $this->loadParameters($className, $method));
}
// properly format so an iteration can do the work for us
$this->modules[] = array('name' => $module, 'methods' => $methods);
}
}
示例5: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// validate fields
$this->meta->validate();
if ($this->frm->isCorrect()) {
// build item
$item['language'] = BL::getWorkingLanguage();
$item['meta_id'] = $this->meta->save();
$item['sequence'] = BackendCatalogModel::getMaximumSpecificationSequence() + 1;
// save the data
$item['id'] = BackendCatalogModel::insertSpecification($item);
//--Add the languages
foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) {
$itemLanguage = array();
$itemLanguage['id'] = $item['id'];
$itemLanguage['language'] = $language;
$itemLanguage['title'] = $this->frm->getField('title_' . $language)->getValue();
BackendCatalogModel::insertSpecificationLanguage($itemLanguage);
}
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_specification', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('specifications') . '&report=added-specification&var=' . urlencode($this->frm->getField('title_nl')->getValue()) . '&highlight=row-' . $item['id']);
}
}
}
示例6: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// action to execute
$action = \SpoonFilter::getGetValue('action', array('delete'), '');
// form id
$formId = \SpoonFilter::getGetValue('form_id', null, '', 'int');
// no id's provided
if (!isset($_GET['id'])) {
$this->redirect(BackendModel::createURLForAction('Index') . '&error=no-items-selected');
} elseif ($action == '') {
// no action provided
$this->redirect(BackendModel::createURLForAction('Index') . '&error=no-action-selected');
} elseif (!BackendFormBuilderModel::exists($formId)) {
// valid form id
$this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
} else {
// redefine id's
$ids = (array) $_GET['id'];
// delete comment(s)
if ($action == 'delete') {
BackendFormBuilderModel::deleteData($ids);
}
// define report
$report = count($ids) > 1 ? 'items-' : 'item-';
// init var
if ($action == 'delete') {
$report .= 'deleted';
}
// redirect
$this->redirect(BackendModel::createURLForAction('Data') . '&id=' . $formId . '&report=' . $report);
}
}
示例7: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
BackendCatalogModel::deleteSpamComments();
// item was deleted, so redirect
$this->redirect(BackendModel::createURLForAction('comments') . '&report=deleted-spam#tabSpam');
}
示例8: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
$fields = $this->frm->getFields();
// validate fields
$fields['title']->isFilled(BL::err('TitleIsRequired'));
if ($this->frm->isCorrect()) {
// build item
$item['id'] = BackendContentBlocksModel::getMaximumId() + 1;
$item['user_id'] = BackendAuthentication::getUser()->getUserId();
$item['template'] = count($this->templates) > 1 ? $fields['template']->getValue() : $this->templates[0];
$item['language'] = BL::getWorkingLanguage();
$item['title'] = $fields['title']->getValue();
$item['text'] = $fields['text']->getValue();
$item['hidden'] = $fields['hidden']->getValue() ? 'N' : 'Y';
$item['status'] = 'active';
$item['created_on'] = BackendModel::getUTCDate();
$item['edited_on'] = BackendModel::getUTCDate();
// insert the item
$item['revision_id'] = BackendContentBlocksModel::insert($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('Index') . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']);
}
}
}
示例9: 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();
// validate field
$this->frm->getField('synonym')->isFilled(BL::err('SynonymIsRequired'));
$this->frm->getField('term')->isFilled(BL::err('TermIsRequired'));
if (BackendSearchModel::existsSynonymByTerm($this->frm->getField('term')->getValue())) {
$this->frm->getField('term')->addError(BL::err('TermExists'));
}
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item = array();
$item['term'] = $this->frm->getField('term')->getValue();
$item['synonym'] = $this->frm->getField('synonym')->getValue();
$item['language'] = BL::getWorkingLanguage();
// insert the item
$id = BackendSearchModel::insertSynonym($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_synonym', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('Synonyms') . '&report=added-synonym&var=' . rawurlencode($item['term']) . '&highlight=row-' . $id);
}
}
}
示例10: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
BackendAgendaModel::deleteSubscribedSubscriptions();
// item was deleted, so redirect
$this->redirect(BackendModel::createURLForAction('subscriptions') . '&report=deleted-subscribed#tabSubscribed');
}
示例11: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
BackendCatalogModel::deleteCompletedOrders();
// item was deleted, so redirect
$this->redirect(BackendModel::createURLForAction('orders') . '&report=deleted-completed#tabCompleted');
}
示例12: validateForm
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$fields = $this->frm->getFields();
$fields['title']->isFilled(BL::err('TitleIsRequired'));
if ($this->frm->isCorrect()) {
$item = [];
$item['title'] = $fields['title']->getValue();
$item['capacity'] = $fields['capacity']->getValue();
$item['price'] = $fields['price']->getValue();
$item['count'] = $fields['count']->getValue();
$item['image'] = null;
$item['hotel_id'] = $this->id;
if ($fields['image']->isFilled()) {
// the image path
$imagePath = FRONTEND_FILES_PATH . '/rooms/images';
// create folders if needed
$fs = new Filesystem();
$fs->mkdir(array($imagePath . '/source', $imagePath . '/128x128'));
$item['image'] = $fields['image']->getFileName(false) . '.' . $fields['image']->getExtension();
$i = 2;
while ($fs->exists($imagePath . '/source/' . $item['image'])) {
$item['image'] = $fields['image']->getFileName(false) . '(' . $i . ')' . '.' . $fields['image']->getExtension();
$i++;
}
// upload the image & generate thumbnails
$fields['image']->generateThumbnails($imagePath, $item['image']);
}
$item['id'] = BackendHotelsModel::insertRecord('hotels_rooms', $item);
$this->redirect(BackendModel::createURLForAction('Rooms') . '&id=' . $this->id . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']);
}
}
}
示例13: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// action to execute
$action = SpoonFilter::getGetValue('action', array('deleteImages', 'deleteFiles', 'deleteVideos'), 'delete');
if (!isset($_GET['id'])) {
$this->redirect(BackendModel::createURLForAction('index') . '&error=no-selection');
} else {
// redefine id's
$aIds = (array) $_GET['id'];
$agendaID = (int) $_GET['agenda_id'];
// delete media
if ($action == 'deleteImages') {
BackendAgendaModel::deleteImage($aIds);
} else {
if ($action == 'deleteFiles') {
BackendAgendaModel::deleteFile($aIds);
} else {
if ($action == 'deleteVideos') {
BackendAgendaModel::deleteVideo($aIds);
}
}
}
}
$this->redirect(BackendModel::createURLForAction('media') . '&agenda_id=' . $agendaID . '&report=deleted');
}
示例14: validateForm
/**
* Validate the form
*/
protected function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// Validation
$fields = $this->frm->getFields();
$fields['username']->isFilled(Language::err('FieldIsRequired'));
if ($this->frm->isCorrect()) {
// Build the item
$item['username'] = $fields['username']->getValue();
// Lookup user id
$userObj = Helper::searchUser($item['username']);
if (isset($userObj->data)) {
$userId = $userObj->data[0]->id;
$item['user_id'] = $userId;
} else {
$this->redirect(Model::createURLForAction('Index') . '&error=api_error');
}
// Insert it
$item['id'] = BackendInstagramModel::insert($item);
Model::triggerEvent($this->getModule(), 'after_add', $item);
$this->redirect(Model::createURLForAction('Index') . '&report=added&highlight=row-' . $item['id']);
}
}
}
示例15: validateForm
/**
* Validate the form
*/
protected function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
$frmFields = $this->frm->getFields();
// validate form
if ($frmFields['twitter']->isChecked()) {
// we need fields when search is ticked
$frmFields['twitter_name']->isFilled(Language::err('FieldIsRequired'));
}
if ($this->frm->isCorrect()) {
// if this field is checked, let's add a boolean searchable true to the chosen fields
if ($frmFields['twitter']->isChecked()) {
$this->record['twitter'] = $frmFields['twitter_name']->getValue();
} else {
if (array_key_exists('twitter', $this->record)) {
unset($this->record['twitter']);
}
}
// save the object in our session
\SpoonSession::set('module', $this->record);
$this->redirect(Model::createURLForAction('Generate'));
}
}
}