public function page(Request $request, $search_api_page, $keyword = '')
 {
     $build = array();
     /** @var $searchApiPage SearchApiPageInterface */
     $searchApiPage = SearchApiPage::load($search_api_page);
     // Page title.
     $build['#title'] = $searchApiPage->label();
     /** @var $searchApiIndex IndexInterface */
     $searchApiIndex = Index::load($searchApiPage->getIndex());
     // Create the query.
     $query = $searchApiIndex->query(['parse_mode' => 'direct', 'limit' => $searchApiPage->getLimit(), 'offset' => !is_null($request->get('page')) ? $request->get('page') : 0, 'search id' => 'search_api_page:' . $searchApiPage->id()]);
     // Keywords.
     if (!empty($keyword)) {
         $query->keys($keyword);
     }
     // Index fields.
     $query->setFulltextFields(array('rendered_item'));
     $result = $query->execute();
     $items = $result->getResultItems();
     /** @var $item ItemInterface*/
     $results = array();
     foreach ($items as $item) {
         list(, $path, $langcode) = explode(':', $item->getId());
         list($entity_type, $id) = explode('/', $path);
         $entity = $this->entityManager()->getStorage($entity_type)->load($id);
         $results[] = $this->entityManager()->getViewBuilder($entity_type)->view($entity, 'teaser');
     }
     if (!empty($results)) {
         $build['results'] = $results;
         // Build pager.
         pager_default_initialize($result->getResultCount(), $searchApiPage->getLimit());
         $build['pager'] = array('#type' => 'pager');
     }
     return $build;
 }
Exemplo n.º 2
0
 /**
  * Override the execute method.
  *
  * Before we run the query, we need to add pager-based range() instructions
  * to it.
  */
 public function execute()
 {
     // Add convenience tag to mark that this is an extended query. We have to
     // do this in the constructor to ensure that it is set before preExecute()
     // gets called.
     if (!$this->preExecute($this)) {
         return NULL;
     }
     // A NULL limit is the "kill switch" for pager queries.
     if (empty($this->limit)) {
         return;
     }
     $this->ensureElement();
     $total_items = $this->getCountQuery()->execute()->fetchField();
     $current_page = pager_default_initialize($total_items, $this->limit, $this->element);
     $this->range($current_page * $this->limit, $this->limit);
     // Now that we've added our pager-based range instructions, run the query normally.
     return $this->query->execute();
 }
 /**
  * Override the execute method.
  *
  * Before we run the query, we need to add pager-based range() instructions
  * to it.
  */
 public function execute()
 {
     // By calling preExecute() here, we force it to preprocess the extender
     // object rather than just the base query object. That means
     // hook_query_alter() gets access to the extended object.
     if (!$this->preExecute($this)) {
         return NULL;
     }
     // A NULL limit is the "kill switch" for pager queries.
     if (empty($this->limit)) {
         return;
     }
     $this->ensureElement();
     $total_items = $this->getCountQuery()->execute()->fetchField();
     $current_page = pager_default_initialize($total_items, $this->limit, $this->element);
     $this->range($current_page * $this->limit, $this->limit);
     // Now that we've added our pager-based range instructions, run the query normally.
     return $this->query->execute();
 }
Exemplo n.º 4
0
 /**
  * Gets the total number of results and initialize a pager for the query.
  *
  * The pager can be disabled by either setting the pager limit to 0, or by
  * setting this query to be a count query.
  */
 protected function initializePager()
 {
     if ($this->pager && !empty($this->pager['limit']) && !$this->count) {
         $page = pager_find_page($this->pager['element']);
         $count_query = clone $this;
         $this->pager['total'] = $count_query->count()->execute();
         $this->pager['start'] = $page * $this->pager['limit'];
         pager_default_initialize($this->pager['total'], $this->pager['limit'], $this->pager['element']);
         $this->range($this->pager['start'], $this->pager['limit']);
     }
 }
       <?php 
    //print render($page['content']);
    ?>

		<?php 
    if (!empty($_REQUEST['page'])) {
        $perpageStart = $_REQUEST['page'] * 10;
    } else {
        $perpageStart = 0;
    }
    $num_rows = db_query("select count(*) from users where uid  and uid !=1> 0")->fetchField();
    $list = $num_rows;
    $per_page = 10;
    // Initialise the pager
    $current_page = pager_default_initialize($list, $per_page);
    ?>
				 
		
  <div class="row pagenav">
    <div class="col-md-6 col-sm-6" style="padding-top:10px; font-size:20px;">Filter by
      <div class="btn-group" role="group">
        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Newest <span class="caret"></span> </button>
        <ul class="dropdown-menu">
          <li><a href="#">ALL</a></li>
          <li><a href="#">One</a></li>
        </ul>
      </div>
    </div>
    <div class="col-md-6 col-sm-6 text-right" style="padding-top:10px;">
      <nav> <?php 
 public function renderPager($limit, $total, $page = 1, $element = 0)
 {
     pager_default_initialize($total, $limit, $element);
     return theme('pager', ['element' => $element]);
 }
Exemplo n.º 7
0
    ?>
    <?php 
    print theme('abuse_report', array('object' => $report));
    ?>
  <?php 
}
?>
</ul>

<?php 
// hide the controls for the main abuse page on the individual ticket page
if (!preg_match('/^admin\\/abuse\\/status/i', request_path())) {
    ?>
  <div id="abuse-report-list-controls">
    <?php 
    print l(t('Get More Tickets'), request_path());
    ?>
  </div>
<?php 
}
?>

<!--
<?php 
print theme('pager', array(), 10, 0);
$total = count($reports);
pager_default_initialize($total, 1, $element = 0);
print theme('pager', array('quantity' => $total));
?>
-->
 /**
  * Get the build from current search page.
  */
 protected function build()
 {
     pager_default_initialize($this->result->getTotalCount(), $this->resultsPerPage);
     $build = array();
     if ($this->fullPage) {
         $build['results'] = array('#theme' => 'culturefeed_search_page', '#searchresult' => $this->result);
     } else {
         $build['results'] = array('#theme' => 'culturefeed_search_list', '#items' => $this->result, '#nowrapper' => TRUE);
     }
     if ($this->result->getTotalCount() > 0) {
         $build['pager-container'] = array('#type' => 'container', '#attributes' => array());
         if ($this->pagerType == self::PAGER_NORMAL) {
             $build['pager-container']['pager_summary'] = array('#theme' => 'culturefeed_search_pager_summary', '#result' => $this->result, '#start' => ($this->pageNumber - 1) * $this->resultsPerPage);
             $build['pager-container']['pager'] = array('#theme' => 'pager', '#quantity' => 5);
         } elseif ($this->pagerType == self::PAGER_INFINITE_SCROLL) {
             $params = drupal_get_query_parameters();
             $rest = $this->result->getTotalCount() - ($this->pageNumber - 1) * $this->resultsPerPage;
             $params['page'] = $this->pageNumber;
             $build['pager-container'] = array('#type' => 'container', '#attributes' => array('class' => array('more-link infinite-scroll')));
             if ($rest >= 0) {
                 $build['pager-container']['pager'] = array('#type' => 'link', '#title' => t('More results'), '#href' => strpos($_GET['q'], 'nojs') === FALSE ? $_GET['q'] . '/nojs' : $_GET['q'], '#options' => array('query' => $params), '#ajax' => array(), '#attributes' => array('class' => array('btn btn-primary btn-block btn-large'), 'rel' => array('nofollow')));
             }
             if ($rest <= $this->resultsPerPage) {
                 $link = l(t('perform a new search.'), str_replace("/ajax", "", $_GET['q']));
                 $build['pager-container']['pager'] = array('#markup' => '<div class="alert"><p><strong>' . t('There are no more search results.') . '</strong></p>
       <p>' . t('Refine your search results or') . ' ' . $link . '</p></div>');
             }
             if ($this->fullPage) {
                 $build['#prefix'] = '<div id="culturefeed-search-results-more-wrapper">';
                 $build['#suffix'] = '</div>';
             }
         }
     }
     return $build;
 }
         case "payroll":
             print theme('payroll', array('payroll_results' => $value, 'SearchTerm' => $searchTerms[0]));
             break;
         case "contracts":
             print theme('contracts', array('contracts_results' => $value, 'SearchTerm' => $searchTerms[0], 'IsOge' => isset($value["oge_agency_name"])));
             break;
     }
     print "</li>";
 }
 print "</ol>";
 print "<div id='smart-search-transactions'>Showing: " . number_format($startIndex) . " to " . number_format($endIndex) . " of " . number_format($noOfTotalResults) . " entries</div>";
 //Begin of Pagination at the bottom
 if ($noOfTotalResults > 1000000) {
     pager_default_initialize(1000000, $noOfResultsPerPage);
 } else {
     pager_default_initialize($noOfTotalResults, $noOfResultsPerPage);
 }
 $output = theme('pager', array('quantity' => $total));
 if ($output == "") {
     $output = '<div class=" item-list"><ul class="pager">
 <li class="pager-first first"><a href="" title="Go to first page" class="pagerItemDisabled">First</a></li>
 <li class="pager-first previous"><a href="" title="Go to previous page" class="pagerItemDisabled">Previous</a></li>
 <li class="pager-current">1</li>
 <li class="pager-first next"><a href="" title="Go to Next page" class="pagerItemDisabled">Next</a></li>
 <li class="pager-first last"><a href="" title="Go to Last page" class="pagerItemDisabled">Last</a></li>
 </ul></div>';
 }
 print $output;
 //End of Pagination at the bottom
 print "</div>";
 // End of search results
        if (property_exists($biomaterial, 'nid')) {
            $bname = l($bname, 'node/' . $biomaterial->nid, array('attributes' => array('target' => '_blank')));
        }
        if ($biomaterial->taxon_id) {
            if (property_exists($biomaterial->taxon_id, 'nid')) {
                $bgenus = $biomaterial->taxon_id->genus;
                $bspecies = $biomaterial->taxon_id->species;
                $bcommon_name = $biomaterial->taxon_id->common_name;
                $borganism = l($bgenus . ' ' . $bspecies . ' (' . $bcommon_name . ')', 'node/' . $biomaterial->taxon_id->nid, array('attributes' => array('target' => '_blank')));
            } else {
                $bgenus = $biomaterial->taxon_id->nid;
                $bspecies = $biomaterial->taxon_id->species;
                $bcommon_name = $biomaterial->taxon_id->common_name;
                $borganism = $bgenus . ' ' . $bspecies . ' (' . $bcommon_name . ')';
            }
        }
        if ($biomaterial->biosourceprovider_id) {
            if (property_exists($biomaterial->biosourceprovider_id, 'nid')) {
                $bcontact = l($biomaterial->biosourceprovider_id->name, 'node/' . $biomaterial->biosourceprovider_id->nid, array('attributes' => array('target' => '_blank')));
            } else {
                $bcontact = $biomaterial->biosourceprovider_id->name;
            }
        }
        $rows[] = array($bname, $borganism, $bcontact);
    }
    $current_page = pager_default_initialize(count($rows), $num_per_page, 1);
    $chunks = array_chunk($rows, $num_per_page, TRUE);
    $output = theme('table', array('header' => $headers, 'rows' => $chunks[$current_page]));
    $output .= theme('pager', array('quantity' => count($rows), 'element' => $element, 'parameters' => array('block' => 'biomaterial_browser')));
    print $output;
}
Exemplo n.º 11
0
    /**
     * Router callback.
     *
     * @param Request $request
     *   The request.
     * @param string $search_api_page_name
     *   The search api page name.
     * @param string $keys
     *   The search word.
     *
     * @return array $build
     *   The page build.
     */
    public function page(Request $request, $search_api_page_name, $keys = '')
    {
        $build = array();
        /* @var $search_api_page \Drupal\search_api_page\SearchApiPageInterface */
        $search_api_page = SearchApiPage::load($search_api_page_name);
        // Keys can be in the query.
        if (!$search_api_page->getCleanUrl()) {
            $keys = $request->get('keys');
        }
        // Page title.
        $build['#title'] = $search_api_page->label();
        // Show the search form.
        if ($search_api_page->showSearchForm()) {
            $args = array('search_api_page' => $search_api_page->id(), 'keys' => $keys);
            $build['#form'] = $this->formBuilder()->getForm('Drupal\\search_api_page\\Form\\SearchApiPageBlockForm', $args);
        }
        $perform_search = TRUE;
        if (empty($keys) && !$search_api_page->showAllResultsWhenNoSearchIsPerformed()) {
            $perform_search = FALSE;
        }
        if ($perform_search) {
            /* @var $search_api_index \Drupal\search_api\IndexInterface */
            $search_api_index = Index::load($search_api_page->getIndex());
            // Create the query.
            $query = $search_api_index->query(['parse_mode' => 'direct', 'limit' => $search_api_page->getLimit(), 'offset' => !is_null($request->get('page')) ? $request->get('page') : 0, 'search id' => 'search_api_page:' . $search_api_page->id()]);
            // Search for keys.
            if (!empty($keys)) {
                $query->keys($keys);
            }
            // Index fields.
            $query->setFulltextFields($search_api_page->getSearchedFields());
            $result = $query->execute();
            $items = $result->getResultItems();
            /* @var $item \Drupal\search_api\Item\ItemInterface*/
            $results = array();
            foreach ($items as $item) {
                list(, $path, $langcode) = explode(':', $item->getId());
                list($entity_type, $id) = explode('/', $path);
                // Get the entity.
                $entity = $this->entityTypeManager()->getStorage($entity_type)->load($id);
                // Render as view modes.
                if ($search_api_page->renderAsViewModes()) {
                    $key = 'entity:' . $entity_type . '_' . $entity->bundle();
                    $view_mode_configuration = $search_api_page->getViewModeConfiguration();
                    $view_mode = isset($view_mode_configuration[$key]) ? $view_mode_configuration[$key] : 'default';
                    $results[] = $this->entityTypeManager()->getViewBuilder($entity_type)->view($entity, $view_mode);
                }
                // Render as snippets.
                if ($search_api_page->renderAsSnippets()) {
                    $results[] = array('#theme' => 'search_api_page_result', '#item' => $item, '#entity' => $entity);
                }
            }
            if (!empty($results)) {
                $build['#search_title'] = array('#markup' => $this->t('Search results'));
                $build['#no_of_results'] = array('#markup' => $this->formatPlural($result->getResultCount(), '1 result found', '@count results found'));
                $build['#results'] = $results;
                // Build pager.
                pager_default_initialize($result->getResultCount(), $search_api_page->getLimit());
                $build['#pager'] = array('#type' => 'pager');
            } elseif ($perform_search) {
                $build['#no_results_found'] = array('#markup' => $this->t('Your search yielded no results.'));
                $build['#search_help'] = array('#markup' => $this->t('<ul>
<li>Check if your spelling is correct.</li>
<li>Remove quotes around phrases to search for each word individually. <em>bike shed</em> will often show more results than <em>&quot;bike shed&quot;</em>.</li>
<li>Consider loosening your query with <em>OR</em>. <em>bike OR shed</em> will often show more results than <em>bike shed</em>.</li>
</ul>'));
            }
        }
        $build['#theme'] = 'search_api_page';
        // TODO caching dependencies.
        return $build;
    }
        $class = _cmisro_class_for_type($o['type']);
        // Only render links on folders
        //
        // This browser is written to navigate the directory structure.
        // It makes no sense to render a link on a document.
        //
        // However, if this browser is being used as a popup, the user
        // should be able to choose either a folder or a document.
        // We should render buttons on every item.
        $params = '';
        $button = '';
        if (!empty($_GET['popup']) && !empty($_GET['id'])) {
            $params = '&amp;popup=1&amp;id=' . $_GET['id'];
            $button = "\n\t\t\t\t\t<button type=\"button\" onclick=\"CMISRO_BROWSER.handleSelection('{$_GET['id']}', '{$o['id']}');\">\n\t\t\t\t\t\tChoose\n\t\t\t\t\t</button>\n\t\t\t\t\t";
        }
        if ($o['type'] == 'cmis:folder') {
            $title = "<a href=\"{$url}?ref={$o['id']}{$params}\">{$title}</a>";
        }
        echo "\n                <tr><td class=\"cmis_object {$class}\">{$title}</td>\n                    <td>{$button}</td>\n                </tr>\n                ";
    }
}
?>
	</table>
    <?php 
if (!empty($variables['listing']->hasMoreItems)) {
    pager_default_initialize($variables['listing']->numItems, _cmisro_service()->maxItems);
    echo theme('pager');
}
?>
</div>
Exemplo n.º 13
0
function userbase_quiz_get_user_results($variables)
{
    global $language;
    $results = $variables['results'];
    $rows = array();
    // load user # from the URL /user/#/myresults to check required permissions..
    $uid = (int) arg(1);
    $account = user_load($uid);
    watchdog('eqgur', $uid . ' <pre>' . print_r($account, true) . '</pre> <pre>' . print_r($variables, true) . '</pre>');
    while (list($key, $result) = each($results)) {
        $interval = _quiz_format_duration($result['time_end'] - $result['time_start']);
        $passed = $result['score'] >= $result['pass_rate'];
        $grade = $passed ? t('Passed') : t('Failed');
        $passed_class = $passed ? 'quiz-passed' : 'quiz-failed';
        if (!is_numeric($result['score'])) {
            $score = t('In progress');
        } elseif (!$result['is_evaluated']) {
            $score = t('Not evaluated');
        } else {
            if (!empty($result['pass_rate']) && is_numeric($result['score'])) {
                $pre_score = '<span class = "' . $passed_class . '">';
                $post_score = ' %<br><em>' . $grade . '</em></span>';
            } else {
                $post_score = ' %';
            }
            $score = $pre_score . $result['score'] . $post_score;
        }
        // instead of linking to the Quiz and Quiz title, link to the Training for the Quiz?
        $quiz_title = l($result['title'], 'node/' . $result['nid']);
        $required = false;
        if (function_exists('userbase_custom_quiz_training')) {
            $tnode = userbase_custom_quiz_training($result['nid']);
            if ($tnode) {
                if ($tnode->nid > 0) {
                    $tnodetitle = $tnode->title;
                    // check req
                    $required = userbase_custom_check_required($tnode, $uid, $account);
                    // link to Training with title in correct language even?
                    if ($tnode->language != $language->language) {
                        $tlang = new stdClass();
                        $tlang->language = $tnode->language;
                        $quiz_title = l($tnodetitle, 'node/' . $tnode->nid, array('prefix' => $tnode->language . '/', 'language' => $tlang));
                    } else {
                        $quiz_title = l($tnodetitle, 'node/' . $tnode->nid);
                        //, array( 'language' => $tlang ) );
                    }
                }
            }
        }
        $rows[] = array('title' => $quiz_title, 'required' => $required ? t('Yes') : t('No'), 'time_start' => format_date($result['time_start'], 'short'), 'time_end' => $result['time_end'] > 0 ? format_date($result['time_end'], 'short') : t('In Progress'), 'duration' => $result['time_end'] > 0 ? $interval : '', 'score' => $score, 'op' => l(t('View answers'), 'user/quiz/' . $result['result_id'] . '/userresults'));
    }
    if (empty($rows)) {
        return t('No @quiz results found.', array('@quiz' => QUIZ_NAME));
    }
    $header = array(t('Trainings'), t('Required'), t('Started'), t('Finished'), t('Duration'), t('Score'), t('Operation'));
    $per_page = 10;
    // Initialise the pager
    $current_page = pager_default_initialize(count($rows), $per_page);
    // Split your list into page sized chunks
    $chunks = array_chunk($rows, $per_page, TRUE);
    // Show the appropriate items from the list
    $output = theme('table', array('header' => $header, 'rows' => $chunks[$current_page]));
    // Show the pager
    $output .= theme('pager', array('quantity', count($rows)));
    //$output .= '<p><em>' . t('@quizzes that are not evaluated may have a different score and grade once evaluated.', array('@quizzes' => QUIZ_NAME)) . '</em></p>';
    $counts = userbase_custom_user_training_count($uid, false, true);
    //$comp_markup = '<div style="display:none"><pre>'. print_r($counts,true) .'</pre></div>';
    $comp_markup .= '<div class="user-completecount"><div class="completed-required"><h5>' . t('Required Completed') . '</h5>';
    $comp_markup .= '<span class="count">' . $counts['required']['complete'] . '</span>' . ' / ';
    //$comp_markup .= '<progress value="'. $counts['required']['complete'] .'" max="'. $counts['required']['total'] .'"></progress>';
    $comp_markup .= '<span class="count">' . $counts['required']['total'] . '</span></div>';
    $comp_markup .= '<div class="completed-total"><h5>' . t('Total Completed') . '</h5>';
    $comp_markup .= '<span class="count">' . $counts['complete'] . '</span>' . ' / ';
    //$comp_markup .= '<progress value="'. $counts['complete'] .'" max="'. $counts['total'] .'"></progress>';
    $comp_markup .= '<span class="count">' . $counts['total'] . '</span></div></div>';
    $output .= $comp_markup;
    return $output;
}