当前位置: 首页>>代码示例>>PHP>>正文


PHP Engine\Model类代码示例

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


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


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