本文整理汇总了PHP中DataList::get_data_list方法的典型用法代码示例。如果您正苦于以下问题:PHP DataList::get_data_list方法的具体用法?PHP DataList::get_data_list怎么用?PHP DataList::get_data_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataList
的用法示例。
在下文中一共展示了DataList::get_data_list方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processRecord
protected function processRecord($record, $columnMap, &$results, $preview = false)
{
$class = $this->objectClass;
$title = trim($record['Title']);
$item = trim($record['ListItem']);
$existingList = DataList::get_data_list($title);
if (!$existingList) {
$existingList = new DataList();
$existingList->Title = $title;
$existingList->write();
}
// now add the item to that list
$existingItem = DataObject::get_one('DataListItem', '"Title"=\'' . Convert::raw2sql($item) . '\' AND "ListID" = ' . (int) $existingList->ID);
if (!$existingItem) {
$existingItem = new DataListItem();
$existingItem->Title = $item;
$existingItem->ListID = $existingList->ID;
$existingItem->write();
}
}
示例2: getFormField
function getFormField()
{
$sourceList = $this->getSetting('SourceList') ? $this->getSetting('SourceList') : null;
// first off lets go and output all the options we need
$fields = $this->Parent()->Fields();
$source = null;
foreach ($fields as $field) {
if ($field->Name == $sourceList) {
$source = $field;
break;
}
}
$optionLists = array();
if ($source) {
// all our potential lists come from the source list's data list source, so we need to go load that
// first, then iterate it and build all the additional required lists
$sourceList = DataList::get_data_list($source->getSetting('ListTitle'));
if ($sourceList) {
$items = $sourceList->Items();
// now lets create a bunch of option fields
foreach ($items as $sourceItem) {
// now get the data list that is represented by this one
$list = DataList::get_data_list($sourceItem->Title);
if ($list) {
// add its items to this lists' list of items
$listItems = $list->Items()->map('Title', 'Title');
$optionLists[$sourceItem->Title] = $listItems;
}
}
}
$me = new DropdownField($this->Name, $this->Title, array());
if (count($optionLists)) {
$me = new DependentDropdownField($this->Name, $this->Title, $optionLists, $source->Name);
}
return $me;
}
// return a new list
return new LiteralField($this->Name);
}
示例3: Field
public function Field()
{
$dependScript = '';
// lets find out if we've got an existing selection in our dependon list
if ($this->form) {
$dependent = $this->form->Fields()->dataFieldByName($this->dependentOn);
if ($dependent && $dependent->Value()) {
$dependScript = "showList('" . Convert::raw2js($dependent->Value()) . "', '" . Convert::raw2js($this->value) . "');";
}
}
$dependentName = $this->dependentOn;
if (strpos($dependentName, '.')) {
$dependentName = substr($dependentName, strrpos($dependentName, '.') + 1);
}
$listItems = array();
if (is_string($this->dependentLists)) {
$list = DataList::get_data_list($this->dependentLists);
if ($list) {
$this->dependentLists = $list->Items()->map('Title', 'Title');
}
}
foreach ($this->dependentLists as $listTitle) {
$list = DataList::get_data_list($listTitle);
if ($list) {
$listItems[$listTitle] = $list->Items()->map('Title', 'Title');
}
}
$jsonStruct = Convert::raw2json($listItems);
$jscript = <<<JSCRIPT
(function (\$) {
\t\$().ready(function () {
\t\tvar listOptions = {$jsonStruct};
\t\tvar me = \$('select[name={$this->name}]');
\t\t/**
\t\t * Shows the specified list when needed
\t\t */
\t\tvar showList = function(name, value) {
\t\t\t// need to create all the options
\t\t\tif (listOptions[name]) {
\t\t\t\tfor (var k in listOptions[name]) {
\t\t\t\t\tvar sel = '';
\t\t\t\t\tif (k == value) {
\t\t\t\t\t\tsel = ' selected="selected"';
\t\t\t\t\t}
\t\t\t\t\tme.append('<option val="' + k + '"' + sel + '>' + k + '</option>');
\t\t\t\t}
\t\t\t}
\t\t}
\t\t\$('select[name={$dependentName}]').change(function () {
\t\t\t// when this list changes, make sure to update the contained list items
\t\t\tvar _this = \$(this);
\t\t\tme.empty();
\t\t\tif (_this.val()) {
\t\t\t\tshowList(_this.val());
\t\t\t}
\t\t});
\t\t{$dependScript}
\t});
})(jQuery);
JSCRIPT;
Requirements::customScript($jscript, $this->name . 'dropdown');
return parent::Field();
}