/**
  * @param  array $data
  * @return DrupalTermContentItem
  */
 public static function factory($source, $data)
 {
     $item = new self($source, 'taxonomyterm:' . $data['tid']);
     $item->DrupalID = $data['tid'];
     $item->VocabularyID = $data['vid'];
     $item->TermName = html_entity_decode($data['name']);
     $item->Title = $item->TermName;
     $item->Description = html_entity_decode($data['description']);
     $item->Weight = $data['weight'];
     if (isset($data['language'])) {
         $item->Language = $data['language'];
     }
     if (isset($data['trid'])) {
         $item->TRID = $data['trid'];
     }
     $item->Depth = $data['depth'];
     $parents = new ArrayData(array());
     foreach ($data['parents'] as $key => $value) {
         $parents->setField($key, $value);
     }
     $item->Parents = $parents;
     // Set the name for the tree.
     $item->Name = $item->TermName;
     return $item;
 }
 public function getColumnContent($field, $record, $col)
 {
     if ($record->canView()) {
         $data = new ArrayData(array('Link' => Controller::join_links('CapturedEmailController', 'view', $record->ID)));
         return $data->renderWith('ViewEmailButton');
     }
 }
 /**
  * @param GridField $gridField
  * @param DataObject $record
  * @param string $columnName
  *
  * @return string - the HTML for the column 
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     // No permission checks - handled through GridFieldDetailForm
     // which can make the form readonly if no edit permissions are available.
     $data = new ArrayData(array('Link' => $record->CMSEditLink()));
     return $data->renderWith('GridFieldEditButton');
 }
 protected function loadData($data)
 {
     if (isset($data['link'])) {
         $linkData = $data['link'];
         $this->DrupalMenuLinkID = $linkData['mlid'];
         $this->MenuTitle = html_entity_decode($linkData['title']);
         $this->Description = $linkData['description'];
         $this->Path = $linkData['path'];
         $this->PathAlias = $linkData['path_alias'];
         $this->Href = $linkData['href'];
         $this->Hidden = $linkData['hidden'];
         $this->External = $linkData['external'];
         $this->HasChildren = $linkData['has_children'];
         $this->Weight = $linkData['weight'];
         $this->Depth = $linkData['depth'];
         $options = new ArrayData(array());
         foreach ($linkData['options'] as $key => $value) {
             $options->setField($key, $value);
         }
         $this->Options = $options;
     }
     // Set the name for the tree.
     $this->Name = $this->MenuTitle;
     // Set up this default. It will get overridden by the DrupalNodeContentItem base class.
     $this->Title = $this->MenuTitle;
 }
 public function onAfterInit()
 {
     if ($this->owner instanceof DevelopmentAdmin || $this->owner instanceof DatabaseAdmin || class_exists('DevBuildController') && $this->owner instanceof DevBuildController) {
         return;
     }
     // include the JS snippet into the frontend page markup
     if (GoogleConfig::get_google_config('code')) {
         $snippet = new ArrayData(array('GoogleAnalyticsCode' => GoogleConfig::get_google_config('code'), 'UseGoogleUniversalSnippet' => GoogleConfig::get_google_config('universal')));
         Requirements::customScript($snippet->renderWith('GoogleAnalyticsJSSnippet'));
     }
     // if this request comes from a web crawler, leave a trace
     if (isset($_SERVER['HTTP_USER_AGENT']) && $this->owner instanceof ContentController && $this->owner->data()->ID) {
         foreach (GoogleLogger::$web_crawlers as $name => $signature) {
             if (preg_match('/' . str_replace('/', "\\/", $signature) . '/i', $_SERVER['HTTP_USER_AGENT'])) {
                 $trace = new GoogleLogEvent();
                 $trace->Title = $name;
                 $trace->PageID = $this->owner->data()->ID;
                 $trace->write();
             }
         }
     }
     // include event tracking api if required, jQuery 1.5 is required for automatic data attributes
     if (self::event_tracking_enabled()) {
         Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
         Requirements::javascript('googleanalytics/javascript/googleanalytics.event.tracking.js');
     }
 }
 public function getColumnContent($field, $record, $col)
 {
     if ($record->canView()) {
         $data = new ArrayData(array('Link' => $record->Url));
         return $data->renderWith('HailAttachmentDownloadButton');
     }
 }
 public function getColumnContent($field, $record, $col)
 {
     if ($record->canView()) {
         $data = new ArrayData(array('Link' => singleton('HailModelAdmin')->Link($record->ClassName . '/EditForm/field/' . $record->ClassName . '/item/' . $record->ID)));
         return $data->renderWith('GridFieldViewButton');
     }
 }
 public function getColumnContent($field, $record, $col)
 {
     if ($record->canView()) {
         $data = new ArrayData(array('Link' => 'code-bank-api/export-package?id=' . $record->ID));
         return $data->renderWith('ExportPackageButton');
     }
 }
 public function getColumnContent($field, $record, $col)
 {
     if ($record->canView()) {
         $data = new ArrayData(array('Link' => 'admin/codeBank/show/' . $record->ID));
         return $data->renderWith('GridFieldViewButton');
     }
 }
 /**
  * @param GridField $gridField
  *
  * @return array
  */
 public function getHTMLFragments($gridField)
 {
     Requirements::css(CMC_BULKUPDATER_MODULE_DIR . '/css/CmcGridFieldBulkUpdater.css');
     Requirements::javascript(CMC_BULKUPDATER_MODULE_DIR . '/javascript/CmcGridFieldBulkUpdater.js');
     Requirements::add_i18n_javascript(CMC_BULKUPDATER_MODULE_DIR . '/lang/js');
     //initialize column data
     $cols = new ArrayList();
     $fields = $gridField->getConfig()->getComponentByType('GridFieldEditableColumns')->getDisplayFields($gridField);
     foreach ($gridField->getColumns() as $col) {
         $fieldName = $col;
         $fieldType = '';
         $fieldLabel = '';
         if (isset($fields[$fieldName])) {
             $fieldData = $fields[$fieldName];
             if (isset($fieldData['field'])) {
                 $fieldType = $fieldData['field'];
             }
             if (isset($fieldData['title'])) {
                 $fieldLabel = $fieldData['title'];
             }
         }
         //Debug::show($fieldType);
         if (class_exists($fieldType) && $fieldType != 'ReadonlyField') {
             $field = new $fieldType($fieldName, $fieldLabel);
             if ($fieldType == 'DatetimeField' || $fieldType == 'DateField' || $fieldType == 'TimeField') {
                 $field->setValue(date('Y-m-d H:i:s'));
                 $field->setConfig('showcalendar', true);
             }
             $cols->push(new ArrayData(array('UpdateField' => $field, 'Name' => $fieldName, 'Title' => $fieldLabel)));
         } else {
             $meta = $gridField->getColumnMetadata($col);
             $cols->push(new ArrayData(array('Name' => $col, 'Title' => $meta['title'])));
         }
     }
     $templateData = array();
     if (!count($this->config['actions'])) {
         user_error('Trying to use GridFieldBulkManager without any bulk action.', E_USER_ERROR);
     }
     //set up actions
     $actionsListSource = array();
     $actionsConfig = array();
     foreach ($this->config['actions'] as $action => $actionData) {
         $actionsListSource[$action] = $actionData['label'];
         $actionsConfig[$action] = $actionData['config'];
     }
     reset($this->config['actions']);
     $firstAction = key($this->config['actions']);
     $dropDownActionsList = DropdownField::create('bulkActionName', '')->setSource($actionsListSource)->setAttribute('class', 'bulkActionName no-change-track')->setAttribute('id', '');
     //initialize buttonLabel
     $buttonLabel = _t('CMC_GRIDFIELD_BULK_UPDATER.ACTION1_BTN_LABEL', $this->config['actions'][$firstAction]['label']);
     //add menu if more than one action
     if (count($this->config['actions']) > 1) {
         $templateData = array('Menu' => $dropDownActionsList->FieldHolder());
         $buttonLabel = _t('CMC_GRIDFIELD_BULK_UPDATER.ACTION_BTN_LABEL', 'Go');
     }
     //Debug::show($buttonLabel);
     $templateData = array_merge($templateData, array('Button' => array('Label' => $buttonLabel, 'Icon' => $this->config['actions'][$firstAction]['config']['icon']), 'Select' => array('Label' => _t('CMC_GRIDFIELD_BULK_UPDATER.SELECT_ALL_LABEL', 'Select all')), 'Colspan' => count($gridField->getColumns()) - 1, 'Cols' => $cols));
     $templateData = new ArrayData($templateData);
     return array('header' => $templateData->renderWith('CmcBulkUpdaterButtons'));
 }
	function trackbackping() {
		$error = 0;
		$message = '';
		
		if(!(isset($_POST['url']) && $_POST['url'])) {
			$error = 1;
			$message = 'Missing required POST parameter \'url\'.';
		} else {
			$trackbackping = new TrackBackPing();
			$trackbackping->Url = $_POST['url'];
			if(isset($_POST['title']) && $_POST['title']) {
				$trackbackping->Title = $_POST['title'];
			}
			if(isset($_POST['excerpt']) && $_POST['excerpt']) {
				$trackbackping->Excerpt = $_POST['excerpt'];
			}
			if(isset($_POST['blog_name']) && $_POST['blog_name']) {
				$trackbackping->BlogName = $_POST['blog_name'];
			}
			$trackbackping->PageID = $this->owner->ID;
			$trackbackping->write();
		}
		
		$returnData = new ArrayData(array(
			'Error' => $error,
			'Message' => $message
		));
		
		return $returnData->renderWith('TrackBackPingReturn');
	}
    public function FieldHolder($attributes = array())
    {
        Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
        Requirements::css("registration/css/affiliations.css");
        Requirements::javascript(Director::protocol() . "ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js");
        Requirements::javascript(Director::protocol() . "ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.min.js");
        Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js');
        $js_scripts = array("themes/openstack/javascript/pure.min.js", "themes/openstack/javascript/jquery.serialize.js", "themes/openstack/javascript/jquery.cleanform.js", "themes/openstack/javascript/jquery.ui.datepicker.validation.package-1.0.1/jquery.ui.datepicker.validation.js", "themes/openstack/javascript/jquery.validate.custom.methods.js", 'registration/javascript/affiliations.js');
        foreach ($js_scripts as $js) {
            Requirements::javascript($js);
        }
        $arrayData = new ArrayData(array('Title' => 'Edit Affiliation'));
        $modal = $arrayData->renderWith('AffiliationModalForm');
        $modal = trim(preg_replace('/\\s\\s+/', ' ', $modal));
        $script = <<<JS

        (function( \$ ){

            \$(document).ready(function() {
                \$('{$modal}').appendTo(\$('body'));
                \$("#edit-affiliation-form").affiliations({
                    storage:'{$this->mode}'
                });
            });


        }( jQuery ));
JS;
        Requirements::customScript($script);
        return parent::FieldHolder($attributes);
    }
 /**
  * 
  * @param GridField $gridField
  * @return string - HTML
  */
 public function getHTMLFragments($gridField)
 {
     $searchState = $gridField->State->GridFieldSearchRelation;
     $dataClass = $gridField->getList()->dataClass();
     $forTemplate = new ArrayData(array());
     $forTemplate->Fields = new ArrayList();
     $searchFields = $this->getSearchFields() ? $this->getSearchFields() : $this->scaffoldSearchFields($dataClass);
     $value = $this->findSingleEntry($gridField, $searchFields, $searchState, $dataClass);
     $searchField = new TextField('gridfield_relationsearch', _t('GridField.RelationSearch', "Relation search"), $value);
     // Apparently the data-* needs to be double qouted for the jQuery.meta data plugin
     $searchField->setAttribute('data-search-url', '\'' . Controller::join_links($gridField->Link('search') . '\''));
     $searchField->setAttribute('placeholder', $this->getPlaceholderText($dataClass));
     $searchField->addExtraClass('relation-search no-change-track');
     $findAction = new GridField_FormAction($gridField, 'gridfield_relationfind', _t('GridField.Find', "Find"), 'find', 'find');
     $findAction->setAttribute('data-icon', 'relationfind');
     $addAction = new GridField_FormAction($gridField, 'gridfield_relationadd', _t('GridField.LinkExisting', "Link Existing"), 'addto', 'addto');
     $addAction->setAttribute('data-icon', 'chain--plus');
     // If an object is not found, disable the action
     if (!is_int($gridField->State->GridFieldAddRelation)) {
         $addAction->setReadonly(true);
     }
     $forTemplate->Fields->push($searchField);
     $forTemplate->Fields->push($findAction);
     $forTemplate->Fields->push($addAction);
     return array($this->targetFragment => $forTemplate->renderWith($this->itemClass));
 }
 public function getColumnContent($field, $record, $col)
 {
     if ($record->canView()) {
         $data = new ArrayData(array('Link' => Controller::join_links($field->Link('item'), $record->ID, 'version', $record->Version, 'view')));
         return $data->renderWith('GridFieldViewButton');
     }
 }
 /**
  *
  * @param GridField $gridField
  * @param DataObject $record
  * @param string $columnName
  * @return string - the HTML for the column
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     // No permission checks, handled through GridFieldDetailForm,
     // which can make the form readonly if no edit permissions are available.
     $data = new ArrayData(array('Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'version', $record->Version, 'edit')));
     return $data->renderWith('GridFieldEditButton');
 }
 /**
  *
  * @param GridField $gridField
  * @param DataObject $record
  * @param string $columnName
  * @return string - the HTML for the column 
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     $data = new ArrayData(array('Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'refresh')));
     $templatePath = dirname(dirname(__FILE__)) . '/templates/GridFieldRefreshButton.ss';
     $templatePath = str_replace(BASE_PATH, '', $templatePath);
     return $data->renderWith('../' . $templatePath);
 }
 /**
  * @param  array $data
  * @return DrupalTermContentItem
  */
 public static function factory($source, $data)
 {
     $linkData = $data['link'];
     $item = new self($source, 'menulink:' . $linkData['mlid']);
     $item->DrupalID = $linkData['mlid'];
     $item->Title = html_entity_decode($linkData['title']);
     $item->MenuTitle = $item->Title;
     $item->Description = $linkData['description'];
     $item->Path = $linkData['path'];
     $item->PathAlias = $linkData['path_alias'];
     $item->Href = $linkData['href'];
     $item->Hidden = $linkData['hidden'];
     $item->External = $linkData['external'];
     $item->HasChildren = $linkData['has_children'];
     $item->Weight = $linkData['weight'];
     $item->Depth = $linkData['depth'];
     $options = new ArrayData(array());
     if (isset($linkData['options'])) {
         foreach ($linkData['options'] as $key => $value) {
             $options->setField($key, $value);
         }
     }
     $item->Options = $options;
     // Set the name for the tree.
     $item->Name = $item->MenuTitle;
     // Check if we have to load any node content
     $item->Node = NULL;
     if (strlen($item->Path) > 5 && substr($item->Path, 0, 5) == 'node/') {
         $nodeId = 'node:' . substr($item->Path, 5);
         $item->Node = $source->getObject($source->encodeId($nodeId));
         $item->Title = $item->Node->Title;
     }
     return $item;
 }
 public function getHTMLFragments($gridField)
 {
     $model = Injector::inst()->create($gridField->getModelClass());
     $parent = SiteTree::get()->byId(Controller::curr()->currentPageID());
     if (!$model->canCreate()) {
         return array();
     }
     $children = $this->getAllowedChildren($parent);
     if (count($children) > 1) {
         $pageTypes = DropdownField::create("PageType", "Page Type", $children, $model->defaultChild());
         $pageTypes->setFieldHolderTemplate("GridFieldSiteTreeAddNewButton_holder")->addExtraClass("gridfield-dropdown no-change-track");
         if (!$this->buttonName) {
             $this->buttonName = _t('GridFieldSiteTreeAddNewButton.AddMultipleOptions', 'Add new', "Add button text for multiple options.");
         }
     } else {
         $keys = array_keys($children);
         $pageTypes = HiddenField::create('PageType', 'Page Type', $keys[0]);
         if (!$this->buttonName) {
             $this->buttonName = _t('GridFieldSiteTreeAddNewButton.Add', 'Add new {name}', 'Add button text for a single option.', array($children[$keys[0]]));
         }
     }
     $state = $gridField->State->GridFieldSiteTreeAddNewButton;
     $state->currentPageID = $parent->ID;
     $state->pageType = $parent->defaultChild();
     $addAction = new GridField_FormAction($gridField, 'add', $this->buttonName, 'add', 'add');
     $addAction->setAttribute('data-icon', 'add')->addExtraClass("no-ajax ss-ui-action-constructive dropdown-action");
     $forTemplate = new ArrayData(array());
     $forTemplate->Fields = new ArrayList();
     $forTemplate->Fields->push($pageTypes);
     $forTemplate->Fields->push($addAction);
     Requirements::css(LUMBERJACK_DIR . "/css/lumberjack.css");
     Requirements::javascript(LUMBERJACK_DIR . "/javascript/GridField.js");
     return array($this->targetFragment => $forTemplate->renderWith("GridFieldSiteTreeAddNewButton"));
 }
 /**
  * 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;
 }
예제 #20
0
	public function getHTMLFragments($gridField) {
		$data = new ArrayData(array(
			'NewLink' => Controller::join_links($gridField->Link('item'), 'new'),
		));
		return array(
			$this->targetFragment => $data->renderWith('GridFieldAddNewbutton'),
		);
	}
예제 #21
0
 public function testIncludeTruthyness()
 {
     $data = new ArrayData(array('Title' => 'TruthyTest', 'Items' => new ArrayList(array(new ArrayData(array('Title' => 'Item 1')), new ArrayData(array('Title' => '')), new ArrayData(array('Title' => true)), new ArrayData(array('Title' => false)), new ArrayData(array('Title' => null)), new ArrayData(array('Title' => 0)), new ArrayData(array('Title' => 7))))));
     $result = $data->renderWith('SSViewerTestIncludeScopeInheritanceWithArgs');
     // We should not end up with empty values appearing as empty
     $expected = array('Item 1 _ Item 1 - First-ODD top:Item 1', 'Untitled - EVEN top:', '1 _ 1 - ODD top:1', 'Untitled - EVEN top:', 'Untitled - ODD top:', 'Untitled - EVEN top:0', '7 _ 7 - Last-ODD top:7');
     $this->assertExpectedStrings($result, $expected);
 }
 /**
  * Update $state and $state_id properties.
  *
  * If the $state array does not exist in the session, create it.
  *
  * The current implementation is borrowed directly from
  * GridField_FormAction::getAttributes() 3.2.0-beta2.
  *
  * @param  GridField $grid The subject GridField instance
  * @return array           An associative array of target => fragment
  */
 public function getHTMLFragments($grid)
 {
     $this->updateState($grid);
     $active = $this->state['active'];
     $params = http_build_query(array('StateID' => $this->state_id));
     $data = new ArrayData(array('state' => $active ? 'ui-state-default' : 'ss-ui-alternate ui-state-highlight', 'icon' => Config::inst()->get(__CLASS__, $active ? 'enable_icon' : 'disable_icon'), 'label' => $active ? _t(__CLASS__ . '.DISABLE', 'Disable') : _t(__CLASS__ . '.ENABLE', 'Enable'), 'name' => 'action_gridFieldAlterAction?' . $params, 'url' => $grid->Link()));
     return array($this->target => $data->renderWith(__CLASS__));
 }
 public function getHTMLFragments($gridField)
 {
     $this->gridField = $gridField;
     Requirements::javascript('summit/javascript/GridFieldDeleteAllSummitEntityEventsAction.js');
     Requirements::css('summit/css/GridFieldDeleteAllSummitEntityEventsAction.css');
     $data = new ArrayData(array('Title' => "Delete All Summit Entity Events", 'Link' => Controller::join_links($gridField->Link(), 'deleteAllSummitEntityEventsAction')));
     return array($this->targetFragment => $data->renderWith(__CLASS__));
 }
 /**
  * Get a flash message that is rendered into a template
  *
  * @return String
  */
 public function getFlashMessage()
 {
     if ($message = Session::get('Site.Message')) {
         Session::clear('Site.Message');
         $array = new ArrayData($message);
         return $array->renderWith('FlashMessage');
     }
 }
 /**
  *
  * @param GridField $gridField
  * @param DataObject $record
  * @param string $columnName
  * @return string - the HTML for the column 
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     if (!$record->canEdit()) {
         return;
     }
     $data = new ArrayData(array('Link' => Controller::join_links(Director::baseURL(), '/admin/pages/edit/show/', $record->ID)));
     return $data->renderWith('GridFieldEditButton');
 }
 /**
  *
  * @param GridField $gridField
  * @param DataObject $record
  * @param string $columnName
  * @return string - the HTML for the column 
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     if (!$record->canEdit()) {
         return;
     }
     $data = new ArrayData(array('Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit')));
     return $data->renderWith('GridFieldEditButton');
 }
예제 #27
0
	/**
	 * Test that a template without a <head> tag still renders.
	 */
	function testTemplateWithoutHeadRenders() {
		$data = new ArrayData(array(
			'Var' => 'var value'
		));
		
		$result = $data->renderWith("SSViewerTestPartialTemplate");
		$this->assertEquals('Test partial template: var value', trim(preg_replace("/<!--.*-->/U",'',$result)));
	}
 private static function _convertNode($node)
 {
     $data = new ArrayData(array('Id' => $node['id'], 'Title' => $node['title']));
     if (isset($node['children'])) {
         $data->setField('Children', self::_convertChildren($node['children']));
     }
     return $data;
 }
예제 #29
0
 public function assignteams(SS_HTTPRequest $request)
 {
     $params = $request->params();
     $game_id = $params['ID'];
     $teams = Team::get();
     $data = new ArrayData(array('Form' => $this->assignTeamsForm($game_id), 'ParentLink' => $this->Link()));
     return $data->renderWith(array('AssignTeams', 'Page'));
 }
예제 #30
-1
 public function getHTMLFragments($gridField)
 {
     $fields = new ArrayList();
     $state = $gridField->State->UserFormsGridField;
     $selectedField = $state->filter;
     $selectedValue = $state->value;
     // show dropdown of all the fields available from the submitted form fields
     // that have been saved. Takes the titles from the currently live form.
     $columnField = new DropdownField('FieldNameFilter', '');
     $columnField->setSource($this->columns);
     $columnField->setEmptyString(_t('UserFormsGridFieldFilterHeader.FILTERSUBMISSIONS', 'Filter Submissions..'));
     $columnField->setHasEmptyDefault(true);
     $columnField->setValue($selectedField);
     $valueField = new TextField('FieldValue', '', $selectedValue);
     $columnField->addExtraClass('ss-gridfield-sort');
     $columnField->addExtraClass('no-change-track');
     $valueField->addExtraClass('ss-gridfield-sort');
     $valueField->addExtraClass('no-change-track');
     $valueField->setAttribute('placeholder', _t('UserFormsGridFieldFilterHeader.WHEREVALUEIS', 'where value is..'));
     $fields->push(new FieldGroup(new CompositeField($columnField, $valueField)));
     $fields->push(new FieldGroup(new CompositeField($start = new DateField('StartFilter', 'From'), $end = new DateField('EndFilter', 'Till'))));
     foreach (array($start, $end) as $date) {
         $date->setConfig('showcalendar', true);
         $date->setConfig('dateformat', 'y-mm-dd');
         $date->setConfig('datavalueformat', 'y-mm-dd');
         $date->addExtraClass('no-change-track');
     }
     $end->setValue($state->end);
     $start->setValue($state->start);
     $fields->push($actions = new FieldGroup(GridField_FormAction::create($gridField, 'filter', false, 'filter', null)->addExtraClass('ss-gridfield-button-filter')->setAttribute('title', _t('GridField.Filter', "Filter"))->setAttribute('id', 'action_filter_' . $gridField->getModelClass() . '_' . $columnField), GridField_FormAction::create($gridField, 'reset', false, 'reset', null)->addExtraClass('ss-gridfield-button-close')->setAttribute('title', _t('GridField.ResetFilter', "Reset"))->setAttribute('id', 'action_reset_' . $gridField->getModelClass() . '_' . $columnField)));
     $actions->addExtraClass('filter-buttons');
     $actions->addExtraClass('no-change-track');
     $forTemplate = new ArrayData(array('Fields' => $fields));
     return array('header' => $forTemplate->renderWith('GridFieldFilterHeader_Row'));
 }