• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Engine\Model类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Backend\Core\Engine\Model的典型用法代码示例。如果您正苦于以下问题:PHP Model类的具体用法?PHP Model怎么用?PHP Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Model类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
 }
开发者ID:jonasdekeukelaere,项目名称:moduleMaker,代码行数:37,代码来源:Generate.php


示例2: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     BackendAuthentication::logout();
     // redirect to login-screen
     $this->redirect(BackendModel::createURLForAction('Index', $this->getModule()));
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:10,代码来源:Logout.php


示例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');
         }
     }
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:31,代码来源:Settings.php


示例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);
     }
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:29,代码来源:Client.php


示例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']);
         }
     }
 }
开发者ID:Comsa-Veurne,项目名称:modules,代码行数:31,代码来源:AddSpecification.php


示例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);
     }
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:36,代码来源:MassDataAction.php


示例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');
 }
开发者ID:Comsa-Veurne,项目名称:modules,代码行数:10,代码来源:DeleteSpam.php


示例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']);
         }
     }
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:31,代码来源:Add.php


示例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);
         }
     }
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:31,代码来源:AddSynonym.php


示例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');
 }
开发者ID:Comsa-Veurne,项目名称:modules,代码行数:10,代码来源:DeleteSubscribed.php


示例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');
 }
开发者ID:Comsa-Veurne,项目名称:modules,代码行数:10,代码来源:DeleteCompleted.php


示例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']);
         }
     }
 }
开发者ID:andsci,项目名称:hotels,代码行数:33,代码来源:RoomAdd.php


示例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');
 }
开发者ID:Comsa-Veurne,项目名称:modules,代码行数:29,代码来源:MassAction.php


示例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']);
         }
     }
 }
开发者ID:jeroendesloovere,项目名称:fork-cms-module-instagram,代码行数:28,代码来源:Add.php


示例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'));
         }
     }
 }
开发者ID:jonasdekeukelaere,项目名称:moduleMaker,代码行数:28,代码来源:AddStep4.php


示例16: execute

 /**
  * Execute the action
  */
 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
         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 {
         // something went wrong
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:37,代码来源:Delete.php


示例17: generateURL

 /**
  * Generate an url, using the predefined callback.
  *
  * @param string $url The base-url to start from.
  * @param string $class The Fully Qualified Class Name or service name
  * @param string $method The method that needs to be called
  * @param array $parameters The parameters for the callback
  *
  * @throws Exception When the function does not exist
  *
  * @return string
  */
 public function generateURL($url, $class, $method, array $parameters = [])
 {
     // check if the class is a service
     if (Model::getContainer()->has($class)) {
         $class = Model::getContainer()->get($class);
     }
     // validate (check if the function exists)
     if (!is_callable([$class, $method])) {
         throw new Exception('The callback-method doesn\'t exist.');
     }
     // when using ->getValue() in SpoonFormText fields the function is using htmlentities(),
     // so we must decode it again first!
     $url = SpoonFilter::htmlentitiesDecode($url);
     $actualParameters = [];
     // build parameters for use in the callback
     $actualParameters[] = Uri::getUrl($url);
     // add parameters set by user
     if (!empty($parameters)) {
         foreach ($parameters as $parameter) {
             $actualParameters[] = $parameter;
         }
     }
     // get the real url
     return call_user_func_array([$class, $method], $actualParameters);
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:37,代码来源:MetaRepository.php


示例18: execute

 public function execute()
 {
     // get parameters
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendHotelsModel::exists('hotels_rooms', $this->id)) {
         // call parent, this will probably add some general CSS/JS or other required files
         parent::execute();
         // get data
         $this->record = (array) BackendHotelsModel::getRecord('hotels_rooms', $this->id);
         if ($this->record['image']) {
             // the image path
             $imagePath = FRONTEND_FILES_PATH . '/rooms/images';
             BackendModel::deleteThumbnails($imagePath, $this->record['image']);
         }
         // delete item
         BackendHotelsModel::deleteRecord('hotels_rooms', $this->id);
         // build redirect URL
         $redirectUrl = BackendModel::createURLForAction('Rooms') . '&report=deleted&var=' . urlencode($this->record['title'] . '&id=' . $this->record['id']);
         // item was deleted, so redirect
         $this->redirect($redirectUrl);
     } else {
         // something went wrong
         $this->redirect(BackendModel::createURLForAction('Rooms') . '&error=non-existing&id=' . $this->record['id']);
     }
 }
开发者ID:andsci,项目名称:hotels,代码行数:26,代码来源:RoomDelete.php


示例19: getContent

 /**
  * Create the XML based on the locale items.
  */
 public function getContent()
 {
     $charset = BackendModel::getContainer()->getParameter('kernel.charset');
     // create XML
     $xmlOutput = BackendLocaleModel::createXMLForExport($this->locale);
     return new Response($xmlOutput, Response::HTTP_OK, ['Content-Disposition' => 'attachment; filename="locale_' . BackendModel::getUTCDate('d-m-Y') . '.xml"', 'Content-Type' => 'application/octet-stream;charset=' . $charset, 'Content-Length' => '' . mb_strlen($xmlOutput)]);
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:10,代码来源:ExportAnalyse.php


示例20: getUrl

 /**
  * Retrieve the unique URL for an teamMember
  *
  * @param string $url
  * @param int $id The id of the teamMember to ignore.
  * @return string
  */
 public static function getUrl($url, $id = null)
 {
     $url = CommonUri::getUrl((string) $url);
     $database = BackendModel::get('database');
     if ($id === null) {
         $urlExists = (bool) $database->getVar('SELECT 1
                FROM team_members AS i
                     INNER JOIN meta AS m
                     ON i.meta_id = m.id
               WHERE i.language = ? AND m.url = ?
               LIMIT 1', [Language::getWorkingLanguage(), $url]);
     } else {
         $urlExists = (bool) $database->getVar('SELECT 1
                FROM team_members AS i
                     INNER JOIN meta AS m
                     ON i.meta_id = m.id
               WHERE i.language = ? AND m.url = ? AND i.id != ?
               LIMIT 1', [Language::getWorkingLanguage(), $url, $id]);
     }
     if ($urlExists) {
         $url = Model::addNumber($url);
         return self::getUrl($url, $id);
     }
     return $url;
 }
开发者ID:WouterSioen,项目名称:fork-cms-module-team,代码行数:32,代码来源:Model.php



注:本文中的Backend\Core\Engine\Model类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Base\ActionEdit类代码示例发布时间:2022-05-23
下一篇:
PHP Engine\Language类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap