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


PHP SpoonFilter::isURL方法代码示例

本文整理汇总了PHP中SpoonFilter::isURL方法的典型用法代码示例。如果您正苦于以下问题:PHP SpoonFilter::isURL方法的具体用法?PHP SpoonFilter::isURL怎么用?PHP SpoonFilter::isURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpoonFilter的用法示例。


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

示例1: validateForm

 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // shorten values
         $pagePath = $this->frm->getField('page_path')->getValue();
         if (count($this->linkList) > 1) {
             $pageList = $this->frm->getField('page_list')->getSelected();
         }
         // get the target
         if ($this->frm->getfield('page_path')->isFilled()) {
             $page = $pagePath;
         } elseif ($pageList == '0') {
             $page = null;
         } else {
             $page = SITE_MULTILANGUAGE ? substr($pageList, strpos($pageList, '/', 1)) : $pageList;
         }
         // validate fields
         if (isset($page) && !SpoonFilter::isURL(SITE_URL . $page)) {
             $this->frm->getField('page_path')->addError(BL::err('InvalidURL'));
         }
         if (!isset($page)) {
             $this->frm->getField('page_path')->addError(BL::err('FieldIsRequired'));
         }
         if (!$this->frm->getField('page_path')->isFilled() && !$this->frm->getfield('page_list')->isFilled()) {
             $this->frm->getField('page_path')->addError(BL::err('FieldIsRequired'));
         }
         if ($this->frm->isCorrect()) {
             // get metrics
             $metrics = BackendAnalyticsHelper::getMetricsForPage($page, $this->startTimestamp, $this->endTimestamp);
             // build item
             $item['page_path'] = $page;
             $item['entrances'] = isset($metrics['entrances']) ? $metrics['entrances'] : 0;
             $item['bounces'] = isset($metrics['bounces']) ? $metrics['bounces'] : 0;
             $item['bounce_rate'] = ($metrics['entrances'] == 0 ? 0 : number_format((int) $metrics['bounces'] / $metrics['entrances'] * 100, 2)) . '%';
             $item['start_date'] = date('Y-m-d', $this->startTimestamp) . ' 00:00:00';
             $item['end_date'] = date('Y-m-d', $this->endTimestamp) . ' 00:00:00';
             $item['updated_on'] = date('Y-m-d H:i:s');
             // insert the item
             $item['id'] = (int) BackendAnalyticsModel::insertLandingPage($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add_landing_page', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('landing_pages') . '&report=saved&var=' . urlencode($item['page_path']));
         }
     }
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:50,代码来源:add_landing_page.php

示例2: validateForm

 /**
  * Validates the form
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // validate required fields
         $this->frm->getField('site_title')->isFilled(BL::err('FieldIsRequired'));
         // date & time
         $this->frm->getField('time_format')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('date_format_short')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('date_format_long')->isFilled(BL::err('FieldIsRequired'));
         // number
         $this->frm->getField('number_format')->isFilled(BL::err('FieldIsRequired'));
         // akismet key may be filled in
         if ($this->needsAkismet && $this->frm->getField('akismet_key')->isFilled()) {
             // key has changed
             if ($this->frm->getField('akismet_key')->getValue() != $this->get('fork.settings')->get('Core', 'akismet_key', null)) {
                 // create instance
                 $akismet = new Akismet($this->frm->getField('akismet_key')->getValue(), SITE_URL);
                 // invalid key
                 if (!$akismet->verifyKey()) {
                     $this->frm->getField('akismet_key')->setError(BL::err('InvalidAPIKey'));
                 }
             }
         }
         // domains filled in
         if ($this->frm->getField('site_domains')->isFilled()) {
             // split on newlines
             $domains = explode("\n", trim($this->frm->getField('site_domains')->getValue()));
             // loop domains
             foreach ($domains as $domain) {
                 // strip funky stuff
                 $domain = trim(str_replace(array('www.', 'http://', 'https://'), '', $domain));
                 // invalid URL
                 if (!\SpoonFilter::isURL('http://' . $domain)) {
                     // set error
                     $this->frm->getField('site_domains')->setError(BL::err('InvalidDomain'));
                     // stop looping domains
                     break;
                 }
             }
         }
         if ($this->frm->getField('ckfinder_image_max_width')->isFilled()) {
             $this->frm->getField('ckfinder_image_max_width')->isInteger(BL::err('InvalidInteger'));
         }
         if ($this->frm->getField('ckfinder_image_max_height')->isFilled()) {
             $this->frm->getField('ckfinder_image_max_height')->isInteger(BL::err('InvalidInteger'));
         }
         // no errors ?
         if ($this->frm->isCorrect()) {
             // general settings
             $this->get('fork.settings')->set('Core', 'site_title_' . BL::getWorkingLanguage(), $this->frm->getField('site_title')->getValue());
             $this->get('fork.settings')->set('Core', 'site_html_header', $this->frm->getField('site_html_header')->getValue());
             $this->get('fork.settings')->set('Core', 'site_start_of_body_scripts', $this->frm->getField('site_start_of_body_scripts')->getValue());
             $this->get('fork.settings')->set('Core', 'site_html_footer', $this->frm->getField('site_html_footer')->getValue());
             // facebook settings
             $this->get('fork.settings')->set('Core', 'facebook_admin_ids', $this->frm->getField('facebook_admin_ids')->isFilled() ? $this->frm->getField('facebook_admin_ids')->getValue() : null);
             $this->get('fork.settings')->set('Core', 'facebook_app_id', $this->frm->getField('facebook_application_id')->isFilled() ? $this->frm->getField('facebook_application_id')->getValue() : null);
             $this->get('fork.settings')->set('Core', 'facebook_app_secret', $this->frm->getField('facebook_application_secret')->isFilled() ? $this->frm->getField('facebook_application_secret')->getValue() : null);
             // twitter settings
             /** @var \SpoonFormText $txtTwitterSiteName */
             $txtTwitterSiteName = $this->frm->getField('twitter_site_name');
             if ($txtTwitterSiteName->isFilled()) {
                 $this->get('fork.settings')->set('Core', 'twitter_site_name', '@' . ltrim($txtTwitterSiteName->getValue(), '@'));
             }
             // ckfinder settings
             $this->get('fork.settings')->set('Core', 'ckfinder_license_name', $this->frm->getField('ckfinder_license_name')->isFilled() ? $this->frm->getField('ckfinder_license_name')->getValue() : null);
             $this->get('fork.settings')->set('Core', 'ckfinder_license_key', $this->frm->getField('ckfinder_license_key')->isFilled() ? $this->frm->getField('ckfinder_license_key')->getValue() : null);
             $this->get('fork.settings')->set('Core', 'ckfinder_image_max_width', $this->frm->getField('ckfinder_image_max_width')->isFilled() ? $this->frm->getField('ckfinder_image_max_width')->getValue() : 1600);
             $this->get('fork.settings')->set('Core', 'ckfinder_image_max_height', $this->frm->getField('ckfinder_image_max_height')->isFilled() ? $this->frm->getField('ckfinder_image_max_height')->getValue() : 1200);
             // api keys
             $this->get('fork.settings')->set('Core', 'fork_api_public_key', $this->frm->getField('fork_api_public_key')->getValue());
             $this->get('fork.settings')->set('Core', 'fork_api_private_key', $this->frm->getField('fork_api_private_key')->getValue());
             if ($this->needsAkismet) {
                 $this->get('fork.settings')->set('Core', 'akismet_key', $this->frm->getField('akismet_key')->getValue());
             }
             if ($this->needsGoogleMaps) {
                 $this->get('fork.settings')->set('Core', 'google_maps_key', $this->frm->getField('google_maps_key')->getValue());
             }
             // date & time formats
             $this->get('fork.settings')->set('Core', 'time_format', $this->frm->getField('time_format')->getValue());
             $this->get('fork.settings')->set('Core', 'date_format_short', $this->frm->getField('date_format_short')->getValue());
             $this->get('fork.settings')->set('Core', 'date_format_long', $this->frm->getField('date_format_long')->getValue());
             // date & time formats
             $this->get('fork.settings')->set('Core', 'number_format', $this->frm->getField('number_format')->getValue());
             // before we save the languages, we need to ensure that each language actually exists and may be chosen.
             $languages = array(SITE_DEFAULT_LANGUAGE);
             $activeLanguages = array_unique(array_merge($languages, $this->frm->getField('active_languages')->getValue()));
             $redirectLanguages = array_unique(array_merge($languages, $this->frm->getField('redirect_languages')->getValue()));
             // cleanup redirect-languages, by removing the values that aren't present in the active languages
             $redirectLanguages = array_intersect($redirectLanguages, $activeLanguages);
             // save active languages
             $this->get('fork.settings')->set('Core', 'active_languages', $activeLanguages);
             $this->get('fork.settings')->set('Core', 'redirect_languages', $redirectLanguages);
             // domains may not contain www, http or https. Therefor we must loop and create the list of domains.
             $siteDomains = array();
             // domains filled in
             if ($this->frm->getField('site_domains')->isFilled()) {
//.........这里部分代码省略.........
开发者ID:bwgraves,项目名称:forkcms,代码行数:101,代码来源:Index.php

示例3: isURL

 /**
  * Checks this field for a valid url.
  *
  * @return	bool
  * @param	string[optional] $error		The error message to set.
  */
 public function isURL($error = null)
 {
     // filled
     if ($this->isFilled()) {
         // post/get data
         $data = $this->getMethod(true);
         // validate
         if (!isset($data[$this->attributes['name']]) || !SpoonFilter::isURL($data[$this->attributes['name']])) {
             if ($error !== null) {
                 $this->setError($error);
             }
             return false;
         }
         return true;
     }
     // not submitted
     if ($error !== null) {
         $this->setError($error);
     }
     return false;
 }
开发者ID:szLuis,项目名称:oac,代码行数:27,代码来源:text.php

示例4: setLink

 /**
  * Set the link for the feed.
  *
  * @param	string $link	The link of the feed.
  */
 public function setLink($link)
 {
     // redefine vars
     $link = (string) $link;
     // validate
     if (!SpoonFilter::isURL($link)) {
         throw new SpoonFeedException('This (' . $link . ') isn\'t a valid link');
     }
     // set property
     $this->link = $link;
 }
开发者ID:jincongho,项目名称:clienthub,代码行数:16,代码来源:rss.php

示例5: validateForm

 /**
  * Validates the form
  *
  * @return	void
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // validate required fields
         $this->frm->getField('site_title')->isFilled(BL::err('FieldIsRequired'));
         // date & time
         $this->frm->getField('time_format')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('date_format_short')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('date_format_long')->isFilled(BL::err('FieldIsRequired'));
         // number
         $this->frm->getField('number_format')->isFilled(BL::err('FieldIsRequired'));
         // akismet key may be filled in
         if ($this->needsAkismet && $this->frm->getField('akismet_key')->isFilled()) {
             // key has changed
             if ($this->frm->getField('akismet_key')->getValue() != BackendModel::getModuleSetting('core', 'akismet_key', null)) {
                 // load akismet
                 require_once PATH_LIBRARY . '/external/akismet.php';
                 // create instance
                 $akismet = new Akismet($this->frm->getField('akismet_key')->getValue(), SITE_URL);
                 // invalid key
                 if (!$akismet->verifyKey()) {
                     $this->frm->getField('akismet_key')->setError(BL::err('InvalidAPIKey'));
                 }
             }
         }
         // domains filled in
         if ($this->frm->getField('site_domains')->isFilled()) {
             // split on newlines
             $domains = explode("\n", trim($this->frm->getField('site_domains')->getValue()));
             // loop domains
             foreach ($domains as $domain) {
                 // strip funky stuff
                 $domain = trim(str_replace(array('www.', 'http://', 'https://'), '', $domain));
                 // invalid URL
                 if (!SpoonFilter::isURL('http://' . $domain)) {
                     // set error
                     $this->frm->getField('site_domains')->setError(BL::err('InvalidDomain'));
                     // stop looping domains
                     break;
                 }
             }
         }
         // no errors ?
         if ($this->frm->isCorrect()) {
             // general settings
             BackendModel::setModuleSetting('core', 'site_title_' . BL::getWorkingLanguage(), $this->frm->getField('site_title')->getValue());
             BackendModel::setModuleSetting('core', 'site_html_header', $this->frm->getField('site_html_header')->getValue());
             BackendModel::setModuleSetting('core', 'site_html_footer', $this->frm->getField('site_html_footer')->getValue());
             // facebook settings
             BackendModel::setModuleSetting('core', 'facebook_admin_ids', $this->frm->getField('facebook_admin_ids')->isFilled() ? $this->frm->getField('facebook_admin_ids')->getValue() : null);
             BackendModel::setModuleSetting('core', 'facebook_app_id', $this->frm->getField('facebook_application_id')->isFilled() ? $this->frm->getField('facebook_application_id')->getValue() : null);
             BackendModel::setModuleSetting('core', 'facebook_app_secret', $this->frm->getField('facebook_application_secret')->isFilled() ? $this->frm->getField('facebook_application_secret')->getValue() : null);
             // api keys
             BackendModel::setModuleSetting('core', 'fork_api_public_key', $this->frm->getField('fork_api_public_key')->getValue());
             BackendModel::setModuleSetting('core', 'fork_api_private_key', $this->frm->getField('fork_api_private_key')->getValue());
             if ($this->needsAkismet) {
                 BackendModel::setModuleSetting('core', 'akismet_key', $this->frm->getField('akismet_key')->getValue());
             }
             if ($this->needsGoogleMaps) {
                 BackendModel::setModuleSetting('core', 'google_maps_key', $this->frm->getField('google_maps_key')->getValue());
             }
             // date & time formats
             BackendModel::setModuleSetting('core', 'time_format', $this->frm->getField('time_format')->getValue());
             BackendModel::setModuleSetting('core', 'date_format_short', $this->frm->getField('date_format_short')->getValue());
             BackendModel::setModuleSetting('core', 'date_format_long', $this->frm->getField('date_format_long')->getValue());
             // date & time formats
             BackendModel::setModuleSetting('core', 'number_format', $this->frm->getField('number_format')->getValue());
             // before we save the languages, we need to ensure that each language actually exists and may be chosen.
             $languages = array(SITE_DEFAULT_LANGUAGE);
             // save active languages
             BackendModel::setModuleSetting('core', 'active_languages', array_unique(array_merge($languages, $this->frm->getField('active_languages')->getValue())));
             BackendModel::setModuleSetting('core', 'redirect_languages', array_unique(array_merge($languages, $this->frm->getField('redirect_languages')->getValue())));
             // domains may not contain www, http or https. Therefor we must loop and create the list of domains.
             $siteDomains = array();
             // domains filled in
             if ($this->frm->getField('site_domains')->isFilled()) {
                 // split on newlines
                 $domains = explode("\n", trim($this->frm->getField('site_domains')->getValue()));
                 // loop domains
                 foreach ($domains as $domain) {
                     // strip funky stuff
                     $siteDomains[] = trim(str_replace(array('www.', 'http://', 'https://'), '', $domain));
                 }
             }
             // save domains
             BackendModel::setModuleSetting('core', 'site_domains', $siteDomains);
             // assign report
             $this->tpl->assign('report', true);
             $this->tpl->assign('reportMessage', BL::msg('Saved'));
         }
     }
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:98,代码来源:index.php

示例6: isURL

 /**
  * Checks this field for a valid url.
  *
  * @return	bool
  * @param	string[optional] $error		The error message to set.
  */
 public function isURL($error = null)
 {
     // filled
     if ($this->isFilled()) {
         // post/get data
         $data = $this->getMethod(true);
         // validate
         if (isset($data[$this->attributes['name']]) && is_string($data[$this->attributes['name']])) {
             $url = $data[$this->attributes['name']];
             // appends http:// if not provided
             // we deliberately left spoonFilter::isURL unchanged
             // because SpoonFilter should not validate "www.spoon.be" as true
             $url = (strncasecmp('http://', $url, 7) && strncasecmp('https://', $url, 8) ? 'http://' : '') . $url;
             if (SpoonFilter::isURL($url)) {
                 return true;
             }
         }
     }
     // not submitted
     if ($error !== null) {
         $this->setError($error);
     }
     return false;
 }
开发者ID:jeroendesloovere,项目名称:library,代码行数:30,代码来源:text.php

示例7: setSource

 /**
  * Set source.
  *
  * @param	string $name	The name of the source.
  * @param	string $URL		The URL of the source.
  */
 public function setSource($name, $URL)
 {
     // redefine var
     $URL = (string) $URL;
     // validate
     if (!SpoonFilter::isURL($URL)) {
         throw new SpoonFeedException('This (' . $URL . ') isn\'t a valid URL for a source.');
     }
     // create array
     $source['name'] = (string) $name;
     $source['url'] = $URL;
     // set property
     $this->source = $source;
 }
开发者ID:sunkangtaichi,项目名称:library,代码行数:20,代码来源:rss_item.php

示例8: testIsURL

 /**
  * URL tests based on those of Mathias Bynens (http://mathiasbynens.be/demo/url-regex)
  */
 public function testIsURL()
 {
     // URLs that should match
     $this->assertTrue(SpoonFilter::isURL('http://foo.com/blah_blah/'));
     $this->assertTrue(SpoonFilter::isURL('http://foo.com/blah_blah_(wikipedia)'));
     $this->assertTrue(SpoonFilter::isURL('http://foo.com/blah_blah_(wikipedia)_(again)'));
     $this->assertTrue(SpoonFilter::isURL('http://www.example.com/wpstyle/?p=364'));
     $this->assertTrue(SpoonFilter::isURL('https://www.example.com/foo/?bar=baz&inga=42&quux'));
     $this->assertTrue(SpoonFilter::isURL('http://✪df.ws/123'));
     $this->assertTrue(SpoonFilter::isURL('http://userid:password@example.com:8080'));
     $this->assertTrue(SpoonFilter::isURL('http://userid:password@example.com:8080/'));
     $this->assertTrue(SpoonFilter::isURL('http://userid@example.com'));
     $this->assertTrue(SpoonFilter::isURL('http://userid@example.com/'));
     $this->assertTrue(SpoonFilter::isURL('http://userid@example.com:8080'));
     $this->assertTrue(SpoonFilter::isURL('http://userid@example.com:8080/'));
     $this->assertTrue(SpoonFilter::isURL('http://userid:password@example.com'));
     $this->assertTrue(SpoonFilter::isURL('http://userid:password@example.com/'));
     $this->assertTrue(SpoonFilter::isURL('http://142.42.1.1/'));
     $this->assertTrue(SpoonFilter::isURL('http://142.42.1.1:8080/'));
     $this->assertTrue(SpoonFilter::isURL('http://➡.ws/䨹'));
     $this->assertTrue(SpoonFilter::isURL('http://⌘.ws'));
     $this->assertTrue(SpoonFilter::isURL('http://⌘.ws/'));
     $this->assertTrue(SpoonFilter::isURL('http://foo.com/blah_(wikipedia)#cite-1'));
     $this->assertTrue(SpoonFilter::isURL('http://foo.com/blah_(wikipedia)_blah#cite-1'));
     $this->assertTrue(SpoonFilter::isURL('http://foo.com/unicode_(✪)_in_parens'));
     $this->assertTrue(SpoonFilter::isURL('http://foo.com/(something)?after=parens'));
     $this->assertTrue(SpoonFilter::isURL('http://☺.damowmow.com/'));
     $this->assertTrue(SpoonFilter::isURL('http://code.google.com/events/#&product=browser'));
     $this->assertTrue(SpoonFilter::isURL('http://j.mp'));
     $this->assertTrue(SpoonFilter::isURL('ftp://foo.bar/baz'));
     $this->assertTrue(SpoonFilter::isURL('http://foo.bar/?q=Test%20URL-encoded%20stuff'));
     $this->assertTrue(SpoonFilter::isURL('http://例子.测试'));
     $this->assertTrue(SpoonFilter::isURL('http://उदाहरण.परीक्षा'));
     $this->assertTrue(SpoonFilter::isURL('http://-.~_!$&\'()*+,;=:%40:80%2f::::::@example.com'));
     $this->assertTrue(SpoonFilter::isURL('http://1337.net'));
     $this->assertTrue(SpoonFilter::isURL('http://223.255.255.254'));
     $this->assertTrue(SpoonFilter::isURL('http://feedproxy.google.com/~r/netlog/~3/EdqJ5FkO78o/internet-is-de-petrischaal-van-de-maatschappij'));
     // URLs that should fail
     $this->assertFalse(SpoonFilter::isURL('http://'));
     $this->assertFalse(SpoonFilter::isURL('http://.'));
     $this->assertFalse(SpoonFilter::isURL('http://..'));
     $this->assertFalse(SpoonFilter::isURL('http://../'));
     $this->assertFalse(SpoonFilter::isURL('http://?'));
     $this->assertFalse(SpoonFilter::isURL('http://??'));
     $this->assertFalse(SpoonFilter::isURL('http://??/'));
     $this->assertFalse(SpoonFilter::isURL('http://#'));
     $this->assertFalse(SpoonFilter::isURL('http://##'));
     $this->assertFalse(SpoonFilter::isURL('http://##/'));
     $this->assertFalse(SpoonFilter::isURL('http://foo.bar?q=Spaces should be encoded'));
     $this->assertFalse(SpoonFilter::isURL('//'));
     $this->assertFalse(SpoonFilter::isURL('//a'));
     $this->assertFalse(SpoonFilter::isURL('///a'));
     $this->assertFalse(SpoonFilter::isURL('///'));
     $this->assertFalse(SpoonFilter::isURL('http:///a'));
     $this->assertFalse(SpoonFilter::isURL('foo.com'));
     $this->assertFalse(SpoonFilter::isURL('rdar://1234'));
     $this->assertFalse(SpoonFilter::isURL('h://test'));
     $this->assertFalse(SpoonFilter::isURL('http:// shouldfail.com'));
     $this->assertFalse(SpoonFilter::isURL(':// should fail'));
     $this->assertFalse(SpoonFilter::isURL('http://foo.bar/foo(bar)baz quux'));
     $this->assertFalse(SpoonFilter::isURL('ftps://foo.bar/'));
     $this->assertFalse(SpoonFilter::isURL('http://-error-.invalid/'));
     $this->assertFalse(SpoonFilter::isURL('http://a.b--c.de/'));
     $this->assertFalse(SpoonFilter::isURL('http://-a.b.co'));
     $this->assertFalse(SpoonFilter::isURL('http://a.b-.co'));
     $this->assertFalse(SpoonFilter::isURL('http://0.0.0.0'));
     $this->assertFalse(SpoonFilter::isURL('http://10.1.1.0'));
     $this->assertFalse(SpoonFilter::isURL('http://10.1.1.255'));
     $this->assertFalse(SpoonFilter::isURL('http://224.1.1.1'));
     $this->assertFalse(SpoonFilter::isURL('http://1.1.1.1.1'));
     $this->assertFalse(SpoonFilter::isURL('http://123.123.123'));
     $this->assertFalse(SpoonFilter::isURL('http://.www.foo.bar/'));
     $this->assertFalse(SpoonFilter::isURL('http://www.foo.bar./'));
     $this->assertFalse(SpoonFilter::isURL('http://.www.foo.bar./8*/'));
     $this->assertFalse(SpoonFilter::isURL('http://10.1.1.1'));
     $this->assertFalse(SpoonFilter::isURL('http://10.1.1.254'));
 }
开发者ID:jeroendesloovere,项目名称:library,代码行数:80,代码来源:SpoonFilterIsURLTest.php

示例9: loadForm

 /**
  * Load the form
  */
 private function loadForm()
 {
     // create form
     $this->frm = new FrontendForm('commentsForm');
     $this->frm->setAction($this->frm->getAction() . '#' . FL::act('Comment'));
     // init vars
     $author = CommonCookie::exists('comment_author') ? CommonCookie::get('comment_author') : null;
     $email = CommonCookie::exists('comment_email') && \SpoonFilter::isEmail(CommonCookie::get('comment_email')) ? CommonCookie::get('comment_email') : null;
     $website = CommonCookie::exists('comment_website') && \SpoonFilter::isURL(CommonCookie::get('comment_website')) ? CommonCookie::get('comment_website') : 'http://';
     // create elements
     $this->frm->addText('author', $author)->setAttributes(array('required' => null));
     $this->frm->addText('email', $email)->setAttributes(array('required' => null, 'type' => 'email'));
     $this->frm->addText('website', $website, null);
     $this->frm->addTextarea('message')->setAttributes(array('required' => null));
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:18,代码来源:Detail.php

示例10: validateForm

 /**
  * Validates the settings form
  *
  * @return	void
  */
 private function validateForm()
 {
     // form is submitted
     if ($this->frm->isSubmitted()) {
         // shorten fields
         $feedburnerURL = $this->frm->getField('feedburner_url');
         // validation
         $this->frm->getField('rss_title')->isFilled(BL::err('FieldIsRequired'));
         // feedburner URL is set
         if ($feedburnerURL->isFilled()) {
             // check if http:// is set and add if necessary
             $feedburner = !strstr($feedburnerURL->getValue(), 'http://') ? 'http://' . $feedburnerURL->getValue() : $feedburnerURL->getValue();
             // check if feedburner URL is valid
             if (!SpoonFilter::isURL($feedburner)) {
                 $feedburnerURL->addError(BL::err('InvalidURL'));
             }
         } else {
             $feedburner = null;
         }
         // form is validated
         if ($this->frm->isCorrect()) {
             // set our settings
             BackendModel::setModuleSetting($this->URL->getModule(), 'overview_num_items', (int) $this->frm->getField('overview_number_of_items')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'recent_articles_full_num_items', (int) $this->frm->getField('recent_articles_full_number_of_items')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'recent_articles_list_num_items', (int) $this->frm->getField('recent_articles_list_number_of_items')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'spamfilter', (bool) $this->frm->getField('spamfilter')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'allow_comments', (bool) $this->frm->getField('allow_comments')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'moderation', (bool) $this->frm->getField('moderation')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'notify_by_email_on_new_comment_to_moderate', (bool) $this->frm->getField('notify_by_email_on_new_comment_to_moderate')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'notify_by_email_on_new_comment', (bool) $this->frm->getField('notify_by_email_on_new_comment')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'ping_services', (bool) $this->frm->getField('ping_services')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'rss_title_' . BL::getWorkingLanguage(), $this->frm->getField('rss_title')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'rss_description_' . BL::getWorkingLanguage(), $this->frm->getField('rss_description')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'rss_meta_' . BL::getWorkingLanguage(), $this->frm->getField('rss_meta')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'feedburner_url_' . BL::getWorkingLanguage(), $feedburner);
             if (BackendModel::getModuleSetting('core', 'akismet_key') === null) {
                 BackendModel::setModuleSetting($this->URL->getModule(), 'spamfilter', false);
             }
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_saved_settings');
             // redirect to the settings page
             $this->redirect(BackendModel::createURLForAction('settings') . '&report=saved');
         }
     }
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:50,代码来源:settings.php

示例11: setId

 /**
  * Set the id (URI).
  *
  * @param	string $id	The id (URI) of the item (example: http://example.com/blog/1234).
  */
 public function setId($id)
 {
     // redefine var
     $id = (string) $id;
     // validate
     if (!SpoonFilter::isURL($id)) {
         throw new SpoonFeedException('This (' . $id . ') isn\'t a valid link.');
     }
     // set property
     $this->id = $id;
 }
开发者ID:sunkangtaichi,项目名称:library,代码行数:16,代码来源:atom_rss_item.php

示例12: loadForm

 /**
  * Load the form
  */
 private function loadForm()
 {
     // create form
     $this->frm = new FrontendForm('commentsForm');
     $this->frm->setAction($this->frm->getAction() . '#' . FL::act('Comment'));
     // init vars
     $author = Cookie::exists('comment_author') ? Cookie::get('comment_author') : null;
     $email = Cookie::exists('comment_email') && \SpoonFilter::isEmail(Cookie::get('comment_email')) ? Cookie::get('comment_email') : null;
     $website = Cookie::exists('comment_website') && \SpoonFilter::isURL(Cookie::get('comment_website')) ? Cookie::get('comment_website') : 'http://';
     // create elements
     $this->frm->addText('author', $author)->setAttributes(array('required' => null));
     $this->frm->addText('email', $email)->setAttributes(array('required' => null, 'type' => 'email'));
     $this->frm->addText('website', $website, null);
     $this->frm->addTextarea('message')->setAttributes(array('required' => null));
     $this->frmContact = new FrontendForm('contact', null, 'post');
     $this->frmContact->addText('name')->setAttribute('class', 'form-control');
     $this->frmContact->addText('emailContact', null, 255, 'form-control');
     //->setAttribute('class', 'form-control');
     $this->frmContact->addText('phone')->setAttribute('class', 'form-control');
     $this->frmContact->addTextarea('messageContact', Language::lbl('ProductMoreInfo') . ' ' . $this->record['title'])->setAttribute('class', 'form-control');
 }
开发者ID:Comsa-Veurne,项目名称:modules,代码行数:24,代码来源:Detail.php


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