Ejemplo n.º 1
0
 private function render()
 {
     $this->_breadcrumbs = HTML::backendBreadcrumbs($this->_breadcrumbs);
     $data = array();
     foreach ($this as $key => $value) {
         $data[$key] = $value;
     }
     echo View::tpl($data, $this->_template);
     echo System::global_massage();
 }
Ejemplo n.º 2
0
 /**
  *  Delete image
  *  @param string $mainFolder - name of th block in Config/images.php
  *  @param string $filename   - name of the file we delete
  *  @return bool
  */
 public static function deleteImage($mainFolder, $filename)
 {
     $need = Config::get('images.' . $mainFolder);
     if (!$need) {
         return false;
     }
     foreach ($need as $one) {
         $file = HOST . HTML::media('/images/' . $mainFolder . '/' . Arr::get($one, 'path') . '/' . $filename);
         @unlink($file);
     }
     return true;
 }
Ejemplo n.º 3
0
 private function render()
 {
     if (Config::get('error')) {
         $this->_template = '404';
     }
     $this->_breadcrumbs = HTML::breadcrumbs($this->_breadcrumbs);
     $data = array();
     foreach ($this as $key => $value) {
         $data[$key] = $value;
     }
     echo View::tpl($data, $this->_template);
     echo System::global_massage();
 }
Ejemplo n.º 4
0
 public function getItemsAction()
 {
     $id = Arr::get($_POST, 'parent_id');
     $result = DB::select('catalog.*', 'catalog_images.image')->from('catalog')->join('catalog_images')->on('catalog_images.catalog_id', '=', 'catalog.id')->on('catalog_images.main', '=', DB::expr(1))->where('parent_id', '=', $id)->order_by('created_at', 'DESC')->find_all();
     $data = array();
     foreach ($result as $obj) {
         $data[] = array('image' => is_file(HOST . HTML::media('images/catalog/medium/' . $obj->image)) ? HTML::media('images/catalog/medium/' . $obj->image) : '', 'name' => $obj->name, 'cost' => $obj->cost, 'id' => $obj->id);
     }
     die(json_encode(array('success' => true, 'result' => $data)));
 }
Ejemplo n.º 5
0
 public function moreAffisheAction()
 {
     $page = (int) Arr::get($_POST, 'page');
     if (!isset($page)) {
         $this->error('Ошибка загрузки');
     }
     // list posts
     if (isset($_SESSION['idCity'])) {
         // select places id
         $places = DB::select('id')->from('places')->where('city_id', '=', $_SESSION['idCity'])->where('status', '=', DB::expr(1))->as_object()->execute();
         $ids = array();
         foreach ($places as $key => $value) {
             $ids[] = $value->id;
         }
         if (count($ids) == 0) {
             $ids[] = 0;
         }
     }
     $dbObj = DB::select('afisha.*', array('places.name', 'p_name'), array(DB::expr('MIN(prices.price)'), 'p_from'), array(DB::expr('MAX(prices.price)'), 'p_to'))->from('afisha')->join('places', 'left outer')->on('afisha.place_id', '=', 'places.id')->on('places.status', '=', DB::expr(1))->join('prices', 'left outer')->on('afisha.id', '=', 'prices.afisha_id')->where('afisha.status', '=', 1)->where('afisha.event_date', '>', DB::expr(time()));
     if (isset($_SESSION['idCity'])) {
         $dbObj->where_open()->where('afisha.place_id', 'IN', $ids)->or_where('afisha.city_id', '=', $_SESSION['idCity'])->where_close();
     }
     $result = $dbObj->group_by('afisha.id')->order_by('afisha.event_date')->limit(Config::get('limit'))->offset(($page - 1) * (int) Config::get('limit'))->execute()->as_array();
     foreach ($result as $key => $value) {
         $result[$key]['p_name'] = Afisha\Models\Afisha::getItemPlace($value, true);
         $result[$key]['cost'] = Afisha\Models\Afisha::getItemPrice($value, true);
         $result[$key]['event_date'] = date('j', $value['event_date']) . ' ' . Dates::month(date('n', $value['event_date'])) . ' ' . date('Y', $value['event_date']);
         if (!is_file(HOST . HTML::media('images/afisha/medium/' . $value['image']))) {
             $result[$key]['image'] = false;
         }
     }
     // Count of all posts
     $dbObj = DB::select(array(DB::expr('COUNT(afisha.id)'), 'count'))->from('afisha');
     if (isset($_SESSION['idCity'])) {
         $dbObj->where_open()->where('afisha.place_id', 'IN', $ids)->or_where('afisha.city_id', '=', $_SESSION['idCity'])->where_close();
     }
     $count = $dbObj->where('afisha.status', '=', 1)->where('afisha.event_date', '>', DB::expr(time()))->as_object()->execute()->current()->count;
     // Set view button more load
     $showBut = true;
     if ($count <= Config::get('limit') * $page) {
         $showBut = false;
     }
     // Render template
     $this->success(array('result' => $result, 'showBut' => $showBut));
 }
Ejemplo n.º 6
0
                    Изображение
                </div>
            </div>
            <div class="widgetContent">
                <div class="form-vertical row-border">
                    <div class="form-group">
                        <div class="">
                            <?php 
if (is_file(HOST . \Core\HTML::media('images/afisha/medium/' . $obj->image))) {
    ?>
                                <a href="<?php 
    echo \Core\HTML::media('images/afisha/medium/' . $obj->image);
    ?>
" rel="lightbox">
                                    <img src="<?php 
    echo \Core\HTML::media('images/afisha/medium/' . $obj->image);
    ?>
" style="max-width: 100%;"/>
                                </a>
                                <br />
                                <a href="/backend/<?php 
    echo \Core\Route::controller();
    ?>
/delete_image/<?php 
    echo $obj->id;
    ?>
">Удалить изображение</a>
                            <?php 
} else {
    ?>
                                <input type="file" name="file" style="max-width: 100%;" />
Ejemplo n.º 7
0
 function deleteAction()
 {
     $id = (int) Route::param('id');
     if (!$id) {
         Message::GetMessage(0, 'Данные не существуют!');
         HTTP::redirect('backend/' . Route::controller() . '/index');
     }
     $page = DB::select()->from($this->tablename)->where('id', '=', $id)->find();
     if (!$page) {
         Message::GetMessage(0, 'Данные не существуют!');
         HTTP::redirect('backend/' . Route::controller() . '/index');
     }
     $images = DB::select()->from('catalog_images')->where('catalog_id', '=', $id)->find_all();
     foreach ($images as $im) {
         @unlink(HOST . HTML::media('images/catalog/small/' . $im->image));
         @unlink(HOST . HTML::media('images/catalog/medium/' . $im->image));
         @unlink(HOST . HTML::media('images/catalog/big/' . $im->image));
         @unlink(HOST . HTML::media('images/catalog/original/' . $im->image));
     }
     DB::delete($this->tablename)->where('id', '=', $id)->execute();
     Message::GetMessage(1, 'Данные удалены!');
     HTTP::redirect('backend/' . Route::controller() . '/index');
 }
Ejemplo n.º 8
0
 /**
  * Render the given field
  *
  * @return string
  */
 protected function render_field()
 {
     $html = "\n";
     if (!$this->attributes) {
         $this->attributes = array();
     }
     // Configure the attributes
     $attributes = $this->attributes;
     // Get the current value
     if ($this->value !== NULL) {
         $value = $this->value;
     } else {
         $value = $this->validation->value($this->field);
     }
     if ($this->label) {
         $html .= '<label for="' . $this->field . '">' . $this->label . "</label>";
     }
     if ($this->type == 'select') {
         $html .= \Core\HTML::select($this->field, $this->options, $value, $attributes);
     } elseif ($this->type == 'textarea') {
         $html .= \Core\HTML::tag('textarea', $value, $attributes);
     } else {
         // Input field
         $attributes = $attributes + array('type' => $this->type, 'value' => $value);
         $html .= \Core\HTML::tag('input', FALSE, $attributes);
     }
     // If there was a validation error
     if ($error = $this->validation->error($this->field)) {
         if (isset($attributes['class'])) {
             $attributes['class'] .= ' error';
         } else {
             $attributes['class'] = $this->field . ' ' . $this->type . ' error';
         }
         $html .= "\n<div class=\"error_message\">{$error}</div>";
     }
     if ($this->tag) {
         $html = \Core\HTML::tag($this->tag, $html . "\n") . "\n";
     }
     return $html;
 }
Ejemplo n.º 9
0
<script src="<?php 
echo HTML::media("js/jquery-1.11.0.min.js");
?>
"></script>
<script src="<?php 
echo HTML::media("js/plugins.js");
?>
"></script>
<script src="<?php 
echo HTML::media("js/init.js");
?>
"></script>

<script type="text/javascript" src="<?php 
echo HTML::media('js/noty/jquery.noty.js');
?>
"></script>
<script type="text/javascript" src="<?php 
echo HTML::media('js/noty/layouts/massageOutput.js');
?>
"></script>
<script type="text/javascript" src="<?php 
echo HTML::media('js/noty/themes/default.js');
?>
"></script>

<script src="<?php 
echo HTML::media("js/prog.js");
?>
"></script>
Ejemplo n.º 10
0
        echo $content;
        ?>
</a>
        <?php 
    }
    ?>
    <?php 
}
?>
    
    <?php 
if ($_navigation) {
    ?>
        <?php 
    if ($_next !== FALSE) {
        ?>
            <a href="<?php 
        echo \Core\HTML::chars($page->url($_next));
        ?>
" rel="next">Следующая</a>
        <?php 
    } else {
        ?>
            Следующая
        <?php 
    }
    ?>
    <?php 
}
?>
</div>
Ejemplo n.º 11
0
 public function orderAction()
 {
     // Check incoming data
     $name = Text::xssClean(Arr::get($this->post, 'name'));
     if (!$name) {
         $this->error('Вы не указали имя!');
     }
     $email = Text::xssClean(Arr::get($this->post, 'email'));
     if (!$email or !filter_var($email, FILTER_VALIDATE_EMAIL)) {
         $this->error('Вы указали неверный e-mail!');
     }
     $phone = Text::xssClean(Arr::get($this->post, 'phone'));
     if (!$phone or !preg_match('/\\(\\d{3}\\)\\s\\d{3}-\\d{2}-\\d{2}/', $phone, $matches)) {
         $this->error('Вы указали неверный телефон!');
     }
     $places = Text::xssClean(Arr::get($this->post, 'seats'));
     $places = array_filter(explode(',', $places));
     if (!$places or !is_array($places)) {
         $this->error('Вы не выбрали места!');
     }
     $message = nl2br(Text::xssClean(Arr::get($this->post, 'message', null)));
     $afishaId = (int) Text::xssClean(Arr::get($this->post, 'id'));
     // Get prices by afisha ID
     $prices = DB::select('id')->from('prices')->where('afisha_id', '=', $afishaId)->find_all();
     if (count($prices) == 0) {
         $this->error('Ошибка создания заказа (выборка цен)');
     }
     $pricesIds = array();
     foreach ($prices as $price) {
         $pricesIds[] = $price->id;
     }
     // Generate seats id from places list
     $seats = DB::select('id')->from('seats')->where('view_key', 'IN', $places)->where('price_id', 'IN', $pricesIds)->and_where_open()->where('status', '=', 1)->or_where_open()->where('status', '=', 2)->where('reserved_at', '<', time() - 60 * 60 * 24 * conf::get('reserved_days'))->or_where_close()->and_where_close()->find_all();
     if (count($seats) == 0) {
         $this->error('Ошибка создания заказа (выборка мест)');
     }
     $seatsId = array();
     foreach ($seats as $seat) {
         $seatsId[] = $seat->id;
     }
     $data = array('afisha_id' => $afishaId, 'name' => $name, 'email' => $email, 'phone' => $phone, 'message' => $message, 'seats_keys' => implode(',', $places), 'created_at' => time(), 'first_created_at' => time(), 'updated_at' => time(), 'ip' => System::getRealIP());
     $res = \Core\Common::insert('afisha_orders', $data)->execute();
     if (!$res) {
         $this->error('ошибка создания заказа');
     }
     // Update status
     $res2 = DB::update('seats')->set(array('status' => 2, 'reserved_at' => time()))->where('id', 'IN', $seatsId)->execute();
     $afisha = DB::select()->from('afisha')->where('id', '=', $afishaId)->find();
     $data['event_name'] = $afisha->name;
     // Send email messages for adimn and user
     Afisha\Models\Afisha::sendOrderMessageAdmin(array('id_order' => $res[0], 'order' => $data, 'order_text' => Arr::get($this->post, 'order')));
     Afisha\Models\Afisha::sendOrderMessageUser(array('id_order' => $res[0], 'order' => $data, 'order_text' => Arr::get($this->post, 'order')));
     // Save log
     $qName = 'Новый заказ';
     $url = '/backend/afisha_orders/edit/' . $res[0];
     Log::add($qName, $url, 8);
     $response = array();
     // Redirect to payment system
     if (Arr::get($this->post, 'action') == 'payment') {
         $response['redirect'] = \Core\HTML::link('payment/' . $res[0]);
     } else {
         $response['reload'] = true;
     }
     $response['response'] = 'Ваш заказ отправлен';
     return $this->success($response);
 }
Ejemplo n.º 12
0
                </div>
            </div>
            <div class="widgetContent">
                <div class="form-vertical row-border">
                    <div class="form-group">
                        <label class="control-label">Изображение</label>
                        <div class="">
                            <?php 
if (is_file(HOST . \Core\HTML::media('images/articles/original/' . $obj->image))) {
    ?>
                                <a href="<?php 
    echo \Core\HTML::media('images/articles/original/' . $obj->image);
    ?>
" rel="lightbox">
                                    <img src="<?php 
    echo \Core\HTML::media('images/articles/small/' . $obj->image);
    ?>
" />
                                </a>
                                <br />
                                <a href="/backend/<?php 
    echo \Core\Route::controller();
    ?>
/delete_image/<?php 
    echo $obj->id;
    ?>
">Удалить изображение</a>
                            <?php 
} else {
    ?>
                                <input type="file" name="file" />