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


PHP DBField::create_field方法代码示例

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


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

示例1: GlobalNav

 public function GlobalNav()
 {
     Requirements::css(Controller::join_links(GlobalNavSiteTreeExtension::get_toolbar_hostname(), Config::inst()->get('GlobalNav', 'css_path')));
     $html = DBField::create_field('HTMLText', $this->globalNav);
     $html->setOptions(array('shortcodes' => false));
     return $html;
 }
开发者ID:stojg,项目名称:silverstripe-globaltoolbar,代码行数:7,代码来源:GlobalNavIteratorProperties.php

示例2: testNice

 public function testNice()
 {
     $time = DBField::create_field('Time', '17:15:55');
     $this->assertEquals('5:15pm', $time->Nice());
     Config::inst()->update('Time', 'nice_format', 'H:i:s');
     $this->assertEquals('17:15:55', $time->Nice());
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:7,代码来源:TimeTest.php

示例3: onBeforeWrite

 function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->DispatchedOn) {
         $this->DispatchedOn = DBField::create_field('Date', date('Y-m-d'));
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:7,代码来源:OrderStatusLog_DispatchPhysicalOrder.php

示例4: parse

 /**
  * Parses the snippet short code
  * @example [snippet id=123]
  * @example [snippet id=123 version=456]
  */
 public static function parse($arguments, $content = null, $parser = null)
 {
     //Ensure ID is pressent in the arguments
     if (!array_key_exists('id', $arguments)) {
         return '<p><b><i>' . _t('CodeBankShortCode.MISSING_ID_ATTRIBUTE', '_Short Code missing the id attribute') . '</i></b></p>';
     }
     //Fetch Snippet
     $snippet = Snippet::get()->byID(intval($arguments['id']));
     if (empty($snippet) || $snippet === false || $snippet->ID == 0) {
         return '<p><b><i>' . _t('CodeBankShortCode.SNIPPET_NOT_FOUND', '_Snippet not found') . '</i></b></p>';
     }
     //Fetch Text
     $snippetText = $snippet->SnippetText;
     //If the version exists fetch it, and replace the text with that of the version
     if (array_key_exists('version', $arguments)) {
         $version = $snippet->Version(intval($arguments['version']));
         if (empty($version) || $version === false || $version->ID == 0) {
             $snippetText = $version->Text;
         }
     }
     //Load CSS Requirements
     Requirements::css(CB_DIR . '/javascript/external/syntaxhighlighter/themes/shCore.css');
     Requirements::css(CB_DIR . '/javascript/external/syntaxhighlighter/themes/shCoreDefault.css');
     Requirements::css(CB_DIR . '/javascript/external/syntaxhighlighter/themes/shThemeDefault.css');
     //Load JS Requirements
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript(CB_DIR . '/javascript/external/syntaxhighlighter/brushes/shCore.js');
     Requirements::javascript(CB_DIR . '/javascript/external/syntaxhighlighter/brushes/' . self::getBrushName($snippet->Language()->HighlightCode) . '.js');
     Requirements::javascriptTemplate(CB_DIR . '/javascript/CodeBankShortCode.template.js', array('ID' => $snippet->ID), 'snippet-highlightinit-' . $snippet->ID);
     //Render the snippet
     $obj = new ViewableData();
     return $obj->renderWith('CodeBankShortCode', array('ID' => $snippet->ID, 'Title' => $snippet->getField('Title'), 'Description' => $snippet->getField('Description'), 'SnippetText' => DBField::create_field('Text', $snippetText), 'HighlightCode' => strtolower($snippet->Language()->HighlightCode)));
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-codebank,代码行数:38,代码来源:CodeBankShortCode.php

示例5: Tweets

 public function Tweets()
 {
     $twitterApp = TwitterApp::get()->first();
     if (!$twitterApp) {
         return null;
     }
     $siteConfig = SiteConfig::current_site_config();
     $twitter = $twitterApp->getTwitter();
     $twitter->setAccess(new OAuthToken($twitterApp->TwitterAccessToken, $twitterApp->TwitterAccessSecret));
     if ($twitter->hasAccess()) {
         $result = $twitter->api("1.1/statuses/user_timeline.json", "GET", array("screen_name" => $this->TwitterHandle, "count" => $this->NumberOfTweets));
         if ($result->statusCode() == 200) {
             $rawTweets = json_decode($result->body(), true);
             if (count($rawTweets) > 0) {
                 $tweets = new ArrayList();
                 foreach ($rawTweets as $tweet) {
                     // Parse tweet links, users and hashtags.
                     $parsed = preg_replace("#(^|[\n ])([\\w]+?://[\\w]+[^ \"\n\r\t<]*)#ise", "'\\1<a href=\"\\2\" target=\"_blank\">\\2</a>'", $tweet['text']);
                     $parsed = preg_replace("#(^|[\n ])@([A-Za-z0-9\\_]*)#ise", "'\\1<a href=\"http://www.twitter.com/\\2\" target=\"_blank\">@\\2</a>'", $parsed);
                     $parsed = preg_replace("#(^|[\n ])\\#([A-Za-z0-9]*)#ise", "'\\1<a href=\"http://www.twitter.com/search?q=\\2\" target=\"_blank\">#\\2</a>'", $parsed);
                     $t = new ArrayData(array());
                     $t->Tweet = DBField::create_field("HTMLText", $parsed, "Tweet");
                     $t->TweetDate = DBField::create_field("SS_Datetime", strtotime($tweet['created_at']));
                     $t->TweetLink = DBField::create_field("Varchar", "http://www.twitter.com/" . rawurlencode($tweet['user']['screen_name']) . "/status/" . rawurlencode($tweet['id_str']));
                     $tweets->push($t);
                 }
                 return $tweets;
             }
         }
     }
     return null;
 }
开发者ID:helpfulrobot,项目名称:micmania1-sstwitter,代码行数:32,代码来源:LatestTweetsWidget.php

示例6: Languages

 /**
  * Get a set of content languages (for quick language navigation)
  * @example
  * <code>
  * <!-- in your template -->
  * <ul class="langNav">
  * 		<% loop Languages %>
  * 		<li><a href="$Link" class="$LinkingMode" title="$Title.ATT">$Language</a></li>
  * 		<% end_loop %>
  * </ul>
  * </code>
  *
  * @return ArrayList|null
  */
 public function Languages()
 {
     $locales = TranslatableUtility::get_content_languages();
     // there's no need to show a navigation when there's less than 2 languages. So return null
     if (count($locales) < 2) {
         return null;
     }
     $currentLocale = Translatable::get_current_locale();
     $homeTranslated = null;
     if ($home = SiteTree::get_by_link('home')) {
         /** @var SiteTree $homeTranslated */
         $homeTranslated = $home->getTranslation($currentLocale);
     }
     /** @var ArrayList $langSet */
     $langSet = ArrayList::create();
     foreach ($locales as $locale => $name) {
         Translatable::set_current_locale($locale);
         /** @var SiteTree $translation */
         $translation = $this->owner->hasTranslation($locale) ? $this->owner->getTranslation($locale) : null;
         $langSet->push(new ArrayData(array('Locale' => $locale, 'RFC1766' => i18n::convert_rfc1766($locale), 'Language' => DBField::create_field('Varchar', strtoupper(i18n::get_lang_from_locale($locale))), 'Title' => DBField::create_field('Varchar', html_entity_decode(i18n::get_language_name(i18n::get_lang_from_locale($locale), true), ENT_NOQUOTES, 'UTF-8')), 'LinkingMode' => $currentLocale == $locale ? 'current' : 'link', 'Link' => $translation ? $translation->AbsoluteLink() : ($homeTranslated ? $homeTranslated->Link() : ''))));
     }
     Translatable::set_current_locale($currentLocale);
     i18n::set_locale($currentLocale);
     return $langSet;
 }
开发者ID:bummzack,项目名称:translatable-dataobject,代码行数:39,代码来源:TranslatableUtility.php

示例7: GlobalNav

 /**
  * @param   $key The nav key, e.g. "doc", "userhelp"
  * @return HTMLText
  */
 public static function GlobalNav($key)
 {
     $baseURL = GlobalNavSiteTreeExtension::get_toolbar_baseurl();
     Requirements::css(Controller::join_links($baseURL, Config::inst()->get('GlobalNav', 'css_path')));
     // If this method haven't been called before, get the toolbar and cache it
     if (self::$global_nav_html === null) {
         // Set the default to empty
         self::$global_nav_html = '';
         // Prevent recursion from happening
         if (empty($_GET['globaltoolbar'])) {
             $host = GlobalNavSiteTreeExtension::get_toolbar_hostname();
             $path = Director::makeRelative(GlobalNavSiteTreeExtension::get_navbar_filename($key));
             if (Config::inst()->get('GlobalNav', 'use_localhost')) {
                 self::$global_nav_html = file_get_contents(BASE_PATH . $path);
             } else {
                 $url = Controller::join_links($baseURL, $path, '?globaltoolbar=true');
                 $connectionTimeout = Config::inst()->get('GlobalNavTemplateProvider', 'connection_timeout');
                 $transferTimeout = Config::inst()->get('GlobalNavTemplateProvider', 'transfer_timeout');
                 // Get the HTML and cache it
                 self::$global_nav_html = self::curl_call($url, $connectionTimeout, $transferTimeout);
             }
         }
     }
     $html = DBField::create_field('HTMLText', self::$global_nav_html);
     $html->setOptions(array('shortcodes' => false));
     return $html;
 }
开发者ID:newleeland,项目名称:silverstripe-globaltoolbar,代码行数:31,代码来源:GlobalNavTemplateProvider.php

示例8: renderRows

 protected function renderRows($rows, ArrayIterator $splitcontent, &$pos = -1)
 {
     $output = "";
     $rownumber = 0;
     foreach ($rows as $row) {
         if ($row->cols) {
             $columns = array();
             foreach ($row->cols as $col) {
                 $nextcontent = $splitcontent->current();
                 $isholder = !isset($col->rows);
                 if ($isholder) {
                     $splitcontent->next();
                     //advance iterator if there are no sub-rows
                     $pos++;
                     //wrap split content in a HTMLText object
                     $dbObject = DBField::create_field('HTMLText', $nextcontent, "Content");
                     $dbObject->setOptions(array("shortcodes" => true));
                     $nextcontent = $dbObject;
                 }
                 $width = $col->width ? (int) $col->width : 1;
                 //width is at least 1
                 $columns[] = new ArrayData(array("Width" => $width, "EnglishWidth" => $this->englishWidth($width), "Content" => $isholder ? $nextcontent : $this->renderRows($col->rows, $splitcontent, $pos), "IsHolder" => $isholder, "GridPos" => $pos, "ExtraClasses" => isset($col->extraclasses) ? $col->extraclasses : null));
             }
             $output .= ArrayData::create(array("Columns" => new ArrayList($columns), "RowNumber" => (string) $rownumber++, "ExtraClasses" => isset($row->extraclasses) ? $row->extraclasses : null))->renderWith($this->template);
         } else {
             //every row should have columns!!
         }
     }
     return $output;
 }
开发者ID:helpfulrobot,项目名称:burnbright-silverstripe-gridstructuredcontent,代码行数:30,代码来源:GSCRenderer.php

示例9: handlePost

 protected function handlePost(array $data, $settings = [])
 {
     $post = ['ID' => isset($data['id']) && isset($data['id']['videoId']) ? $data['id']['videoId'] : '0', 'Author' => isset($data['snippet']) && isset($data['snippet']['channelTitle']) ? \FormField::name_to_label($data['snippet']['channelTitle']) : '', 'AuthorID' => isset($data['snippet']) && isset($data['snippet']['channelId']) ? $data['snippet']['channelId'] : 0, 'AuthorURL' => isset($data['snippet']) && isset($data['snippet']['channelId']) ? \Controller::join_links($this->url, 'channel', $data['snippet']['channelId']) : '', 'Title' => isset($data['snippet']) && isset($data['snippet']['title']) ? $data['snippet']['title'] : '', 'Content' => isset($data['snippet']) && isset($data['snippet']['description']) ? $this->textParser()->text($data['snippet']['description']) : '', 'Priority' => isset($data['snippet']) && isset($data['snippet']['publishedAt']) ? strtotime($data['snippet']['publishedAt']) : 0, 'Posted' => isset($data['snippet']) && isset($data['snippet']['publishedAt']) ? \DBField::create_field('SS_Datetime', strtotime($data['snippet']['publishedAt'])) : null];
     if (isset($data['snippet']) && isset($data['snippet']['thumbnails'])) {
         if (isset($data['snippet']['thumbnails']['high']) && isset($data['snippet']['thumbnails']['high']['url'])) {
             $post['Cover'] = $data['snippet']['thumbnails']['high']['url'];
         } else {
             if (isset($data['snippet']['thumbnails']['medium']) && isset($data['snippet']['thumbnails']['medium']['url'])) {
                 $post['Cover'] = $data['snippet']['thumbnails']['medium']['url'];
             } else {
                 if (isset($data['snippet']['thumbnails']['default']) && isset($data['snippet']['thumbnails']['default']['url'])) {
                     $post['Cover'] = $data['snippet']['thumbnails']['default']['url'];
                 }
             }
         }
     }
     if ($post['ID']) {
         $params = (array) singleton('env')->get('Youtube.video_params');
         if (isset($settings['videoParams'])) {
             $params = array_merge($params, (array) $settings['videoParams']);
         }
         $params['v'] = $post['ID'];
         $post['Link'] = \Controller::join_links($this->url, 'watch', '?' . http_build_query($params));
         $this->setFromEmbed($post);
     }
     if (isset($post['ObjectDescription']) && $post['ObjectDescription'] == $post['Content']) {
         unset($post['ObjectDescription']);
     }
     if (isset($post['Description']) && $post['Description'] == $post['Content']) {
         unset($post['Description']);
     }
     return $post;
 }
开发者ID:spekulatius,项目名称:ss-social-feed,代码行数:33,代码来源:Youtube.php

示例10: Field

    public function Field($properties = array())
    {
        $content = '';
        Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js');
        Requirements::javascript(FRAMEWORK_DIR . "/javascript/ToggleField.js");
        if ($this->startClosed) {
            $this->addExtraClass('startClosed');
        }
        $valforInput = $this->value ? Convert::raw2att($this->value) : "";
        $rawInput = Convert::html2raw($valforInput);
        if ($this->charNum) {
            $reducedVal = substr($rawInput, 0, $this->charNum);
        } else {
            $reducedVal = DBField::create_field('Text', $rawInput)->{$this->truncateMethod}();
        }
        // only create togglefield if the truncated content is shorter
        if (strlen($reducedVal) < strlen($rawInput)) {
            $content = <<<HTML
\t\t\t<div class="readonly typography contentLess" style="display: none">
\t\t\t\t{$reducedVal}
\t\t\t\t&nbsp;<a href="#" class="triggerMore">{$this->labelMore}</a>
\t\t\t</div>
\t\t\t<div class="readonly typography contentMore">
\t\t\t\t{$this->value}
\t\t\t\t&nbsp;<a href="#" class="triggerLess">{$this->labelLess}</a>
\t\t\t</div>\t
\t\t\t<br />
\t\t\t<input type="hidden" name="{$this->name}" value="{$valforInput}" />
HTML;
        } else {
            $this->dontEscape = true;
            $content = parent::Field();
        }
        return $content;
    }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:35,代码来源:ToggleField.php

示例11: getEventsAction

 public function getEventsAction(SS_HTTPRequest $request)
 {
     // Search date
     $date = DBField::create_field("SS_Datetime", $request->param("SearchDate"));
     if (!$date->getValue()) {
         $date = SS_Datetime::now();
     }
     // Get event data
     $cache = SS_Cache::factory(self::EVENTS_CACHE_NAME);
     $cacheKey = $date->Format('Y_m_d');
     if ($result = $cache->load($cacheKey)) {
         $data = unserialize($result);
     } else {
         $data = EventsDataUtil::get_events_data_for_day($date);
         $cache->save(serialize($data), $cacheKey);
     }
     // Get init data
     if ($request->param("GetAppConfig")) {
         $cache = SS_Cache::factory(self::CONFIG_CACHE_NAME);
         $cacheKey = 'APP_CONFIG';
         if ($result = $cache->load($cacheKey)) {
             $configData = unserialize($result);
         } else {
             $configData = AppConfigDataUtil::get_config_data();
             $cache->save(serialize($configData), $cacheKey);
         }
         $data['appConfig'] = $configData;
     }
     return $this->sendResponse($data);
 }
开发者ID:ehyland,项目名称:some-painter-cms,代码行数:30,代码来源:EventsController.php

示例12: getPostContent

 /** 
  * @return HTMLText
  */
 public function getPostContent($post)
 {
     $text = isset($post->text) ? $post->text : '';
     $text = preg_replace('/(https?:\\/\\/[a-z0-9\\.\\/]+)/i', '<a href="$1" target="_blank">$1</a>', $text);
     $result = DBField::create_field('HTMLText', $text);
     return $result;
 }
开发者ID:isaacrankin,项目名称:silverstripe-social-feed,代码行数:10,代码来源:SocialFeedProviderTwitter.php

示例13: writeToManipulation

 public function writeToManipulation(&$manipulation)
 {
     // Write ID, checking that the value is valid
     $manipulation['fields'][$this->name . 'ID'] = $this->exists() ? $this->prepValueForDB($this->getIDValue()) : $this->nullValue();
     // Write class
     $classObject = DBField::create_field('Enum', $this->getClassValue(), $this->name . 'Class');
     $classObject->writeToManipulation($manipulation);
 }
开发者ID:miamollie,项目名称:echoAerial,代码行数:8,代码来源:PolymorphicForeignKey.php

示例14: ConfirmTimeLimit

 /**
  * @return SS_Datetime
  */
 public function ConfirmTimeLimit()
 {
     $unconfirmed = $this->Status == 'Unconfirmed';
     $limit = $this->Time()->Event()->ConfirmTimeLimit;
     if ($unconfirmed && $limit) {
         return DBField::create_field('SS_Datetime', strtotime($this->Created) + $limit);
     }
 }
开发者ID:tim-lar,项目名称:silverstripe-eventmanagement,代码行数:11,代码来源:EventRegistration.php

示例15: getNextRun

 /**
  * @return string Date time string of next run for this task
  */
 public function getNextRun()
 {
     if (!$this->isEnabled()) {
         return '';
     }
     $cron = CronExpression::factory($this->ScheduleString);
     return DBField::create_field('SS_Datetime', $cron->getNextRunDate()->Format('U'))->getValue();
 }
开发者ID:botzkobg,项目名称:silverstripe-crontask,代码行数:11,代码来源:CronTaskStatus.php


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