html media list
@param  array $data     item: [thumb/title/description/url/id]
@param  array $settings keys: class, li_class
@return string
976221
static public function media_list($data, $settings=null)
    {
        if ($data instanceof \Wslim\Util\Paginator) {
            $paginator = $data->toArray();
            $data = $data->getData();
        }
        
        $settings['class'] = isset($settings['class']) ? 'media-list ' . $settings['class'] : 'media-list list-group';
        $li_class = isset($settings['li_class']) ? "media " . $settings['li_class'] : "media list-group-item";
        $width = isset($settings['width']) ? $settings['width'] : '100px';
        $index = 0;
        $template = <<<INPUT
<li class="%s">
    <div class="media-left">
        <img style="width:%s" src="%s">
    </div>
    <div class="media-body">
        <h5 class="media-heading">%s</h5>
        <div class="content-description">%s</div>
    </div>
    <div class="content-op" style="display:none;">
        <input type="button" class="btn btn-primary btn-sm edit-content" value="编辑">
        <input type="button" class="btn btn-primary btn-sm delete-content" value="删除">
    </div>
</li>
INPUT;
        $noimg_tpl = <<<INPUT
<li class="%s">
    <div class="media-body">
        <h5 class="media-heading">%s</h5>
        <div class="content-description">%s</div>
    </div>
    <div class="content-op" style="display:none;">
        <input type="button" class="btn btn-primary btn-sm edit-content" value="编辑">
        <input type="button" class="btn btn-primary btn-sm delete-content" value="删除">
    </div>
</li>
INPUT;
        if (!isset($settings['fields'])) {
            $settings['fields'] = array('thumb', 'title', 'description', 'url');
        } elseif (is_string($settings['fields'])) {
            $settings['fields'] = explode(',', $settings['fields']);
        }
        $thumb_key = isset($settings['fields'][0]) ? $settings['fields'][0] : 'thumb';
        $title_key = isset($settings['fields'][1]) ? $settings['fields'][1] : 'title';
        $desc_key = isset($settings['fields'][2]) ? $settings['fields'][2] : 'description';
        $url_key = isset($settings['fields'][3]) ? $settings['fields'][3] : 'url';
        
        $str = '<ul class="' . $settings['class'] . '">' . PHP_EOL;
        if (isset($data) && is_array($data)) foreach ($data as $k => $v) {
            $img_src = isset($v[$thumb_key]) ? $v[$thumb_key] : '';
            $img_src && $img_src = Config::getUploadFileUrl($img_src);
            
            $title = isset($v[$title_key]) ? $v[$title_key] : '';
            $description = isset($v[$desc_key]) ? $v[$desc_key] : '';
            $url = isset($v[$url_key]) ? $v[$url_key] : '';
            $id  = isset($v['id']) ? $v['id'] : 0;
            
            if ($img_src) {
                $str .= sprintf($template, $li_class, $width, $img_src, $title, $description);
            } else {
                $str .= sprintf($noimg_tpl, $li_class, $title, $description);
            }
            
            $index += 1;
        }
        $str .= '</ul>' . PHP_EOL;
        
        $str .= '<style>.media.list-group-item {margin-top:0;}</style>' . PHP_EOL;
        
        return $str;
    }
223694
public static function deserialize(array $data)
    {
        return new static(
            new UUID($data['media_object_id']),
            new MIMEType($data['mime_type']),
            new StringLiteral($data['description']),
            new StringLiteral($data['copyright_holder']),
            Url::fromNative($data['source_location']),
            array_key_exists('language', $data) ? new Language($data['language']) : new Language('nl')
        );
    }
14256
protected function createImagesList($media)
    {
        $url = $media->thumbnail_url;
        $width = $media->thumbnail_width;
        $height = $media->thumbnail_height;

        return array(
            array(
                'url'    => $url,
                'width'  => $width,
                'height' => $height,
                'area'   => ($width * $height)
            )
        );
    }
33706
public function getFormName($data)
    {
        $context = $data;

        if ($data instanceof MediaCommonInterface) {
            if ($data instanceof MediaProviderInterface) {
                $context = $data->getMedia()->getContext();
            } else {
                $context = $data->getContext();
            }
        }

        return $this->providerService->getProviderManager($context)->getFormName();
    }
814267
public function create(array $data)
    {
        $playlistItem = new YoutubePlaylistItem();

        $snippet = $data['snippet'];

        $author = new Author();
        $author->setIdentifier($snippet['channelId']);
        $author->setName($snippet['channelTitle']);
        $author->setUsername($snippet['channelTitle']);

        $playlistItem
            ->setIdentifier($data['id'])
            ->setMessage($snippet['title'])
            ->setCreatedAt(new \DateTime($snippet['publishedAt']))
            ->setAuthor($author);

        $media = $this->getBestThumbnailRes($snippet['thumbnails']);
        $media->setLink('https://www.youtube.com/watch?v=' . $snippet['resourceId']['videoId']);

        $playlistItem->addMedia($media);

        return $playlistItem;
    }
1149744
public function write_setting($data) {
        if (!is_array($data)) {
            return ''; // ignore it
        }
        if (!$this->load_choices() or empty($this->choices)) {
            return '';
        }
        unset($data['xxxxx']);
        $result = array();
        foreach ($data as $key => $value) {
            if ($value and array_key_exists($key, $this->choices)) {
                $result[] = $key;
            }
        }
        return $this->config_write($this->name, implode(',', $result)) ? '' : get_string('errorsetting', 'admin');
    }
112692
private static function music($music){
        $data = array();
        list(
            $data['title'],
            $data['description'],
            $data['musicurl'],
            $data['hqmusicurl'],
            $data['thumb_media_id'],
        ) = $music;

        return $data;
    }
826836
public function get_user_list_info($data){

        $url = self::API_URI . self::USER_LIST_INFO_URI;
        $param['access_token'] = $this->access_token;
         
        $user_list_url = $this->create_url($url, $param);

        $postData['user_list'] = $data;
        $postData = json_encode($postData,true);

        $data = $this->http_post($user_list_url, $postData);
         
        return $this->return_data($data);
    }
1229413
public static function saveDataAsHtml($data)
	{
		$html='';
		if(is_array($data))
		{
			foreach($data as $node)
			{
				if(!isset($node['text']))
					continue;

				if(isset($node['expanded']))
					$css=$node['expanded'] ? 'open' : 'closed';
				else
					$css='';

				if(isset($node['hasChildren']) && $node['hasChildren'])
				{
					if($css!=='')
						$css.=' ';
					$css.='hasChildren';
				}

				$options=isset($node['htmlOptions']) ? $node['htmlOptions'] : array();
				if($css!=='')
				{
					if(isset($options['class']))
						$options['class'].=' '.$css;
					else
						$options['class']=$css;
				}

				if(isset($node['id']))
					$options['id']=$node['id'];

				$html.=CHtml::tag('li',$options,$node['text'],false);
				if(!empty($node['children']))
				{
					$html.="\n<ul>\n";
					$html.=self::saveDataAsHtml($node['children']);
					$html.="</ul>\n";
				}
				$html.=CHtml::closeTag('li')."\n";
			}
		}
		return $html;
	}
950957
public function write_setting($data) {
        if(!is_array($data)) {
            return ''; // ignore it
        }

        $result = '';
        foreach ($data as $roleid => $data) {
            if (!$this->config_write('contexts_role'.$roleid, trim($data['contexts']))) {
                $return = get_string('errorsetting', 'admin');
            }
            if (!$this->config_write('memberattribute_role'.$roleid, core_text::strtolower(trim($data['memberattribute'])))) {
                $return = get_string('errorsetting', 'admin');
            }
        }
        return $result;
    }
1017860
static public function formatSettings($settings)
    {
        if (isset($settings) && is_string($settings)) {
            $settings['class'] = $settings;
        }
        
        $settings['style'] = isset($settings['style']) ? $settings['style'] : '';
        if (isset($settings['width'])) {
            $settings['style'] .= ';width:' . $settings['width'] . ';max-width:' . $settings['width'] . ';';
        }
        if (isset($settings['height'])) {
            $settings['style'] .= ';height:' . $settings['height'] . ';';
        }
        $settings['style'] = trim(str_replace(';;', ';', $settings['style']), ';');
        
        return $settings;
    }
1069486
def get_media(self, id, **data):
        
        
        return self.get("/media/{0}/".format(id), data=data)
982843
public function formatToItems(string $data): array
    {
        return array_map(function (array $item) {
            $itemAsArray = [
                'uuid' => [
                    'id' => $item[0],
                    'type' => $item[1],
                ],
                'metadata' => $item[2],
                'indexed_metadata' => $item[3],
                'searchable_metadata' => $item[4],
                'exact_matching_metadata' => $item[5],
                'suggest' => $item[6],
            ];

            if (!empty($item[7])) {
                $itemAsArray['coordinate'] = $item[7];
            }

            return Item::createFromArray($itemAsArray);
        }, json_decode($data, true));
    }
764576
public static function ul($data, $attributes = array())
    {
        if (! is_array($data)) {
            return '';
        }
        $attributes = $attributes + array('id'=>'', 'class'=>'');

        $str="<ul id=\"". $attributes['id'] ."\" class=\"". $attributes['class'] ."\">\n";
        foreach ($data as $k => $v) {
            $str .= "\t<li>";
            $str .= is_array($v) ? $k.self::ul($v) : $v;
            $str .= "</li>\n";
        }
        $str .= "</ul>\n";
        return $str;
    }
305351
public function item($item = [], $options = [])
    {
        $html = '<li style="display: inline; list-style-type: none; padding-right: 20px;">';
        $html .= (key_exists('active', $item) && $item['active'] ? '<b>' : '');
        $html .= $this->Html->link(__($item['title']), $item['url']);
        $html .= (key_exists('active', $item) ? '</b>' : '');
        $html .= '</li>';
        return $html;
    }
613494
public function datalist( $id, $list = [] ) {
		$this->type = 'datalist';

		$attributes['id'] = $id;

		$html = [];

		if ( $this->is_associative_array( $list ) ) {
			foreach ( $list as $value => $display ) {
				$html[] = $this->option( $display, $value, null, [] );
			}
		} else {
			foreach ( $list as $value ) {
				$html[] = $this->option( $value, $value, null, [] );
			}
		}

		$attributes = $this->attributes( $attributes );

		$list = implode( '', $html );

		return $this->to_html_string( "<datalist{$attributes}>{$list}</datalist>" );
	}
57017
public function definitionList(array $data, array $options = []): string
    {
        $options = Hash::merge([
            'class' => 'dl-horizontal',
            'escape' => true,
        ], $options);
        $ret = '<dl class="' . $options['class'] . '">';
        foreach ($data as $key => $value) {
            $ret .= '<dt>' . $key . '</dt>';
            $ret .= '<dd>' . (empty($value) ? '&nbsp;' : ($options['escape'] ? h($value) : $value)) . '</dd>';
        }
        $ret .= '</dl>';

        return $ret;
    }