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


PHP Object::get_static方法代码示例

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


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

示例1: order

 /**
  * Handles saving the updated order of objects.
  */
 public function order($request)
 {
     $objects = $this->sourceItems();
     $sort = Object::get_static($this->sourceClass, 'default_sort');
     $newIDs = $request->postVar('ids');
     $sortVals = array_values($objects->map('ID', $sort));
     // populate new ID values
     foreach ($objects as $object) {
         if (!$object->{$sort}) {
             $table = $object->class;
             $query = DB::query("SELECT MAX(\"{$sort}\") + 1 FROM \"{$table}\"");
             $object->{$sort} = $oldIDs[$object->ID] = $query->value();
             $object->write();
         }
     }
     // save the new ID values - but only use existing sort values to prevent
     // conflicts with items not in the table
     foreach ($newIDs as $key => $id) {
         $object = $objects->find('ID', $id);
         $object->{$sort} = $sortVals[$key];
         $object->write();
     }
     $objects->sort($sort);
     return $this->FieldHolder();
 }
开发者ID:nyeholt,项目名称:silverstripe-datalists,代码行数:28,代码来源:DataListOrderableComplexTableField.php

示例2: get_for_record

 /**
  * @param SiteTree $record
  * @return Array template data
  */
 static function get_for_record($record)
 {
     $items = '';
     $message = '';
     $navItemClasses = ClassInfo::subclassesFor('SilverStripeNavigatorItem');
     array_shift($navItemClasses);
     // Sort menu items according to priority
     $menuPriority = array();
     $i = 0;
     foreach ($navItemClasses as $navItemClass) {
         if ($navItemClass == 'SilverStripeNavigatorItem') {
             continue;
         }
         $i++;
         $obj = new $navItemClass();
         // This funny litle formula ensures that the first item added with the same priority will be left-most.
         $priority = Object::get_static($navItemClass, 'priority');
         $menuPriority[$priority * 100 - 1] = $obj;
     }
     ksort($menuPriority);
     foreach ($menuPriority as $obj) {
         $text = $obj->getHTML($record);
         if ($text) {
             $items .= $text;
         }
         $newMessage = $obj->getMessage($record);
         if ($newMessage) {
             $message = $newMessage;
         }
     }
     return array('items' => $items, 'message' => $message);
 }
开发者ID:rixrix,项目名称:silverstripe-cms,代码行数:36,代码来源:SilverStripeNavigatorItem.php

示例3: alternateFilepathForErrorcode

 /**
  * Alter file path to generated a static (static) error page file to handle error page template on different sub-sites 
  *
  * @see Error::get_filepath_for_errorcode()
  *
  * FIXME since {@link Subsite::currentSubsite()} partly relies on Session, viewing other sub-site (including main site) between 
  * opening ErrorPage in the CMS and publish ErrorPage causes static error page to get generated incorrectly. 
  */
 function alternateFilepathForErrorcode($statusCode, $locale = null)
 {
     $static_filepath = Object::get_static($this->owner->ClassName, 'static_filepath');
     $subdomainPart = "";
     // Try to get current subsite from session
     $subsite = Subsite::currentSubsite(false);
     // since this function is called from Page class before the controller is created, we have to get subsite from domain instead
     if (!$subsite) {
         $subsiteID = Subsite::getSubsiteIDForDomain();
         if ($subsiteID != 0) {
             $subsite = DataObject::get_by_id("Subsite", $subsiteID);
         } else {
             $subsite = null;
         }
     }
     if ($subsite) {
         $subdomain = $subsite->domain();
         $subdomainPart = "-{$subdomain}";
     }
     if (singleton('SiteTree')->hasExtension('Translatable') && $locale && $locale != Translatable::default_locale()) {
         $filepath = $static_filepath . "/error-{$statusCode}-{$locale}{$subdomainPart}.html";
     } else {
         $filepath = $static_filepath . "/error-{$statusCode}{$subdomainPart}.html";
     }
     return $filepath;
 }
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:34,代码来源:ErrorPageSubsite.php

示例4: onAfterInit

	public function onAfterInit() {
		$cssTemplate = Object::get_static('GalleristPageDecorator', 'css_template');
		if ((bool)$cssTemplate && $this->owner->hasMethod('data')) {
			Requirements::customCSS($this->owner->data()->renderWith($cssTemplate));
		}
		Requirements::themedCSS('gallerist');
	}
开发者ID:redema,项目名称:silverstripe-gallerist,代码行数:7,代码来源:GalleristPageControllerExtension.php

示例5: testErrorPageLocations

 function testErrorPageLocations()
 {
     $subsite1 = $this->objFromFixture('Subsite', 'domaintest1');
     Subsite::changeSubsite($subsite1->ID);
     $path = ErrorPage::get_filepath_for_errorcode(500);
     $static_path = Object::get_static('ErrorPage', 'static_filepath');
     $expected_path = $static_path . '/error-500-' . $subsite1->domain() . '.html';
     $this->assertEquals($expected_path, $path);
 }
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:9,代码来源:SiteTreeSubsitesTest.php

示例6: setUp

	public function setUp() {
		parent::setUp();
		$this->oldMarkupTemplate = Object::get_static('GalleristPageDecorator', 'markup_template');
		Object::add_static_var('GalleristPageDecorator', 'markup_template', 'Gallerist', true);
		$this->oldGalleristActive = Object::get_static('Page', 'gallerist_active');
		Object::add_static_var('Page', 'gallerist_active', true, true);
		foreach($this->allFixtureIDs('Image') as $fileID) {
			$file = DataObject::get_by_id('Image', $fileID);
			copy(BASE_PATH . "/gallerist/images/{$file->Name}", BASE_PATH . "/{$file->Filename}");
		}
	}
开发者ID:redema,项目名称:silverstripe-gallerist,代码行数:11,代码来源:GalleristPageDecoratorTest.php

示例7: testAddStaticReplace

 /**
  * Test {@link Object::addStaticVar()} correctly replaces static vars
  */
 public function testAddStaticReplace()
 {
     Object::addStaticVars('ObjectStaticTest_Fourth', array('second' => array('test_4')), true);
     Object::addStaticVars('ObjectStaticTest_Third', array('second' => array('test_3_2')));
     $this->assertEquals(Object::get_static('ObjectStaticTest_Fourth', 'second', true), array('test_4'));
     $this->assertEquals(Object::get_static('ObjectStaticTest_Third', 'second', true), array('test_3_2', 'test_3'));
     Object::addStaticVars('ObjectStaticTest_Third', array('second' => array('test_3_2')), true);
     $this->assertEquals(Object::get_static('ObjectStaticTest_Third', 'second', true), array('test_3_2'));
     Object::add_static_var('ObjectStaticTest_Third', 'fourth', array('test_3_2'));
     $this->assertEquals(Object::get_static('ObjectStaticTest_Fourth', 'fourth', true), array('test_3_2', 'test_4'));
     Object::add_static_var('ObjectStaticTest_Third', 'fourth', array('test_3_2'), true);
     $this->assertEquals(Object::get_static('ObjectStaticTest_Fourth', 'fourth', true), array('test_4', 'test_3_2'));
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:16,代码来源:ObjectStaticTest.php

示例8: __construct

 public function __construct($controller, $name = null, $sourceClass = null, $fileFieldName = null, $fieldList = null, $detailFormFields = null, $sourceFilter = "", $sourceSort = "Created DESC", $sourceJoin = "")
 {
     if (!class_exists("SWFUploadField")) {
         die("<strong>" . _t('DataObjectManager.ERROR', 'Error') . "</strong>: " . _t('FileDataObjectManager.SWFUPLOAD', 'DataObjectManager requires the SWFUpload module.'));
     }
     parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
     // Intelligent constructor for fileFieldName
     $SNG = singleton($this->sourceClass());
     if ($fileFieldName === null) {
         if ($has_ones = $SNG->stat('has_one')) {
             foreach ($has_ones as $relation => $value) {
                 if (is_subclass_of($value, "File")) {
                     $fileFieldName = $relation;
                     $fileClassName = $value;
                     break;
                 }
             }
         }
     }
     if (isset($_REQUEST['ctf'][$this->Name()])) {
         $this->view = $_REQUEST['ctf'][$this->Name()]['view'];
     }
     if ($this->sourceClass() == "File" || is_subclass_of($this->sourceClass(), "File")) {
         $this->hasDataObject = false;
         $this->fileFieldName = $name;
         $this->fileClassName = $this->sourceClass();
         $this->dataObjectFieldName = null;
     } else {
         $this->dataObjectFieldName = $name;
         $this->fileFieldName = $fileFieldName;
         $this->fileClassName = $SNG->has_one($this->fileFieldName);
         if (!$this->fileClassName) {
             die("<strong>FileDataObjectManager::__construct():</strong>" . _t('FileDataObjectManager.FILERELATION', 'Could not determine file relationship'));
         }
     }
     $this->controllerClassName = $controller->class;
     if ($key = array_search($this->controllerClassName, $SNG->stat('has_one'))) {
         $this->controllerFieldName = $key;
     } else {
         $this->controllerFieldName = $this->controllerClassName;
     }
     $this->controllerID = $controller->ID;
     // Check for allowed file types
     if ($types = Object::get_static($this->fileClassName, 'allowed_file_types')) {
         $this->setAllowedFileTypes($types);
     }
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:47,代码来源:FileDataObjectManager.php

示例9: get_formatter

 /**
  * Factory that returns a RESTFormatter subclass that formats in a particular format based on mimetype or extension
  *
  * @static
  * @param SS_HTTPRequest | string - $request
  * @return RESTFormatter - an instance of a RESTFormatter that can do the job, or null if none can.
  */
 public static function get_formatter($request = null)
 {
     // Request can be an SS_HTTPRequest object
     if ($request instanceof SS_HTTPRequest) {
         // Try and get the mimetype from the request's Accept header
         $mimetypes = $request->getAcceptMimetypes();
         // Alternatively the type might be specified by the client as an extension on the URL
         $extension = $request->getExtension();
     } else {
         $mimetypes = array($request);
         $extension = $request;
     }
     // Filter out empty items and */*
     $mimetypes = array_filter($mimetypes, array(__CLASS__, 'useful_mimetype'));
     // If we didn't get a mimetype _or_ an extension, use the default
     if (!$mimetypes && !$extension) {
         $mimetypes = array(self::$default);
     }
     // Now step through looking for matches on any specified mimetype or exception
     $byMimeType = null;
     $byExtension = null;
     foreach (ClassInfo::subclassesFor(__CLASS__) as $class) {
         if ($class == __CLASS__) {
             continue;
         }
         if ($mimetypes && count(array_intersect($mimetypes, Object::get_static($class, 'mimetypes')))) {
             $byMimeType = $class;
             break;
             // Mimetypes take priority over extensions. If we get a match we're done.
         }
         if ($extension && in_array($extension, Object::get_static($class, 'url_extensions'))) {
             $byExtension = $class;
             if (!$mimetypes) {
                 break;
             }
             // We're only done on a match if we don't have a mimetype to look for.
         }
     }
     // Mime type match gets priority over extension
     if ($byMimeType) {
         return new $byMimeType();
     }
     if ($byExtension) {
         return new $byExtension();
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-restassured,代码行数:53,代码来源:RESTFormatter.php

示例10: add_director_rule_for_controller

 /**
  * Add the appropriate Director rules for the given controller.
  */
 protected static function add_director_rule_for_controller($controllerClass)
 {
     $urlBase = Object::get_static($controllerClass, 'url_base');
     $urlSegment = Object::get_static($controllerClass, 'url_segment');
     $urlRule = Object::get_static($controllerClass, 'url_rule');
     $urlPriority = Object::get_static($controllerClass, 'url_priority');
     if ($urlSegment || $controllerClass == "CMSMain") {
         $link = Controller::join_links($urlBase, $urlSegment) . '/';
         // Make director rule
         if ($urlRule[0] == '/') {
             $urlRule = substr($urlRule, 1);
         }
         $rule = $link . '/' . $urlRule;
         // the / will combine with the / on the end of $link to make a //
         Director::addRules($urlPriority, array($rule => $controllerClass));
     }
 }
开发者ID:rixrix,项目名称:sapphire,代码行数:20,代码来源:CMSMenu.php

示例11: get_parser

 /**
  * Factory that returns a RESTParser subclass that parses data in a particular format based on mimetype or content
  *
  * TODO: This is pretty copy-pasta from RESTFormatter. Maybe consolidate this code with that?
  *
  * @static
  * @param SS_HTTPRequest | string - $request
  * @return RESTParser - an instance of a RESTParser that can do the job, or null if none can.
  */
 public static function get_parser($request = null)
 {
     // Request can be an SS_HTTPRequest object
     if ($request instanceof SS_HTTPRequest) {
         // Try and get the mimetype from the request's Accept header
         $mimetypes = self::get_content_type_mimetypes($request);
         // Alternatively the type might be auto-detected from the request
         $body = $request->getBody();
     } else {
         $mimetypes = array($request);
         $body = '';
     }
     // Filter out empty items and */*
     $mimetypes = array_filter($mimetypes, array(__CLASS__, 'useful_mimetype'));
     // Now step through looking for matches on any specified mimetype or exception
     $byMimeType = null;
     $bySignature = null;
     foreach (ClassInfo::subclassesFor(__CLASS__) as $class) {
         if ($class == __CLASS__) {
             continue;
         }
         if ($mimetypes && count(array_intersect($mimetypes, Object::get_static($class, 'mimetypes')))) {
             $byMimeType = $class;
             break;
             // Mimetypes take priority over extensions. If we get a match we're done.
         }
         if ($body && call_user_func(array($class, 'matches_signature'), $body)) {
             $bySignature = $class;
             if (!$mimetypes) {
                 break;
             }
             // We're only done on a match if we don't have a mimetype to look for.
         }
     }
     // Mime type match gets priority over extension
     if ($byMimeType) {
         return new $byMimeType();
     }
     if ($bySignature) {
         return new $bySignature();
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-restassured,代码行数:51,代码来源:RESTParser.php

示例12: debug

 /**
  * Debug helper method.
  * Can be called from /shoppingcart/debug/
  * @return String
  */
 public function debug()
 {
     $this->calculateOrderAttributes(true);
     $html = "\r\n\t\t\t<h2>" . $this->ClassName . "</h2><ul>";
     $fields = Object::get_static($this->ClassName, "db");
     foreach ($fields as $key => $type) {
         $html .= "<li><b>{$key} ({$type}):</b> " . $this->{$key} . "</li>";
     }
     $fields = Object::get_static($this->ClassName, "casting");
     foreach ($fields as $key => $type) {
         $method = "get" . $key;
         $html .= "<li><b>{$key} ({$type}):</b> " . $this->{$method}() . " </li>";
     }
     $html .= "</ul>";
     return $html;
 }
开发者ID:nieku,项目名称:silverstripe-ecommerce,代码行数:21,代码来源:Order.php

示例13: __construct

 /**
  * Start the MultiForm instance.
  *
  * @param Controller instance $controller Controller this form is created on
  * @param string $name The form name, typically the same as the method name
  */
 public function __construct($controller, $name)
 {
     if (isset($_GET['MultiFormSessionID'])) {
         $this->setCurrentSessionHash($_GET['MultiFormSessionID']);
     }
     // Set up the session for this MultiForm instance
     $this->setSession();
     // Get the current step available (Note: either returns an existing
     // step or creates a new one if none available)
     $currentStep = $this->getCurrentStep();
     // Set the step returned above as the current step
     $this->setCurrentStep($currentStep);
     // Set the form of the step to this form instance
     $currentStep->setForm($this);
     // Set up the fields for the current step
     $fields = $currentStep->getFields();
     // Set up the actions for the current step
     $actions = $this->actionsFor($currentStep);
     // Set up validation (if necessary)
     $validator = null;
     $applyValidation = true;
     // Check if the $_REQUEST action that user clicked is an exempt one
     $actionNames = Object::get_static(get_class($this), 'actions_exempt_from_validation');
     if ($actionNames) {
         foreach ($actionNames as $exemptAction) {
             if (!empty($_REQUEST[$exemptAction])) {
                 $applyValidation = false;
                 break;
             }
         }
     }
     // Apply validation if the current step requires validation (is not exempt)
     if ($applyValidation) {
         if ($currentStep->getValidator()) {
             $validator = $currentStep->getValidator();
         }
     }
     // Give the fields, actions, and validation for the current step back to the parent Form class
     parent::__construct($controller, $name, $fields, $actions, $validator);
     // Set a hidden field in our form with an encrypted hash to identify this session.
     $this->fields->push(new HiddenField('MultiFormSessionID', false, $this->session->Hash));
     // If there is saved data for the current step, we load it into the form it here
     //(CAUTION: loadData() MUST unserialize first!)
     if ($currentStep->loadData()) {
         $this->loadDataFrom($currentStep->loadData());
     }
     // Disable security token - we tie a form to a session ID instead
     $this->disableSecurityToken();
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:55,代码来源:MultiForm.php

示例14: convertDataObjectWithoutHeader

 /**
  * Builds the XML data.
  *
  * SilvercartPaymentMethod relations get treated specially here.
  *
  * @param DataObject $obj       Object to build XML data for
  * @param array      $fields    Fields to build XML data for
  * @param array      $relations Relations to support
  *
  * @return string
  *
  * @author Sebastian Diel <sdiel@pixeltricks.de>
  * @since 23.06.2014
  */
 public function convertDataObjectWithoutHeader(DataObject $obj, $fields = null, $relations = null)
 {
     $className = $obj->class;
     $id = $obj->ID;
     $objHref = Director::absoluteURL(static::$api_base . $obj->class . "/" . $obj->ID);
     if (substr($obj->ClassName, 0, 17) == 'SilvercartPayment') {
         $relClassName = 'SilvercartPaymentMethod';
     } else {
         $relClassName = $obj->ClassName;
     }
     $xml = "<{$relClassName} href=\"{$objHref}.xml\">\n";
     $this->getDataObjectFieldPermissions($obj);
     $fields = array_intersect((array) $this->getCustomAddFields(), (array) $this->getCustomFields());
     foreach ($this->getFieldsForObj($obj) as $fieldName => $fieldType) {
         // Field filtering
         if (SilvercartRestfulServer::isBlackListField($obj->class, $fieldName)) {
             continue;
         }
         if ($fields && !in_array($fieldName, $fields)) {
             continue;
         }
         $fieldValue = $obj->{$fieldName};
         if (!mb_check_encoding($fieldValue, 'utf-8')) {
             $fieldValue = "(data is badly encoded)";
         }
         if (is_object($fieldValue) && is_subclass_of($fieldValue, 'Object') && $fieldValue->hasMethod('toXML')) {
             $xml .= $fieldValue->toXML();
         } else {
             $xml .= "<{$fieldName}>" . Convert::raw2xml($fieldValue) . "</{$fieldName}>\n";
         }
     }
     if ($this->getRelationDepth() > 0) {
         foreach ($obj->has_one() as $relName => $relClass) {
             if ($this->skipRelation($relName, $relClass, $fields)) {
                 continue;
             }
             $fieldName = $relName . 'ID';
             $href = '';
             if ($obj->{$fieldName}) {
                 $relObj = null;
                 if ($this->getRelationDetailDepth() > 0) {
                     $relObj = DataObject::get_by_id($relClass, $obj->{$fieldName});
                 }
                 if ($relObj) {
                     $relationDepth = $this->getRelationDepth();
                     $this->setRelationDepth($relationDepth - 1);
                     $originalCustomAddFields = $this->getCustomAddFields();
                     $customAddFields = Object::get_static($relObj->ClassName, 'custom_add_export_fields');
                     $this->setCustomAddFields((array) $customAddFields);
                     $xml .= $this->convertDataObjectWithoutHeader($relObj, $fields);
                     $this->setCustomAddFields($originalCustomAddFields);
                     $this->setRelationDepth($relationDepth);
                 } else {
                     $href = Director::absoluteURL(static::$api_base . "{$relClass}/" . $obj->{$fieldName});
                 }
             } else {
                 $href = Director::absoluteURL(static::$api_base . "{$className}/{$id}/{$relName}");
             }
             if (!empty($href)) {
                 $xml .= "<{$relName} linktype=\"has_one\" href=\"{$href}.xml\" id=\"" . $obj->{$fieldName} . "\"></{$relName}>\n";
             }
         }
         foreach ($obj->has_many() as $relName => $relClass) {
             if ($this->skipRelation($relName, $relClass, $fields)) {
                 continue;
             }
             $xml .= $this->addMany($relName, $relClass, $objHref, $obj, 'has_many', $fields);
         }
         foreach ($obj->many_many() as $relName => $relClass) {
             if ($this->skipRelation($relName, $relClass, $fields)) {
                 continue;
             }
             $xml .= $this->addMany($relName, $relClass, $objHref, $obj, 'many_many', $fields);
         }
     }
     $xml .= "</{$relClassName}>\n";
     return $xml;
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:92,代码来源:SilvercartRestfulXMLDataFormatter.php

示例15: run

	/**
	 * Perform retroactive DataObject cleaning.
	 * 
	 * @param SS_HTTPRequest $request
	 */
	public function run($request) {
		if (!Object::get_static('SapphireTest', 'is_running_test')) {
			JanitorDebug::set_verbose(true);
		}
		if (JanitorDBP::available()) {
			$this->backupPath = JanitorDBP::backup_database();
		}
		$dataObjectSubClasses = (array)ClassInfo::subclassesFor('DataObject');
		// Remove DataObject
		array_shift($dataObjectSubClasses);
		foreach ($dataObjectSubClasses as $class) {
			$retroactiveCleaner = new DataObjectRetroactiveCleaner($class);
			$retroactiveCleaner->clean();
		}
	}
开发者ID:redema,项目名称:silverstripe-janitor,代码行数:20,代码来源:DataObjectRetroactiveCleanerTask.php


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