public function get($class, $name, $default) { if (!isset($this->statics[$class])) { if (isset($this->index[$class])) { $info = $this->index[$class]; if (isset($info['key']) && ($details = $this->cache->load($this->key . '_' . $info['key']))) { $this->statics += $details; } if (!isset($this->statics[$class])) { $this->handleFile(null, $info['path'], null); } } else { $this->statics[$class] = false; } } if (isset($this->statics[$class][$name])) { $static = $this->statics[$class][$name]; if ($static['access'] != T_PRIVATE) { Deprecation::notice('3.2.0', "Config static {$class}::\${$name} must be marked as private", Deprecation::SCOPE_GLOBAL); // Don't warn more than once per static $this->statics[$class][$name]['access'] = T_PRIVATE; } return $static['value']; } return $default; }
/** * @deprecated 3.0 */ public function __construct($items = array()) { Deprecation::notice('3.0', 'Use DataList or ArrayList instead'); if ($items) { if (!is_array($items) || func_num_args() > 1) { $items = func_get_args(); } foreach ($items as $i => $item) { if ($item instanceof ViewableData) { continue; } if (is_object($item) || ArrayLib::is_associative($item)) { $items[$i] = new ArrayData($item); } else { user_error( "DataObjectSet::__construct: Passed item #{$i} is not an" . ' and object or associative array, can\'t be properly' . ' iterated on in templates', E_USER_WARNING ); } } } parent::__construct($items); }
/** * Process upload through UploadField, * creates new record and link newly uploaded file * adds record to GrifField relation list * and return image/file data and record edit form * * @param SS_HTTPRequest $request * @return string json */ public function upload(SS_HTTPRequest $request) { //create record $recordClass = $this->gridField->list->dataClass; $record = Object::create($recordClass); $record->write(); // passes the current gridfield-instance to a call-back method on the new object $record->extend("onBulkUpload", $this->gridField); if ($record->hasMethod('onBulkImageUpload')) { Deprecation::notice('2.0', '"onBulkImageUpload" callback is deprecated, use "onBulkUpload" instead.'); $record->extend("onBulkImageUpload", $this->gridField); } //get uploadField and process upload $uploadField = $this->getUploadField(); $uploadField->setRecord($record); $fileRelationName = $uploadField->getName(); $uploadResponse = $uploadField->upload($request); //get uploaded File response datas $uploadResponse = Convert::json2array($uploadResponse->getBody()); $uploadResponse = array_shift($uploadResponse); // Attach the file to record. $record->{"{$fileRelationName}ID"} = $uploadResponse['id']; $record->write(); // attached record to gridField relation $this->gridField->list->add($record->ID); // JS Template Data $responseData = $this->newRecordJSTemplateData($record, $uploadResponse); $response = new SS_HTTPResponse(Convert::raw2json(array($responseData))); $this->contentTypeNegotiation($response); return $response; }
static function add_to_class($class, $extensionClass, $args = null) { if(method_exists($class, 'extraDBFields')) { $extraStaticsMethod = 'extraDBFields'; } else { $extraStaticsMethod = 'extraStatics'; } $statics = singleton($extensionClass)->$extraStaticsMethod($class, $extensionClass); if ($statics) { Deprecation::notice('3.1.0', "$extraStaticsMethod deprecated. Just define statics on your extension, or use add_to_class"); // TODO: This currently makes extraStatics the MOST IMPORTANT config layer, not the least foreach (self::$extendable_statics as $key => $merge) { if (isset($statics[$key])) { if (!$merge) Config::inst()->remove($class, $key); Config::inst()->update($class, $key, $statics[$key]); } } // TODO - remove this DataObject::$cache_has_own_table[$class] = null; DataObject::$cache_has_own_table_field[$class] = null; } parent::add_to_class($class, $extensionClass, $args); }
public function createTable($table, $fields = null, $indexes = null, $options = null, $advancedOptions = null) { $fieldSchemas = $indexSchemas = ""; if (!empty($options[self::ID])) { $addOptions = $options[self::ID]; } elseif (!empty($options[get_class($this)])) { Deprecation::notice('3.2', 'Use MySQLSchemaManager::ID for referencing mysql-specific table creation options'); $addOptions = $options[get_class($this)]; } elseif (!empty($options[get_parent_class($this)])) { Deprecation::notice('3.2', 'Use MySQLSchemaManager::ID for referencing mysql-specific table creation options'); $addOptions = $options[get_parent_class($this)]; } else { $addOptions = "ENGINE=InnoDB"; } if (!isset($fields['ID'])) { $fields['ID'] = "int(11) not null auto_increment"; } if ($fields) { foreach ($fields as $k => $v) { $fieldSchemas .= "\"{$k}\" {$v},\n"; } } if ($indexes) { foreach ($indexes as $k => $v) { $indexSchemas .= $this->getIndexSqlDefinition($k, $v) . ",\n"; } } // Switch to "CREATE TEMPORARY TABLE" for temporary tables $temporary = empty($options['temporary']) ? "" : "TEMPORARY"; $this->query("CREATE {$temporary} TABLE \"{$table}\" (\n\t\t\t\t{$fieldSchemas}\n\t\t\t\t{$indexSchemas}\n\t\t\t\tprimary key (ID)\n\t\t\t) {$addOptions}"); return $table; }
static function init() { Deprecation::notice('3.1', 'The Profiler class is deprecated, use third party tools like XHProf instead'); if (!self::$inst) { self::$inst = new Profiler(true, true); } }
public function __construct($controller, $name) { $member = Member::currentUser(); $requiredFields = null; if ($member && $member->exists()) { $fields = $member->getMemberFormFields(); $fields->removeByName('Password'); $requiredFields = $member->getValidator(); $requiredFields->addRequiredField('Surname'); } else { $fields = FieldList::create(); } if (get_class($controller) == 'AccountPage_Controller') { $actions = FieldList::create(FormAction::create('submit', _t('MemberForm.SAVE', 'Save Changes'))); } else { $actions = FieldList::create(FormAction::create('submit', _t('MemberForm.SAVE', 'Save Changes')), FormAction::create('proceed', _t('MemberForm.SAVEANDPROCEED', 'Save and proceed to checkout'))); } parent::__construct($controller, $name, $fields, $actions, $requiredFields); $this->extend('updateShopAccountForm'); if ($record = $controller->data()) { $record->extend('updateShopAccountForm', $fields, $actions, $requiredFields); } if ($controller->data() && $controller->data()->hasMethod('updateShopAccountForm')) { // if accessing through the model Deprecation::notice('2.0', 'Please access updateShopAccountForm through ShopAccountForm instead of AccountPage (this extension point is due to be removed)'); } if ($member) { $member->Password = ""; //prevents password field from being populated with encrypted password data $this->loadDataFrom($member); } }
/** * @see TextareaField::__construct() */ public function __construct($name, $title = null, $value = '') { if(count(func_get_args()) > 3) Deprecation::notice('3.0', 'Use setRows() and setCols() instead of constructor arguments'); parent::__construct($name, $title, $value); self::include_js(); }
function __construct($controller, $name, $sourceClass, $fieldList = null, $detailFormFields = null, $sourceFilter = "", $sourceSort = "", $sourceJoin = "") { Deprecation::notice('3.0', 'Use GridField with GridFieldConfig_RelationEditor'); parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin); $classes = array_reverse(ClassInfo::ancestry($this->controllerClass())); foreach($classes as $class) { $singleton = singleton($class); $manyManyRelations = $singleton->uninherited('many_many', true); if(isset($manyManyRelations) && array_key_exists($this->name, $manyManyRelations)) { $this->manyManyParentClass = $class; $manyManyTable = $class . '_' . $this->name; break; } $belongsManyManyRelations = $singleton->uninherited( 'belongs_many_many', true ); if( isset( $belongsManyManyRelations ) && array_key_exists( $this->name, $belongsManyManyRelations ) ) { $this->manyManyParentClass = $class; $manyManyTable = $belongsManyManyRelations[$this->name] . '_' . $this->name; break; } } $tableClasses = ClassInfo::dataClassesFor($this->sourceClass); $source = array_shift($tableClasses); $sourceField = $this->sourceClass; if($this->manyManyParentClass == $sourceField) $sourceField = 'Child'; $parentID = $this->controller->ID; $this->sourceJoin .= " LEFT JOIN \"$manyManyTable\" ON (\"$source\".\"ID\" = \"$manyManyTable\".\"{$sourceField}ID\" AND \"{$this->manyManyParentClass}ID\" = '$parentID')"; $this->joinField = 'Checked'; }
/** * Extend through {@link updateBackLinkTracking()} in your own {@link Extension}. * * @param string|array $filter * @param string $sort * @param string $join * @param string $limit * @return ManyManyList */ public function BackLinkTracking($filter = null, $sort = null, $join = null, $limit = null) { if ($filter !== null || $sort !== null || $join !== null || $limit !== null) { Deprecation::notice('4.0', 'The $filter, $sort, $join and $limit parameters for SiteTreeFileExtension::BackLinkTracking() have been deprecated. Please manipluate the returned list directly.', Deprecation::SCOPE_GLOBAL); } if (class_exists("Subsite")) { $rememberSubsiteFilter = Subsite::$disable_subsite_filter; Subsite::disable_subsite_filter(true); } if ($filter || $sort || $join || $limit) { Deprecation::notice('4.0', 'The $filter, $sort, $join and $limit parameters for SiteTreeFileExtension::BackLinkTracking() have been deprecated. Please manipluate the returned list directly.', Deprecation::SCOPE_GLOBAL); } $links = $this->owner->getManyManyComponents('BackLinkTracking'); if ($this->owner->ID) { $links = $links->where($filter)->sort($sort)->limit($limit); } $this->owner->extend('updateBackLinkTracking', $links); if (class_exists("Subsite")) { Subsite::disable_subsite_filter($rememberSubsiteFilter); } return $links; }
/** * Returns an input field, class="text" and type="text" with an optional * maxlength */ public function __construct($name, $title = null, $value = "") { if (count(func_get_args()) > 3) { Deprecation::notice('3.0', 'Use setMaxLength() instead of constructor arguments', Deprecation::SCOPE_GLOBAL); } parent::__construct($name, $title, $value); }
/** * Constructor * * @deprecated 3.1 Use DataList to aggregate data * * @param string $type The DataObject type we are building an aggregate for * @param string $filter (optional) An SQL filter to apply to the selected rows before calculating the aggregate */ public function __construct($type, $filter = '') { Deprecation::notice('3.1', 'Call aggregate methods on a DataList directly instead. In templates' . ' an example of the new syntax is <% cached List(Member).max(LastEdited) %> instead' . ' (check partial-caching.md documentation for more details.)'); $this->type = $type; $this->filter = $filter; parent::__construct(); }
/** * set_default_quality * * @deprecated 4.0 Use the "ImagickBackend.default_quality" config setting instead * @param int $quality * @return void */ public static function set_default_quality($quality) { Deprecation::notice('4.0', 'Use the "ImagickBackend.default_quality" config setting instead'); if (is_numeric($quality) && (int) $quality >= 0 && (int) $quality <= 100) { Config::inst()->update('ImagickBackend', 'default_quality', (int) $quality); } }
/** * Create a new action button. * @param action The method to call when the button is clicked * @param title The label on the button * @param image The default image to display * @param hoverImage The image to display on hover * @param form The parent form, auto-set when the field is placed inside a form */ function __construct($action, $title = "", $image = "", $hoverImage = null, $className = null, $form = null) { Deprecation::notice('3.0', "Use FormAction with setAttribute('src', 'myimage.png') and custom JavaScript to achieve hover effect"); $this->image = $image; $this->hoverImage = $hoverImage; $this->className = $className; parent::__construct($action, $title, $form); }
public static function getArticlesPerPage() { /* provide warnings of old static configurations */ if (self::$articles_per_page) { Deprecation::notice('3.2.0', 'Use the "NewsPage.articles_per_page" yaml config instead'); } return Config::inst()->get('NewsPage', 'articles_per_page'); }
/** * @inheritdoc * * @param string $name * @param string $title * @param string $value */ public function __construct($name, $title = '', $value = '') { Deprecation::notice('4.0', 'Use custom javascript with a ReadOnlyField'); $this->labelMore = _t('ToggleField.MORE', 'more'); $this->labelLess = _t('ToggleField.LESS', 'less'); $this->startClosed(true); parent::__construct($name, $title, $value); }
/** * @return array */ public function getAllowedIps() { if (!empty($this->allowedIps)) { Deprecation::notice('1.1', 'Use the "IpAccess.allowed_ips" config setting instead'); self::config()->allowed_ips = $this->allowedIps; } return self::$allowed_ips ? self::$allowed_ips : (array) self::config()->allowed_ips; }
/** * Adds the filter, so the dropdown displays only images and folders. * * @return Form */ public function EditFileForm() { Deprecation::notice('3.0', 'Use UploadField', Deprecation::SCOPE_CLASS); $filter = create_function('$item', 'return (in_array("Folder", ClassInfo::ancestry($item->ClassName)) || in_array("Image", ClassInfo::ancestry($item->ClassName)));'); $form = parent::EditFileForm(); $form->Fields()->dataFieldByName('ExistingFile')->setFilterFunction($filter); return $form; }
/** * @return string */ public function InternallyLabelledField() { Deprecation::notice('4.0', 'Please use ->setValue() instead'); if (!$this->value) { $this->value = $this->Title(); } return $this->Field(); }
/** * Socialnav on SSTweaks is removed, in place of the social nav * module */ public function SocialNav() { if (!class_exists("SocialNav")) { Deprecation::notice('3.0', 'SSTweaks.Socialnav is discontinued, please install i-lateral/silverstripe-socialnav instead.'); } else { return SocialNav::create(); } }
function __construct($name, $title = null, $value = null) { Deprecation::notice('3.0', "Use UploadField with \$myField->allowedExtensions = array('jpg', 'gif', 'png')"); if (count(func_get_args()) > 3) { Deprecation::notice('3.0', 'Use setRightTitle() and setFolderName() instead of constructor arguments'); } parent::__construct($name, $title, $value); $this->getValidator()->setAllowedExtensions(array('jpg', 'gif', 'png')); }
public function __construct($name, $title = null, $value = null) { Deprecation::notice('3.0', "SimpleImageField is deprecated. Use UploadField with " . "\$myField->allowedExtensions = array('jpg', 'gif', 'png')", Deprecation::SCOPE_CLASS); if (count(func_get_args()) > 3) { Deprecation::notice('3.0', 'Use setRightTitle() and setFolderName() instead of constructor arguments', Deprecation::SCOPE_GLOBAL); } parent::__construct($name, $title, $value); $this->getValidator()->setAllowedExtensions(array('jpg', 'gif', 'png')); }
public function EmailAddress() { Deprecation::notice('3.0', 'Use "$Email" instead.'); if ($this->Email) { return $this->Email; } elseif ($this->EmailAddress) { return $this->EmailAddress; } return false; }
/** * Construct a SQLMap. * @param SQLQuery $query The query to generate this map. THis isn't executed until it's needed. */ public function __construct(SQLQuery $query, $keyField = "ID", $titleField = "Title") { Deprecation::notice('3.0', 'Use SS_Map or DataList::map() instead.', Deprecation::SCOPE_CLASS); if (!$query) { user_error('SQLMap constructed with null query.', E_USER_ERROR); } $this->query = $query; $this->keyField = $keyField; $this->titleField = $titleField; parent::__construct(); }
/** * Check if we should merge * * @param SS_HTTPRequest $request */ protected function getIsMerge($request) { $merge = $request->getVar('merge'); // Default to false if not given if (!isset($merge)) { Deprecation::notice("4.0", "merge will be enabled by default in 4.0. Please use merge=false if you do not want to merge."); return false; } // merge=0 or merge=false will disable merge return !in_array($merge, array('0', 'false')); }
public static function get_extra_config($class, $extension, $args) { if (method_exists($extension, 'extraDBFields')) { $extraStaticsMethod = 'extraDBFields'; } else { $extraStaticsMethod = 'extraStatics'; } $statics = Injector::inst()->get($extension, true, $args)->{$extraStaticsMethod}($class, $extension); if ($statics) { Deprecation::notice('3.1.0', "{$extraStaticsMethod} deprecated. Just define statics on your extension, or use get_extra_config", Deprecation::SCOPE_GLOBAL); return $statics; } }
/** * Shortcut for handling configuration parameters */ public function __call($name, $arguments) { if (preg_match('/^(?<op>(get)|(set))_(?<arg>.+)$/', $name, $matches)) { $field = $matches['arg']; Deprecation::notice('3.1', "Call DynamicCache::config()->{$field} directly"); if ($matches['op'] === 'set') { return DynamicCache::config()->{$field} = $arguments[0]; } else { return DynamicCache::config()->{$field}; } } return parent::__call($name, $arguments); }
public function __construct($environmentDir = null, $keyDir = null, $dataTransferDir = null, $gitUser = null) { parent::__construct(); // Better to use injector to set these if (func_num_args() == 0) { return; } Deprecation::notice('1.2.0', "Don't construct DNData with parameters. Assign settings via properties instead"); $this->setEnvironmentDir($environmentDir); $this->setKeyDir($keyDir); $this->setDataTransferDir($dataTransferDir); $this->setGitUser($gitUser); }
public function __construct($controller, $name, $sourceClass, $fieldList = null, $detailFormFields = null, $sourceFilter = "", $sourceSort = "", $sourceJoin = "") { parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin); Deprecation::notice('3.0', 'Use GridField with GridFieldConfig_RelationEditor', Deprecation::SCOPE_CLASS); $this->Markable = true; if ($controllerClass = $this->controllerClass()) { $this->joinField = $this->getParentIdName($controllerClass, $this->sourceClass); if (!$this->joinField) { user_error("Can't find a has_one relationship from '{$this->sourceClass}' to '{$controllerClass}'", E_USER_WARNING); } } else { user_error("Can't figure out the data class of {$controller}", E_USER_WARNING); } }
public function getSettingsFields() { $dataTypes = $this->getAvailableTypes(); $reportable = $this->getReportableFields(); $converted = array(); foreach ($reportable as $k => $v) { $converted[$this->dottedFieldToUnique($k)] = $v; } $dataTypes = array_merge(array('' => ''), $dataTypes); $types = new MultiValueDropdownField('DataTypes', _t('AdvancedReport.DATA_TYPES', 'Data types'), $dataTypes); $fieldsGroup = new FieldGroup('Fields', $reportFieldsSelect = new MultiValueDropdownField('ReportFields', _t('AdvancedReport.REPORT_FIELDS', 'Report Fields'), $reportable)); $fieldsGroup->push(new MultiValueTextField('ReportHeaders', _t('AdvancedReport.HEADERS', 'Header labels'))); $fieldsGroup->addExtraClass('reportMultiField'); $reportFieldsSelect->addExtraClass('reportFieldsSelection'); $fieldsGroup->setName('FieldsGroup'); $fieldsGroup->addExtraClass('advanced-report-fields dropdown'); $conditions = new FieldGroup('Conditions', new MultiValueDropdownField('ConditionFields', _t('AdvancedReport.CONDITION_FIELDS', 'Condition Fields'), $reportable), new MultiValueDropdownField('ConditionOps', _t('AdvancedReport.CONDITION_OPERATIONS', 'Op'), $this->config()->allowed_conditions), new MultiValueTextField('ConditionValues', _t('AdvancedReport.CONDITION_VALUES', 'Value'))); $conditions->setName('ConditionsGroup'); $conditions->addExtraClass('dropdown'); // define the group for the sort field $sortGroup = new FieldGroup('Sort', new MultiValueDropdownField('SortBy', _t('AdvancedReport.SORTED_BY', 'Sorted By'), $reportable), new MultiValueDropdownField('SortDir', _t('AdvancedReport.SORT_DIRECTION', 'Sort Direction'), array('ASC' => _t('AdvancedReport.ASC', 'Ascending'), 'DESC' => _t('AdvancedReport.DESC', 'Descending')))); $sortGroup->setName('SortGroup'); $sortGroup->addExtraClass('dropdown'); // build a list of the formatters $formatters = ClassInfo::implementorsOf('ReportFieldFormatter'); $fmtrs = array(); foreach ($formatters as $formatterClass) { $formatter = new $formatterClass(); $fmtrs[$formatterClass] = $formatter->label(); } // define the group for the custom field formatters $fieldFormattingGroup = new FieldGroup(_t('AdvancedReport.FORMAT_FIELDS', 'Custom field formatting'), new MultiValueDropdownField('FieldFormattingField', _t('AdvancedReport.FIELDFORMATTING', 'Field'), $converted), new MultiValueDropdownField('FieldFormattingFormatter', _t('AdvancedReport.FIELDFORMATTINGFORMATTER', 'Formatter'), $fmtrs)); $fieldFormattingGroup->setName('FieldFormattingGroup'); $fieldFormattingGroup->addExtraClass('dropdown'); // assemble the fieldlist $fields = new FieldList(new TextField('Title', _t('AdvancedReport.TITLE', 'Title')), new TextareaField('Description', _t('AdvancedReport.DESCRIPTION', 'Description')), $types, $fieldsGroup, $conditions, new KeyValueField('ReportParams', _t('AdvancedReport.REPORT_PARAMETERS', 'Default report parameters')), $sortGroup, new MultiValueDropdownField('NumericSort', _t('AdvancedReport.SORT_NUMERICALLY', 'Sort these fields numerically'), $reportable), DropdownField::create('PaginateBy')->setTitle(_t('AdvancedReport.PAGINATE_BY', 'Paginate By'))->setSource($reportable)->setHasEmptyDefault(true), TextField::create('PageHeader')->setTitle(_t('AdvancedReport.HEADER_TEXT', 'Header text'))->setDescription(_t('AdvancedReport.USE_NAME_FOR_PAGE_NAME', 'use $name for the page name'))->setValue('$name'), new MultiValueDropdownField('AddInRows', _t('AdvancedReport.ADD_IN_ROWS', 'Add these columns for each row'), $converted), new MultiValueDropdownField('AddCols', _t('AdvancedReport.ADD_IN_ROWS', 'Provide totals for these columns'), $converted), $fieldFormattingGroup, new MultiValueDropdownField('ClearColumns', _t('AdvancedReport.CLEARED_COLS', '"Cleared" columns'), $converted)); if ($this->config()->allow_grouping) { // GroupBy $groupingGroup = new FieldGroup('Grouping', new MultiValueDropdownField('GroupBy', _t('AdvancedReport.GROUPBY_FIELDS', 'Group by fields'), $reportable), new MultiValueDropdownField('SumFields', _t('AdvancedReport.SUM_FIELDS', 'SUM fields'), $reportable)); $groupingGroup->addExtraClass('dropdown'); $fields->insertAfter($groupingGroup, 'ConditionsGroup'); } if ($this->hasMethod('updateReportFields')) { Deprecation::notice('3.0', 'The updateReportFields method is deprecated, instead overload getSettingsFields'); $this->updateReportFields($fields); } $this->extend('updateSettingsFields', $fields); return $fields; }