예제 #1
0
 function lists()
 {
     require_once 'Pager/Sliding.php';
     if (@$this->input->post('cid')) {
         foreach ($this->input->post('cid') as $v) {
             switch ($this->input->post('task')) {
                 case 'activate':
                     if ($this->campaign->setStatusCampaign($v, 'active')) {
                         $this->notify->set_message('success', $this->getMsg('update_true'));
                     } else {
                         $this->notify->set_message('error', $this->getMsg('update_false'));
                     }
                     break;
                 case 'deactivate':
                     if ($this->campaign->setStatusCampaign($v, 'inactive')) {
                         $this->notify->set_message('success', $this->getMsg('update_true'));
                     } else {
                         $this->notify->set_message('error', $this->getMsg('update_false'));
                     }
                     break;
                 case 'delete':
                     if ($this->campaign->removeCampaign($v)) {
                         $this->notify->set_message('success', $this->getMsg('delete_true'));
                     } else {
                         $this->notify->set_message('error', $this->getMsg('delete_false'));
                     }
                     break;
                 case 'announcewinner':
                     if ($this->campaign->announceWinner($v, '1')) {
                         $this->notify->set_message('success', $this->getMsg('update_true'));
                     } else {
                         $this->notify->set_message('error', $this->getMsg('update_false'));
                     }
                     break;
                 case 'haltwinner':
                     if ($this->campaign->announceWinner($v, '0')) {
                         $this->notify->set_message('success', $this->getMsg('update_true'));
                     } else {
                         $this->notify->set_message('error', $this->getMsg('update_false'));
                     }
                     break;
             }
         }
     } elseif ($this->input->post('task')) {
         $this->notify->set_message('error', 'You haven\'t select any items required for the action.');
     }
     $sql_filter = "";
     //$config['path'] = APP_ADMIN_URL;
     $config['totalItems'] = $this->db->get_var("SELECT COUNT(*) FROM campaign_group " . $sql_filter);
     $config['perPage'] = 50;
     $config['urlVar'] = 'pageID';
     $pageID = $this->input->get('pageID') ? $this->input->get('pageID') : 1;
     $pager = new Pager_Sliding($config);
     $links = $pager->getLinks($pageID);
     list($from, $to) = $pager->getOffsetByPageId();
     $data = $this->campaign->retrieveCampaign(NULL, array('limit_number' => $config['perPage'], 'limit_offset' => --$from));
     $this->load->view('admin/campaign', array('data' => $data, 'pagination' => $links));
 }
예제 #2
0
 /**
  * Generate the pager HTML using the options passed to the constructor.
  *
  * @access  public
  * @return  array
  */
 public function getLinks()
 {
     $links = $this->pager->getLinks();
     $allLinks = $links['all'];
     $allLinks = str_replace('<a', '<li><a', $allLinks);
     $allLinks = str_replace('</a>', '</li></a>', $allLinks);
     if (strlen($allLinks) > 0) {
         $links['all'] = '<ul class="pagination">' . $allLinks . '</ul>';
     } else {
         $links['all'] = null;
     }
     return $links;
 }
예제 #3
0
 /**
  * The pager constructor. Takes a few values, and then assigns a lot of defaults
  * to the PEAR pager class
  * We have embedded some html in this class. Need to figure out how to export this
  * to the top level at some point in time
  *
  * @param array $params
  *
  * @return \CRM_Utils_Pager the newly created and initialized pager object
  */
 public function __construct($params)
 {
     if ($params['status'] === NULL) {
         $params['status'] = ts('Contacts %%StatusMessage%%');
     }
     $this->initialize($params);
     parent::__construct($params);
     list($offset, $limit) = $this->getOffsetAndRowCount();
     $start = $offset + 1;
     $end = $offset + $limit;
     if ($end > $params['total']) {
         $end = $params['total'];
     }
     if ($params['total'] == 0) {
         $statusMessage = '';
     } else {
         $statusMessage = ts('%1 - %2 of %3', array(1 => $start, 2 => $end, 3 => $params['total']));
     }
     $params['status'] = str_replace('%%StatusMessage%%', $statusMessage, $params['status']);
     $this->_response = array('first' => $this->getFirstPageLink(), 'back' => $this->getBackPageLink(), 'next' => $this->getNextPageLink(), 'last' => $this->getLastPageLink(), 'currentPage' => $this->getCurrentPageID(), 'numPages' => $this->numPages(), 'csvString' => CRM_Utils_Array::value('csvString', $params), 'status' => CRM_Utils_Array::value('status', $params), 'buttonTop' => CRM_Utils_Array::value('buttonTop', $params), 'buttonBottom' => CRM_Utils_Array::value('buttonBottom', $params), 'currentLocation' => $this->getCurrentLocation());
     /**
      * A page cannot have two variables with the same form name. Hence in the
      * pager display, we have a form submission at the top with the normal
      * page variable, but a different form element for one at the bottom.
      */
     $this->_response['titleTop'] = ts('Page %1 of %2', array(1 => '<input size="2" maxlength="3" name="' . self::PAGE_ID . '" type="text" value="' . $this->_response['currentPage'] . '" />', 2 => $this->_response['numPages']));
     $this->_response['titleBottom'] = ts('Page %1 of %2', array(1 => '<input size="2" maxlength="3" name="' . self::PAGE_ID_BOTTOM . '" type="text" value="' . $this->_response['currentPage'] . '" />', 2 => $this->_response['numPages']));
 }
예제 #4
0
 function lists()
 {
     require_once 'Pager/Sliding.php';
     if ($this->input->post('cid')) {
         foreach ($this->input->post('cid') as $v) {
             switch ($this->input->post('task')) {
                 case 'delete':
                     if ($this->app->remove($v)) {
                         $this->notify->set_message('success', $this->getMsg('delete_true'));
                     } else {
                         $this->notify->set_message('error', $this->getMsg('delete_false'));
                     }
                     break;
                 case 'dispatch':
                     if ($this->app->dispatch($v)) {
                         $this->notify->set_message('success', $this->getMsg('update_true'));
                     } else {
                         $this->notify->set_message('error', $this->getMsg('update_false'));
                     }
                     break;
             }
         }
     }
     //echo "test";
     $sql_filter = "";
     //$config['path'] = APP_ADMIN_URL;
     $config['totalItems'] = $this->db->get_var("SELECT COUNT(*) FROM campaign_app " . $sql_filter);
     $config['perPage'] = 20;
     $config['urlVar'] = 'pageID';
     $pager = new Pager_Sliding($config);
     $pageID = $this->input->get('pageID') ? $this->input->get('pageID') : 1;
     $links = $pager->getLinks($pageID);
     list($from, $to) = $pager->getOffsetByPageId();
     $data = $this->app->retrieve(NULL, array('limit_number' => $config['perPage'], 'limit_offset' => --$from));
     $this->load->view('admin/app', array('data' => $data, 'pagination' => $links));
 }
예제 #5
0
 function display()
 {
     //		if($this->ArrayHiddenTables[$GLOBALS["table"]]) { $this->addError(TEDeniedAccess); $this->displayHeader(); $this->displayFooter(); exit(); } // Raul 07-Ene-2008 Si la tabla esta considerada oculta, no podrá accesar...
     if (isset($_GET['edit'])) {
         if ($this->getConfig('allowEdit')) {
             $this->handleAddEditCopy($_GET['edit']);
         } else {
             $this->errors[] = TEDeniedAccessEdit;
         }
     } elseif (isset($_GET['idcopy'])) {
         if ($this->getConfig('allowCopy')) {
             $this->handleAddEditCopy($_GET['idcopy']);
         } else {
             $this->errors[] = TEDeniedAccessCopy;
         }
     } elseif (!empty($_GET['add'])) {
         if ($this->getConfig('allowAdd')) {
             return $this->handleAddEditCopy();
         } else {
             $this->errors[] = TEDeniedAccessAdd;
         }
     }
     if (isset($_GET['view'])) {
         if ($this->getConfig('allowView')) {
             $this->handleView($_GET['view']);
         } else {
             $this->errors[] = TEDeniedAccessView;
         }
     }
     if (isset($_GET['delete'])) {
         if ($this->getConfig('allowDelete')) {
             $result = $this->deleteRow($_GET['delete']);
             //exit;
             if ($result || 1 == 1) {
                 $url = new TableEditor_URL();
                 $url->removeQueryString('delete');
                 // header('Location: ' . $url->getURL());     jmm 2/Ago/2005
                 TERedirection($url->getURL());
                 exit;
             }
             $url = new TableEditor_URL();
             $url->removeQueryString('delete');
             $this->errors[] = TEDeleteErrorB;
         } else {
             $this->errors[] = TEDeniedAccess;
         }
     }
     foreach ($this->fields as $field => $v) {
         if (empty($v['noDisplay'])) {
             if (isset($this->fields[$field]['FieldTypeList']["html"])) {
                 $this->addDisplayFilter($field, 'FieldInputHtml');
             } else {
                 //$this->addDisplayFilter($field, 'htmlspecialchars');
                 switch ($this->fields[$field]['input']) {
                     case "date":
                         $this->addDisplayFilter($field, 'TE_formato_fecha');
                         break;
                         // formatea todos los campos fecha
                         //					     case "int": $this->addDisplayFilter($field, 'formato_numero');   break;      // formatea a miles separados por comas
                     // formatea todos los campos fecha
                     //					     case "int": $this->addDisplayFilter($field, 'formato_numero');   break;      // formatea a miles separados por comas
                     case "decimal":
                         $this->addDisplayFilter($field, 'formato_moneda_avanzado');
                         break;
                         // formatea a miles separados por comas
                     // formatea a miles separados por comas
                     default:
                         $this->addDisplayFilter($field, 'htmlspecialchars');
                         break;
                 }
             }
         }
     }
     if (count($this->getConfig('searchableFields')) > 0 and isset($_GET['search']) and $_GET['search'] !== '') {
         $this->search = $_GET['search'];
         $searchStr = $this->dbQuote('%' . $this->search . '%');
         $searchFields = $this->getConfig('searchableFields');
         $searchClause = array();
         foreach ($searchFields as $sf) {
             $this->addDisplayFilter($sf, array(&$this, 'searchDisplayFilter'));
             if (!empty($this->fields[$sf]['values'])) {
                 $in = array();
                 // Inicializo el Arreglo solo una vez...
                 foreach ($this->fields[$sf]['values'] as $k => $v) {
                     if (strpos(strtolower($v), strtolower($this->search)) !== false) {
                         $in[] = $this->dbQuote($k);
                     }
                 }
                 if (!empty($in) && is_array($in)) {
                     $in = implode(', ', $in);
                     $searchClause[] = "{$sf} IN({$in})";
                 }
                 continue;
             }
             $searchClause[] = "{$sf} LIKE {$searchStr}";
         }
         if (!empty($searchClause)) {
             $searchClause = implode(' OR ', $searchClause);
         } else {
             $searchClause = '0';
         }
         $url = new TableEditor_URL();
         $url->removeQueryString('search');
         $clearURL = $url->getURL(true);
     } else {
         $searchClause = '1';
     }
     if (!empty($_GET['orderby']) and preg_match('#^([a-z0-9_]+)(:desc)?$#i', $_GET['orderby'], $matches)) {
         $this->orderby = array('field' => $matches[1], 'direction' => (int) empty($matches[2]));
     }
     $orderbyClause = "ORDER BY {$this->orderby['field']}" . (!$this->orderby['direction'] ? '' : ' DESC');
     if (count(explode('orderby', $_SERVER['QUERY_STRING'])) > 2) {
         $url = new TableEditor_URL();
         /*header('Location: ' . $url->getURL());      2/Ago/2005*/
         TERedirection($url->getURL());
         exit;
     }
     if (!empty($this->dataFilters)) {
         $filters = implode(' AND ', $this->dataFilters);
     } else {
         $filters = 1;
     }
     list($tables, $joinClause) = $this->getQueryTables();
     $total = $this->dbGetOne("SELECT COUNT(*) FROM {$tables} WHERE {$joinClause} AND {$filters} AND ({$searchClause})");
     $perPage = $this->config['perPage'];
     $pager = new Pager_Sliding(array('totalItems' => $total, 'delta' => 5, 'prevImg' => '<img src="' . TEImagesPath . 'PagesArrowPrev.gif"  width="6" height="7" border="0" />', 'nextImg' => '<img src="' . TEImagesPath . 'PagesArrowNext.gif"  width="6" height="7" border="0" />', 'firstPageText' => '<img src="' . TEImagesPath . 'PagesArrowFirst.gif" width="9" height="7" border="0" />', 'lastPageText' => '<img src="' . TEImagesPath . 'PagesArrowLast.gif"  width="9" height="7" border="0" />', 'spacesBeforeSeparator' => '1', 'spacesAfterSeparator' => '1', 'curPageLinkClassName' => 'avgbold', 'perPage' => $perPage));
     list($startOffset, $endOffset) = $pager->getOffsetByPageId();
     $startOffset--;
     // Eww - For SQL query
     list($back, $pages, $next) = $pager->getLinks();
     foreach ($this->fields as $field => $f) {
         if (empty($f['noDisplay'])) {
             $fields[] = $field;
         }
     }
     $fields = implode(', ', $fields);
     $results = $this->dbGetAll($s = "SELECT {$fields} FROM {$tables} WHERE {$joinClause} AND {$filters} AND ({$searchClause}) {$orderbyClause} LIMIT {$startOffset},{$perPage}");
     //echo "SELECT $fields FROM $tables WHERE $joinClause AND $filters AND ($searchClause) $orderbyClause LIMIT $startOffset,$perPage";
     if ($results === false) {
         $this->errors[] = TEErrorDatabase . ' ' . $this->dbError() . "<br>" . $s;
     }
     if (!empty($results)) {
         foreach ($results as $k => $row) {
             $this->parseResults($results[$k]);
         }
         unset($row);
         $nonFilteredData = $results;
         foreach ($results as $k => $row) {
             $this->applyDisplayFilters($results[$k]);
         }
         unset($row);
     }
     if (!$_GET["edit"]) {
         include '' . TEFunctionsPath . 'ClassTableEditorList.php';
     }
     $this->displayFooter();
     exit;
 }
예제 #6
0
 public function gallery()
 {
     require_once 'Pager/Sliding.php';
     if (!($active_campaign = $this->campaign->getActiveCampaign())) {
         show_404();
     }
     $sr = $this->facebook->getSignedRequest();
     $redirect_url = isset($sr['page']) ? $this->config->item('APP_FANPAGE') . "&app_data=redirect|" . current_url() : "http://apps.facebook.com/" . $this->config->item('APP_APPLICATION_ID') . "/gallery";
     if (!($user = getAuthorizedUser(true))) {
         redirect(mobile_menu_url('authorize') . '?ref=' . $redirect_url);
     }
     $userMedia = $this->media->mediaByUID($user['id'], $active_campaign['GID'], 'active');
     $randMedia = $this->media->mediaByRandom($active_campaign['GID'], 'active');
     $sql_filter = "WHERE campaign_media.media_status = 'active' AND campaign_media.GID = " . $active_campaign['GID'];
     $sumPerCampaign = $this->ezsql_mysql->get_var("SELECT COUNT(*) FROM campaign_media " . $sql_filter);
     $orderby = 'campaign_media.media_id';
     $order = 'DESC';
     if ($byorder = $this->input->get_post('orderby', TRUE)) {
         switch ($byorder) {
             case "mostvote":
                 $orderby = "campaign_media.media_vote_total";
                 $order = "DESC";
                 break;
             case "latest":
                 $orderby = 'campaign_media.media_id';
                 $order = 'DESC';
                 break;
         }
     }
     //$config['path'] = APP_ADMIN_URL;
     $config['totalItems'] = $sumPerCampaign;
     $config['perPage'] = 2;
     $config['urlVar'] = ($this->input->post('orderby') ? 'orderby=' . $this->input->post('orderby') . '&' : '') . 'pageID';
     $pager = new Pager_Sliding($config);
     $pageID = $this->input->get_post('pageID') ? $this->input->get_post('pageID') : 1;
     $links = $pager->getLinks($pageID);
     list($from, $to) = $pager->getOffsetByPageId();
     $rowsMedia = $this->media->retrieveMedia(array('campaign_media.media_status' => 'active', 'campaign_media.GID' => $active_campaign['GID']), array('orderby' => $orderby, 'order' => $order, 'limit_number' => $config['perPage'], 'limit_offset' => --$from));
     $this->load->view('mobile/mobile_gallery', array('campaign' => $active_campaign, 'media' => $rowsMedia, 'user_media' => $userMedia ? $userMedia : null, 'random_media' => $randMedia ? $randMedia : null, 'pagination' => $links));
 }
예제 #7
0
    /**
     * Displays the page
     */
    function display()
    {
        /**
         * Call a different function if we're editing/copying/adding a row.
         */
        if (isset($_GET['edit'])) {
            if ($this->getConfig('allowEdit')) {
                $this->handleAddEditCopy($_GET['edit']);
            } else {
                $this->errors[] = 'Editing rows is not permitted';
            }
        } else {
            if (isset($_GET['copy'])) {
                if ($this->getConfig('allowCopy')) {
                    $this->handleAddEditCopy($_GET['copy']);
                } else {
                    $this->errors[] = 'Copying rows is not permitted';
                }
            } else {
                if (!empty($_GET['add'])) {
                    if ($this->getConfig('allowAdd')) {
                        return $this->handleAddEditCopy();
                    } else {
                        $this->errors[] = 'Adding rows is not permitted';
                    }
                }
            }
        }
        /**
         * Also call a different function if we're viewing a row
         */
        if (isset($_GET['view'])) {
            if ($this->getConfig('allowView')) {
                $this->handleView($_GET['view']);
            } else {
                $this->errors[] = 'Viewing rows is not permitted';
            }
        }
        /**
         * Handle a delete if necessary. Has to be here to allow the object
         * to be setup in the calling script (eg. custom values).
         */
        if (isset($_GET['delete'])) {
            if ($this->getConfig('allowDelete')) {
                $result = $this->deleteRow($_GET['delete']);
                if ($result) {
                    $url = new TableEditor_URL();
                    $url->removeQueryString('delete');
                    header('Location: ' . $url->getURL());
                    exit;
                }
                $this->errors[] = 'Failed to delete row!';
            } else {
                $this->errors[] = 'Deleting rows is not permitted';
            }
        }
        /**
         * Handle displaying the advanced search page
         */
        if ($this->getConfig('allowASearch') and !empty($_GET['asearch']) and $_GET['asearch'] == '1') {
            $this->displayAdvancedSearchPage();
        } else {
            if ($this->getConfig('allowASearch') and !empty($_GET['asearch']) and $_GET['asearch'] == '2' and !empty($_GET['fields'])) {
                $searchClause = $this->handleAdvancedSearch();
                // Get URL for clear link
                $url = new TableEditor_URL();
                $url->addRawQueryString('');
                $clearURL = $url->getURL(true);
                // Get URL for modify link
                $url = new TableEditor_URL();
                $url->addQueryString('asearch', '1');
                $modifyURL = $url->getURL(true);
            }
        }
        /**
         * Add htmlspecialchars() display filter. Has to be before search to prevent
         * search term highlighting being munged.
         */
        foreach ($this->fields as $field => $v) {
            if (empty($v['noDisplay'])) {
                #    $this->addDisplayFilter($field, 'htmlspecialchars');
            }
        }
        /**
         * Handle searching
         */
        if (count($this->getConfig('searchableFields')) > 0 and isset($_GET['search']) and $_GET['search'] !== '') {
            $this->search = $_GET['search'];
            $searchStr = $this->dbQuote('%' . $this->search . '%');
            $searchFields = $this->getConfig('searchableFields');
            $searchClause = array();
            foreach ($searchFields as $sf) {
                $this->addDisplayFilter($sf, array(&$this, 'searchDisplayFilter'));
                // Handle fields which have predefined value sets
                if (!empty($this->fields[$sf]['values'])) {
                    foreach ($this->fields[$sf]['values'] as $k => $v) {
                        if (strpos(strtolower($v), strtolower($this->search)) !== false) {
                            $in[] = $this->dbQuote($k);
                        }
                    }
                    if (!empty($in)) {
                        $in = implode(', ', $in);
                        $searchClause[] = "{$sf} IN({$in})";
                    }
                    continue;
                }
                $searchClause[] = "{$sf} LIKE {$searchStr}";
            }
            // If no resulting search clauses (feasible), set search clause to "0"
            if (!empty($searchClause)) {
                $searchClause = implode(' OR ', $searchClause);
            } else {
                $searchClause = '0';
            }
            // Get URL for clear link
            $url = new TableEditor_URL();
            $url->removeQueryString('search');
            $clearURL = $url->getURL(true);
        } else {
            if (empty($searchClause)) {
                $searchClause = '1';
            }
        }
        /**
         * Handle ordering
         */
        if (!empty($_GET['orderby']) and preg_match('#^([a-z0-9_]+)(:desc)?$#i', $_GET['orderby'], $matches)) {
            $this->orderby = array('field' => $matches[1], 'direction' => (int) empty($matches[2]));
        }
        $orderbyClause = "ORDER BY {$this->orderby['field']}" . (!$this->orderby['direction'] ? ' DESC' : '');
        // Handle multiple instances of "orderby" on the query string; messy.
        if (count(explode('orderby', $_SERVER['QUERY_STRING'])) > 2) {
            $url = new TableEditor_URL();
            header('Location: ' . $url->getURL());
            exit;
        }
        /**
         * Handle data filters
         */
        if (!empty($this->dataFilters)) {
            $filters = implode(' AND ', $this->dataFilters);
        } else {
            $filters = 1;
        }
        /**
         * Setup which tables we're selecting from
         */
        list($tables, $joinClause) = $this->getQueryTables();
        /**
         * Get total rows
         */
        $total = $this->dbGetOne("SELECT COUNT(*) FROM {$tables} WHERE {$joinClause} AND {$filters} AND ({$searchClause})");
        $perPage = $this->config['perPage'];
        /**
         * Handle paging of results
         */
        $pager = new Pager_Sliding(array('totalItems' => $total, 'delta' => 5, 'prevImg' => '<span class="nextBackLink">&laquo;</span>', 'nextImg' => '<span class="nextBackLink">&raquo;</span>', 'spacesBeforeSeparator' => '1', 'spacesAfterSeparator' => '1', 'curPageLinkClassName' => 'avgbold', 'perPage' => $perPage));
        list($startOffset, $endOffset) = $pager->getOffsetByPageId();
        $startOffset--;
        // Eww - For SQL query
        list($back, $pages, $next) = $pager->getLinks();
        /**
         * CSV handling - If downloading entire table as CSV, need to remove
         * the LIMIT information.
         */
        if (!empty($_GET['csvdownload']) and $_GET['type'] == 'table') {
            $startOffset = 0;
            $perPage = $total;
        }
        /**
         * Get data
         */
        $fields = $this->getDisplayFields();
        $fields = implode(', ', $fields);
        $results = $this->dbGetAll($s = "SELECT {$fields} FROM {$tables} WHERE {$joinClause} AND {$filters} AND ({$searchClause}) {$orderbyClause} LIMIT {$startOffset},{$perPage}");
        if ($results === false) {
            $this->errors[] = 'Error getting data. Database said: ' . $this->dbError();
        }
        /**
         * Allow for value substitution
         */
        if (!empty($results)) {
            foreach ($results as $k => $row) {
                $this->parseResults($results[$k]);
            }
            // Necessary to allow searching and highlighting on primary key field
            $nonFilteredData = $results;
            /**
             * Apply display filters
             */
            foreach ($results as $k => $row) {
                $this->applyDisplayFilters($results[$k]);
            }
        }
        /**
         * If a CSV download is required, do that instead of showing the table
         */
        if (!empty($_GET['csvdownload'])) {
            if ($this->getConfig('allowCSV')) {
                $this->handleCsvDownload($nonFilteredData);
            } else {
                $this->addError('CSV Download is not permitted');
            }
        }
        // Advanced Search
        $url = new TableEditor_URL();
        $url->addRawQueryString('asearch=1');
        $aSearchURL = $url->getURL();
        /**
         * Show the page in all it's wonderbar glory
         */
        $this->displayHeader();
        ?>
<center>
<table border="0" align="center">
    <tr>
        <td>&nbsp;</td>
        <td colspan="<?php 
        echo count($this->fields);
        ?>
" align="center">
            Displaying [<?php 
        echo $total > 0 ? $startOffset + 1 : 0;
        ?>
 - <?php 
        echo min($startOffset + $perPage, $total);
        ?>
] of <?php 
        echo $total;
        ?>
 records
        </td>
    </tr>

    <tr>
        <td>&nbsp;</td>
        <td colspan="<?php 
        echo count($this->fields) + 1;
        ?>
" align="center">
            <?php 
        echo $back;
        ?>
            <?php 
        echo $pages;
        ?>
            <?php 
        echo $next;
        ?>

            <?if($this->getConfig('searchableFields')):?>
                <div style="float: left; text-align: left">
                    <input type="text" value="<?php 
        echo $this->search;
        ?>
" id="searchInput" onkeypress="if (event.keyCode == 13) search()">&nbsp;
                    <button onclick="search()">Search &raquo;</button>&nbsp;<br>
                    
                    <?if($this->getConfig('allowASearch')):?>
                        <?if(!empty($_GET['asearch'])):?>
                            <i>Advanced Search: <a href="<?php 
        echo $modifyURL;
        ?>
">Modify</a> :: <a href="<?php 
        echo $clearURL;
        ?>
">Clear</a></i>
                        <?else:?>
                            <a href="<?php 
        echo $aSearchURL;
        ?>
"><i>Advanced Search</i></a>
                        <?endif?>
                        
                        <?if(isset($this->search)):?>::<?endif?>
                    <?endif?>

                    <?if(isset($this->search)):?>
                        <a href="<?php 
        echo $clearURL;
        ?>
"><i>Clear search</i></a>
                    <?endif?>
                </div>
            <?endif?>

            <div style="float: right; white-space: nowrap">
                <?$this->displayActionButtons()?>
            </div>
        </td>
    </tr>

    <tr>
        <td>&nbsp;</td>

        <?foreach($this->fields as $field => $f):?>
            <?if(empty($f['noDisplay'])):?>
                <th style="white-space: nowrap">
                    <a href="javascript: orderBy('<?php 
        echo $field . ($this->orderby['field'] == $field && $this->orderby['direction'] == 1 ? ':desc' : '');
        ?>
')"><?php 
        echo $f['display'];
        ?>
</a><?if($this->orderby['field'] == $field):?><?php 
        echo $this->orderby['direction'] == 1 ? '&nbsp;&uarr;' : '&nbsp;&darr;';
        ?>
<?endif?>
                </th>
            <?endif?>
        <?endforeach?>
    </tr>

    <?if(!empty($results)):?>
        <?foreach($results as $k => $row):?>
            <tr <?php 
        echo $k % 2 == 1 ? 'class="altRow"' : '';
        ?>
 style="cursor: default" onclick="row_highlight(event, this, this.getElementsByTagName('input')[0], '<?php 
        echo $k % 2 == 1 ? 'altRow' : '';
        ?>
')">
                <td>
                    <input type="checkbox"
                           id="rowSelector"
                           value="<?php 
        echo $nonFilteredData[$k][$this->pk];
        ?>
"
                           onclick="row_highlight(event, this.parentNode.parentNode, this, '<?php 
        echo $k % 2 == 1 ? 'altRow' : '';
        ?>
')">
                </td>

                <?foreach($row as $field => $v):?>
                    <?if(empty($this->fields[$field]['noDisplay'])):?>
                        <td valign="top"><?php 
        echo $v;
        ?>
</td>
                    <?endif?>
                <?endforeach?>
            </tr>
        <?endforeach?>

    <?else:?>

        <tr>
            <td colspan="<?php 
        echo count($this->fields);
        ?>
" align="center">No data found!</td>
        </tr>
    <?endif?>

    <tr>
        <td>&nbsp;</td>
        <td colspan="<?php 
        echo count($this->fields);
        ?>
">
            <div style="float: right">
                <?$this->displayActionButtons()?>
            </div>
        </td>
    </tr>

    <tr>
        <td>&nbsp;</td>
        <td colspan="<?php 
        echo count($this->fields);
        ?>
" align="center">
            <?php 
        echo $back;
        ?>
            <?php 
        echo $pages;
        ?>
            <?php 
        echo $next;
        ?>
        </td>
    </tr>
</table>

<?php 
        $this->displayFooter();
    }
예제 #8
0
 /**
  * Returns previous page ID. If current page is first page
  * this function returns FALSE
  *
  * @return mixed Previous pages' ID
  */
 function getPreviousPageID()
 {
     return parent::getNextPageID();
 }
예제 #9
0
 function lists()
 {
     require_once 'Pager/Sliding.php';
     if ($this->input->post('cid')) {
         foreach ($this->input->post('cid') as $v) {
             list($asset_id, $asset_type, $asset_platform) = explode('|', $v);
             switch ($this->input->post('task')) {
                 case 'delete':
                     if ($this->asset->removeAssets($asset_id)) {
                         $this->notify->set_message('success', $this->getMsg('delete_true'));
                     } else {
                         $this->notify->set_message('error', $this->getMsg('delete_false'));
                     }
                     break;
                 case 'link':
                     if ($gid = $this->input->post('bycampaign')) {
                         if ($this->asset->setConnectionCampaign($asset_id, $gid, $asset_type, $asset_platform)) {
                             $this->notify->set_message('success', $this->getMsg('update_true'));
                         } else {
                             $this->notify->set_message('error', $this->getMsg('update_false'));
                         }
                     }
                     break;
                 case 'unlink':
                     if ($gid = $this->input->post('bycampaign')) {
                         if ($this->asset->unsetConnectionCampaign($asset_id, $gid)) {
                             $this->notify->set_message('success', $this->getMsg('update_true'));
                         } else {
                             $this->notify->set_message('error', $this->getMsg('update_false'));
                         }
                     }
                     break;
             }
         }
     } elseif ($this->input->post('task')) {
         $this->notify->set_message('error', 'You haven\'t select any items required for the action.');
     }
     //dg($this->notify);
     $clauses = array();
     $orderby = 'campaign_media.media_id';
     $order = 'DESC';
     if ($this->input->get_post('bycampaign', TRUE)) {
         $clauses['campaign_group_assets.GID'] = $this->input->get_post('bycampaign', TRUE);
     }
     if ($bysearch = $this->input->get_post('bysearch', TRUE)) {
         $clauses['campaign_assets.asset_name'] = " LIKE '%" . $this->input->get_post('bysearch', TRUE) . "%' ";
     }
     //$config['path'] = APP_ADMIN_URL;
     $total = $this->asset->retrieveAssets($clauses, array('fields' => 'count(*) as total'));
     $config['totalItems'] = $total[0]['total'];
     $config['perPage'] = 15;
     //$config['urlVar'] = 'pageID';
     $config['urlVar'] = ($this->input->post('bycampaign') ? 'bycampaign=' . $this->input->post('bycampaign') . '&' : '') . ($this->input->post('bysearch') ? 'bysearch=' . $this->input->post('bysearch') . '&' : '') . 'pageID';
     $pager = new Pager_Sliding($config);
     $pageID = $this->input->get_post('pageID') ? $this->input->get_post('pageID') : 1;
     $links = $pager->getLinks($pageID);
     list($from, $to) = $pager->getOffsetByPageId();
     $campaigns = $this->campaign->retrieveCampaign(null, array('fields' => 'campaign_group.GID,campaign_group.title'));
     $data = $this->asset->retrieveAssets($clauses, array('limit_number' => $config['perPage'], 'limit_offset' => --$from));
     $this->load->view('admin/asset', array('data' => $data, 'offset' => $from, 'pagination' => $links, 'campaigns' => $campaigns));
 }
예제 #10
0
 function lists()
 {
     require_once 'Pager/Sliding.php';
     if ($this->input->post('cid')) {
         foreach ($this->input->post('cid') as $v) {
             switch ($this->input->post('task')) {
                 case 'activate':
                     if ($this->media->setStatusMedia($v, 'active')) {
                         $this->notify->set_message('success', $this->getMsg('update_true'));
                     } else {
                         $this->notify->set_message('error', $this->getMsg('update_false'));
                     }
                     break;
                 case 'deactivate':
                     if ($this->media->setStatusMedia($v, 'banned')) {
                         $this->notify->set_message('success', $this->getMsg('update_true'));
                     } else {
                         $this->notify->set_message('error', $this->getMsg('update_false'));
                     }
                     break;
                 case 'delete':
                     if ($this->media->removeMedia($v)) {
                         $this->notify->set_message('success', $this->getMsg('delete_true'));
                     } else {
                         $this->notify->set_message('error', $this->getMsg('delete_false'));
                     }
                     break;
                 case 'winner':
                     if ($this->media->setWinnerMedia($v, 1)) {
                         $this->notify->set_message('success', $this->getMsg('update_true'));
                     } else {
                         $this->notify->set_message('error', $this->getMsg('update_false'));
                     }
                     break;
                 case 'resetwinner':
                     if ($this->media->setWinnerMedia($v, 0)) {
                         $this->notify->set_message('success', $this->getMsg('update_true'));
                     } else {
                         $this->notify->set_message('error', $this->getMsg('update_false'));
                     }
                     break;
             }
             if ($this->input->post('notify') && in_array($this->input->post('task'), array('activate', 'deactivate'))) {
                 $data = $this->media->detailMedia($v);
                 switch ($this->input->post('task')) {
                     case 'activate':
                         $this->media->sendNotificationMail('approved', $data);
                         break;
                     case 'deactivate':
                         $this->media->sendNotificationMail('banned', $data);
                         break;
                 }
             }
         }
     } elseif ($this->input->post('task')) {
         $this->notify->set_message('error', 'You haven\'t select any items required for the action.');
     }
     $clauses = array();
     $orderby = 'campaign_media.media_id';
     $order = 'DESC';
     if ($this->input->get_post('bycampaign', TRUE)) {
         $clauses['campaign_media.GID'] = $this->input->get_post('bycampaign', TRUE);
     }
     if ($this->input->get_post('byuid', TRUE)) {
         $clauses['campaign_media_owner.uid'] = $this->input->get_post('byuid', TRUE);
     }
     if ($this->input->get_post('bystatus', TRUE)) {
         $clauses['campaign_media.media_status'] = $this->input->get_post('bystatus', TRUE);
     }
     if ($byorder = $this->input->get_post('byorder', TRUE)) {
         $orderby = "campaign_media.media_vote_total";
         switch ($byorder) {
             case "mostvoted":
                 $order = "DESC";
                 break;
             case "lessvoted":
                 $order = "ASC";
                 break;
         }
     }
     //$config['path'] = APP_ADMIN_URL;
     $total = $this->media->retrieveMedia($clauses, array('fields' => 'count(*) as total'));
     $config['totalItems'] = $total[0]['total'];
     $config['perPage'] = 15;
     //$config['urlVar'] = 'pageID';
     $config['urlVar'] = ($this->input->post('bycampaign') ? 'bycampaign=' . $this->input->post('bycampaign') . '&' : '') . ($this->input->post('byuid') != '' ? 'byuid=' . $this->input->post('byuid') . '&' : '') . ($this->input->post('bystatus') ? 'bystatus=' . $this->input->post('bystatus') . '&' : '') . ($this->input->post('byorder') ? 'byorder=' . $this->input->post('byorder') . '&' : '') . 'pageID';
     $pager = new Pager_Sliding($config);
     $pageID = $this->input->get_post('pageID') ? $this->input->get_post('pageID') : 1;
     $links = $pager->getLinks($pageID);
     list($from, $to) = $pager->getOffsetByPageId();
     $campaigns = $this->campaign->retrieveCampaign(null, array('fields' => 'campaign_group.GID,campaign_group.title'));
     $data = $this->media->retrieveMedia($clauses, array('orderby' => $orderby, 'order' => $order, 'limit_number' => $config['perPage'], 'limit_offset' => --$from));
     $this->load->view('admin/media', array('data' => $data, 'offset' => $from, 'pagination' => $links, 'campaigns' => $campaigns));
 }