*************************************************************************
Action buttons + pagination infos
4851
function actionButtons($options = array())
    {
        $default_options = [
                            'buttons_group'           => 'list',
                            'model_id'                => null,
                            'paginate_infos'          => false,
                            'paginate_infos_format'   => '<div>' . ___d('alaxos', 'elements') . ': {{start}} - {{end}} / {{count}}</div><div>' . ___d('alaxos', 'page') . ': {{page}} on {{pages}}</div>',

                            'select_pagination_limit' => false,
                            'pagination_limits'       => [10, 20, 50, 100],
                            'pagination_limits_text'  => 'show {0} elements per page',

                            /*
                             * Groups of buttons to show
                             */
                            'buttons_list'  => [['add']],
                            'buttons_add'   => [['back_to_list']],
                            'buttons_view'  => [['list', 'add'], ['edit', 'copy', 'delete']],
                            'buttons_edit'  => [['list'], ['back_to_view']],
                            'buttons_copy'  => [['list', 'back_to_view']],

                            /*
                             * Buttons properties
                             */
                            'btn_list'           => ['visible' => true, 'link' => ['action' => 'index']],
                            'btn_add'            => ['visible' => true, 'link' => ['action' => 'add']],
                            'btn_view'           => ['visible' => true, 'link' => ['action' => 'view']],
                            'btn_edit'           => ['visible' => true, 'link' => ['action' => 'edit']],
                            'btn_copy'           => ['visible' => true, 'link' => ['action' => 'copy']],
                            'btn_delete'         => ['visible' => true, 'link' => ['action' => 'delete']],
                            'btn_back_to_view'   => ['visible' => true, 'link' => ['action' => 'view']],
                            'btn_back_to_list'   => ['visible' => true, 'link' => ['action' => 'index']],
        ];

        $options = array_merge($default_options, $options);

        $html = [];

        $html[] = '<div class="row">';

        /*
         * Buttons groups
         */
        $html[] = $this->getButtonsGroups($options);

        /*
         * Pagination infos
         */
        if($options['paginate_infos'])
        {
            $html[] = $this->get_paginate_infos($options);
        }

        $html[] = '</div>';

        /*
         * Combobox allowing to select pagination limit
         */
        if($options['select_pagination_limit'])
        {
            $html[] = $this->get_pagination_limit_combobox($options);
        }

        return implode("\n", $html);
    }
92030
private void initButtons() {

        // the buttons for the search form
        bSearchRow = new Button("Search Rows");
        bNewRow    = new Button("Insert New Row");

        bSearchRow.addActionListener(this);
        bNewRow.addActionListener(this);

        pSearchButs = new Panel();

        pSearchButs.setLayout(new GridLayout(1, 0, 4, 4));
        pSearchButs.add(bSearchRow);
        pSearchButs.add(bNewRow);

        // the buttons for editing a row
        bCancel1         = new Button("Cancel");
        bPrev            = new Button("Prev");
        bNext            = new Button("Next");
        bDelete          = new Button("Delete");
        lastButtonDelete = false;
        bNewSearch       = new Button("Search");

        bCancel1.addActionListener(this);
        bPrev.addActionListener(this);
        bNext.addActionListener(this);
        bDelete.addActionListener(this);
        bNewSearch.addActionListener(this);

        pEditButs = new Panel();

        pEditButs.setLayout(new GridLayout(1, 0, 4, 4));
        pEditButs.add(bCancel1);
        pEditButs.add(bPrev);
        pEditButs.add(bNext);
        pEditButs.add(bDelete);
        pEditButs.add(bNewSearch);

        // the buttons for inserting a new row
        pInsertButs = new Panel();

        pInsertButs.setLayout(new GridLayout(1, 0, 4, 4));

        bCancel2    = new Button("Cancel Insert");
        bNewInsert  = new Button("New Insert");
        bNewSearch1 = new Button("Search");

        bCancel2.addActionListener(this);
        bNewInsert.addActionListener(this);
        bNewSearch1.addActionListener(this);
        pInsertButs.add(bCancel2);
        pInsertButs.add(bNewInsert);
        pInsertButs.add(bNewSearch1);
    }
613522
private function appendPaginationLinks()
    {
        if (class_basename($this->models) == 'LengthAwarePaginator') {
            // This set of models was paginated.  Make it append our current view variables.
            $this->models->appends(Input::only(config('gbrock-tables.key_field'),
                config('gbrock-tables.key_direction')));
        }
    }
267338
function (e) {
        YAHOO.util.Event.stopEvent(e);
        this.paginator.setPage(this.paginator.getTotalPages());
    }
497419
function (currentPage) {
			this.writeDebug('paginationSetup',arguments);
			var pagesOutput = '';
			var totalPages;
			var $paginationList = $('.bh-sl-pagination-container .bh-sl-pagination');

			// Total pages
			if ( this.settings.storeLimit === -1 || locationset.length < this.settings.storeLimit ) {
				totalPages = locationset.length / this.settings.locationsPerPage;
			} else {
				totalPages = this.settings.storeLimit / this.settings.locationsPerPage;
			}

			// Current page check
			if (typeof currentPage === 'undefined') {
				currentPage = 0;
			}

			// Initial pagination setup
			if ($paginationList.length === 0) {

				pagesOutput = this._paginationOutput(currentPage, totalPages);
			}
			// Update pagination on page change
			else {
				// Remove the old pagination
				$paginationList.empty();

				// Add the numbers
				pagesOutput = this._paginationOutput(currentPage, totalPages);
			}

			$paginationList.append(pagesOutput);
		}
445722
protected function createPageButtons()
	{
		if (($pageCount = $this->getPageCount()) <= 1)
			return array();

		list ($beginPage, $endPage) = $this->getPageRange();

		$currentPage = $this->getCurrentPage(false); // currentPage is calculated in getPageRange()

		$buttons = array();

		// first page
		if ($this->displayFirstAndLast)
			$buttons[] = $this->createPageButton($this->firstPageLabel, 0, 'first', $currentPage <= 0, false);

		// prev page
		if (($page = $currentPage - 1) < 0)
			$page = 0;

		$buttons[] = $this->createPageButton($this->prevPageLabel, $page, 'previous', $currentPage <= 0, false);

		// internal pages
		for ($i = $beginPage; $i <= $endPage; ++$i)
			$buttons[] = $this->createPageButton($i + 1, $i, '', false, $i == $currentPage);

		// next page
		if (($page = $currentPage+1) >= $pageCount-1)
			$page = $pageCount-1;

		$buttons[] = $this->createPageButton($this->nextPageLabel, $page, 'next', $currentPage >= ($pageCount - 1), false);

		// last page
		if ($this->displayFirstAndLast)
			$buttons[] = $this->createPageButton($this->lastPageLabel, $pageCount - 1, 'last', $currentPage >= ($pageCount - 1), false);

		return $buttons;
	}
1356754
private void setUpActionButtons() {
		// Buttons Panel
		WPanel buttonPanel = new WPanel();
		actionContainer.add(buttonPanel);

		// Edit Button
		final WButton editButton = new WButton("Edit") {
			@Override
			public boolean isVisible() {
				Object key = TableUtil.getCurrentRowKey();
				return !isEditRow(key);
			}
		};
		editButton.setImage("/image/pencil.png");
		editButton.setRenderAsLink(true);
		editButton.setToolTip("Edit");
		editButton.setAction(new Action() {
			@Override
			public void execute(final ActionEvent event) {
				Object key = TableUtil.getCurrentRowKey();
				addEditRow(key);
			}
		});

		// Cancel Button
		final WButton cancelButton = new WButton("Cancel") {
			@Override
			public boolean isVisible() {
				Object key = TableUtil.getCurrentRowKey();
				return isEditRow(key);
			}
		};
		cancelButton.setImage("/image/cancel.png");
		cancelButton.setRenderAsLink(true);
		cancelButton.setToolTip("Cancel");
		cancelButton.setAction(new Action() {
			@Override
			public void execute(final ActionEvent event) {
				Object key = TableUtil.getCurrentRowKey();
				removeEditRow(key);
				firstNameField.reset();
				lastNameField.reset();
				dobField.reset();
			}
		});

		// Delete Button
		WConfirmationButton deleteButton = new WConfirmationButton("Delete") {
			@Override
			public boolean isVisible() {
				Object key = TableUtil.getCurrentRowKey();
				return !isEditRow(key);
			}
		};
		deleteButton.setMessage("Do you want to delete row?");
		deleteButton.setImage("/image/remove.png");
		deleteButton.setRenderAsLink(true);
		deleteButton.setToolTip("Delete");
		deleteButton.setAction(new Action() {
			@Override
			public void execute(final ActionEvent event) {
				Object key = TableUtil.getCurrentRowKey();
				removeEditRow(key);
				PersonBean bean = (PersonBean) actionContainer.getBean();
				List<PersonBean> beans = (List<PersonBean>) table.getBean();
				beans.remove(bean);
				table.handleDataChanged();
				messages.success(bean.getFirstName() + " " + bean.getLastName() + " removed.");
			}
		});

		buttonPanel.add(editButton);
		buttonPanel.add(cancelButton);
		buttonPanel.add(deleteButton);

		// Ajax - edit button
		WAjaxControl editAjax = new WAjaxControl(editButton,
				new AjaxTarget[]{firstNameField, lastNameField,
					dobField, buttonPanel}) {
			@Override
			public boolean isVisible() {
				return editButton.isVisible();
			}

		};
		buttonPanel.add(editAjax);

		// Ajax - cancel button
		WAjaxControl cancelAjax = new WAjaxControl(cancelButton,
				new AjaxTarget[]{firstNameField, lastNameField,
					dobField, buttonPanel}) {
			@Override
			public boolean isVisible() {
				return cancelButton.isVisible();
			}
		};
		buttonPanel.add(cancelAjax);

		buttonPanel.setIdName("buttons");
		editAjax.setIdName("ajax_edit");
		cancelAjax.setIdName("ajax_can");
		editButton.setIdName("edit_btn");
		cancelButton.setIdName("cancel_btn");
		deleteButton.setIdName("delete_btn");
	}
1025936
public function listAction()
    {
        $this->routeParam()->mapPageTo($this->queryService);
        $collection = $this->queryService->findUsedTags();

        return $this->viewModelFactory()->createFor($collection);
    }
12608
public function indexAction()
    {
        $query = (string) $this->params()->fromQuery('query', null);
        $query = strlen($query) > 0 ? $query : null;

        $orderBy = (string) $this->params()->fromQuery('orderBy', null);
        $orderBy = strlen($orderBy) > 0 ? $orderBy : null;

        $sort = (string) $this->params()->fromQuery('sort', null);
        $sort = strlen($sort) > 0 ? $sort : null;

        $page  = (int) $this->params()->fromRoute('page', 1);
        $limit = $this->getOptions()->getDefaultItemsPerPage();

        $entities = $this->getService()->pagination($page, $limit, $query, $orderBy, $sort);

        $view = new ViewModel(array(
            'options'  => $this->getOptions(),
            'entities' => $entities,
            'query'    => $query,
            'orderBy'  => $orderBy,
            'sort'     => $sort,
        ));

        return $view;
    }
1366785
public function actionList() 
	{
		if(Yii::app()->request->isPostRequest) {
			$paging = trim($_POST['paging']);
			$pagesize = trim($_POST['pagesize']);
			
			$criteria=new CDbCriteria;
			$criteria->compare('publish', 1);
			$criteria->order = 'page_id DESC';
			
			if($paging && $paging == 'true') {
				$dataProvider = new CActiveDataProvider('OmmuPages', array(
					'criteria' => $criteria,
					'pagination' => array(
						'pageSize' => $pagesize ? $pagesize : 20,
					),
				));
				$model = $dataProvider->getData();
			} else {
				$criteria->limit = $pagesize ? $pagesize : 5;
				$model = OmmuPages::model()->findAll($criteria);
			}
			
			if(!empty($model)) {
				foreach($model as $key => $item) {
					$page_url = Utility::getProtocol().'://'.Yii::app()->request->serverName.Yii::app()->request->baseUrl;
					$page_path = 'public/page';
					
					if($item->media && file_exists($page_path.'/'.$item->media))
						$image_url_path = $page_url.'/'.$page_path.'/'.$item->media;
					
					$data[] = array(
						'id' => $item->page_id,
						'title' => $item->title->message,
						'description' => $item->desc ? Utility::shortText(Utility::hardDecode($item->description->message),200) : '-',
						'quote' => $item->quote ? $item->quote_r->message : '-',
						'media_image' => $image_url_path ? $image_url_path : '-',
						'media_show' => $item->media_show == 0 ? 'hide' : 'show',
						'media_type' => $item->media_show != 0 ? (($item->media_type == 0 || $item->media_type == 1) ? 'large' : 'medium') : '-',
						'creation_date' => strtotime($item->creation_date),
					);					
				}
			} else
				$data = array();
			
			if($paging && $paging == 'true') {
				$pager = OFunction::getDataProviderPager($dataProvider);
				$get = array_merge($_GET, array($pager['pageVar'] => $pager['nextPage']));
				$nextPager = $pager['nextPage'] != 0 ? OFunction::validHostURL(Yii::app()->controller->createUrl('list', $get)) : '-';
				$return = array(
					'data' => $data,
					'pager' => $pager,
					'nextPager' => $nextPager,
				);
				$this->_sendResponse(200, CJSON::encode($this->renderJson($return)));	
				
			} else
				$this->_sendResponse(200, CJSON::encode($this->renderJson($data)));
			
		} else 
			$this->redirect(Yii::app()->createUrl('site/index'));
	}
463533
public function index() {
        if ($this->overrideAction('index')) {
            return;
        }

        $this->paginate = array_merge(array(
            'limit' => 25,
            'order' => array($this->Model->alias . '.' . $this->Model->displayField => 'ASC'),
            'contain' => array_keys($this->Model->belongsTo)
        ), $this->Model->admin['paginate']);

        $this->AdminToolbar->setBelongsToData($this->Model);

        // Filters
        if (!empty($this->request->params['named'])) {
            $this->paginate['conditions'] = $this->AdminToolbar->parseFilterConditions($this->Model, $this->request->params['named']);
        }

        // Batch delete
        if ($this->request->is('post')) {
            if (!$this->Model->admin['batchProcess']) {
                throw new ForbiddenException(__d('admin', 'Batch Access Protected'));
            }

            $action = $this->request->data[$this->Model->alias]['batch_action'];
            $items = $this->request->data[$this->Model->alias]['items'];
            $processed = array();

            foreach ($items as $id) {
                if (!$id) {
                    continue;
                }

                if ($action === 'delete_item') {
                    if ($this->Model->delete($id, true)) {
                        $processed[] = $id;
                    }
                } else {
                    if (call_user_func(array($this->Model, $action), $id)) {
                        $processed[] = $id;
                    }
                }
            }

            $count = count($processed);

            if ($count > 0) {
                $this->AdminToolbar->logAction(ActionLog::BATCH_DELETE, $this->Model, '', sprintf('Processed IDs: %s', implode(', ', $processed)));
                $this->AdminToolbar->setFlashMessage(__d('admin', '%s %s have been processed', array($count, mb_strtolower($this->Model->pluralName))));

                $this->request->data[$this->Model->alias] = array();
            }
        }

        $this->set('results', $this->paginate($this->Model));
        $this->overrideView('index');
    }
976587
function (id_base) {
        var p     = this.paginator,
            c     = p.get('nextPageLinkClass'),
            label = p.get('nextPageLinkLabel'),
            last  = p.getTotalPages();

        this.link     = document.createElement('a');
        this.span     = document.createElement('span');

        this.link.id        = id_base + '-next-link';
        this.link.href      = '#';
        this.link.className = c;
        this.link.innerHTML = label;
        YAHOO.util.Event.on(this.link,'click',this.onClick,this,true);

        this.span.id        = id_base + '-next-span';
        this.span.className = c;
        this.span.innerHTML = label;

        this.current = p.getCurrentPage() === last ? this.span : this.link;

        return this.current;
    }
303842
function internalAction(scope, page) {

        // Block clicks we try to load the active page
        if (scope.page == page) {
            return;
        }

        // Block if we are forcing disabled 
        if(scope.isDisabled)
        {
            return;
        }

        // Update the page in scope
        scope.page = page;

        // Pass our parameters to the paging action
        scope.pagingAction({
            page: scope.page,
            pageSize: scope.pageSize,
            total: scope.total
        });

        // If allowed scroll up to the top of the page
        if (scope.scrollTop) {
            scrollTo(0, 0);
        }
    }
1197064
function paginate() {
        //Check for valid mysql connection
         
         
        //Find total number of rows
        $all_rs = $this->conn->prepare( $this->sql );
        $all_rs->execute();
         
        if (! $all_rs) {
            if ($this->debug)
                echo "SQL query failed. Check your query.<br /><br />Error Returned: " . mysql_error();
            return false;
        }
        $this->total_rows = $all_rs->rowCount();
         
        //Return FALSE if no rows found
        if ($this->total_rows == 0) {
            if ($this->debug)
                echo "Query returned zero rows.";
            return FALSE;
        }
         
        //Max number of pages
        $this->max_pages = ceil($this->total_rows / $this->rows_per_page );
        if ($this->links_per_page > $this->max_pages) {
            $this->links_per_page = $this->max_pages;
        }
         
        //Check the page value just in case someone is trying to input an aribitrary value
        if ($this->page > $this->max_pages || $this->page <= 0) {
            $this->page = 1;
        }
         
        //Calculate Offset
        $this->offset = $this->rows_per_page * ($this->page - 1);
         
        //Fetch the required result set
        $query = $this->sql . " LIMIT {$this->rows_per_page} OFFSET {$this->offset}";

        $rs = $this->conn->prepare( $query );
        $rs->execute();
         
        if (! $rs) {
            if ($this->debug)
                echo "Pagination query failed. Check your query.<br /><br />Error Returned: " . mysql_error();
            return false;
        }

        return $rs;
    }
716546
function start_html() {
        global $OUTPUT;

        // Render button to allow user to reset table preferences.
        echo $this->render_reset_button();

        // Do we need to print initial bars?
        $this->print_initials_bar();

        // Paging bar
        if ($this->use_pages) {
            $pagingbar = new paging_bar($this->totalrows, $this->currpage, $this->pagesize, $this->baseurl);
            $pagingbar->pagevar = $this->request[TABLE_VAR_PAGE];
            echo $OUTPUT->render($pagingbar);
        }

        if (in_array(TABLE_P_TOP, $this->showdownloadbuttonsat)) {
            echo $this->download_buttons();
        }

        $this->wrap_html_start();
        // Start of main data table

        echo html_writer::start_tag('div', array('class' => 'no-overflow'));
        echo html_writer::start_tag('table', $this->attributes);

    }
860654
public function indexAction()
    {
        $group = $this->currentUser->getGroup();
        if ($group && $this->enableScreens) {
            $browse = $group->getRespondentBrowseScreen();

            if ($browse) {
                if ($browse instanceof ProcessModelInterface) {
                    $browse->processModel($this->getModel());
                }

                // All are arrays, so easy to set
                $this->autofilterParameters = $browse->getAutofilterParameters() + $this->autofilterParameters;
                $this->indexParameters      = $browse->getStartStopParameters() + $this->indexParameters;

                $autoSnippets = $browse->getAutofilterSnippets();
                if (false !== $autoSnippets) {
                    $this->autofilterSnippets = $autoSnippets;
                }
                $startSnippets = $browse->getStartSnippets();
                if (false !== $startSnippets) {
                    $this->indexStartSnippets = $startSnippets;
                }
                $stopSnippets = $browse->getStopSnippets();
                if (false !== $stopSnippets) {
                    $this->indexStopSnippets = $stopSnippets;
                }
            }
        }
        if ($this->currentUser->hasPrivilege('pr.respondent.multiorg') ||
                $this->currentOrganization->canHaveRespondents()) {
            parent::indexAction();
        } else {
            $this->addSnippet('Organization\\ChooseOrganizationSnippet');
        }
    }
17217
private function renderFooter()
    {
        if (!$this->paginator) {
            return "";
        }
        if (count($this->columns) == 0) {
            return "";
        }
        $currentpage = $this->currentpage;

        $content = '<ul class="pagination">';
        $pages = $this->getPageCount();
        if ($pages <= 1)
            return '';

        if ($currentpage - $this->firstButton > $this->maxbuttons) {

            $this->firstButton = $currentpage - $this->maxbuttons;
        }
        if ($currentpage < $this->firstButton) {
            $this->firstButton = $currentpage - 1;
        }

        if ($this->firstButton > 1) {
            $content .= "<li  class=\"page-item\"><a   class=\"page-link\"  href='void(0);' onclick=\"" . $this->getPaginatorLink(1) . "\"><span aria-hidden=\"true\">&laquo;</span></a></li>";
            $content .= "<li class=\"page-item\"><a   class=\"page-link\"  href='void(0);' onclick=\"" . $this->getPaginatorLink($currentpage - 1) . "\"><span aria-hidden=\"true\">&lsaquo;</span></a></li>";
            $content .= "<li  class=\"page-item\"><a   class=\"page-link\" href=\"javascript:void(0);\" >&hellip;</a></li>";
        }



        for ($i = $this->firstButton; $i <= $this->firstButton + $this->maxbuttons; $i++) {
            if ($i > $pages)
                break;
            if ($currentpage == $i) {
                $content .= "<li class=\"page-item active\"><a  class=\"page-link\"  href=\"javascript:void(0);\" > {$i} </a></li>";
            } else {
                $content .= "<li  class=\"page-item\"><a   class=\"page-link\" href=\"javascript:void(0);\"  onclick=\"" . $this->getPaginatorLink($i) . "\"> {$i} </a></li>";
            }
        }

        if ($pages > $this->firstButton + $this->maxbuttons) {
            $content .= "<li  class=\"page-item\" ><a   class=\"page-link\" href=\"javascript:void(0);\" >&hellip;</a></li>";
            $content .= "<li  class=\"page-item\"><a  class=\"page-link\" href='void(0);' onclick=\"" . $this->getPaginatorLink($currentpage + 1) . "\"aria-label=\"Next\">       <span aria-hidden=\"true\">&rsaquo;</span></a></li>";
            $content .= "<li  class=\"page-item\"><a  class=\"page-link\" href='void(0);' onclick=\"" . $this->getPaginatorLink($pages) . "\"aria-label=\"Next\">       <span aria-hidden=\"true\">&raquo;</span></a></li>";
        }
        
        $countall = $this->getAllRowsCount();
        $show =  $currentpage * $this->pagesize;
        if($pages ==$currentpage) $show = $countall;
        if($countall <= $this->pagesize) $show = $countall;
        
        $content = "<table  ><tr><td valign='middle'>{$show} строк с  {$countall} &nbsp;&nbsp;&nbsp;&nbsp;</td><td align='right'> {$content}</td></tr></table>";
        return "<tr ><td class=\"footercell\"  colspan=\"" . count($this->columns) . "\" >{$content}</ul></td></tr>";
    }