本文整理汇总了PHP中Tags::search方法的典型用法代码示例。如果您正苦于以下问题:PHP Tags::search方法的具体用法?PHP Tags::search怎么用?PHP Tags::search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tags
的用法示例。
在下文中一共展示了Tags::search方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSearch
/**
* @covers Instaphp\Instagram\Tags::Search
*/
public function testSearch()
{
$res = $this->object->search('insta', ['count' => 10]);
$this->assertInstanceOf('\\Instaphp\\Instagram\\Response', $res);
$this->assertNotEmpty($res->data);
$this->assertEquals(200, $res->meta['code']);
}
示例2:
<?php
/*
------------------------------------------
------ About the search-tags script ------
------------------------------------------
This script will allow search results to populate in an automatic dropdown list. These results pull from the tags that are available.
*/
// Append a wildcard if the last character isn't whitespace
if (strlen($_POST['search']) > 2 and $_POST['search'] == rtrim($_POST['search'])) {
$_POST['search'] .= "*";
}
// Retrieve a list of tags
$searchResults = Tags::search($_POST['search'], true, 0, 5);
// Prepare the search dropdown
echo '<ul>';
foreach ($searchResults as $result) {
echo '
<li><a class="searchSel" href="/?tag=' . $result['id'] . '" onmousedown="window.location=\'/?tag=' . $result['id'] . '\'">' . $result['title'] . '</a></li>';
}
echo '</ul>';
示例3: __static
/**
* Register plugin hooks
* @static
*/
public static function __static()
{
/*
* These registration functions are here rather than the classes that directly provide
* their data (like Tags for tag_list or Posts for post_list) because putting them in
* their respective classes would require that they be autoloaded on every page load
* so that these functions could register their ajax endpoints.
*/
// Registers an auth_ajax endpoint for tag autocompletion
self::register_auth_ajax('tag_list', function () {
$tags = Tags::search($_GET['q']);
$results = array();
foreach ($tags as $tag) {
$results[] = array('id' => $tag->term_display, 'text' => $tag->term_display);
}
$ar = new AjaxResponse();
$ar->data = array('results' => $results, 'more' => false, 'context' => array());
$ar->out();
});
// Registers an auth_ajax endpoint for post autocompletion
self::register_auth_ajax('post_list', function () {
$posts = Posts::get(array('title_search' => $_GET['q']));
$results = array();
foreach ($posts as $post) {
$results[] = array('id' => $post->id, 'text' => $post->title);
}
$ar = new AjaxResponse();
$ar->data = array('results' => $results, 'more' => false, 'context' => array());
$ar->out();
});
}
示例4: filter_facetvalues
/**
* Plugin hook filter for the values of a faceted search
* @param array $other_values The incoming array of values for this facet
* @param string $facet The selected facet
* @param string $q A string filter for facet values
* @return array The returned list of possible values
*/
public static function filter_facetvalues($other_values, $facet, $q)
{
switch ($facet) {
case 'type':
$values = array_keys(Post::list_active_post_types());
break;
case 'status':
$values = array_keys(Post::list_post_statuses());
break;
case 'tag':
$tags = Tags::search($q);
$values = array();
foreach ($tags as $tag) {
$values[] = $tag->term_display;
}
break;
case 'author':
$values = array();
$users = Users::get(array('criteria' => $q));
foreach ($users as $user) {
$values[] = $user->username;
}
break;
case 'before':
case 'after':
$values = array($q);
break;
}
return array_merge($other_values, $values);
}