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


PHP Requirements类代码示例

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


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

示例1: __construct

 /**
  * Returns an instance of this class
  *
  * @param Controller $controller
  * @param string $name
  */
 public function __construct($controller, $name)
 {
     $fields = new FieldList(array(new HiddenField('AuthenticationMethod', null, $this->authenticator_class)));
     $actions = new FieldList(array(FormAction::create('redirectToRealMe', _t('RealMeLoginForm.LOGINBUTTON', 'LoginAction'))->setUseButtonTag(true)->setButtonContent('<span class="realme_button_padding">Login or register with RealMe<span class="realme_icon_new_window"></span> <span class="realme_icon_padlock"></span>')->setAttribute('class', 'realme_button')));
     // Taken from MemberLoginForm
     if (isset($_REQUEST['BackURL'])) {
         $backURL = $_REQUEST['BackURL'];
     } elseif (Session::get('BackURL')) {
         $backURL = Session::get('BackURL');
     }
     if (isset($backURL)) {
         // Ensure that $backURL isn't redirecting us back to login form or a RealMe authentication page
         if (strpos($backURL, 'Security/login') === false && strpos($backURL, 'Security/realme') === false) {
             $fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
         }
     }
     // optionally include requirements {@see /realme/_config/config.yml}
     if ($this->config()->include_jquery) {
         Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js");
     }
     if ($this->config()->include_javascript) {
         Requirements::javascript(REALME_MODULE_PATH . "/javascript/realme.js");
     }
     if ($this->config()->include_css) {
         Requirements::css(REALME_MODULE_PATH . "/css/realme.css");
     }
     parent::__construct($controller, $name, $fields, $actions);
 }
开发者ID:helpfulrobot,项目名称:silverstripe-realme,代码行数:34,代码来源:RealMeLoginForm.php

示例2: generatePDF

 function generatePDF()
 {
     // tempfolder
     $tmpBaseFolder = TEMP_FOLDER . '/shopsystem';
     $tmpFolder = project() ? "{$tmpBaseFolder}/" . project() : "{$tmpBaseFolder}/site";
     if (is_dir($tmpFolder)) {
         Filesystem::removeFolder($tmpFolder);
     }
     if (!file_exists($tmpFolder)) {
         Filesystem::makeFolder($tmpFolder);
     }
     $baseFolderName = basename($tmpFolder);
     //Get site
     Requirements::clear();
     $link = Director::absoluteURL($this->pdfLink() . "/?view=1");
     $response = Director::test($link);
     $content = $response->getBody();
     $content = utf8_decode($content);
     $contentfile = "{$tmpFolder}/" . $this->PublicURL . ".html";
     if (!file_exists($contentfile)) {
         // Write to file
         if ($fh = fopen($contentfile, 'w')) {
             fwrite($fh, $content);
             fclose($fh);
         }
     }
     return $contentfile;
 }
开发者ID:pstaender,项目名称:ShopSystem,代码行数:28,代码来源:ShopInvoice.php

示例3: FieldHolder

    function FieldHolder()
    {
        Requirements::javascript("sapphire/javascript/ReportField.js");
        $headerHTML = $this->columnheaders();
        $dataCellHTML = $this->datacells();
        $id = $this->id() . '_exportToCSV';
        if ($this->export) {
            $exportButton = <<<HTML
<input name="{$id}" type="submit" id="{$id}" class="ReportField_ExportToCSVButton" value="Export to CSV" />
HTML;
        } else {
            $exportButton = "";
        }
        // display the table of results
        $html = <<<HTML
<div style="width: 98%; overflow: auto">
\t{$exportButton}
<table class="ReportField" summary="">
\t<thead>
\t\t{$headerHTML}
\t</thead>
\t<tbody>
\t\t{$dataCellHTML}
\t</tbody>
</table>
</div>
HTML;
        return $html;
    }
开发者ID:ramziammar,项目名称:websites,代码行数:29,代码来源:ReportField.php

示例4: overview_data

 /**
  * Gets the overview data from new relic
  */
 public function overview_data()
 {
     //Purge Requirements
     Requirements::clear();
     //If we're not configured properly return an error
     if (!$this->getIsConfigured()) {
         $msg = _t('NewRelicPerformanceReport.API_APP_CONFIG_ERROR', '_New Relic API Key or Application ID is missing, check configuration');
         $e = new SS_HTTPResponse_Exception($msg, 400);
         $e->getResponse()->addHeader('Content-Type', 'text/plain');
         $e->getResponse()->addHeader('X-Status', rawurlencode($msg));
         throw $e;
         return;
     }
     //Build the base restful service object
     $service = new RestfulService('https://api.newrelic.com/v2/applications/' . Convert::raw2url($this->config()->application_id) . '/metrics/data.json', $this->config()->refresh_rate);
     $service->httpHeader('X-Api-Key:' . Convert::raw2url($this->config()->api_key));
     //Perform the request
     $response = $service->request('', 'POST', 'names[]=HttpDispatcher&names[]=Apdex&names[]=EndUser/Apdex&names[]=Errors/all&names[]=EndUser&period=60');
     //Retrieve the body
     $body = $response->getBody();
     if (!empty($body)) {
         $this->response->addHeader('Content-Type', 'application/json; charset=utf-8');
         return $body;
     }
     //Data failed to load
     $msg = _t('NewRelicPerformanceReport.DATA_LOAD_FAIL', '_Failed to retrieve data from New Relic');
     $e = new SS_HTTPResponse_Exception($msg, 400);
     $e->getResponse()->addHeader('Content-Type', 'text/plain');
     $e->getResponse()->addHeader('X-Status', rawurlencode($msg));
     throw $e;
 }
开发者ID:webbuilders-group,项目名称:silverstripe-new-relic,代码行数:34,代码来源:NewRelicPerformanceReport.php

示例5: FieldHolder

 public function FieldHolder($properties = array())
 {
     Requirements::css(LINKABLE_PATH . '/css/embeddedobjectfield.css');
     Requirements::javascript(LINKABLE_PATH . '/javascript/embeddedobjectfield.js');
     if ($this->object && $this->object->ID) {
         $properties['SourceURL'] = TextField::create($this->getName() . '[sourceurl]', '')->setAttribute('placeholder', _t('Linkable.SOURCEURL', 'Source URL'));
         if (strlen($this->object->SourceURL)) {
             $properties['ObjectTitle'] = TextField::create($this->getName() . '[title]', _t('Linkable.TITLE', 'Title'));
             $properties['Width'] = TextField::create($this->getName() . '[width]', _t('Linkable.WIDTH', 'Width'));
             $properties['Height'] = TextField::create($this->getName() . '[height]', _t('Linkable.HEIGHT', 'Height'));
             $properties['ThumbURL'] = HiddenField::create($this->getName() . '[thumburl]', '');
             $properties['Type'] = HiddenField::create($this->getName() . '[type]', '');
             $properties['EmbedHTML'] = HiddenField::create($this->getName() . '[embedhtml]', '');
             $properties['ObjectDescription'] = TextAreaField::create($this->getName() . '[description]', _t('Linkable.DESCRIPTION', 'Description'));
             $properties['ExtraClass'] = TextField::create($this->getName() . '[extraclass]', _t('Linkable.CSSCLASS', 'CSS class'));
             foreach ($properties as $key => $field) {
                 if ($key == 'ObjectTitle') {
                     $key = 'Title';
                 } elseif ($key == 'ObjectDescription') {
                     $key = 'Description';
                 }
                 $field->setValue($this->object->{$key});
             }
             if ($this->object->ThumbURL) {
                 $properties['ThumbImage'] = LiteralField::create($this->getName(), '<img src="' . $this->object->ThumbURL . '" />');
             }
         }
     } else {
         $properties['SourceURL'] = TextField::create($this->getName() . '[sourceurl]', '')->setAttribute('placeholder', _t('Linkable.SOURCEURL', 'Source URL'));
     }
     $field = parent::FieldHolder($properties);
     return $field;
 }
开发者ID:jason-zz,项目名称:silverstripe-linkable,代码行数:33,代码来源:EmbeddedObjectField.php

示例6: init

	function init() {
		parent::init();
		
		Requirements::themedCSS("layout");
		Requirements::themedCSS("typography");
		Requirements::themedCSS("form");
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:7,代码来源:Page.php

示例7: init

 function init()
 {
     parent::init();
     Requirements::css('newsletter/css/SubscriptionPage.css');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-validate/jquery.validate.min.js');
 }
开发者ID:tractorcow,项目名称:silverstripe-newsletter,代码行数:7,代码来源:UnsubscribeController.php

示例8: FieldHolder

 public function FieldHolder()
 {
     Requirements::javascript('dataobject_manager/javascript/jquery.wysiwyg.js');
     Requirements::css('dataobject_manager/css/jquery.wysiwyg.css');
     Requirements::customScript("\n\t\t\t\$(function() {\n\t\t\t\t\$('#{$this->id()}').wysiwyg({\n\t\t\t\t\t{$this->getConfig()}\n\t\t\t\t}).parents('.simplehtmleditor').removeClass('hidden');\n\t\t\t\t\n\t\t\t});\n\t\t");
     return parent::FieldHolder();
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:7,代码来源:SimpleHTMLEditorField.php

示例9: jsValidation

    function jsValidation()
    {
        $formID = $this->form->FormName();
        $error = _t('EmailField.VALIDATIONJS', 'Please enter an email address.');
        $jsFunc = <<<JS
Behaviour.register({
\t"#{$formID}": {
\t\tvalidateEmailField: function(fieldName) {
\t\t\tvar el = _CURRENT_FORM.elements[fieldName];
\t\t\tif(!el || !el.value) return true;

\t\t \tif(el.value.match(/^[a-z0-9!#\$%&'*+\\/=?^_`{|}~-]+(?:\\.[a-z0-9!#\$%&'*+\\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\$/i)) {
\t\t \t\treturn true;
\t\t \t} else {
\t\t\t\tvalidationError(el, "{$error}","validation");
\t\t \t\treturn false;
\t\t \t} \t
\t\t}
\t}
});
JS;
        //fix for the problem with more than one form on a page.
        Requirements::customScript($jsFunc, 'func_validateEmailField' . '_' . $formID);
        //return "\$('$formID').validateEmailField('$this->name');";
        return <<<JS
if(typeof fromAnOnBlur != 'undefined'){
\tif(fromAnOnBlur.name == '{$this->name}')
\t\t\$('{$formID}').validateEmailField('{$this->name}');
}else{
\t\$('{$formID}').validateEmailField('{$this->name}');
}
JS;
    }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:33,代码来源:EmailField.php

示例10: onAfterInit

 public function onAfterInit()
 {
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
     Requirements::javascript("silverstripe-accordian-content/assets/javascript/main.js");
     Requirements::css("silverstripe-accordian-content/assets/css/styles.css");
 }
开发者ID:helpfulrobot,项目名称:gdmedia-silverstripe-accordian-content,代码行数:7,代码来源:AccordianControllerExtension.php

示例11: 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

示例12: getHTMLFragments

 /**
  * Returns a map where the keys are fragment names and the values are pieces of HTML to add to these fragments.
  * @param GridField $gridField Grid Field Reference
  * @return Array Map where the keys are fragment names and the values are pieces of HTML to add to these fragments.
  */
 public function getHTMLFragments($gridField)
 {
     $dataList = $gridField->getList();
     if (class_exists('UnsavedRelationList') && $dataList instanceof UnsavedRelationList) {
         return array();
     }
     $state = $gridField->State->GridFieldSortableRows;
     if (!is_bool($state->sortableToggle)) {
         $state->sortableToggle = false;
     }
     //Ensure user can edit
     if (!singleton($gridField->getModelClass())->canEdit()) {
         return array();
     }
     //Sort order toggle
     $sortOrderToggle = GridField_FormAction::create($gridField, 'sortablerows-toggle', 'sorttoggle', 'sortableRowsToggle', null)->addExtraClass('sortablerows-toggle');
     $sortOrderSave = GridField_FormAction::create($gridField, 'sortablerows-savesort', 'savesort', 'saveGridRowSort', null)->addExtraClass('sortablerows-savesort');
     //Sort to Page Action
     $sortToPage = GridField_FormAction::create($gridField, 'sortablerows-sorttopage', 'sorttopage', 'sortToPage', null)->addExtraClass('sortablerows-sorttopage');
     $data = array('SortableToggle' => $sortOrderToggle, 'SortOrderSave' => $sortOrderSave, 'SortToPage' => $sortToPage, 'Checked' => $state->sortableToggle == true ? ' checked = "checked"' : '', 'List' => $dataList);
     $forTemplate = new ArrayData($data);
     //Inject Requirements
     $custom = Config::inst()->get('GridFieldSortableRows', 'Base');
     $base = $custom ?: SORTABLE_GRIDFIELD_BASE;
     Requirements::css($base . '/css/GridFieldSortableRows.css');
     Requirements::javascript($base . '/javascript/GridFieldSortableRows.js');
     $args = array('Colspan' => count($gridField->getColumns()), 'ID' => $gridField->ID(), 'DisableSelection' => $this->disable_selection);
     $fragments = array('header' => $forTemplate->renderWith('GridFieldSortableRows', $args));
     if ($gridField->getConfig()->getComponentByType('GridFieldPaginator')) {
         $fragments['after'] = $forTemplate->renderWith('GridFieldSortableRows_paginator');
     }
     return $fragments;
 }
开发者ID:helpfulrobot,项目名称:maldicore-sortablegridfield,代码行数:38,代码来源:GridFieldSortableRows.php

示例13: Dates

 function Dates()
 {
     Requirements::themedCSS('archivewidget');
     $results = new DataObjectSet();
     $container = BlogTree::current();
     $ids = $container->BlogHolderIDs();
     $stage = Versioned::current_stage();
     $suffix = !$stage || $stage == 'Stage' ? "" : "_{$stage}";
     $monthclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%m') : 'MONTH("Date")';
     $yearclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%Y') : 'YEAR("Date")';
     if ($this->DisplayMode == 'month') {
         $sqlResults = DB::query("\n\t\t\t\tSELECT DISTINCT CAST({$monthclause} AS " . DB::getConn()->dbDataType('unsigned integer') . ") AS \"Month\", {$yearclause} AS \"Year\"\n\t\t\t\tFROM \"SiteTree{$suffix}\" INNER JOIN \"BlogEntry{$suffix}\" ON \"SiteTree{$suffix}\".\"ID\" = \"BlogEntry{$suffix}\".\"ID\"\n\t\t\t\tWHERE \"ParentID\" IN (" . implode(', ', $ids) . ")\n\t\t\t\tORDER BY \"Year\" DESC, \"Month\" DESC;");
     } else {
         $sqlResults = DB::query("\n\t\t\t\tSELECT DISTINCT {$yearclause} AS \"Year\" \n\t\t\t\tFROM \"SiteTree{$suffix}\" INNER JOIN \"BlogEntry{$suffix}\" ON \"SiteTree{$suffix}\".\"ID\" = \"BlogEntry{$suffix}\".\"ID\"\n\t\t\t\tWHERE \"ParentID\" IN (" . implode(', ', $ids) . ")\n\t\t\t\tORDER BY \"Year\" DESC");
     }
     if ($sqlResults) {
         foreach ($sqlResults as $sqlResult) {
             $isMonthDisplay = $this->DisplayMode == 'month';
             $monthVal = isset($sqlResult['Month']) ? (int) $sqlResult['Month'] : 1;
             $month = $isMonthDisplay ? $monthVal : 1;
             $year = $sqlResult['Year'] ? (int) $sqlResult['Year'] : date('Y');
             $date = DBField::create('Date', array('Day' => 1, 'Month' => $month, 'Year' => $year));
             if ($isMonthDisplay) {
                 $link = $container->Link('date') . '/' . $sqlResult['Year'] . '/' . sprintf("%'02d", $monthVal);
             } else {
                 $link = $container->Link('date') . '/' . $sqlResult['Year'];
             }
             $results->push(new ArrayData(array('Date' => $date, 'Link' => $link)));
         }
     }
     return $results;
 }
开发者ID:nicmart,项目名称:comperio-site,代码行数:32,代码来源:ArchiveWidget.php

示例14: __construct

 /**
  * Taken from MemberLoginForm::__construct with minor changes
  */
 public function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
 {
     $customCSS = project() . '/css/member_login.css';
     if (Director::fileExists($customCSS)) {
         Requirements::css($customCSS);
     }
     if (isset($_REQUEST['BackURL'])) {
         $backURL = $_REQUEST['BackURL'];
     } else {
         $backURL = Session::get('BackURL');
     }
     if ($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) {
         $fields = new FieldList(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this));
         $actions = new FieldList(new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else")));
     } else {
         if (!$fields) {
             $fields = new FieldList(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this));
         }
         if (!$actions) {
             $actions = new FieldList(new FormAction('dologin', _t('GoogleAuthenticator.BUTTONLOGIN', "Log in with Google")));
         }
     }
     if (isset($backURL)) {
         $fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
     }
     // Allow GET method for callback
     $this->setFormMethod('GET', true);
     parent::__construct($controller, $name, $fields, $actions);
 }
开发者ID:helpfulrobot,项目名称:xpointo-silverstripe-google-authenticator,代码行数:32,代码来源:GoogleAuthenticatorLoginForm.php

示例15: Field

 /**
  * Renders the button, includes the JS and CSS
  * @param array $properties
  */
 public function Field($properties = array())
 {
     Requirements::css(BETTER_BUTTONS_DIR . '/css/dropdown_form_action.css');
     Requirements::javascript(BETTER_BUTTONS_DIR . '/javascript/dropdown_form_action.js');
     $this->setAttribute('data-form-action-dropdown', '#' . $this->DropdownID());
     return parent::Field();
 }
开发者ID:dawidcieszynski,项目名称:silverstripe-gridfield-betterbuttons,代码行数:11,代码来源:DropdownFormAction.php


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