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

PHP Engine\Model类代码示例

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

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



在下文中一共展示了Model类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * Execute the extra.
  */
 public function execute()
 {
     // get activation key
     $key = $this->URL->getParameter(0);
     // load template
     $this->loadTemplate();
     // do we have an activation key?
     if (isset($key)) {
         // get profile id
         $profileId = FrontendProfilesModel::getIdBySetting('activation_key', $key);
         // have id?
         if ($profileId != null) {
             // update status
             FrontendProfilesModel::update($profileId, array('status' => 'active'));
             // delete activation key
             FrontendProfilesModel::deleteSetting($profileId, 'activation_key');
             // login profile
             FrontendProfilesAuthentication::login($profileId);
             // trigger event
             FrontendModel::triggerEvent('Profiles', 'after_activate', array('id' => $profileId));
             // show success message
             $this->tpl->assign('activationSuccess', true);
         } else {
             // failure
             $this->redirect(FrontendNavigation::getURL(404));
         }
     } else {
         $this->redirect(FrontendNavigation::getURL(404));
     }
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:33,代码来源:Activate.php


示例2: getData

 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     // requested page
     $requestedPage = $this->URL->getParameter('page', 'int', 1);
     // set URL and limit
     $this->pagination['url'] = FrontendNavigation::getURLForBlock('catalog');
     $this->pagination['limit'] = FrontendModel::getModuleSetting('catalog', 'overview_num_items', 10);
     // populate count fields in pagination
     $this->pagination['num_items'] = FrontendCatalogModel::getAllCount();
     $this->pagination['num_pages'] = (int) ceil($this->pagination['num_items'] / $this->pagination['limit']);
     // num pages is always equal to at least 1
     if ($this->pagination['num_pages'] == 0) {
         $this->pagination['num_pages'] = 1;
     }
     // redirect if the request page doesn't exist
     if ($requestedPage > $this->pagination['num_pages'] || $requestedPage < 1) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // populate calculated fields in pagination
     $this->pagination['requested_page'] = $requestedPage;
     $this->pagination['offset'] = $this->pagination['requested_page'] * $this->pagination['limit'] - $this->pagination['limit'];
     // get all categories
     $this->categories = FrontendCatalogModel::getAllCategories();
     // get tree of all categories
     $this->categoriesTree = FrontendCatalogModel::getCategoriesTree();
     // get all products
     $this->products = FrontendCatalogModel::getAll($this->pagination['limit'], $this->pagination['offset']);
 }
开发者ID:Comsa-Veurne,项目名称:modules,代码行数:31,代码来源:Index.php


示例3: processLinks

 /**
  * Process links, will prepend SITE_URL if needed and append UTM-parameters
  *
  * @param string $content The content to process.
  *
  * @return string
  */
 public function processLinks($content)
 {
     // redefine
     $content = (string) $content;
     // replace URLs and images
     $search = array('href="/', 'src="/');
     $replace = array('href="' . SITE_URL . '/', 'src="' . SITE_URL . '/');
     // replace links to files
     $content = str_replace($search, $replace, $content);
     // init var
     $matches = array();
     // match links
     preg_match_all('/href="(http:\\/\\/(.*))"/iU', $content, $matches);
     // any links?
     if (isset($matches[1]) && !empty($matches[1])) {
         // init vars
         $searchLinks = array();
         $replaceLinks = array();
         // loop old links
         foreach ($matches[1] as $i => $link) {
             $searchLinks[] = $matches[0][$i];
             $replaceLinks[] = 'href="' . Model::addURLParameters($link, $this->utm) . '"';
         }
         // replace
         $content = str_replace($searchLinks, $replaceLinks, $content);
     }
     return $content;
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:35,代码来源:RssItem.php


示例4: parse

 /**
  * Parse
  */
 private function parse()
 {
     // get list of recent products
     $numItems = FrontendModel::getModuleSetting('Catalog', 'recent_products_full_num_items', 3);
     $recentProducts = FrontendCatalogModel::getAll($numItems);
     $this->tpl->assign('widgetCatalogRecentProducts', $recentProducts);
 }
开发者ID:Comsa-Veurne,项目名称:modules,代码行数:10,代码来源:RecentProducts.php


示例5: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $charset = $this->getContainer()->getParameter('kernel.charset');
     $searchTerm = \SpoonFilter::getPostValue('term', null, '');
     $term = $charset == 'utf-8' ? \SpoonFilter::htmlspecialchars($searchTerm) : \SpoonFilter::htmlentities($searchTerm);
     // validate search term
     if ($term == '') {
         $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
     } else {
         // previous search result
         $previousTerm = \SpoonSession::exists('searchTerm') ? \SpoonSession::get('searchTerm') : '';
         \SpoonSession::set('searchTerm', '');
         // save this term?
         if ($previousTerm != $term) {
             // format data
             $this->statistics = array();
             $this->statistics['term'] = $term;
             $this->statistics['language'] = LANGUAGE;
             $this->statistics['time'] = FrontendModel::getUTCDate();
             $this->statistics['data'] = serialize(array('server' => $_SERVER));
             $this->statistics['num_results'] = FrontendSearchModel::getTotal($term);
             // save data
             FrontendSearchModel::save($this->statistics);
         }
         // save current search term in cookie
         \SpoonSession::set('searchTerm', $term);
         // output
         $this->output(self::OK);
     }
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:35,代码来源:Save.php


示例6: validateForm

 /**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $fields = $this->frm->getFields();
         if ($fields['email']->isEmail(FL::err('EmailIsInvalid'))) {
         }
         if (FrontendMailengineModel::isSubscribed($fields['email']->getValue())) {
             $fields['email']->addError(FL::err('AlreadySubscribed'));
         }
         if ($this->frm->isCorrect()) {
             //--Subscribe
             $id = FrontendMailengineModel::subscribe($fields['email']->getValue());
             //--Get the default group
             $defaultGroup = FrontendModel::getModuleSetting($this->module, 'default_group');
             if ($defaultGroup > 0) {
                 $data = array();
                 $data['user_id'] = $id;
                 $data['group_id'] = $defaultGroup;
                 //--Add user to group
                 FrontendMailengineModel::insertUserToGroup($data);
             }
             // redirect
             $this->redirect(FrontendNavigation::getURLForBlock('Mailengine', 'MailengineSubscribe') . '?sent=true#subscribe');
         }
     }
     $this->frm->parse($this->tpl);
 }
开发者ID:Comsa-Veurne,项目名称:modules,代码行数:30,代码来源:MailengineSubscribe.php


示例7: setImage

 /**
  * Set the image for the feed.
  *
  * @param string $url         URL of the image.
  * @param string $title       Title of the image.
  * @param string $link        Link of the image.
  * @param int    $width       Width of the image.
  * @param int    $height      Height of the image.
  * @param string $description Description of the image.
  */
 public function setImage($url, $title, $link, $width = null, $height = null, $description = null)
 {
     // add UTM-parameters
     $link = Model::addURLParameters($link, array('utm_source' => 'feed', 'utm_medium' => 'rss', 'utm_campaign' => CommonUri::getUrl($this->getTitle())));
     // call the parent
     parent::setImage($url, $title, $link, $width, $height, $description);
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:17,代码来源:Rss.php


示例8: set

 /**
  * Stores a value in a cookie, by default the cookie will expire in one day.
  *
  * @param string $key      A name for the cookie.
  * @param mixed  $value    The value to be stored. Keep in mind that they will be serialized.
  * @param int    $time     The number of seconds that this cookie will be available, 30 days is the default.
  * @param string $path     The path on the server in which the cookie will
  *                         be available. Use / for the entire domain, /foo
  *                         if you just want it to be available in /foo.
  * @param string $domain   The domain that the cookie is available on. Use
  *                         .example.com to make it available on all
  *                         subdomains of example.com.
  * @param bool   $secure   Should the cookie be transmitted over a
  *                         HTTPS-connection? If true, make sure you use
  *                         a secure connection, otherwise the cookie won't be set.
  * @param bool   $httpOnly Should the cookie only be available through
  *                         HTTP-protocol? If true, the cookie can't be
  *                         accessed by Javascript, ...
  * @return bool    If set with success, returns true otherwise false.
  */
 public static function set($key, $value, $time = 2592000, $path = '/', $domain = null, $secure = null, $httpOnly = true)
 {
     // redefine
     $key = (string) $key;
     $value = serialize($value);
     $time = time() + (int) $time;
     $path = (string) $path;
     $httpOnly = (bool) $httpOnly;
     // when the domain isn't passed and the url-object is available we can set the cookies for all subdomains
     if ($domain === null && FrontendModel::getContainer()->has('request')) {
         $domain = '.' . FrontendModel::getContainer()->get('request')->getHost();
     }
     // when the secure-parameter isn't set
     if ($secure === null) {
         /*
         detect if we are using HTTPS, this wil only work in Apache, if you are using nginx you should add the
         code below into your config:
             ssl on;
            fastcgi_param HTTPS on;
         
         for lighttpd you should add:
             setenv.add-environment = ("HTTPS" => "on")
         */
         $secure = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
     }
     // set cookie
     $cookie = setcookie($key, $value, $time, $path, $domain, $secure, $httpOnly);
     // problem occurred
     return $cookie === false ? false : true;
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:50,代码来源:Cookie.php


示例9: get

 /**
  * Get an item.
  *
  * @param string $id The id of the item to fetch.
  *
  * @return array
  *
  * @deprecated use doctrine instead
  */
 public static function get($id)
 {
     trigger_error('Frontend\\Modules\\ContentBlocks\\Engine is deprecated.
          Switch to doctrine instead.', E_USER_DEPRECATED);
     return (array) FrontendModel::getContainer()->get('database')->getRecord('SELECT i.title, i.text, i.template
          FROM content_blocks AS i
          WHERE i.id = ? AND i.status = ? AND i.hidden = ? AND i.language = ?', array((int) $id, 'active', 'N', LANGUAGE));
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:17,代码来源:Model.php


示例10: getRoom

 public static function getRoom($room_id)
 {
     $room = (array) FrontendModel::getContainer()->get('database')->getRecord('SELECT hr.id, hr.title, hr.price, hr.image, hr.count
          FROM hotels_rooms AS hr
          WHERE hr.id = ?', array($room_id));
     if ($room) {
         $room['image'] = HOTELS_API_URL . FRONTEND_FILES_URL . '/rooms/images/source/' . $room['image'];
     }
     return $room;
 }
开发者ID:andsci,项目名称:hotels,代码行数:10,代码来源:Model.php


示例11: get

 /**
  * Fetches a certain item
  *
  * @param string $id
  * @return array
  */
 public static function get($id)
 {
     $item = (array) FrontendModel::get('database')->getRecord('SELECT i.*
          FROM instagram_users AS i
          WHERE i.id = ? AND i.hidden = ?', array((int) $id, 'N'));
     // no results?
     if (empty($item)) {
         return array();
     }
     return $item;
 }
开发者ID:jessedobbelaere,项目名称:fork-cms-module-instagram,代码行数:17,代码来源:Model.php


示例12: execute

 /**
  * Execute the extra.
  */
 public function execute()
 {
     // logout
     if (FrontendProfilesAuthentication::isLoggedIn()) {
         FrontendProfilesAuthentication::logout();
     }
     // trigger event
     FrontendModel::triggerEvent('Profiles', 'after_logout');
     // redirect
     $this->redirect(SITE_URL);
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:14,代码来源:Logout.php


示例13: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // Get POST parameters
     $userId = \SpoonFilter::getPostValue('userId', null, '');
     // Get count settings
     $this->recentCount = FrontendModel::get('fork.settings')->get('Instagram', 'num_recent_items', 10);
     // Get the images from the Instagram API
     $this->images = FrontendInstagramModel::getRecentMedia($userId, $this->recentCount);
     // Output the result
     $this->output(self::OK, $this->images);
 }
开发者ID:jeroendesloovere,项目名称:fork-cms-module-instagram,代码行数:15,代码来源:LoadRecentMedia.php


示例14: testTruncate

 public function testTruncate()
 {
     $containerMock = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerInterface')->disableOriginalConstructor()->getMock();
     $containerMock->expects(self::any())->method('getParameter')->with('kernel.charset')->will(self::returnValue('UTF-8'));
     FrontendModel::setContainer($containerMock);
     self::assertEquals(TemplateModifiers::truncate('foo bar baz qux', 3, false, true), 'foo');
     self::assertEquals(TemplateModifiers::truncate('foo bar baz qux', 4, false, true), 'foo');
     self::assertEquals(TemplateModifiers::truncate('foo bar baz qux', 8, false, true), 'foo bar');
     self::assertEquals(TemplateModifiers::truncate('foo bar baz qux', 100, false, true), 'foo bar baz qux');
     // Hellip
     self::assertEquals(TemplateModifiers::truncate('foo bar baz qux', 5, true, true), 'foo…');
     self::assertEquals(TemplateModifiers::truncate('foo bar baz qux', 14, true, true), 'foo bar baz…');
     self::assertEquals(TemplateModifiers::truncate('foo bar baz qux', 15, true, true), 'foo bar baz qux');
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:14,代码来源:TemplateModifiersTest.php


示例15: saveData

 private function saveData()
 {
     $booking['id'] = 0;
     $booking['room_id'] = \SpoonFilter::getPostValue('room_id', null, null);
     $booking['start'] = \SpoonFilter::getPostValue('arrival', null, null);
     $booking['end'] = \SpoonFilter::getPostValue('departure', null, null);
     $booking['client_name'] = \SpoonFilter::getPostValue('client_name', null, null);
     $booking['client_email'] = \SpoonFilter::getPostValue('client_email', null, null);
     $booking['date'] = FrontendModel::getUTCDate();
     if ($booking['room_id'] && $booking['start'] && $booking['end'] && $booking['client_name']) {
         $booking['id'] = $this->addReservation($booking);
     }
     echo json_encode($booking['id']);
     die;
 }
开发者ID:andsci,项目名称:hotels,代码行数:15,代码来源:Rooms.php


示例16: delete

 /**
  * Deletes one or more cookies.
  *
  * This overwrites the spoon cookie method and adds the same functionality
  * as in the set method to automatically set the domain.
  */
 public static function delete()
 {
     $domain = null;
     if (FrontendModel::getContainer()->has('request')) {
         $domain = '.' . FrontendModel::getContainer()->get('request')->getHost();
     }
     foreach (func_get_args() as $argument) {
         // multiple arguments are given
         if (is_array($argument)) {
             foreach ($argument as $key) {
                 self::delete($key);
             }
         } else {
             // delete the given cookie
             unset($_COOKIE[(string) $argument]);
             setcookie((string) $argument, null, 1, '/', $domain);
         }
     }
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:25,代码来源:Cookie.php


示例17: getData

 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     $parameter_count = count($this->URL->getParameters(false));
     if ($parameter_count <= 0) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get category
     $this->category = FrontendAgendaModel::getCategory($this->URL->getParameter($parameter_count - 1));
     if (empty($this->category)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // requested page
     $requestedPage = $this->URL->getParameter('page', 'int', 1);
     // set URL and limit
     $this->pagination['url'] = FrontendNavigation::getURLForBlock('Agenda', 'Category') . '/' . $this->category['url'];
     $this->pagination['limit'] = FrontendModel::getModuleSetting('Agenda', 'overview_num_items', 10);
     // populate count fields in pagination
     $this->pagination['num_items'] = FrontendAgendaModel::getCategoryCount($this->category['id']);
     $this->pagination['num_pages'] = (int) ceil($this->pagination['num_items'] / $this->pagination['limit']);
     // num pages is always equal to at least 1
     if ($this->pagination['num_pages'] == 0) {
         $this->pagination['num_pages'] = 1;
     }
     // redirect if the request page doesn't exist
     if ($requestedPage > $this->pagination['num_pages'] || $requestedPage < 1) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // populate calculated fields in pagination
     $this->pagination['requested_page'] = $requestedPage;
     $this->pagination['offset'] = $this->pagination['requested_page'] * $this->pagination['limit'] - $this->pagination['limit'];
     // timestamps
     // @todo SET CORRECT TIMES
     $startTimestamp = strtotime('last Monday 00:59', time());
     // first day of the week
     $endTimestamp = strtotime("next Monday 0:59", time());
     // last day of the week
     // get items
     $this->items = FrontendAgendaModel::getAllByCategory($this->category['id'], $this->pagination['limit'], $this->pagination['offset'], $startTimestamp, $endTimestamp);
     // sort dates
     usort($this->items, "self::cmpValues");
 }
开发者ID:Comsa-Veurne,项目名称:modules,代码行数:44,代码来源:Category.php


示例18: validateForm

 /**
  * Validate the form
  */
 private function validateForm()
 {
     // is the form submitted
     if ($this->frm->isSubmitted()) {
         // validate required fields
         $email = $this->frm->getField('email');
         // validate required fields
         if ($email->isEmail(FL::err('EmailIsInvalid'))) {
             if (FrontendMailmotorModel::isSubscribed($email->getValue())) {
                 $email->addError(FL::err('AlreadySubscribed'));
             }
         }
         // no errors
         if ($this->frm->isCorrect()) {
             try {
                 // subscribe the user to our default group
                 if (!FrontendMailmotorCMHelper::subscribe($email->getValue())) {
                     throw new FrontendException('Could not subscribe');
                 }
                 // trigger event
                 FrontendModel::triggerEvent('Mailmotor', 'after_subscribe', array('email' => $email->getValue()));
                 // redirect
                 $this->redirect(FrontendNavigation::getURLForBlock('Mailmotor', 'Subscribe') . '?sent=true#subscribeForm');
             } catch (\Exception $e) {
                 // make sure RedirectExceptions get thrown
                 if ($e instanceof RedirectException) {
                     throw $e;
                 }
                 // when debugging we need to see the exceptions
                 if ($this->getContainer()->getParameter('kernel.debug')) {
                     throw $e;
                 }
                 // show error
                 $this->tpl->assign('subscribeHasError', true);
             }
         } else {
             $this->tpl->assign('subscribeHasFormError', true);
         }
     }
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:43,代码来源:Subscribe.php


示例19: onFormSubmitted

 /**
  * @param FormBuilderSubmittedEvent $event
  */
 public function onFormSubmitted(FormBuilderSubmittedEvent $event)
 {
     $form = $event->getForm();
     // need to send mail
     if ($form['method'] == 'database_email') {
         // build our message
         $from = FrontendModel::get('fork.settings')->get('Core', 'mailer_from');
         $fieldData = $this->getEmailFields($event->getData());
         $message = \Common\Mailer\Message::newInstance(sprintf(FL::getMessage('FormBuilderSubject'), $form['name']))->parseHtml(FRONTEND_MODULES_PATH . '/FormBuilder/Layout/Templates/Mails/Form.tpl', array('sentOn' => time(), 'name' => $form['name'], 'fields' => $fieldData), true)->setTo($form['email'])->setFrom(array($from['email'] => $from['name']));
         // check if we have a replyTo email set
         foreach ($form['fields'] as $field) {
             if (array_key_exists('reply_to', $field['settings']) && $field['settings']['reply_to'] === true) {
                 $email = $fieldData[$field['id']]['value'];
                 $message->setReplyTo(array($email => $email));
             }
         }
         if ($message->getReplyTo() === null) {
             $replyTo = FrontendModel::get('fork.settings')->get('Core', 'mailer_reply_to');
             $message->setReplyTo(array($replyTo['email'] => $replyTo['name']));
         }
         $this->mailer->send($message);
     }
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:26,代码来源:FormBuilderSubmittedMailSubscriber.php


示例20: __construct

 /**
  * The constructor will store the instance in the reference, preset some settings and map the custom modifiers.
  */
 public function __construct()
 {
     parent::__construct(func_get_arg(0), func_get_arg(1), func_get_arg(2));
     $this->debugMode = Model::getContainer()->getParameter('kernel.debug');
     $this->forkSettings = Model::get('fork.settings');
     // fork has been installed
     if ($this->forkSettings) {
         $this->themePath = FRONTEND_PATH . '/Themes/' . $this->forkSettings->get('Core', 'theme', 'default');
         $loader = $this->environment->getLoader();
         $loader = new \Twig_Loader_Chain(array($loader, new \Twig_Loader_Filesystem($this->getLoadingFolders())));
         $this->environment->setLoader($loader);
         // connect symphony forms
         $formEngine = new TwigRendererEngine($this->getFormTemplates('FormLayout.html.twig'));
         $formEngine->setEnvironment($this->environment);
         $this->environment->addExtension(new SymfonyFormExtension(new TwigRenderer($formEngine, Model::get('security.csrf.token_manager'))));
     }
     $this->environment->disableStrictVariables();
     // init Form extension
     new FormExtension($this->environment);
     // start the filters / globals
     TwigFilters::getFilters($this->environment, 'Frontend');
     $this->startGlobals($this->environment);
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:26,代码来源:TwigTemplate.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Engine\Navigation类代码示例发布时间:2022-05-23
下一篇:
PHP assets\AppAsset类代码示例发布时间: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