Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/cceadmin/
Upload File :
Current File : /var/www/cesa.co.za/cceadmin/CCEGallerylist.php

<?php
//ini_set('display_errors', 1);
//error_reporting(E_ALL);
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg7.php" ?>
<?php include "ewmysql7.php" ?>
<?php include "phpfn7.php" ?>
<?php include "CCEGalleryinfo.php" ?>
<?php include "CCEUsersinfo.php" ?>
<?php include "userfn7.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php
// Create page object
$CCEGallery_list = new cCCEGallery_list();
$Page = & $CCEGallery_list;

// Page init
$CCEGallery_list->Page_Init();

// Page main
$CCEGallery_list->Page_Main();
?>
<?php include "header.php" ?>
<?php if ($CCEGallery->Export == "") { ?>
    <script type="text/javascript">
    <!--

    // Create page object
        var CCEGallery_list = new ew_Page("CCEGallery_list");
    // page properties
        CCEGallery_list.PageID = "list"; // page ID
        CCEGallery_list.FormID = "fCCEGallerylist"; // form ID
        var EW_PAGE_ID = CCEGallery_list.PageID; // for backward compatibility

    // extend page with Form_CustomValidate function
        CCEGallery_list.Form_CustomValidate =
                function(fobj) { // DO NOT CHANGE THIS LINE!

                // Your custom validation code here, return false if invalid.
                return true;
                }
    <?php if (EW_CLIENT_VALIDATE) { ?>
            CCEGallery_list.ValidateRequired = true; // uses JavaScript validation
    <?php } else { ?>
            CCEGallery_list.ValidateRequired = false; // no JavaScript validation
    <?php } ?>

    //-->
    </script>
        <link rel="stylesheet" type="text/css" media="all" href="calendar/calendar-win2k-cold-1.css" title="win2k-1">
    <script type="text/javascript" src="calendar/calendar.js"></script>
    <script type="text/javascript" src="calendar/lang/calendar-en.js"></script>
    <script type="text/javascript" src="calendar/calendar-setup.js"></script>
    <script type="text/javascript">
        <!--
                var ew_DHTMLEditors = [];
        //    -->
        </scri    pt>
            <script language="JavaScript" type="text/javas    cript"    >
        <!--

                // Write your client script here, no need to add scrip    t tags.
                // To include another .js scrip    t, use:
                // ew_ClientScriptInclude("my_javascript    .js");
        //-->

        </script>
    <?php } ?>
    <?php if ($CCEGallery->Export == "") { ?>
    <?php } ?>
    <?php
    $bSelectLimit = EW_SELECT_LIMIT;
    if ($bSelectLimit) {
        $CCEGallery_list->lTotalRecs = $CCEGallery->SelectRecordCount();
    } else {
        if ($rs = $CCEGallery_list->LoadRecordset())
            $CCEGallery_list->lTotalRecs = $rs->RecordCount();
    }
    $CCEGallery_list->lStartRec = 1;
    if ($CCEGallery_list->lDisplayRecs <= 0 || ($CCEGallery->Export <> "" && $CCEGallery->ExportAll)) // Display all records
        $CCEGallery_list->lDisplayRecs = $CCEGallery_list->lTotalRecs;
    if (!($CCEGallery->Export <> "" && $CCEGallery->ExportAll))
        $CCEGallery_list->SetUpStartRec(); // Set up start record position
    if ($bSelectLimit)
        $rs = $CCEGallery_list->LoadRecordset($CCEGallery_list->lStartRec - 1, $CCEGallery_list->lDisplayRecs);
    ?>
    <p><span class="phpmaker" style="white-space: nowrap;"><?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $CCEGallery->TableCaption() ?>
            <?php if ($CCEGallery->Export == "" && $CCEGallery->CurrentAction == "") { ?>
                &nbsp;&nbsp;<a href="<?php echo $CCEGallery_list->ExportPrintUrl ?>"><img src="images/print.gif" alt="<?php echo ew_HtmlEncode($Language->Phrase("PrinterFriendly")) ?>" title="<?php echo ew_HtmlEncode($Language->Phrase("PrinterFriendly")) ?>" width="16" height="16" border="0"></a>
                &nbsp;&nbsp;<a href="<?php echo $CCEGallery_list->ExportExcelUrl ?>"><img src='images/exportxls.gif' alt='<?php echo ew_HtmlEncode($Language->Phrase("ExportToExcel")) ?>' title='<?php echo ew_HtmlEncode($Language->Phrase("ExportToExcel")) ?>' width='16' height='16' border='0'></a>
                &nbsp;&nbsp;<a href="<?php echo $CCEGallery_list->ExportWordUrl ?>"><img src='images/exportdoc.gif' alt='<?php echo ew_HtmlEncode($Language->Phrase("ExportToWord")) ?>' title='<?php echo ew_HtmlEncode($Language->Phrase("ExportToWord")) ?>' width='16' height='16' border='0'></a>
                &nbsp;&nbsp;<a name="emf_CCEGallery" id="emf_CCEGallery" href="javascript:void(0);" onclick="ew_EmailDialogShow({lnk:'emf_CCEGallery', hdr:ewLanguage.Phrase('ExportToEmail'), f:document.fCCEGallerylist, sel:false});"><img src='images/exportemail.gif' alt='<?php echo ew_HtmlEncode($Language->Phrase("ExportToEmail")) ?>' title='<?php echo ew_HtmlEncode($Language->Phrase("ExportToEmail")) ?>' width='16' height='16' border='0'></a>
            <?php } ?>
        </span></p>
    <?php if ($Security->CanSearch()) { ?>
        <?php if ($CCEGallery->Export == "" && $CCEGallery->CurrentAction == "") { ?>
            <a href="javascript:ew_ToggleSearchPanel(CCEGallery_list);" style="text-decoration: none;"><img id="CCEGallery_list_SearchImage" src="images/collapse.gif" alt="" width="9" height="9" border="0"></a><span class="phpmaker">&nbsp;<?php echo $Language->Phrase("Search") ?></span><br>
            <div id="CCEGallery_list_SearchPanel">
                <form name="fCCEGallerylistsrch" id="fCCEGallerylistsrch" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
                    <input type="hidden" id="t" name="t" value="CCEGallery">
                    <table class="ewBasicSearch">
                        <tr>
                            <td><span class="phpmaker">
                                    <input type="text" name="<?php echo EW_TABLE_BASIC_SEARCH ?>" id="<?php echo EW_TABLE_BASIC_SEARCH ?>" size="20" value="<?php echo ew_HtmlEncode($CCEGallery->getSessionBasicSearchKeyword()) ?>">
                                    <input type="Submit" name="Submit" id="Submit" value="<?php echo ew_BtnCaption($Language->Phrase("QuickSearchBtn")) ?>">&nbsp;
                                    <a href="<?php echo $CCEGallery_list->PageUrl() ?>cmd=reset"><?php echo $Language->Phrase("ShowAll") ?></a>&nbsp;
                                </span></td>
                        </tr>
                        <tr>
                            <td><span class="phpmaker"><label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value=""<?php if ($CCEGallery->getSessionBasicSearchType() == "") { ?> checked="checked"<?php } ?>><?php echo $Language->Phrase("ExactPhrase") ?></label>&nbsp;&nbsp;<label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="AND"<?php if ($CCEGallery->getSessionBasicSearchType() == "AND") { ?> checked="checked"<?php } ?>><?php echo $Language->Phrase("AllWord") ?></label>&nbsp;&nbsp;<label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="OR"<?php if ($CCEGallery->getSessionBasicSearchType() == "OR") { ?> checked="checked"<?php } ?>><?php echo $Language->Phrase("AnyWord") ?></label></span></td>
                        </tr>
                    </table>
                </form>
            </div>
        <?php } ?>
    <?php } ?>
    <?php
    if (EW_DEBUG_ENABLED)
        echo ew_DebugMsg();
    $CCEGallery_list->ShowMessage();
    ?>
    <br>
    <table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
                <?php if ($CCEGallery->Export == "") { ?>
                    <div class="ewGridUpperPanel">
                        <?php if ($CCEGallery->CurrentAction <> "gridadd" && $CCEGallery->CurrentAction <> "gridedit") { ?>
                            <form name="ewpagerform" id="ewpagerform" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
                                <table border="0" cellspacing="0" cellpadding="0" class="ewPager">
                                    <tr>
                                        <td nowrap>
                                            <?php if (!isset($CCEGallery_list->Pager)) $CCEGallery_list->Pager = new cPrevNextPager($CCEGallery_list->lStartRec, $CCEGallery_list->lDisplayRecs, $CCEGallery_list->lTotalRecs) ?>
                                            <?php if ($CCEGallery_list->Pager->RecordCount > 0) { ?>
                                                <table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpmaker"><?php echo $Language->Phrase("Page") ?>&nbsp;</span></td>
                                                        <!--first page button-->
                                                        <?php if ($CCEGallery_list->Pager->FirstButton->Enabled) { ?>
                                                            <td><a href="<?php echo $CCEGallery_list->PageUrl() ?>start=<?php echo $CCEGallery_list->Pager->FirstButton->Start ?>"><img src="images/first.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></a></td>
                                                        <?php } else { ?>
                                                            <td><img src="images/firstdisab.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
                                                        <?php } ?>
                                                        <!--previous page button-->
                                                        <?php if ($CCEGallery_list->Pager->PrevButton->Enabled) { ?>
                                                            <td><a href="<?php echo $CCEGallery_list->PageUrl() ?>start=<?php echo $CCEGallery_list->Pager->PrevButton->Start ?>"><img src="images/prev.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></a></td>
                                                        <?php } else { ?>
                                                            <td><img src="images/prevdisab.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
                                                        <?php } ?>
                                                        <!--current page number-->
                                                        <td><input type="text" name="<?php echo EW_TABLE_PAGE_NO ?>" id="<?php echo EW_TABLE_PAGE_NO ?>" value="<?php echo $CCEGallery_list->Pager->CurrentPage ?>" size="4"></td>
                                                        <!--next page button-->
                                                        <?php if ($CCEGallery_list->Pager->NextButton->Enabled) { ?>
                                                            <td><a href="<?php echo $CCEGallery_list->PageUrl() ?>start=<?php echo $CCEGallery_list->Pager->NextButton->Start ?>"><img src="images/next.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></a></td>
                                                        <?php } else { ?>
                                                            <td><img src="images/nextdisab.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
                                                        <?php } ?>
                                                        <!--last page button-->
                                                        <?php if ($CCEGallery_list->Pager->LastButton->Enabled) { ?>
                                                            <td><a href="<?php echo $CCEGallery_list->PageUrl() ?>start=<?php echo $CCEGallery_list->Pager->LastButton->Start ?>"><img src="images/last.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></a></td>
                                                        <?php } else { ?>
                                                            <td><img src="images/lastdisab.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
                                                        <?php } ?>
                                                        <td><span class="phpmaker">&nbsp;<?php echo $Language->Phrase("of") ?>&nbsp;<?php echo $CCEGallery_list->Pager->PageCount ?></span></td>
                                                    </tr></table>
                                            </td>
                                            <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
                                            <td>
                                                <span class="phpmaker"><?php echo $Language->Phrase("Record") ?>&nbsp;<?php echo $CCEGallery_list->Pager->FromIndex ?>&nbsp;<?php echo $Language->Phrase("To") ?>&nbsp;<?php echo $CCEGallery_list->Pager->ToIndex ?>&nbsp;<?php echo $Language->Phrase("Of") ?>&nbsp;<?php echo $CCEGallery_list->Pager->RecordCount ?></span>
                                            <?php } else { ?>
                                                <?php if ($Security->CanList()) { ?>
                                                    <?php if ($CCEGallery_list->sSrchWhere == "0=101") { ?>
                                                        <span class="phpmaker"><?php echo $Language->Phrase("EnterSearchCriteria") ?></span>
                                                    <?php } else { ?>
                                                        <span class="phpmaker"><?php echo $Language->Phrase("NoRecord") ?></span>
                                                    <?php } ?>
                                                <?php } else { ?>
                                                    <span class="phpmaker"><?php echo $Language->Phrase("NoPermission") ?></span>
                                                <?php } ?>
                                            <?php } ?>
                                        </td>
                                    </tr>
                                </table>
                            </form>
                        <?php } ?>
                        <span class="phpmaker">
                            <?php if ($Security->CanAdd()) { ?>
                                <a href="<?php echo $CCEGallery_list->AddUrl ?>"><?php echo $Language->Phrase("AddLink") ?></a>&nbsp;&nbsp;
                            <?php } ?>
                        </span>
                    </div>
                <?php } ?>
                <form name="fCCEGallerylist" id="fCCEGallerylist" class="ewForm" action="" method="post">
                    <div id="gmp_CCEGallery" class="ewGridMiddlePanel">
                        <?php if ($CCEGallery_list->lTotalRecs > 0) { ?>
                            <table cellspacing="0" rowhighlightclass="ewTableHighlightRow" rowselectclass="ewTableSelectRow" roweditclass="ewTableEditRow" class="ewTable ewTableSeparate">
                                <?php echo $CCEGallery->TableCustomInnerHtml ?>
                                <thead><!-- Table header -->
                                    <tr class="ewTableHeader">
                                        <?php
// Render list options
                                        $CCEGallery_list->RenderListOptions();

// Render list options (header, left)
                                        $CCEGallery_list->ListOptions->Render("header", "left");
                                        ?>
                                        <?php if ($CCEGallery->GalleryImage->Visible) { // GalleryImage ?>
                                            <?php if ($CCEGallery->SortUrl($CCEGallery->GalleryImage) == "") { ?>
                                                <td><?php echo $CCEGallery->GalleryImage->FldCaption() ?></td>
                                            <?php } else { ?>
                                                <td><div class="ewPointer" onmousedown="ew_Sort(event, '<?php echo $CCEGallery->SortUrl($CCEGallery->GalleryImage) ?>', 2);">
                                                        <table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEGallery->GalleryImage->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEGallery->GalleryImage->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEGallery->GalleryImage->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
                                                    </div></td>
                                            <?php } ?>
                                        <?php } ?>
                                        <?php if ($CCEGallery->ImageCaption->Visible) { // ImageCaption  ?>
                                            <?php if ($CCEGallery->SortUrl($CCEGallery->ImageCaption) == "") { ?>
                                                <td><?php echo $CCEGallery->ImageCaption->FldCaption() ?></td>
                                            <?php } else { ?>
                                                <td><div class="ewPointer" onmousedown="ew_Sort(event, '<?php echo $CCEGallery->SortUrl($CCEGallery->ImageCaption) ?>', 2);">
                                                        <table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEGallery->ImageCaption->FldCaption() ?><?php echo $Language->Phrase("SrchLegend") ?></td><td style="width: 10px;"><?php if ($CCEGallery->ImageCaption->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEGallery->ImageCaption->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
                                                    </div></td>
                                            <?php } ?>
                                        <?php } ?>
                                        <?php if ($CCEGallery->DateAdded->Visible) { // DateAdded  ?>
                                            <?php if ($CCEGallery->SortUrl($CCEGallery->DateAdded) == "") { ?>
                                                <td><?php echo $CCEGallery->DateAdded->FldCaption() ?></td>
                                            <?php } else { ?>
                                                <td><div class="ewPointer" onmousedown="ew_Sort(event, '<?php echo $CCEGallery->SortUrl($CCEGallery->DateAdded) ?>', 2);">
                                                        <table cellspacing="0" class="ewTableHeaderBtn"><thead><tr><td><?php echo $CCEGallery->DateAdded->FldCaption() ?></td><td style="width: 10px;"><?php if ($CCEGallery->DateAdded->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($CCEGallery->DateAdded->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></thead></table>
                                                    </div></td>
                                            <?php } ?>
                                        <?php } ?>
                                        <?php
// Render list options (header, right)
                                        $CCEGallery_list->ListOptions->Render("header", "right");
                                        ?>
                                    </tr>
                                </thead>
                                <?php
                                if ($CCEGallery->ExportAll && $CCEGallery->Export <> "") {
                                    $CCEGallery_list->lStopRec = $CCEGallery_list->lTotalRecs;
                                } else {
                                    $CCEGallery_list->lStopRec = $CCEGallery_list->lStartRec + $CCEGallery_list->lDisplayRecs - 1; // Set the last record to display
                                }
                                $CCEGallery_list->lRecCount = $CCEGallery_list->lStartRec - 1;
                                if ($rs && !$rs->EOF) {
                                    $rs->MoveFirst();
                                    if (!$bSelectLimit && $CCEGallery_list->lStartRec > 1)
                                        $rs->Move($CCEGallery_list->lStartRec - 1);
                                }

// Initialize aggregate
                                $CCEGallery->RowType = EW_ROWTYPE_AGGREGATEINIT;
                                $CCEGallery_list->RenderRow();
                                $CCEGallery_list->lRowCnt = 0;
                                while (($CCEGallery->CurrentAction == "gridadd" || !$rs->EOF) &&
                                $CCEGallery_list->lRecCount < $CCEGallery_list->lStopRec) {
                                    $CCEGallery_list->lRecCount++;
                                    if (intval($CCEGallery_list->lRecCount) >= intval($CCEGallery_list->lStartRec)) {
                                        $CCEGallery_list->lRowCnt++;

                                        // Init row class and style
                                        $CCEGallery->CssClass = "";
                                        $CCEGallery->CssStyle = "";
                                        $CCEGallery->RowAttrs = array('onmouseover' => 'ew_MouseOver(event, this);', 'onmouseout' => 'ew_MouseOut(event, this);', 'onclick' => 'ew_Click(event, this);');
                                        if ($CCEGallery->CurrentAction == "gridadd") {
                                            $CCEGallery_list->LoadDefaultValues(); // Load default values
                                        } else {
                                            $CCEGallery_list->LoadRowValues($rs); // Load row values
                                        }
                                        $CCEGallery->RowType = EW_ROWTYPE_VIEW; // Render view
                                        // Render row
                                        $CCEGallery_list->RenderRow();

                                        // Render list options
                                        $CCEGallery_list->RenderListOptions();
                                        ?>
                                        <tr<?php echo $CCEGallery->RowAttributes() ?>>
                                            <?php
// Render list options (body, left)
                                            $CCEGallery_list->ListOptions->Render("body", "left");
                                            ?>
                                            <?php if ($CCEGallery->GalleryImage->Visible) { // GalleryImage ?>
                                                <td<?php echo $CCEGallery->GalleryImage->CellAttributes() ?>>
                                                    <?php if ($CCEGallery->GalleryImage->HrefValue <> "" || $CCEGallery->GalleryImage->TooltipValue <> "") { ?>
                                                        <?php if (!empty($CCEGallery->GalleryImage->Upload->DbValue)) { ?>
                                                            <img src="<?php echo ew_IncludeTrailingDelimiter($CCEGallery->GalleryImage->UploadPath, FALSE) . $CCEGallery->GalleryImage->Upload->DbValue ?>" width="150" border=0<?php echo $CCEGallery->GalleryImage->ViewAttributes() ?>>
                                                        <?php } elseif (!in_array($CCEGallery->CurrentAction, array("I", "edit", "gridedit"))) { ?>
                                                            &nbsp;
                                                        <?php } ?>
                                                    <?php } else { ?>
                                                        <?php if (!empty($CCEGallery->GalleryImage->Upload->DbValue)) { ?>
                                                            <img src="<?php echo ew_IncludeTrailingDelimiter($CCEGallery->GalleryImage->UploadPath, FALSE) . $CCEGallery->GalleryImage->Upload->DbValue ?>" width="150" border=0<?php echo $CCEGallery->GalleryImage->ViewAttributes() ?>>
                                                        <?php } elseif (!in_array($CCEGallery->CurrentAction, array("I", "edit", "gridedit"))) { ?>
                                                            &nbsp;
                                                        <?php } ?>
                                                    <?php } ?>
                                                </td>
                                            <?php } ?>
                                            <?php if ($CCEGallery->ImageCaption->Visible) { // ImageCaption  ?>
                                                <td<?php echo $CCEGallery->ImageCaption->CellAttributes() ?>>
                                                    <div<?php echo $CCEGallery->ImageCaption->ViewAttributes() ?>><?php echo $CCEGallery->ImageCaption->ListViewValue() ?></div>
                                                </td>
                                            <?php } ?>
                                            <?php if ($CCEGallery->DateAdded->Visible) { // DateAdded  ?>
                                                <td<?php echo $CCEGallery->DateAdded->CellAttributes() ?>>
                                                    <div<?php echo $CCEGallery->DateAdded->ViewAttributes() ?>><?php echo $CCEGallery->DateAdded->ListViewValue() ?></div>
                                                </td>
                                            <?php } ?>
                                            <?php
// Render list options (body, right)
                                            $CCEGallery_list->ListOptions->Render("body", "right");
                                            ?>
                                        </tr>
                                        <?php
                                    }
                                    if ($CCEGallery->CurrentAction <> "gridadd")
                                        $rs->MoveNext();
                                }
                                ?>
                                </tbody>
                            </table>
                        <?php } ?>
                    </div>
                </form>
                <?php
// Close recordset
                if ($rs)
                    $rs->Close();
                ?>
                <?php if ($CCEGallery_list->lTotalRecs > 0) { ?>
                    <?php if ($CCEGallery->Export == "") { ?>
                        <div class="ewGridLowerPanel">
                            <?php if ($CCEGallery->CurrentAction <> "gridadd" && $CCEGallery->CurrentAction <> "gridedit") { ?>
                                <form name="ewpagerform" id="ewpagerform" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
                                    <table border="0" cellspacing="0" cellpadding="0" class="ewPager">
                                        <tr>
                                            <td nowrap>
                                                <?php if (!isset($CCEGallery_list->Pager)) $CCEGallery_list->Pager = new cPrevNextPager($CCEGallery_list->lStartRec, $CCEGallery_list->lDisplayRecs, $CCEGallery_list->lTotalRecs) ?>
                                                <?php if ($CCEGallery_list->Pager->RecordCount > 0) { ?>
                                                    <table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpmaker"><?php echo $Language->Phrase("Page") ?>&nbsp;</span></td>
                                                            <!--first page button-->
                                                            <?php if ($CCEGallery_list->Pager->FirstButton->Enabled) { ?>
                                                                <td><a href="<?php echo $CCEGallery_list->PageUrl() ?>start=<?php echo $CCEGallery_list->Pager->FirstButton->Start ?>"><img src="images/first.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></a></td>
                                                            <?php } else { ?>
                                                                <td><img src="images/firstdisab.gif" alt="<?php echo $Language->Phrase("PagerFirst") ?>" width="16" height="16" border="0"></td>
                                                            <?php } ?>
                                                            <!--previous page button-->
                                                            <?php if ($CCEGallery_list->Pager->PrevButton->Enabled) { ?>
                                                                <td><a href="<?php echo $CCEGallery_list->PageUrl() ?>start=<?php echo $CCEGallery_list->Pager->PrevButton->Start ?>"><img src="images/prev.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></a></td>
                                                            <?php } else { ?>
                                                                <td><img src="images/prevdisab.gif" alt="<?php echo $Language->Phrase("PagerPrevious") ?>" width="16" height="16" border="0"></td>
                                                            <?php } ?>
                                                            <!--current page number-->
                                                            <td><input type="text" name="<?php echo EW_TABLE_PAGE_NO ?>" id="<?php echo EW_TABLE_PAGE_NO ?>" value="<?php echo $CCEGallery_list->Pager->CurrentPage ?>" size="4"></td>
                                                            <!--next page button-->
                                                            <?php if ($CCEGallery_list->Pager->NextButton->Enabled) { ?>
                                                                <td><a href="<?php echo $CCEGallery_list->PageUrl() ?>start=<?php echo $CCEGallery_list->Pager->NextButton->Start ?>"><img src="images/next.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></a></td>
                                                            <?php } else { ?>
                                                                <td><img src="images/nextdisab.gif" alt="<?php echo $Language->Phrase("PagerNext") ?>" width="16" height="16" border="0"></td>
                                                            <?php } ?>
                                                            <!--last page button-->
                                                            <?php if ($CCEGallery_list->Pager->LastButton->Enabled) { ?>
                                                                <td><a href="<?php echo $CCEGallery_list->PageUrl() ?>start=<?php echo $CCEGallery_list->Pager->LastButton->Start ?>"><img src="images/last.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></a></td>
                                                            <?php } else { ?>
                                                                <td><img src="images/lastdisab.gif" alt="<?php echo $Language->Phrase("PagerLast") ?>" width="16" height="16" border="0"></td>
                                                            <?php } ?>
                                                            <td><span class="phpmaker">&nbsp;<?php echo $Language->Phrase("of") ?>&nbsp;<?php echo $CCEGallery_list->Pager->PageCount ?></span></td>
                                                        </tr></table>
                                                </td>
                                                <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
                                                <td>
                                                    <span class="phpmaker"><?php echo $Language->Phrase("Record") ?>&nbsp;<?php echo $CCEGallery_list->Pager->FromIndex ?>&nbsp;<?php echo $Language->Phrase("To") ?>&nbsp;<?php echo $CCEGallery_list->Pager->ToIndex ?>&nbsp;<?php echo $Language->Phrase("Of") ?>&nbsp;<?php echo $CCEGallery_list->Pager->RecordCount ?></span>
                                                <?php } else { ?>
                                                    <?php if ($Security->CanList()) { ?>
                                                        <?php if ($CCEGallery_list->sSrchWhere == "0=101") { ?>
                                                            <span class="phpmaker"><?php echo $Language->Phrase("EnterSearchCriteria") ?></span>
                                                        <?php } else { ?>
                                                            <span class="phpmaker"><?php echo $Language->Phrase("NoRecord") ?></span>
                                                        <?php } ?>
                                                    <?php } else { ?>
                                                        <span class="phpmaker"><?php echo $Language->Phrase("NoPermission") ?></span>
                                                    <?php } ?>
                                                <?php } ?>
                                            </td>
                                        </tr>
                                    </table>
                                </form>
                            <?php } ?>
                            <?php //if ($CCEGallery_list->lTotalRecs > 0) { ?>
                            <span class="phpmaker">
                                <?php if ($Security->CanAdd()) { ?>
                                    <a href="<?php echo $CCEGallery_list->AddUrl ?>"><?php echo $Language->Phrase("AddLink") ?></a>&nbsp;&nbsp;
                                <?php } ?>
                            </span>
                            <?php //}  ?>
                        </div>
                    <?php } ?>
                <?php } ?>
            </td></tr></table>
    <?php if ($CCEGallery->Export == "" && $CCEGallery->CurrentAction == "") { ?>
    <?php } ?>
    <?php if ($CCEGallery->Export == "") { ?>
                <script language="JavaScript" type="text/javascript">
    <!--

    // Write your table-specific startup script here
        // document.write("page loaded");
        //-->

        </script>
    <?php } ?>
    <?php include "footer.php" ?>
    <?php
    $CCEGallery_list->Page_Terminate();
    ?>
    <?php

//
// Page class
//
    class cCCEGallery_list {

        // Page ID
        var $PageID = 'list';
        // Table name
        var $TableName = 'CCEGallery';
        // Page object name
        var $PageObjName = 'CCEGallery_list';

        // Page name
        function PageName() {
            return ew_CurrentPage();
        }

        // Page URL
        function PageUrl() {
            $PageUrl = ew_CurrentPage() . "?";
            global $CCEGallery;
            if ($CCEGallery->UseTokenInUrl)
                $PageUrl .= "t=" . $CCEGallery->TableVar . "&"; // Add page token
            return $PageUrl;
        }

        // Page URLs
        var $AddUrl;
        var $EditUrl;
        var $CopyUrl;
        var $DeleteUrl;
        var $ViewUrl;
        var $ListUrl;
        // Export URLs
        var $ExportPrintUrl;
        var $ExportHtmlUrl;
        var $ExportExcelUrl;
        var $ExportWordUrl;
        var $ExportXmlUrl;
        var $ExportCsvUrl;
        // Update URLs
        var $InlineAddUrl;
        var $InlineCopyUrl;
        var $InlineEditUrl;
        var $GridAddUrl;
        var $GridEditUrl;
        var $MultiDeleteUrl;
        var $MultiUpdateUrl;

        // Message
        function getMessage() {
            return @$_SESSION[EW_SESSION_MESSAGE];
        }

        function setMessage($v) {
            if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Append
                $_SESSION[EW_SESSION_MESSAGE] .= "<br>" . $v;
            } else {
                $_SESSION[EW_SESSION_MESSAGE] = $v;
            }
        }

        // Show message
        function ShowMessage() {
            $sMessage = $this->getMessage();
            $this->Message_Showing($sMessage);
            if ($sMessage <> "") { // Message in Session, display
                echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
                $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
            }
        }

        // Validate page request
        function IsPageRequest() {
            global $objForm, $CCEGallery;
            if ($CCEGallery->UseTokenInUrl) {
                if ($objForm)
                    return ($CCEGallery->TableVar == $objForm->GetValue("t"));
                if (@$_GET["t"] <> "")
                    return ($CCEGallery->TableVar == $_GET["t"]);
            } else {
                return TRUE;
            }
        }

        //
        // Page class constructor
        //
        function __construct() {
            global $conn, $Language;

            // Language object
            $Language = new cLanguage();

            // Table object (CCEGallery)
            $GLOBALS["CCEGallery"] = new cCCEGallery();

            // Initialize URLs
            $this->ExportPrintUrl = $this->PageUrl() . "export=print";
            $this->ExportExcelUrl = $this->PageUrl() . "export=excel";
            $this->ExportWordUrl = $this->PageUrl() . "export=word";
            $this->ExportHtmlUrl = $this->PageUrl() . "export=html";
            $this->ExportXmlUrl = $this->PageUrl() . "export=xml";
            $this->ExportCsvUrl = $this->PageUrl() . "export=csv";
            $this->AddUrl = $GLOBALS["CCEGallery"]->AddUrl();
            $this->InlineAddUrl = $this->PageUrl() . "a=add";
            $this->GridAddUrl = $this->PageUrl() . "a=gridadd";
            $this->GridEditUrl = $this->PageUrl() . "a=gridedit";
            $this->MultiDeleteUrl = "CCEGallerydelete.php";
            $this->MultiUpdateUrl = "CCEGalleryupdate.php";

            // Table object (CCEUsers)
            $GLOBALS['CCEUsers'] = new cCCEUsers();

            // Page ID
            if (!defined("EW_PAGE_ID"))
                define("EW_PAGE_ID", 'list', TRUE);

            // Table name (for backward compatibility)
            if (!defined("EW_TABLE_NAME"))
                define("EW_TABLE_NAME", 'CCEGallery', TRUE);

            // Start timer
            $GLOBALS["gsTimer"] = new cTimer();

            // Open connection
            $conn = ew_Connect();

            // List options
            $this->ListOptions = new cListOptions();
        }

        //
        //  Page_Init
        //
        function Page_Init() {
            global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
            global $CCEGallery;

            // Security
            $Security = new cAdvancedSecurity();
            if (!$Security->IsLoggedIn())
                $Security->AutoLogin();
            if (!$Security->IsLoggedIn()) {
                $Security->SaveLastUrl();
                $this->Page_Terminate("login.php");
            }
            $Security->TablePermission_Loading();
            $Security->LoadCurrentUserLevel($this->TableName);
            $Security->TablePermission_Loaded();
            if (!$Security->IsLoggedIn()) {
                $Security->SaveLastUrl();
                $this->Page_Terminate("login.php");
            }
            if (!$Security->CanList()) {
                $Security->SaveLastUrl();
                $this->Page_Terminate("login.php");
            }

            // Get export parameters
            if (@$_GET["export"] <> "") {
                $CCEGallery->Export = $_GET["export"];
            } elseif (ew_IsHttpPost()) {
                if (@$_POST["exporttype"] <> "")
                    $CCEGallery->Export = $_POST["exporttype"];
            } else {
                $CCEGallery->setExportReturnUrl(ew_CurrentUrl());
            }
            $gsExport = $CCEGallery->Export; // Get export parameter, used in header
            $gsExportFile = $CCEGallery->TableVar; // Get export file, used in header
            if ($CCEGallery->Export == "excel") {
                header('Content-Type: application/vnd.ms-excel');
                header('Content-Disposition: attachment; filename=' . $gsExportFile . '.xls');
            }
            if ($CCEGallery->Export == "word") {
                header('Content-Type: application/vnd.ms-word');
                header('Content-Disposition: attachment; filename=' . $gsExportFile . '.doc');
            }

            // Global Page Loading event (in userfn*.php)
            Page_Loading();

            // Page Load event
            $this->Page_Load();
        }

        //
        // Page_Terminate
        //
        function Page_Terminate($url = "") {
            global $conn;

            // Page Unload event
            $this->Page_Unload();

            // Global Page Unloaded event (in userfn*.php)
            Page_Unloaded();

            // Close connection
            $conn->Close();

            // Go to URL if specified
            $this->Page_Redirecting($url);
            if ($url <> "") {
                if (!EW_DEBUG_ENABLED && ob_get_length())
                    ob_end_clean();
                header("Location: " . $url);
            }
            exit();
        }

        // Class variables
        var $ListOptions; // List options
        var $lDisplayRecs = 20;
        var $lStartRec;
        var $lStopRec;
        var $lTotalRecs = 0;
        var $lRecRange = 10;
        var $sSrchWhere = ""; // Search WHERE clause
        var $lRecCnt = 0; // Record count
        var $lEditRowCnt;
        var $lRowCnt;
        var $lRowIndex; // Row index
        var $lRecPerRow = 0;
        var $lColCnt = 0;
        var $sDbMasterFilter = ""; // Master filter
        var $sDbDetailFilter = ""; // Detail filter
        var $bMasterRecordExists;
        var $sMultiSelectKey;
        var $RestoreSearch;

        //
        // Page main
        //
        function Page_Main() {
            global $objForm, $Language, $gsSearchError, $Security, $CCEGallery;

            // Search filters
            $sSrchAdvanced = ""; // Advanced search filter
            $sSrchBasic = ""; // Basic search filter
            $sFilter = "";
            if ($this->IsPageRequest()) { // Validate request
                // Handle reset command
                $this->ResetCmd();

                // Set up list options
                $this->SetupListOptions();

                // Get basic search values
                $this->LoadBasicSearchValues();

                // Restore search parms from Session
                $this->RestoreSearchParms();

                // Call Recordset SearchValidated event
                $CCEGallery->Recordset_SearchValidated();

                // Set up sorting order
                $this->SetUpSortOrder();

                // Get basic search criteria
                if ($gsSearchError == "")
                    $sSrchBasic = $this->BasicSearchWhere();
            }

            // Restore display records
            if ($CCEGallery->getRecordsPerPage() <> "") {
                $this->lDisplayRecs = $CCEGallery->getRecordsPerPage(); // Restore from Session
            } else {
                $this->lDisplayRecs = 20; // Load default
            }

            // Load Sorting Order
            $this->LoadSortOrder();

            // Build search criteria
            if ($sSrchAdvanced <> "")
                $this->sSrchWhere = ($this->sSrchWhere <> "") ? "(" . $this->sSrchWhere . ") AND (" . $sSrchAdvanced . ")" : $sSrchAdvanced;
            if ($sSrchBasic <> "")
                $this->sSrchWhere = ($this->sSrchWhere <> "") ? "(" . $this->sSrchWhere . ") AND (" . $sSrchBasic . ")" : $sSrchBasic;

            // Call Recordset_Searching event
            $CCEGallery->Recordset_Searching($this->sSrchWhere);

            // Save search criteria
            if ($this->sSrchWhere <> "") {
                if ($sSrchBasic == "")
                    $this->ResetBasicSearchParms();
                $CCEGallery->setSearchWhere($this->sSrchWhere); // Save to Session
                if (!$this->RestoreSearch) {
                    $this->lStartRec = 1; // Reset start record counter
                    $CCEGallery->setStartRecordNumber($this->lStartRec);
                }
            } else {
                $this->sSrchWhere = $CCEGallery->getSearchWhere();
            }

            // Build filter
            $sFilter = "";
            if (!$Security->CanList())
                $sFilter = "(0=1)"; // Filter all records
            if ($this->sDbDetailFilter <> "")
                $sFilter = ($sFilter <> "") ? "(" . $sFilter . ") AND (" . $this->sDbDetailFilter . ")" : $this->sDbDetailFilter;
            if ($this->sSrchWhere <> "")
                $sFilter = ($sFilter <> "") ? "(" . $sFilter . ") AND (" . $this->sSrchWhere . ")" : $this->sSrchWhere;

            // Set up filter in session
            $CCEGallery->setSessionWhere($sFilter);
            $CCEGallery->CurrentFilter = "";

            // Export data only
            if (in_array($CCEGallery->Export, array("html", "word", "excel", "xml", "csv", "email"))) {
                $this->ExportData();
                if ($CCEGallery->Export <> "email")
                    $this->Page_Terminate(); // Terminate response
                exit();
            }
        }

        // Return basic search SQL
        function BasicSearchSQL($Keyword) {
            global $CCEGallery;
            $sKeyword = ew_AdjustSql($Keyword);
            $sWhere = "";
            $this->BuildBasicSearchSQL($sWhere, $CCEGallery->GalleryImage, $Keyword);
            $this->BuildBasicSearchSQL($sWhere, $CCEGallery->ImageCaption, $Keyword);
            return $sWhere;
        }

        // Build basic search SQL
        function BuildBasicSearchSql(&$Where, &$Fld, $Keyword) {
            $sFldExpression = ($Fld->FldVirtualExpression <> "") ? $Fld->FldVirtualExpression : $Fld->FldExpression;
            $lFldDataType = ($Fld->FldIsVirtual) ? EW_DATATYPE_STRING : $Fld->FldDataType;
            if ($lFldDataType == EW_DATATYPE_NUMBER) {
                $sWrk = $sFldExpression . " = " . ew_QuotedValue($Keyword, $lFldDataType);
            } else {
                $sWrk = $sFldExpression . " LIKE " . ew_QuotedValue("%" . $Keyword . "%", $lFldDataType);
            }
            if ($Where <> "")
                $Where .= " OR ";
            $Where .= $sWrk;
        }

        // Return basic search WHERE clause based on search keyword and type
        function BasicSearchWhere() {
            global $Security, $CCEGallery;
            $sSearchStr = "";
            if (!$Security->CanSearch())
                return "";
            $sSearchKeyword = $CCEGallery->BasicSearchKeyword;
            $sSearchType = $CCEGallery->BasicSearchType;
            if ($sSearchKeyword <> "") {
                $sSearch = trim($sSearchKeyword);
                if ($sSearchType <> "") {
                    while (strpos($sSearch, "  ") !== FALSE)
                        $sSearch = str_replace("  ", " ", $sSearch);
                    $arKeyword = explode(" ", trim($sSearch));
                    foreach ($arKeyword as $sKeyword) {
                        if ($sSearchStr <> "")
                            $sSearchStr .= " " . $sSearchType . " ";
                        $sSearchStr .= "(" . $this->BasicSearchSQL($sKeyword) . ")";
                    }
                } else {
                    $sSearchStr = $this->BasicSearchSQL($sSearch);
                }
            }
            if ($sSearchKeyword <> "") {
                $CCEGallery->setSessionBasicSearchKeyword($sSearchKeyword);
                $CCEGallery->setSessionBasicSearchType($sSearchType);
            }
            return $sSearchStr;
        }

        // Clear all search parameters
        function ResetSearchParms() {
            global $CCEGallery;

            // Clear search WHERE clause
            $this->sSrchWhere = "";
            $CCEGallery->setSearchWhere($this->sSrchWhere);

            // Clear basic search parameters
            $this->ResetBasicSearchParms();
        }

        // Clear all basic search parameters
        function ResetBasicSearchParms() {
            global $CCEGallery;
            $CCEGallery->setSessionBasicSearchKeyword("");
            $CCEGallery->setSessionBasicSearchType("");
        }

        // Restore all search parameters
        function RestoreSearchParms() {
            global $CCEGallery;
            $bRestore = TRUE;
            if (@$_GET[EW_TABLE_BASIC_SEARCH] <> "")
                $bRestore = FALSE;
            $this->RestoreSearch = $bRestore;
            if ($bRestore) {

                // Restore basic search values
                $CCEGallery->BasicSearchKeyword = $CCEGallery->getSessionBasicSearchKeyword();
                $CCEGallery->BasicSearchType = $CCEGallery->getSessionBasicSearchType();
            }
        }

        // Set up sort parameters
        function SetUpSortOrder() {
            global $CCEGallery;

            // Check for Ctrl pressed
            $bCtrl = (@$_GET["ctrl"] <> "");

            // Check for "order" parameter
            if (@$_GET["order"] <> "") {
                $CCEGallery->CurrentOrder = ew_StripSlashes(@$_GET["order"]);
                $CCEGallery->CurrentOrderType = @$_GET["ordertype"];
                $CCEGallery->UpdateSort($CCEGallery->GalleryImage, $bCtrl); // GalleryImage
                $CCEGallery->UpdateSort($CCEGallery->ImageCaption, $bCtrl); // ImageCaption
                $CCEGallery->UpdateSort($CCEGallery->DateAdded, $bCtrl); // DateAdded
                $CCEGallery->setStartRecordNumber(1); // Reset start position
            }
        }

        // Load sort order parameters
        function LoadSortOrder() {
            global $CCEGallery;
            $sOrderBy = $CCEGallery->getSessionOrderBy(); // Get ORDER BY from Session
            if ($sOrderBy == "") {
                if ($CCEGallery->SqlOrderBy() <> "") {
                    $sOrderBy = $CCEGallery->SqlOrderBy();
                    $CCEGallery->setSessionOrderBy($sOrderBy);
                    $CCEGallery->DateAdded->setSort("DESC");
                }
            }
        }

        // Reset command
        // cmd=reset (Reset search parameters)
        // cmd=resetall (Reset search and master/detail parameters)
        // cmd=resetsort (Reset sort parameters)
        function ResetCmd() {
            global $CCEGallery;

            // Get reset command
            if (@$_GET["cmd"] <> "") {
                $sCmd = $_GET["cmd"];

                // Reset search criteria
                if (strtolower($sCmd) == "reset" || strtolower($sCmd) == "resetall")
                    $this->ResetSearchParms();

                // Reset sorting order
                if (strtolower($sCmd) == "resetsort") {
                    $sOrderBy = "";
                    $CCEGallery->setSessionOrderBy($sOrderBy);
                    $CCEGallery->GalleryImage->setSort("");
                    $CCEGallery->ImageCaption->setSort("");
                    $CCEGallery->DateAdded->setSort("");
                }

                // Reset start position
                $this->lStartRec = 1;
                $CCEGallery->setStartRecordNumber($this->lStartRec);
            }
        }

        // Set up list options
        function SetupListOptions() {
            global $Security, $CCEGallery;

            // "edit"
            $this->ListOptions->Add("edit");
            $item = & $this->ListOptions->Items["edit"];
            $item->CssStyle = "white-space: nowrap;";
            $item->Visible = $Security->CanEdit();
            $item->OnLeft = FALSE;

            // "delete"
            $this->ListOptions->Add("delete");
            $item = & $this->ListOptions->Items["delete"];
            $item->CssStyle = "white-space: nowrap;";
            $item->Visible = $Security->CanDelete();
            $item->OnLeft = FALSE;

            // Call ListOptions_Load event
            $this->ListOptions_Load();
            if ($CCEGallery->Export <> "" ||
                    $CCEGallery->CurrentAction == "gridadd" ||
                    $CCEGallery->CurrentAction == "gridedit")
                $this->ListOptions->HideAllOptions();
        }

        // Render list options
        function RenderListOptions() {
            global $Security, $Language, $CCEGallery;
            $this->ListOptions->LoadDefault();

            // "edit"
            $oListOpt = & $this->ListOptions->Items["edit"];
            if ($Security->CanEdit() && $oListOpt->Visible) {
                $oListOpt->Body = "<a href=\"" . $this->EditUrl . "\">" . "<img src=\"images/edit.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("EditLink")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("EditLink")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>";
            }

            // "delete"
            $oListOpt = & $this->ListOptions->Items["delete"];
            if ($Security->CanDelete() && $oListOpt->Visible)
                $oListOpt->Body = "<a" . "" . " href=\"" . $this->DeleteUrl . "\">" . "<img src=\"images/delete.gif\" alt=\"" . ew_HtmlEncode($Language->Phrase("DeleteLink")) . "\" title=\"" . ew_HtmlEncode($Language->Phrase("DeleteLink")) . "\" width=\"16\" height=\"16\" border=\"0\">" . "</a>";
            $this->RenderListOptionsExt();

            // Call ListOptions_Rendered event
            $this->ListOptions_Rendered();
        }

        function RenderListOptionsExt() {
            global $Security, $Language, $CCEGallery;
        }

        // Set up starting record parameters
        function SetUpStartRec() {
            global $CCEGallery;
            if ($this->lDisplayRecs == 0)
                return;
            if ($this->IsPageRequest()) { // Validate request
                if (@$_GET[EW_TABLE_START_REC] <> "") { // Check for "start" parameter
                    $this->lStartRec = $_GET[EW_TABLE_START_REC];
                    $CCEGallery->setStartRecordNumber($this->lStartRec);
                } elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
                    $this->nPageNo = $_GET[EW_TABLE_PAGE_NO];
                    if (is_numeric($this->nPageNo)) {
                        $this->lStartRec = ($this->nPageNo - 1) * $this->lDisplayRecs + 1;
                        if ($this->lStartRec <= 0) {
                            $this->lStartRec = 1;
                        } elseif ($this->lStartRec >= intval(($this->lTotalRecs - 1) / $this->lDisplayRecs) * $this->lDisplayRecs + 1) {
                            $this->lStartRec = intval(($this->lTotalRecs - 1) / $this->lDisplayRecs) * $this->lDisplayRecs + 1;
                        }
                        $CCEGallery->setStartRecordNumber($this->lStartRec);
                    }
                }
            }
            $this->lStartRec = $CCEGallery->getStartRecordNumber();

            // Check if correct start record counter
            if (!is_numeric($this->lStartRec) || $this->lStartRec == "") { // Avoid invalid start record counter
                $this->lStartRec = 1; // Reset start record counter
                $CCEGallery->setStartRecordNumber($this->lStartRec);
            } elseif (intval($this->lStartRec) > intval($this->lTotalRecs)) { // Avoid starting record > total records
                $this->lStartRec = intval(($this->lTotalRecs - 1) / $this->lDisplayRecs) * $this->lDisplayRecs + 1; // Point to last page first record
                $CCEGallery->setStartRecordNumber($this->lStartRec);
            } elseif (($this->lStartRec - 1) % $this->lDisplayRecs <> 0) {
                $this->lStartRec = intval(($this->lStartRec - 1) / $this->lDisplayRecs) * $this->lDisplayRecs + 1; // Point to page boundary
                $CCEGallery->setStartRecordNumber($this->lStartRec);
            }
        }

        // Load basic search values
        function LoadBasicSearchValues() {
            global $CCEGallery;
            $CCEGallery->BasicSearchKeyword = @$_GET[EW_TABLE_BASIC_SEARCH];
            $CCEGallery->BasicSearchType = @$_GET[EW_TABLE_BASIC_SEARCH_TYPE];
        }

        // Load recordset
        function LoadRecordset($offset = -1, $rowcnt = -1) {
            global $conn, $CCEGallery;

            // Call Recordset Selecting event
            $CCEGallery->Recordset_Selecting($CCEGallery->CurrentFilter);

            // Load List page SQL
            $sSql = $CCEGallery->SelectSQL();
            if ($offset > -1 && $rowcnt > -1)
                $sSql .= " LIMIT $offset, $rowcnt";

            // Load recordset
            $rs = ew_LoadRecordset($sSql);

            // Call Recordset Selected event
            $CCEGallery->Recordset_Selected($rs);
            return $rs;
        }

        // Load row based on key values
        function LoadRow() {
            global $conn, $Security, $CCEGallery;
            $sFilter = $CCEGallery->KeyFilter();

            // Call Row Selecting event
            $CCEGallery->Row_Selecting($sFilter);

            // Load SQL based on filter
            $CCEGallery->CurrentFilter = $sFilter;
            $sSql = $CCEGallery->SQL();
            $res = FALSE;
            $rs = ew_LoadRecordset($sSql);
            if ($rs && !$rs->EOF) {
                $res = TRUE;
                $this->LoadRowValues($rs); // Load row values
                // Call Row Selected event
                $CCEGallery->Row_Selected($rs);
                $rs->Close();
            }
            return $res;
        }

        // Load row values from recordset
        function LoadRowValues(&$rs) {
            global $conn, $CCEGallery;
            $CCEGallery->CCEGalleryID->setDbValue($rs->fields('CCEGalleryID'));
            $CCEGallery->GalleryImage->Upload->DbValue = $rs->fields('GalleryImage');
            $CCEGallery->ImageCaption->setDbValue($rs->fields('ImageCaption'));
            $CCEGallery->DateAdded->setDbValue($rs->fields('DateAdded'));
            $CCEGallery->Archived->setDbValue($rs->fields('Archived'));
        }

        // Render row values based on field settings
        function RenderRow() {
            global $conn, $Security, $Language, $CCEGallery;

            // Initialize URLs
            $this->ViewUrl = $CCEGallery->ViewUrl();
            $this->EditUrl = $CCEGallery->EditUrl();
            $this->InlineEditUrl = $CCEGallery->InlineEditUrl();
            $this->CopyUrl = $CCEGallery->CopyUrl();
            $this->InlineCopyUrl = $CCEGallery->InlineCopyUrl();
            $this->DeleteUrl = $CCEGallery->DeleteUrl();

            // Call Row_Rendering event
            $CCEGallery->Row_Rendering();

            // Common render codes for all row types
            // GalleryImage

            $CCEGallery->GalleryImage->CellCssStyle = "";
            $CCEGallery->GalleryImage->CellCssClass = "";
            $CCEGallery->GalleryImage->CellAttrs = array();
            $CCEGallery->GalleryImage->ViewAttrs = array();
            $CCEGallery->GalleryImage->EditAttrs = array();

            // ImageCaption
            $CCEGallery->ImageCaption->CellCssStyle = "";
            $CCEGallery->ImageCaption->CellCssClass = "";
            $CCEGallery->ImageCaption->CellAttrs = array();
            $CCEGallery->ImageCaption->ViewAttrs = array();
            $CCEGallery->ImageCaption->EditAttrs = array();

            // DateAdded
            $CCEGallery->DateAdded->CellCssStyle = "";
            $CCEGallery->DateAdded->CellCssClass = "";
            $CCEGallery->DateAdded->CellAttrs = array();
            $CCEGallery->DateAdded->ViewAttrs = array();
            $CCEGallery->DateAdded->EditAttrs = array();
            if ($CCEGallery->RowType == EW_ROWTYPE_VIEW) { // View row
                // CCEGalleryID
                $CCEGallery->CCEGalleryID->ViewValue = $CCEGallery->CCEGalleryID->CurrentValue;
                $CCEGallery->CCEGalleryID->CssStyle = "";
                $CCEGallery->CCEGalleryID->CssClass = "";
                $CCEGallery->CCEGalleryID->ViewCustomAttributes = "";

                // GalleryImage
                if (!ew_Empty($CCEGallery->GalleryImage->Upload->DbValue)) {
                    $CCEGallery->GalleryImage->ViewValue = $CCEGallery->GalleryImage->Upload->DbValue;
                    $CCEGallery->GalleryImage->ImageWidth = 200;
                    $CCEGallery->GalleryImage->ImageHeight = 0;
                    $CCEGallery->GalleryImage->ImageAlt = $CCEGallery->GalleryImage->FldAlt();
                } else {
                    $CCEGallery->GalleryImage->ViewValue = "";
                }
                $CCEGallery->GalleryImage->CssStyle = "";
                $CCEGallery->GalleryImage->CssClass = "";
                $CCEGallery->GalleryImage->ViewCustomAttributes = "";

                // ImageCaption
                $CCEGallery->ImageCaption->ViewValue = $CCEGallery->ImageCaption->CurrentValue;
                $CCEGallery->ImageCaption->CssStyle = "";
                $CCEGallery->ImageCaption->CssClass = "";
                $CCEGallery->ImageCaption->ViewCustomAttributes = "";

                // DateAdded
                $CCEGallery->DateAdded->ViewValue = $CCEGallery->DateAdded->CurrentValue;
                $CCEGallery->DateAdded->ViewValue = ew_FormatDateTime($CCEGallery->DateAdded->ViewValue, 5);
                $CCEGallery->DateAdded->CssStyle = "";
                $CCEGallery->DateAdded->CssClass = "";
                $CCEGallery->DateAdded->ViewCustomAttributes = "";

                // Archived
                if (strval($CCEGallery->Archived->CurrentValue) <> "") {
                    switch ($CCEGallery->Archived->CurrentValue) {
                        case "1":
                            $CCEGallery->Archived->ViewValue = "Yes";
                            break;
                        case "0":
                            $CCEGallery->Archived->ViewValue = "No";
                            break;
                        default:
                            $CCEGallery->Archived->ViewValue = $CCEGallery->Archived->CurrentValue;
                    }
                } else {
                    $CCEGallery->Archived->ViewValue = NULL;
                }
                $CCEGallery->Archived->CssStyle = "";
                $CCEGallery->Archived->CssClass = "";
                $CCEGallery->Archived->ViewCustomAttributes = "";

                // GalleryImage
                $CCEGallery->GalleryImage->HrefValue = "";
                $CCEGallery->GalleryImage->TooltipValue = "";

                // ImageCaption
                $CCEGallery->ImageCaption->HrefValue = "";
                $CCEGallery->ImageCaption->TooltipValue = "";

                // DateAdded
                $CCEGallery->DateAdded->HrefValue = "";
                $CCEGallery->DateAdded->TooltipValue = "";
            }

            // Call Row Rendered event
            if ($CCEGallery->RowType <> EW_ROWTYPE_AGGREGATEINIT)
                $CCEGallery->Row_Rendered();
        }

        // Export data in HTML/CSV/Word/Excel/XML/Email format
        function ExportData() {
            global $CCEGallery;
            $utf8 = FALSE;
            $bSelectLimit = EW_SELECT_LIMIT;

            // Load recordset
            if ($bSelectLimit) {
                $this->lTotalRecs = $CCEGallery->SelectRecordCount();
            } else {
                if ($rs = $this->LoadRecordset())
                    $this->lTotalRecs = $rs->RecordCount();
            }
            $this->lStartRec = 1;

            // Export all
            if ($CCEGallery->ExportAll) {
                $this->lDisplayRecs = $this->lTotalRecs;
                $this->lStopRec = $this->lTotalRecs;
            } else { // Export one page only
                $this->SetUpStartRec(); // Set up start record position
                // Set the last record to display
                if ($this->lDisplayRecs < 0) {
                    $this->lStopRec = $this->lTotalRecs;
                } else {
                    $this->lStopRec = $this->lStartRec + $this->lDisplayRecs - 1;
                }
            }
            if ($bSelectLimit)
                $rs = $this->LoadRecordset($this->lStartRec - 1, $this->lDisplayRecs);
            if (!$rs) {
                header("Content-Type:"); // Remove header
                header("Content-Disposition:");
                $this->ShowMessage();
                return;
            }
            if ($CCEGallery->Export == "xml") {
                $XmlDoc = new cXMLDocument(EW_XML_ENCODING);
                $XmlDoc->AddRoot();
            } else {
                $ExportDoc = new cExportDocument($CCEGallery, "h");
                $ExportDoc->ExportHeader();
                if ($ExportDoc->Horizontal) { // Horizontal format, write header
                    $ExportDoc->BeginExportRow();
                    $ExportDoc->ExportCaption($CCEGallery->CCEGalleryID);
                    $ExportDoc->ExportCaption($CCEGallery->GalleryImage);
                    $ExportDoc->ExportCaption($CCEGallery->ImageCaption);
                    $ExportDoc->ExportCaption($CCEGallery->DateAdded);
                    $ExportDoc->ExportCaption($CCEGallery->Archived);
                    $ExportDoc->EndExportRow();
                }
            }

            // Move to first record
            $this->lRecCnt = $this->lStartRec - 1;
            if (!$rs->EOF) {
                $rs->MoveFirst();
                if (!$bSelectLimit && $this->lStartRec > 1)
                    $rs->Move($this->lStartRec - 1);
            }
            while (!$rs->EOF && $this->lRecCnt < $this->lStopRec) {
                $this->lRecCnt++;
                if (intval($this->lRecCnt) >= intval($this->lStartRec)) {
                    $this->LoadRowValues($rs);

                    // Render row
                    $CCEGallery->CssClass = "";
                    $CCEGallery->CssStyle = "";
                    $CCEGallery->RowType = EW_ROWTYPE_VIEW; // Render view
                    $this->RenderRow();
                    if ($CCEGallery->Export == "xml") {
                        $XmlDoc->AddRow();
                        $XmlDoc->AddField('CCEGalleryID', $CCEGallery->CCEGalleryID->ExportValue($CCEGallery->Export, $CCEGallery->ExportOriginalValue));
                        $XmlDoc->AddField('GalleryImage', $CCEGallery->GalleryImage->ExportValue($CCEGallery->Export, $CCEGallery->ExportOriginalValue));
                        $XmlDoc->AddField('ImageCaption', $CCEGallery->ImageCaption->ExportValue($CCEGallery->Export, $CCEGallery->ExportOriginalValue));
                        $XmlDoc->AddField('DateAdded', $CCEGallery->DateAdded->ExportValue($CCEGallery->Export, $CCEGallery->ExportOriginalValue));
                        $XmlDoc->AddField('Archived', $CCEGallery->Archived->ExportValue($CCEGallery->Export, $CCEGallery->ExportOriginalValue));
                    } else {
                        $ExportDoc->BeginExportRow(TRUE); // Allow CSS styles if enabled
                        $ExportDoc->ExportField($CCEGallery->CCEGalleryID);
                        $ExportDoc->ExportField($CCEGallery->GalleryImage);
                        $ExportDoc->ExportField($CCEGallery->ImageCaption);
                        $ExportDoc->ExportField($CCEGallery->DateAdded);
                        $ExportDoc->ExportField($CCEGallery->Archived);
                        $ExportDoc->EndExportRow();
                    }
                }
                $rs->MoveNext();
            }
            if ($CCEGallery->Export <> "xml")
                $ExportDoc->ExportFooter();

            // Close recordset
            $rs->Close();

            // Clean output buffer
            if (!EW_DEBUG_ENABLED && ob_get_length())
                ob_end_clean();

            // Write BOM if utf-8
            if ($utf8 && !in_array($CCEGallery->Export, array("email", "xml")))
                echo "\xEF\xBB\xBF";

            // Write debug message if enabled
            if (EW_DEBUG_ENABLED)
                echo ew_DebugMsg();

            // Output data
            if ($CCEGallery->Export == "xml") {
                header("Content-Type: text/xml");
                echo $XmlDoc->XML();
            } elseif ($CCEGallery->Export == "email") {
                $this->ExportEmail($ExportDoc->Text);
                $this->Page_Terminate($CCEGallery->ExportReturnUrl());
            } else {
                echo $ExportDoc->Text;
            }
        }

        // Export email
        function ExportEmail($EmailContent) {
            global $Language, $CCEGallery;
            $sSender = @$_GET["sender"];
            $sRecipient = @$_GET["recipient"];
            $sCc = @$_GET["cc"];
            $sBcc = @$_GET["bcc"];
            $sContentType = @$_GET["contenttype"];

            // Subject
            $sSubject = ew_StripSlashes(@$_GET["subject"]);
            $sEmailSubject = $sSubject;

            // Message
            $sContent = ew_StripSlashes(@$_GET["message"]);
            $sEmailMessage = $sContent;

            // Check sender
            if ($sSender == "") {
                $this->setMessage($Language->Phrase("EnterSenderEmail"));
                return;
            }
            if (!ew_CheckEmail($sSender)) {
                $this->setMessage($Language->Phrase("EnterProperSenderEmail"));
                return;
            }

            // Check recipient
            if (!ew_CheckEmailList($sRecipient, EW_MAX_EMAIL_RECIPIENT)) {
                $this->setMessage($Language->Phrase("EnterProperRecipientEmail"));
                return;
            }

            // Check cc
            if (!ew_CheckEmailList($sCc, EW_MAX_EMAIL_RECIPIENT)) {
                $this->setMessage($Language->Phrase("EnterProperCcEmail"));
                return;
            }

            // Check bcc
            if (!ew_CheckEmailList($sBcc, EW_MAX_EMAIL_RECIPIENT)) {
                $this->setMessage($Language->Phrase("EnterProperBccEmail"));
                return;
            }

            // Check email sent count
            if (!isset($_SESSION[EW_EXPORT_EMAIL_COUNTER]))
                $_SESSION[EW_EXPORT_EMAIL_COUNTER] = 0;
            if (intval($_SESSION[EW_EXPORT_EMAIL_COUNTER]) > EW_MAX_EMAIL_SENT_COUNT) {
                $this->setMessage($Language->Phrase("ExceedMaxEmailExport"));
                return;
            }
            if ($sEmailMessage <> "") {
                $sEmailMessage = ew_RemoveXSS($sEmailMessage);
                $sEmailMessage .= ($sContentType == "url") ? "\r\n\r\n" : "<br><br>";
            }
            if ($sContentType == "url") {
                $sUrl = ew_ConvertFullUrl(ew_CurrentPage() . "?" . $this->ExportQueryString());
                $sEmailMessage .= $sUrl; // send URL only
            } else {
                $sEmailMessage .= $EmailContent; // send HTML
            }

            // Send email
            $Email = new cEmail();
            $Email->Sender = $sSender; // Sender
            $Email->Recipient = $sRecipient; // Recipient
            $Email->Cc = $sCc; // Cc
            $Email->Bcc = $sBcc; // Bcc
            $Email->Subject = $sEmailSubject; // Subject
            $Email->Content = $sEmailMessage; // Content
            $Email->Format = ($sContentType == "url") ? "text" : "html";
            $Email->Charset = EW_EMAIL_CHARSET;
            $EventArgs = array();
            $bEmailSent = FALSE;
            if ($CCEGallery->Email_Sending($Email, $EventArgs))
                $bEmailSent = $Email->Send();

            // Check email sent status
            if ($bEmailSent) {

                // Update email sent count
                $_SESSION[EW_EXPORT_EMAIL_COUNTER] ++;

                // Sent email success
                $this->setMessage($Language->Phrase("SendEmailSuccess"));
            } else {

                // Sent email failure
                $this->setMessage($Email->SendErrDescription);
            }
        }

        // Export QueryString
        function ExportQueryString() {
            global $CCEGallery;

            // Initialize
            $sQry = "export=html";

            // Build QueryString for search
            if ($CCEGallery->getSessionBasicSearchKeyword() <> "") {
                $sQry .= "&" . EW_TABLE_BASIC_SEARCH . "=" . $CCEGallery->getSessionBasicSearchKeyword() . "&" . EW_TABLE_BASIC_SEARCH_TYPE . "=" . $CCEGallery->getSessionBasicSearchType();
            }

            // Build QueryString for pager
            $sQry .= "&" . EW_TABLE_REC_PER_PAGE . "=" . $CCEGallery->getRecordsPerPage() . "&" . EW_TABLE_START_REC . "=" . $CCEGallery->getStartRecordNumber();
            return $sQry;
        }

        // Add search QueryString
        function AddSearchQueryString(&$Qry, &$Fld) {
            global $CCEGallery;
            $FldParm = substr($Fld->FldVar, 2);
            $FldSearchValue = $CCEGallery->GetAdvancedSearch("x_" . $FldParm);
            if (strval($FldSearchValue) <> "") {
                $Qry .= "&x_" . $FldParm . "=" . FldSearchValue .
                        "&z_" . $FldParm . "=" . $CCEGallery->GetAdvancedSearch("z_" . $FldParm);
            }
            $FldSearchValue2 = $CCEGallery->GetAdvancedSearch("y_" . $FldParm);
            if (strval($FldSearchValue2) <> "") {
                $Qry .= "&v_" . $FldParm . "=" . $CCEGallery->GetAdvancedSearch("v_" . $FldParm) .
                        "&y_" . $FldParm . "=" . $FldSearchValue2 .
                        "&w_" . $FldParm . "=" . $CCEGallery->GetAdvancedSearch("w_" . $FldParm);
            }
        }

        // Page Load event
        function Page_Load() {

            //echo "Page Load";
        }

        // Page Unload event
        function Page_Unload() {

            //echo "Page Unload";
        }

        // Page Redirecting event
        function Page_Redirecting(&$url) {

            // Example:
            //$url = "your URL";
        }

        // Message Showing event
        function Message_Showing(&$msg) {

            // Example:
            //$msg = "your new message";
        }

        // Form Custom Validate event
        function Form_CustomValidate(&$CustomError) {

            // Return error message in CustomError
            return TRUE;
        }

        // ListOptions Load event
        function ListOptions_Load() {

            // Example:
            //$this->ListOptions->Add("new");
            //$this->ListOptions->Items["new"]->OnLeft = TRUE; // Link on left
            //$this->ListOptions->MoveItem("new", 0); // Move to first column
        }

        // ListOptions Rendered event
        function ListOptions_Rendered() {

            // Example:
            //$this->ListOptions->Items["new"]->Body = "xxx";
        }

    }
    ?>