本文整理汇总了PHP中Workflow::sortItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Workflow::sortItems方法的具体用法?PHP Workflow::sortItems怎么用?PHP Workflow::sortItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Workflow
的用法示例。
在下文中一共展示了Workflow::sortItems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run($scope, $query)
{
self::$enterprise = 'enterprise' === $scope;
if (' ' !== $query[0]) {
return '';
}
$query = ltrim($query);
self::$query = $query;
self::$parts = $parts = explode(' ', $query);
Workflow::init(self::$enterprise, $query);
if (Workflow::checkUpdate()) {
self::addUpdateCommands();
return Workflow::getItemsAsXml();
}
if (self::$enterprise && !Workflow::getBaseUrl()) {
self::addEnterpriseUrlCommand();
return Workflow::getItemsAsXml();
}
if (!Workflow::getAccessToken() || !(self::$user = Workflow::requestApi('/user'))) {
self::addLoginCommands();
return Workflow::getItemsAsXml();
}
Workflow::stopServer();
$isSystem = isset($query[0]) && $query[0] == '>';
$isMy = 'my' == $parts[0] && isset($parts[1]);
$isUser = isset($query[0]) && $query[0] == '@';
$isRepo = false;
$queryUser = null;
if ($isUser) {
$queryUser = ltrim($parts[0], '@');
} elseif (($pos = strpos($parts[0], '/')) !== false) {
$queryUser = substr($parts[0], 0, $pos);
$isRepo = true;
}
if ($isSystem) {
self::addSystemCommands();
Workflow::sortItems();
} else {
if ($isMy) {
self::addMyCommands();
} elseif ($isUser && isset($parts[1])) {
self::addUserSubCommands($queryUser);
} elseif (!$isUser && $isRepo && isset($parts[1])) {
self::addRepoSubCommands();
} else {
self::addDefaultCommands($isUser, $isRepo, $queryUser);
}
Workflow::sortItems();
if ($query) {
if (!$isUser && $isRepo && isset($parts[1])) {
$repoQuery = substr($query, strlen($parts[0]) + 1);
Workflow::addItem(Item::create()->title("Search '{$parts['0']}' for '{$repoQuery}'")->icon('search')->arg('/' . $parts[0] . '/search?q=' . urlencode($repoQuery))->autocomplete(false), false);
}
$path = $isUser ? $queryUser : 'search?q=' . urlencode($query);
$name = self::$enterprise ? 'GitHub Enterprise' : 'GitHub';
Workflow::addItem(Item::create()->title("Search {$name} for '{$query}'")->icon('search')->arg('/' . $path)->autocomplete(false), false);
}
}
return Workflow::getItemsAsXml();
}
示例2: run
public static function run($query)
{
self::$query = $query;
self::$parts = $parts = explode(' ', $query);
Workflow::init($query);
if (Workflow::checkUpdate()) {
self::addUpdateCommands();
return Workflow::getItemsAsXml();
}
if (!Workflow::getConfig('access_token') || !(self::$user = Workflow::requestGithubApi('/user'))) {
self::addLoginCommands();
return Workflow::getItemsAsXml();
}
Workflow::stopServer();
$isSystem = isset($query[0]) && $query[0] == '>';
$isMy = 'my' == $parts[0] && isset($parts[1]);
$isUser = isset($query[0]) && $query[0] == '@';
$isRepo = false;
$queryUser = null;
if ($isUser) {
$queryUser = ltrim($parts[0], '@');
} elseif (($pos = strpos($parts[0], '/')) !== false) {
$queryUser = substr($parts[0], 0, $pos);
$isRepo = true;
}
if ($isSystem) {
self::addSystemCommands();
Workflow::sortItems();
} else {
if ($isMy) {
self::addMyCommands();
} elseif ($isUser && isset($parts[1])) {
self::addUserSubCommands($queryUser);
} elseif (!$isUser && $isRepo && isset($parts[1])) {
self::addRepoSubCommands();
} else {
self::addDefaultCommands($isUser, $isRepo, $queryUser);
}
Workflow::sortItems();
if ($query) {
if (!$isUser && $isRepo && isset($parts[1])) {
$repoQuery = substr($query, strlen($parts[0]) + 1);
Workflow::addItem(Item::create()->title("Search '{$parts['0']}' for '{$repoQuery}'")->icon('search')->arg('https://github.com/' . $parts[0] . '/search?q=' . urlencode($repoQuery))->autocomplete(false), false);
}
$path = $isUser ? $queryUser : 'search?q=' . urlencode($query);
Workflow::addItem(Item::create()->title("Search GitHub for '{$query}'")->icon('search')->arg('https://github.com/' . $path)->autocomplete(false), false);
}
}
return Workflow::getItemsAsXml();
}
示例3: foreach
}
foreach ($users as $user) {
$name = substr($user->command, 1);
Workflow::addItem(Item::create()->prefix('@', false)->title($name . ' ')->subtitle($user->description)->arg('https://github.com/' . $name)->prio(20 + (isset($user->multiplier) ? $user->multiplier : 1)));
}
}
Workflow::addItem(Item::create()->title('my ')->subtitle('Dashboard, settings, and more')->prio(10)->valid(false));
} else {
$myPages = array('dashboard' => array('', 'View your dashboard'), 'pulls' => array('dashboard/pulls', 'View your pull requests'), 'issues' => array('dashboard/issues', 'View your issues'), 'stars' => array('stars', 'View your starred repositories'), 'profile' => array(Workflow::getConfig('user'), 'View your public user profile'), 'settings' => array('settings', 'View or edit your account settings'), 'notifications' => array('notifications', 'View all your notifications'));
foreach ($myPages as $key => $my) {
Workflow::addItem(Item::create()->title('my ' . $key)->subtitle($my[1])->arg('https://github.com/' . $my[0])->prio(1));
}
}
Workflow::sortItems();
if ($query) {
$path = $isUser ? $queryUser : 'search?q=' . urlencode($query);
Workflow::addItem(Item::create()->title("Search GitHub for '{$query}'")->arg('https://github.com/' . $path)->autocomplete(false), false);
}
} else {
$cmds = array('logout' => 'Log out from GitHub (only this Alfred Workflow)', 'delete cache' => 'Delete GitHub Cache (only for this Alfred Workflow)', 'update' => 'Update this Alfred workflow');
if (Workflow::getConfig('autoupdate', true)) {
$cmds['deactivate autoupdate'] = 'Deactivate auto updating this Alfred Workflow';
} else {
$cmds['activate autoupdate'] = 'Activate auto updating this Alfred Workflow';
}
foreach ($cmds as $cmd => $desc) {
Workflow::addItem(Item::create()->prefix('gh ')->title('> ' . $cmd)->subtitle($desc)->arg('> ' . str_replace(' ', '-', $cmd)));
}
Workflow::sortItems();
}
print Workflow::getItemsAsXml();