public function createPresenters()
 {
     parent::createPresenters();
     $table = new Table(Gallery::find()->addSort('Order'), 50, 'Table');
     $this->addPresenters($table, $up = new Button('Up', 'Up', function ($id) {
         $gallery = new Gallery($id);
         if ($gallery->Order == null) {
             $gallery->Order = 0;
         }
         $gallery->Order--;
         $gallery->save();
     }), $down = new Button('down', 'down', function ($id) {
         $gallery = new Gallery($id);
         if ($gallery->Order == null) {
             $gallery->Order = 0;
         }
         $gallery->Order++;
         $gallery->save();
     }), $delete = new Button('delete', 'delete', function ($id) {
         $g = new Gallery($id);
         $g->delete();
     }));
     $table->addTableCssClass(['table']);
     $table->NoDataHtml = '<h3 class="center-align">Oops! Nav galerijas</h3>';
     $delete->addCssClassName('btn-danger');
     $delete->setConfirmMessage('Vai jūs tiešam gribat dzēst šo galeriju?');
     $table->Columns = ['Nosaukums' => 'Title', 'Indekss' => 'Order', '' => new FixedWidthColumn($up), ' ' => new FixedWidthColumn($down), '  ' => new FixedWidthColumn($delete)];
 }
    protected function printViewContent()
    {
        $html = new HtmlPageSettings();
        $html->PageTitle = "Galerijas";
        if (CustomUser::getLoggedInUser()->IsSuperuser) {
            $html->PageRightTitle = '<a href="/portal/gallery/change/" class="btn btn-default">Mainīt</a>';
        }
        $html->PageRightTitle .= '&nbsp;<a href="gallery/add/" class="btn btn-primary">Pievienot galeriju</a>';
        ?>
        <div class="__container">
            <div class="row" style="height: 150px;">
                <?php 
        $discussions = Gallery::find()->addSort('Order');
        foreach ($discussions as $discussion) {
            print '<div class="col-xs-6 col-md-2 center-align">';
            print new GalleryPresenter($discussion);
            print '</div>';
        }
        ?>
            </div>
            <div class="__clear-floats"></div>

        </div>
        <?php 
    }
 public static function checkRecords($oldVersion, $newVersion)
 {
     if ($newVersion == 2) {
         $i = 0;
         foreach (Gallery::find() as $gallery) {
             $gallery->Order = $i++;
             $gallery->save();
         }
     }
 }
    protected function printViewContent()
    {
        parent::printViewContent();
        $discussions = Gallery::find()->addSort('Order')->setRange(0, 6);
        $users = CustomUser::find(new Equals('Enabled', 1))->addSort('UserID', false)->setRange(0, 6);
        $sql = MySql::executeStatement('SELECT Source FROM tblImage ORDER BY RAND() LIMIT 6');
        $images = [];
        while ($a = $sql->fetch(\PDO::FETCH_ASSOC)) {
            $images[] = $a['Source'];
        }
        ?>
        <div class="__container noPadding">
            <?php 
        echo new ImagePanorama($images);
        ?>
        </div>
        <div class="row">
            <div class="discussion-group col-md-6">
                <div class="__container min-height-500">
                    <div class="center-block clearfix relative">
                        <h1 style="text-align: center">
                            Top 6 Galerijas
                        </h1>
                        <a href="gallery/add/" class="btn btn-primary right-side-title">Pievienot galeriju</a>
                    </div>
                    <div class="row" style="height: 150px; text-align: center">
                        <?php 
        foreach ($discussions as $discussion) {
            print '<div class="col-md-4 center-align">';
            print new GalleryPresenter($discussion);
            print '</div>';
        }
        ?>
                    </div>
                    <div class="__clear-floats"></div>
                    <div class="__clear-floats"></div>
                </div>
            </div>
            <div class="col-md-6">
                <div class="__container noPadding min-height-500">
                    <div class="center-block clearfix relative">
                        <h1 style="text-align: center">
                            6 Jaunākie biedri portālā!
                        </h1>
                        <a href="/portal/users/" class="btn btn-primary right-side-title">Redzēt visus</a>
                    </div>
                    <div class="row">
                        <?php 
        foreach ($users as $user) {
            print '<div class="col-md-4 center-align">';
            print new ProfileSummaryPresenter($user);
            print '</div>';
        }
        ?>
                    </div>
                    <div class="__clear-floats"></div>
                </div>
            </div>
        </div>

        <?php 
    }
Exemple #5
0
 public static function checkRecords($oldVersion, $newVersion)
 {
     parent::checkRecords($oldVersion, $newVersion);
     if ($newVersion == 2) {
         foreach (Gallery::find() as $gallery) {
             $i = 0;
             foreach (Image::find(new Equals('GalleryID', $gallery->GalleryID)) as $image) {
                 $image->Order = $i++;
                 $image->save();
             }
         }
     }
 }