本文整理汇总了PHP中MIME_Type::wildcardMatch方法的典型用法代码示例。如果您正苦于以下问题:PHP MIME_Type::wildcardMatch方法的具体用法?PHP MIME_Type::wildcardMatch怎么用?PHP MIME_Type::wildcardMatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MIME_Type
的用法示例。
在下文中一共展示了MIME_Type::wildcardMatch方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isTrue
/**
* @see File_Archive_Predicate::isTrue()
*/
function isTrue(&$source)
{
$sourceMIME = $source->getMIME();
foreach ($this->mimes as $mime) {
if (MIME_Type::isWildcard($mime)) {
$result = MIME_Type::wildcardMatch($mime, $sourceMIME);
} else {
$result = $mime == $sourceMIME;
}
if ($result !== false) {
return $result;
}
}
return false;
}
示例2: testWildcardMatch
/**
*
*/
public function testWildcardMatch()
{
$this->assertTrue(MIME_Type::wildcardMatch('*/*', 'image/png'));
$this->assertTrue(MIME_Type::wildcardMatch('image/*', 'image/png'));
$this->assertFalse(MIME_Type::wildcardMatch('image/*', 'text/plain'));
}
示例3: dragDataReceived
/**
* Data have been dropped over the widget
* @param GtkWidget The widget on which the data have been dropped
* @param GdkDragContext The context of the drop
* @param int X position
* @param int Y position
* @param int Info parameter (0 in our case)
* @param int The time on which the event happened
*/
function dragDataReceived($widget, $context, $x, $y, $data, $info, $time)
{
$arData = explode("\n", $data->data);
$arAccepted = array();
$arRejected = array();
$bDirectories = false;
foreach ($arData as $strLine) {
$strLine = trim($strLine);
if ($strLine == '') {
continue;
}
$strFile = Gtk_FileDrop::getPathFromUrilistEntry($strLine);
$strFileMime = Gtk_FileDrop::getMimeType($strFile);
$bAccepted = false;
foreach ($this->arTypes as $strType) {
if ($strType == 'inode/directory') {
$bDirectories = true;
}
if ($strType[0] == '.' && Gtk_FileDrop::getFileExtension($strFile) == $strType || $strType == $strFileMime || MIME_Type::wildcardMatch($strType, $strFileMime)) {
$arAccepted[] = $strFile;
$bAccepted = true;
break;
}
}
//foreach type
if (!$bAccepted) {
$arRejected[] = $strFile;
}
}
//foreach line
//make directories from the files if dirs are accepted
//this is done here to give native directories first places on the list
if ($bDirectories && count($arRejected) > 0) {
foreach ($arRejected as $strFile) {
$arAccepted[] = dirname($strFile);
}
}
if (count($arAccepted) == 0) {
//no matching files
return;
}
if ($this->bSetText) {
$strClass = get_class($widget);
switch ($strClass) {
case 'GtkEntry':
case 'GtkLabel':
$widget->set_text($arAccepted[0]);
break;
case 'GtkButton':
case 'GtkToggleButton':
case 'GtkCheckButton':
case 'GtkRadioButton':
$childs = $widget->children();
$child = $childs[0];
if (get_class($child) == 'GtkLabel') {
$child->set_text($arAccepted[0]);
} else {
trigger_error('No label found on widget.');
}
break;
case 'GtkCombo':
$entry = $widget->entry;
$entry->set_text($arAccepted[0]);
break;
case 'GtkFileSelection':
$widget->set_filename($arAccepted[0]);
break;
case 'GtkList':
foreach ($arAccepted as $strFile) {
$items[] =& new GtkListItem($strFile);
}
$widget->append_items($items);
$widget->show_all();
break;
default:
PEAR::raiseError('Widget class "' . $strClass . '" is not supported', GTK_FILEDROP_WIDGET_NOT_SUPPORTED, PEAR_ERROR_TRIGGER, E_USER_WARNING);
break;
}
}
//if bSetText
if ($this->objCallback !== null) {
call_user_func($this->objCallback, $widget, $arAccepted);
}
//objCallback !== null
}
示例4: testWildcardMatchNoWildcard
public function testWildcardMatchNoWildcard()
{
$this->assertFalse(MIME_Type::wildcardMatch('image/foo', 'image/png'));
}