/** * Run the search itself * * GET /wiziapp/search * * @param string category defines where we are searching (all/author/tag/post) * @param string keyword the search term * * @returns a post list screen for the application */ function wiziapp_do_search() { $category = $_GET['category']; $keyword = $_GET['keyword']; $screen_conf = $GLOBALS['WiziappScreens']->getScreenLayout('posts'); $pageNumber = isset($_GET['wizipage']) ? $_GET['wizipage'] : 0; $resultLimit = WiziappConfig::getInstance()->posts_list_limit; $offset = $resultLimit * $pageNumber; $limitForQuery = $resultLimit * 2; $query = "offset={$offset}&orderby=modified&posts_per_page={$limitForQuery}"; // Do not include the same posts, keep track on the posts we collected. // @todo there is no need to keep track of this for now $GLOBALS['wp_posts_listed'] = array(); $GLOBALS['WiziappLog']->write('info', "Searching for posts for {$category}, and with the chars: {$keyword}", "search.wiziapp_do_search"); // According to the search we need to get the searched posts here: if ($category == 'authors') { $query = "{$query}&author_name={$keyword}"; } elseif ($category == 'posts') { $query = "{$query}&s={$keyword}&post_type=post"; } else { if ($category == 'all') { $query = "{$query}&s={$keyword}&post_type=any"; } } $page = wiziapp_buildPostListPage($query, '', $screen_conf['items'], true); $resultCount = count($page); $pager = new WiziappPagination($resultCount, $resultLimit); /** * We are querying the limit * 2 so we can show the next number of items. * Every query already takes the offset into account, therefore we need to * set the offset as 0 for the extract page part */ $pager->setOffset(0); /** * When returning component lists we must *never* keep the array keys since the * protocol defined the component must be a non-associative array */ $page = $pager->extractCurrentPage($page, FALSE); /** * Leave the check whether we should add the show more component to the pager */ $pager->addMoreCell(__("Load %s more items", 'wiziapp'), $page); // The prepareScreen needs to know where are returning a list screen $screen = wiziapp_prepareScreen($page, __(WiziappConfig::getInstance()->getScreenTitle('search'), 'wiziapp'), 'list'); echo json_encode($screen); }
function wiziapp_buildAboutScreen() { $actions = array(); $pages = get_option('wiziapp_pages'); foreach ($pages['about'] as $aboutPage) { $actions[] = array('imageURL' => 'cuts_reg_gold', 'title' => "{$aboutPage}", 'actionURL' => wiziapp_buildBlogPageLink($aboutPage)); } $app_name = WiziappConfig::getInstance()->app_name; if (strlen($app_name) > 20) { $app_name = wiziapp_makeShortString($app_name, 20); } $page = array('title' => $app_name, 'version' => __('version') . ' ' . WiziappConfig::getInstance()->version, 'imageURL' => WiziappConfig::getInstance()->getAppIcon(), 'aboutTitle' => __('About', 'wiziapp') . ' ' . $app_name, 'aboutContent' => WiziappConfig::getInstance()->getAppDescription(), 'actions' => array()); $screen = wiziapp_prepareScreen($page, __(WiziappConfig::getInstance()->getScreenTitle('about'), 'wiziapp'), 'about'); $screen['screen']['class'] = 'about_screen'; echo json_encode($screen); }