示例#1
0
 public function templates($path = '', $post_path = '/views')
 {
     #Helper::dd($path . ' | ' . $post_path . ' | ' . "/*");
     #Helper::dd($path.$post_path."/*");
     $templates = array();
     $temp = glob($path . $post_path . "/*");
     #Helper::dd($temp);
     if (isset($temp) && is_array($temp) && count($temp)) {
         foreach ($temp as $t => $tmp) {
             if (is_dir($tmp)) {
                 continue;
             }
             #Helper::d($tmp);
             $properties = Helper::getFileProperties($tmp);
             #var_dump($properties);
             #echo (int)(in_array('TEMPLATE_IS_NOT_SETTABLE', $properties));
             #echo "<hr/>";
             if (@$properties['TEMPLATE_IS_NOT_SETTABLE'] || !Allow::action('pages', 'advanced') && !@$properties['AVAILABLE_IN_SIMPLE_MODE']) {
                 continue;
             }
             $name = basename($tmp);
             $name = str_replace(".blade.php", "", $name);
             $templates[$name] = @$properties['TITLE'] ?: $name;
         }
     }
     #Helper::dd($templates);
     return $templates;
 }
 public function signup()
 {
     if (!Allow::enabled_module('users')) {
         return App::abort(404);
     }
     $json_request = array('status' => FALSE, 'responseText' => '', 'responseErrorText' => '', 'redirect' => FALSE);
     if (Request::ajax()) {
         $validator = Validator::make(Input::all(), User::$rules);
         if ($validator->passes()) {
             $account = User::where('email', Input::get('email'))->first();
             if (is_null($account)) {
                 if ($account = self::getRegisterAccount(Input::all())) {
                     if (Allow::enabled_module('downloads')) {
                         if (!File::exists(base_path('usersfiles/account-') . $account->id)) {
                             File::makeDirectory(base_path('usersfiles/account-') . $account->id, 777, TRUE);
                         }
                     }
                     Mail::send('emails.auth.signup', array('account' => $account), function ($message) {
                         $message->from('*****@*****.**', 'Monety.pro');
                         $message->to(Input::get('email'))->subject('Monety.pro - регистрация');
                     });
                     $json_request['responseText'] = 'Вы зарегистрированы. Мы отправили на email cсылку для активации аккаунта.';
                     $json_request['status'] = TRUE;
                 }
             } else {
             }
         } else {
             $json_request['responseText'] = 'Неверно заполнены поля';
             $json_request['responseErrorText'] = $validator->messages()->all();
         }
     } else {
         return App::abort(404);
     }
     return Response::json($json_request, 200);
 }
 public function getPhpInfo()
 {
     if (!Allow::superuser()) {
         App::abort(404);
     }
     phpinfo();
     die;
 }
 public function update()
 {
     Allow::permission($this->module['group'], 'settings');
     if (!Request::ajax()) {
         App::abort(404);
     }
     $json_request = array('status' => FALSE, 'responseText' => '', 'responseErrorText' => '', 'redirect' => FALSE);
     ## Скелет настроек из конфига
     $settings = Config::get('settings');
     $settings_sections = isset($settings['sections']) && is_callable($settings['sections']) ? $settings['sections']() : NULL;
     #Helper::ta($settings_sections);
     ## Текущие значения настроек из БД
     $settings_values = Storage::firstOrNew(['module' => 'system', 'name' => 'settings']);
     $settings_values = json_decode($settings_values->value, true);
     #Helper::tad($settings_values);
     ## Новые значения настроек - из формы
     $settings_values_new = @Input::all()['settings'];
     #Helper::tad($settings_values);
     ## Проходим все проверки, и сохраняем настройки
     ## Если в конфиге объявлены секции настроек...
     if (!is_null($settings_sections) && is_array($settings_sections) && count($settings_sections)) {
         ## Если из формы переданы новые значения настроек
         if (is_array($settings_values_new) && count($settings_values_new)) {
             ## Перебираем все секции настроек, переданных из формы
             foreach ($settings_values_new as $section_slug => $options) {
                 ## Если передана неизвестная секция - пропускаем ее
                 if (!isset($settings_sections[$section_slug]) || !is_array($settings_sections[$section_slug]) || !count($settings_sections[$section_slug])) {
                     continue;
                 }
                 #Helper::ta($settings_sections[$section_slug]);
                 ## Перебираем все опции в текущей известной секции (из конфига)
                 foreach ($settings_sections[$section_slug]['options'] as $option_slug => $option_data) {
                     #Helper::ta($section_slug . ' / ' . $option_slug . ' => ');
                     $value = isset($options[$option_slug]) ? $options[$option_slug] : NULL;
                     ## If handler of field is defined
                     if (is_callable($handler = @$option_data['handler'])) {
                         #Helper::d($handler);
                         #var_dump($value);
                         $value = $handler($value);
                     }
                     if ($value === false) {
                         continue;
                     }
                     #var_dump($value);
                     $settings_values[$section_slug][$option_slug] = $value;
                 }
             }
         }
     }
     ## СОХРАНЕНИЕ
     #Helper::tad($settings_values);
     Storage::updateOrCreate(['module' => 'system', 'name' => 'settings'], ['value' => json_encode($settings_values)]);
     ## КЕШИРОВАНИЕ
     Cache::forever('cms.settings', $settings_values);
     $json_request['responseText'] = 'Сохранено';
     $json_request['status'] = TRUE;
     return Response::json($json_request, 200);
 }
示例#5
0
 public static function returnExtFormElements()
 {
     $mod_tpl = static::returnTpl();
     $class = __CLASS__;
     ##
     ## EXTFORM SEO
     ##
     ExtForm::add("seo", function ($name = 'seo', $value = '', $params = null) use($mod_tpl, $class) {
         if (!Allow::action('seo', 'edit', true)) {
             return false;
         }
         ## default template
         $tpl = "extform_seo";
         ## custom template
         if (@$params['tpl']) {
             $tpl = $params['tpl'];
             unset($params['tpl']);
         }
         #$value = $element_meta->seo;
         /*
                         ## Don't work with i18n versions
                         if ( $value === false || $value === null ) {
                             $val = Form::text($name);
                             Helper::dd($val);
                             preg_match("~value=['\"]([^'\"]+?)['\"]~is", $val, $matches);
                             Helper::dd($matches);
                             $val = @$matches[1];
                             $array = json_decode($val, true);
                             if ($array)
                                 $value = $array;
                         }
                         #*/
         ## return view with form element
         return View::make($mod_tpl . $tpl, compact('name', 'value', 'params'));
     }, function ($params) use($mod_tpl, $class) {
         #Helper::dd($params);
         $module = isset($params['module']) ? $params['module'] : false;
         $unit_id = isset($params['unit_id']) ? $params['unit_id'] : false;
         $data = isset($params['data']) ? $params['data'] : false;
         $locale = isset($params['locale']) ? $params['locale'] : NULL;
         if (!$module || !$unit_id) {
             return false;
         }
         #Helper::dd($data);
         #$data['module'] = $module;
         #$data['unit_id'] = $unit_id;
         #Helper::dd($data);
         foreach ($data as $d => $dat) {
             if (!is_string($dat)) {
                 continue;
             }
             $data[$d] = trim($dat);
         }
         $seo = Seo::firstOrCreate(array('module' => $module, 'unit_id' => $unit_id, 'language' => $locale));
         $seo->update($data);
         return $seo;
     });
 }
示例#6
0
 public static function getSidebarModules()
 {
     $start_page = AuthAccount::getStartPage();
     $menu = array();
     ## Modules info
     $mod_info = Config::get('mod_info');
     $mod_menu = Config::get('mod_menu');
     #Helper::dd($mod_info);
     #Helper::d($mod_menu);
     $dic_entities = array();
     if (class_exists('AdminDicvalsController')) {
         $entity_dics = Dic::where('entity', '1')->orderBy(DB::raw('-`order`'), 'DESC')->get();
         #Helper::tad($entity_dics);
         if (count($entity_dics)) {
             $controller = new AdminDicvalsController();
             foreach ($entity_dics as $entity_dic) {
                 if (!$controller->is_available($entity_dic)) {
                     continue;
                 }
                 $dic_entities[$entity_dic->slug] = array(array('title' => $entity_dic->name, 'link' => Helper::clearModuleLink(URL::route('entity.index', $entity_dic->slug)), 'class' => $entity_dic->icon_class, 'module' => 'dictionaries', 'permit' => 'dicval_entity_view'));
             }
             ##$dic_entities += $mod_menu;
             ##$mod_menu = $dic_entities;
             #Helper::d($dic_entities);
             #Helper::dd($mod_menu);
         }
     }
     ## If exists menu elements...
     if (isset($mod_menu) && is_array($mod_menu) && count($mod_menu)) {
         #foreach( $mod_menu as $mod_name => $menu_elements ) {
         foreach ((array) @$dic_entities + Allow::modules() as $mod_name => $module) {
             #Helper::d($mod_name);
             ## Hardcode...
             $menu_elements = @is_object($module) && @is_array($mod_menu[$mod_name]) ? $mod_menu[$mod_name] : $module;
             if (is_array($menu_elements) && count($menu_elements)) {
                 #Helper::d($mod_name); #continue;
                 #Helper::d($menu_elements); #continue;
                 foreach ($menu_elements as $m => $menu_element) {
                     #Helper::d($menu_element); #continue;
                     ## If permit to view menu element
                     $rules = @$menu_element['permit'];
                     $module = @$menu_element['module'] ?: $mod_name;
                     $permit = $rules ? Allow::action($module, $rules, true, false) : true;
                     #Helper::d($module . " :: " . $permit . " :: " . $rules);
                     #Helper::d( $menu_element['title'] . " - " . (int)$permit );
                     if ($permit) {
                         $menu[] = $menu_element;
                     }
                 }
             }
         }
     }
     #Helper::dd($menu);
     return $menu;
 }
示例#7
0
文件: Allow.php 项目: Grapheme/amway
 private static function init()
 {
     if (!self::$modules) {
         self::$modules = array();
         $temp = Module::with('actions')->orderBy('order', 'ASC')->orderBy('name', 'ASC')->get();
         foreach ($temp as $tmp) {
             $actions = array();
             foreach ($tmp->actions as $action) {
                 #Helper::d($action);
                 $actions[$action->action] = $action;
             }
             unset($tmp->actions);
             $tmp->actions = $actions;
             #Helper::ta($tmp->actions);
             #Helper::ta($tmp);
             self::$modules[$tmp['name']] = $tmp;
         }
         #self::$modules['system'] = array('system' => 1);
     }
     #Helper::dd(self::$modules);
     #Helper::tad(self::$modules);
 }
 public function deleteDestroy($id)
 {
     Allow::permission($this->module['group'], 'users');
     if (!Request::ajax()) {
         App::abort(404);
     }
     $json_request = array('status' => FALSE, 'responseText' => '');
     $deleted = User::find($id)->delete();
     $json_request['responseText'] = 'Пользователь удален';
     $json_request['status'] = TRUE;
     return Response::json($json_request, 200);
 }
 public function destroy($id)
 {
     Allow::permission($this->module['group'], $this->module['name']);
     if (!Request::ajax()) {
         App::abort(404);
     }
     $json_request = array('status' => FALSE, 'responseText' => '');
     $deleted = Storage::where('module', 'menu')->where('id', $id)->delete();
     $json_request['responseText'] = 'Удалено';
     $json_request['status'] = TRUE;
     return Response::json($json_request, 200);
 }
示例#10
0
<?
    $menus = array();
    $menus[] = array(
        'link' => URL::route('uploads.index', null),
        'title' => 'Загрузки',
        'class' => 'btn btn-default'
    );
    if (Allow::action($module['group'], 'view_all')) {
        $menus[] = array(
            'link' => URL::route('uploads.index', array('view' => 'all')),
            'title' => 'Все загрузки',
            'class' => 'btn btn-default'
        );
    }
?>
    
    <h1>Загруженные файлы</h1>

    {{ Helper::drawmenu($menus) }}

    @if (@is_dir(Config::get('site.uploads_dir')) && @is_writable(Config::get('site.uploads_dir')))
        {{ Form::open(array('url' => '#', 'class' => 'smart-form', 'files' => true)) }}
            <section>
                <label class="input pull-left" style="width:300px;">
                    {{ ExtForm::uploads('files', null, array('allow' => '*')) }}
                </label>
                &nbsp; <button class="btn btn-default">Загрузить</button>
            </section>
        {{ Form::close() }}
    @else
        <div class="alert alert-danger fade in min-table">
 private function dicval_permission($dic, $permission = '')
 {
     /**
      * Устанавливаем права доступа текущего пользователя к словарю, из конфига (если они заданы)
      */
     $dic_settings = Config::get('dic/' . $dic->slug);
     if (@is_object(Auth::user()) && @is_object(Auth::user()->group) && NULL != ($user_group_name = Auth::user()->group->name)) {
         #Helper::dd($user_group_name);
         #$user_group_name = 'moderator';
         $dicval_permissions = @$dic_settings['group_actions'][$user_group_name];
         #Helper::dd($dicval_permissions);
         if (isset($dicval_permissions) && @is_callable($dicval_permissions)) {
             $dicval_permissions = $dicval_permissions();
             #Helper::dd($dicval_permissions);
             Allow::set_actions($this->module['group'], $dicval_permissions);
         }
     }
     /**
      * Проверяем, есть ли у пользователя необходимые права для выполнения действия
      */
     Allow::permission($this->module['group'], $permission);
 }
示例#12
0
 public function showFullNews($url = false)
 {
     if (!Allow::module($this->module['group'])) {
         App::abort(404);
     }
     if (!@$url) {
         $url = Input::get('url');
     } else {
         $url = (int) $url;
     }
     $news = $this->news->where('publication', 1);
     ## News by ID
     if (is_numeric($url)) {
         $slug = false;
         $news = $news->where('id', $url);
         $news = $news->with('meta.seo', 'meta.photo', 'meta.gallery.photos')->first();
         if (@is_object($news)) {
             if (@is_object($news->meta) && @is_object($news->meta->seo)) {
                 $slug = $news->meta->seo->url;
             } else {
                 $slug = $news->slug;
             }
             #$slug = false;
             #Helper::dd($slug);
             if ($slug) {
                 $redirect = URL::route('news_full', array('url' => $slug));
                 #Helper::dd($redirect);
                 return Redirect::to($redirect, 301);
             }
         }
     } else {
         ## News by SLUG
         ## Search slug in SEO URL
         $news_meta_seo = Seo::where('module', 'news_meta')->where('url', $url)->first();
         #Helper::tad($news_meta_seo);
         if (is_object($news_meta_seo) && is_numeric($news_meta_seo->unit_id)) {
             $news = $this->news_meta->where('id', $news_meta_seo->unit_id)->with(array('news' => function ($query) {
                 $query->with('meta.seo', 'meta.photo', 'meta.gallery.photos');
             }))->first()->news;
             #Helper::tad($news);
         } else {
             ## Search slug in SLUG
             $news = $this->news->where('slug', $url)->with('meta.seo', 'meta.photo', 'meta.gallery.photos')->first();
             ## Check SEO url & gettin' $url
             ## and make 301 redirect if need it
             if (@is_object($news->meta) && @is_object($news->meta->seo) && $news->meta->seo->url != '' && $news->meta->seo->url != $url) {
                 $redirect = URL::route('news_full', array('url' => $news->meta->seo->url));
                 #Helper::dd($redirect);
                 return Redirect::to($redirect, 301);
             }
         }
     }
     #Helper::tad($news->template);
     if (!@is_object($news) || !@is_object($news->meta)) {
         App::abort(404);
     }
     if (!$news->template) {
         $news->template = 'default';
     }
     #Helper::tad($news);
     if (empty($news->template) || !View::exists($this->module['gtpl'] . $news->template)) {
         throw new Exception('Template [' . $this->module['gtpl'] . $news->template . '] not found.');
     }
     return View::make($this->module['gtpl'] . $news->template, compact('news'));
 }
示例#13
0
<?php

return array('sections' => function () {
    $settings = [];
    if (TRUE) {
        $settings['main'] = ['title' => 'Основные', 'options' => array(['group_title' => 'Настройки отправки почты', 'style' => 'margin: 0 0 5px 0'], 'feedback_address' => array('title' => 'Адрес почты для сообщений обратной связи', 'type' => 'text'), 'feedback_from_email' => array('title' => 'Адрес почты, от имени которого будут отправляться сообщения', 'type' => 'text'), 'feedback_from_name' => array('title' => 'Имя пользователя, от которого будут отправляться сообщения', 'type' => 'text'), ['group_title' => 'Кеширование'], 'db_remember_timeout' => array('title' => 'Кол-во минут, на которое кешировать ВСЕ запросы к БД (не рекомендуется)', 'type' => 'text'), ['group_title' => 'Прочее'], 'tpl_footer_counters' => array('title' => 'Код невидимых счетчиков (Я.Метрика, Google Analytics и т.д.)', 'type' => 'textarea'))];
    }
    if (Allow::action('catalog', 'catalog_allow', true, false)) {
        $settings['catalog'] = ['title' => 'Магазин', 'options' => array('allow_products_order' => array('no_label' => true, 'title' => 'Разрешить сортировку всех товаров (не рекомендуется)', 'type' => 'checkbox', 'label_class' => 'normal_checkbox'), 'disable_attributes_for_products' => array('no_label' => true, 'title' => 'Отключить функционал работы с атрибутами для товаров', 'type' => 'checkbox', 'label_class' => 'normal_checkbox'), 'disable_attributes_for_categories' => array('no_label' => true, 'title' => 'Отключить функционал работы с атрибутами для категорий', 'type' => 'checkbox', 'label_class' => 'normal_checkbox'))];
    }
    return $settings;
});
示例#14
0
<?
    $page_title = "Новости";


    $menus = array();

    if (Allow::action($module['group'], 'view')) {
        $menus[] = array(
            'link' => action($module['entity'].'.index'),
            'title' => 'Все новости',
            'class' => 'btn btn-default'
        );
    }

    if (Allow::action($module['group'], 'create')) {
        $menus[] = array(
            'link' => action($module['entity'].'.create'),
            'title' => 'Добавить',
            'class' => 'btn btn-primary'
        );
    }

?>

    <h1>{{ $page_title }}</h1>

    {{ Helper::drawmenu($menus) }}

示例#15
0
@section('content')
<div class="row">

	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-5">

        <h1>Модули</h1>

		<form action="{{ URL::route('modules.change') }}" class="smart-form">
                {{--<label class="label">Список доступных модулей:</label>--}}

                <table class="table table-bordered table-striped white-bg modules-list">
                    <?
                    #Helper::d(SystemModules::getModules());
                    $modules_info = Config::get('mod_info');
                    $modules = Allow::modules();
                    #Helper::tad($modules);
                    #Helper::tad($modules_info);
                    ?>
                    <tbody class="sortable">
                        @foreach($modules as $name => $module)
                        <?
                        if (!isset($modules_info[$module->name]) || !@$modules_info[$module->name]['visible'])
                            continue;
                        ?>
                        <tr data-id="{{ @$module->id }}">
                            <td>{{ @$modules_info[$module->name]['title'] }}</td>
                            <td style="width: 50px;">
                                <label class="toggle">
                                    <?php 
$checked = '';
 /**
  * Функция удаляет резервные копии, превысившие лимит
  *
  * @param int $page_id
  *
  * @return bool
  */
 private function delete_backups($page_id = 0)
 {
     /**
      * Находим запись для удаления ее бэкапов
      * Запись должна быть оригиналом, т.е. иметь version_of = NULL
      */
     $element = $this->essence->where('id', $page_id)->with(['metas', 'blocks.metas', 'seos', 'versions'])->first();
     if (!isset($element) || !is_object($element) || $element->version_of != NULL) {
         return FALSE;
     }
     #Helper::tad($element);
     $versions = Config::get('pages.versions');
     $element_versions = $element->versions;
     $result = TRUE;
     if (count($element_versions) > 0 && count($element_versions) >= $versions) {
         /**
          * Вычисляем ID записей, подлежащих удалению
          */
         $for_delete = $element_versions->lists('id');
         krsort($for_delete);
         $for_delete = array_slice($for_delete, 0, count($element_versions) - $versions);
         #Helper::dd($for_delete);
         if (count($for_delete)) {
             $result = FALSE;
             /**
              * Открываем транзакцию
              */
             DB::transaction(function () use($element, $for_delete, $result) {
                 /**
                  * Удаляем старые резервные копии и META данные, блоки (и их META данные) и SEO-данные
                  */
                 $this->pages_meta->whereIn('page_id', $for_delete)->delete();
                 $element_blocks = $this->pages_blocks->whereIn('page_id', $for_delete)->get();
                 if (isset($element_blocks) && count($element_blocks)) {
                     $element_blocks_ids = $element_blocks->lists('id');
                     $element_blocks_metas = $this->pages_blocks_meta->whereIn('block_id', $element_blocks_ids)->delete();
                 }
                 $this->pages_blocks->whereIn('page_id', $for_delete)->delete();
                 if (Allow::module('seo')) {
                     Seo::where('module', 'Page')->whereIn('unit_id', $for_delete)->delete();
                 }
                 $deleted = $this->essence->where('version_of', $element->id)->whereIn('id', $for_delete)->delete();
                 #Helper::d($deleted);
                 #Helper::dd($for_delete);
                 if ($deleted) {
                     $result = TRUE;
                 }
             });
         }
     }
     return $result;
 }
示例#17
0
 public function getSphinx($dic_id)
 {
     if (!Allow::superuser()) {
         App::abort(404);
     }
     $dic = Dictionary::where(is_numeric($dic_id) ? 'id' : 'slug', $dic_id)->first();
     if (!is_object($dic)) {
         App::abort(404);
     }
     #Helper::d('Данные словаря:') . Helper::ta($dic);
     $fields = Config::get('dic/' . $dic->slug . '.fields');
     if (isset($fields) && is_callable($fields)) {
         $fields = $fields();
     }
     #Helper::d('Доп. поля словаря (fields):') . Helper::d($fields);
     $fields_i18n = Config::get('dic/' . $dic->slug . '.fields_i18n');
     if (isset($fields_i18n) && is_callable($fields_i18n)) {
         $fields_i18n = $fields_i18n();
     }
     #Helper::d('Мультиязычные доп. поля словаря (fields_i18n):') . Helper::d($fields_i18n);
     $tbl_dic_field_val = (new DicFieldVal())->getTable();
     $tbl_dic_textfield_val = (new DicTextFieldVal())->getTable();
     /**
      * Будут индексироваться только поля следующих типов
      */
     $indexed_types = array('textarea', 'textarea_redactor', 'text');
     $fulltext_types = array('textarea', 'textarea_redactor');
     $selects = array("dicval.id AS id", $dic->id . " AS dic_id", $dic->id . " AS source_id", "'" . $dic->name . "' AS dic_name", "'" . $dic->slug . "' AS dic_slug", "dicval.name AS name");
     $sql = array();
     $j = 0;
     /**
      * Поиск по обычным полям
      */
     if (isset($fields) && is_array($fields) && count($fields)) {
         foreach ($fields as $field_key => $field) {
             if (!isset($field['type']) || !in_array($field['type'], $indexed_types)) {
                 continue;
             }
             $tbl_field = in_array($field['type'], $fulltext_types) ? $tbl_dic_textfield_val : $tbl_dic_field_val;
             ++$j;
             $tbl = "tbl" . $j;
             ##$selects[] = $tbl . '.language AS language';
             $selects[] = $tbl . '.value AS ' . $field_key;
             $sql[] = "LEFT JOIN " . $tbl_field . " AS " . $tbl . " ON " . $tbl . ".dicval_id = dicval.id AND " . $tbl . ".key = '" . $field_key . "' AND " . $tbl . ".language IS NULL";
         }
     }
     /**
      * Поиск по мультиязычным полям
      */
     if (isset($fields_i18n) && is_array($fields_i18n) && count($fields_i18n)) {
         foreach ($fields_i18n as $field_key => $field) {
             if (!in_array($field['type'], $indexed_types)) {
                 continue;
             }
             $tbl_field = in_array($field['type'], $fulltext_types) ? $tbl_dic_textfield_val : $tbl_dic_field_val;
             ++$j;
             $tbl = "tbl" . $j;
             ##$selects[] = $tbl . '.language AS language';
             $selects[] = $tbl . '.value AS `' . $field_key . '`';
             $sql[] = "LEFT JOIN " . $tbl_field . " AS " . $tbl . " ON " . $tbl . ".dicval_id = dicval.id AND " . $tbl . ".key = '" . $field_key . "' AND " . $tbl . ".language IS NOT NULL";
         }
     }
     $sql[] = "WHERE dicval.version_of IS NULL AND dicval.dic_id = '" . $dic->id . "'";
     $selects_compile = implode(', ', $selects);
     array_unshift($sql, "SELECT " . $selects_compile . " FROM " . (new DicVal())->getTable() . " AS dicval");
     return "<h1>Поиск по словарю &laquo;" . $dic->name . "&raquo; (" . $dic->slug . ")</h1>" . "<h3>SQL-запрос для тестирования (phpMyAdmin):</h3>" . nl2br(implode("\n", $sql)) . "<h3>SQL-запрос для вставки в конфиг Sphinx:</h3>" . "<pre>\n    sql_query     = \\\n        " . implode(' \\' . "\n        ", $sql) . "\n\n    sql_attr_uint = source_id\n</pre>";
 }
示例#18
0
    }
    if (Allow::action($module['group'], 'create')) {
        $menus[] = array(
            'link' => URL::route('dic.create', null),
            'title' => 'Добавить',
            'class' => 'btn btn-primary'
        );
    }
    if (Allow::action($module['group'], 'import') && @$dic_id) {
        $menus[] = array(
            'link' => action('dic.import', array('dic_id' => $dic_id)),
            'title' => 'Импорт',
            'class' => 'btn btn-primary'
        );
    }
    if (Allow::superuser() && @is_object($element) && $element->id) {
        $menus[] = array(
            'link' => action('dic.sphinx', array('dic_id' => $element->id)),
            'title' => '<i class="fa fa-search-plus"></i>',
            'class' => 'btn btn-info',
            'others' => array(
                'title' => 'SQL-запрос для Sphinx',
                'target' => '_blank',
            ),
        );
    }
?>
    
    <h1>Словари</h1>

    {{ Helper::drawmenu($menus) }}
示例#19
0
    $current_link_attributes = Helper::multiArrayToAttributes(Input::get('filter'), 'filter');
    $menus[] = array(
            'link' => action(is_numeric($dic_id) ? 'dicval.create' : 'entity.create', array('dic_id' => $dic_id) + $current_link_attributes), 'title' => 'Добавить', 'class' => 'btn btn-primary'
    );
}
if (Allow::action($module['group'], 'import')) {
    $menus[] = array(
            'link' => action('dic.import', array('dic_id' => $dic_id)), 'title' => 'Импорт', 'class' => 'btn btn-primary'
    );
}
if (Allow::action($module['group'], 'edit') && (!$dic->entity || Allow::superuser())) {
    $menus[] = array(
            'link' => action('dic.edit', array('dic_id' => $dic->id)), 'title' => 'Изменить', 'class' => 'btn btn-success'
    );
}
if (isset($total_elements_current_selection) && is_numeric($total_elements_current_selection) && $total_elements_current_selection > 0 && Allow::superuser()) {
    $menus[] = array(
        #'link' => URL::route('dic.clear', array('dic_id' => $dic->id)), 'title' => 'Очистить', 'class' => 'btn btn-danger'
        'raw' => Form::open(['url' => URL::route('dic.clear', array('dic_id' => $dic->id)), 'method' => 'POST', 'class' => 'clear_dic', 'style' => 'display:inline-block']) . Form::submit('Очистить', ['class' => 'btn btn-danger margin-bottom-5']) . Form::close(),
    );
}

if (isset($dic_settings['menus']))
    $dic_menu = $dic_settings['menus'];
#Helper::d($dic_menu);
if (isset($dic_menu) && is_callable($dic_menu)) {
    $tmp = (array)$dic_menu($dic, isset($element) && is_object($element) ? $element : NULL);
    $menus = array_merge($menus, $tmp);
}

#Helper::d($menus);
示例#20
0
    @if($groups->count())
    <div class="row">
    	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-8">
    		<table class="table table-striped table-bordered white-bg">
    			<thead>
    				<tr>
    					<th class="col-lg-1 text-center">ID</th>
    					<th class="col-lg-10 text-center" style="white-space:nowrap;">Название группы</th>
    					<th class="col-lg-1 text-center">Действия</th>
    				</tr>
    			</thead>
    			<tbody>
    			@foreach($groups as $group)
    			    <?
    			    if ($group->id == 1 && !Allow::superuser())
    			        continue;
    			    ?>
    				<tr class="vertical-middle">
    					<td class="text-center">{{ (@++$i) }}</td>
    					<td>
                            {{ $group->desc }}
                            <div style="margin:0; padding:0; font-size:80%; color:#777">Пользователей: {{ $group->count_users() }}</div>
                        </td>
    					<td class="text-center" style="white-space:nowrap;">

        					@if(Allow::action('system', 'groups'))
    						<a class="btn btn-info margin-right-10" href="{{ mb_substr(action('AdminUsersController@getIndex'), 0, -6) }}?group={{ $group->name }}">
    							Участники
    						</a>
                    		@endif
示例#21
0
                'link' => mb_substr(action($module['class'] . '@getIndex'), 0, -6) . "?group_id=" . $grp->id,
                'title' => $grp->desc . ' (' . $grp->count_users() . ')',
            );
            if (@is_object($group) && $group->name == $grp->name)
                $def_arr = $arr;
            $temp[] = $arr;
        }

    }

    $def_arr['class'] = 'btn btn-default';
    if (count($temp) > 1)
        $def_arr['child'] = $temp;
    $menus[] = $def_arr;


    if (Allow::action($module['group'], 'users')) {
        $menus[] = array(
            'link' => action($module['class'] . '@getCreate'),
            'title' => 'Добавить',
            'class' => 'btn btn-primary'
        );
    }

?>

    <h1>{{ $page_title }}</h1>

    {{ Helper::drawmenu($menus) }}

 public function deleteDestroy($id)
 {
     Allow::permission($this->module['group'], 'groups');
     if (!Request::ajax()) {
         App::abort(404);
     }
     $json_request = array('status' => FALSE, 'responseText' => '');
     if ($id == 1) {
         $json_request['responseText'] = 'Невозможно удалить группу Администраторы';
         return Response::json($json_request, 400);
     }
     $deleted = Group::find($id)->delete();
     $json_request['responseText'] = 'Группа удалена';
     $json_request['status'] = TRUE;
     return Response::json($json_request, 200);
 }
示例#23
0
 public function destroy($id)
 {
     Allow::permission($this->module['group'], 'delete');
     if (!Request::ajax()) {
         App::abort(404);
     }
     $json_request = array('status' => FALSE, 'responseText' => '');
     $element = Upload::where('id', $id)->first();
     if (is_object($element)) {
         #Helper::tad($element);
         #Helper::dd($element->fullpath());
         @unlink($element->fullpath());
         $element->delete();
     }
     $json_request['responseText'] = 'Удалено';
     $json_request['status'] = TRUE;
     return Response::json($json_request, 200);
 }
示例#24
0
 public function destroy($id)
 {
     if (!Request::ajax()) {
         App::abort(404);
     }
     Allow::permission($this->module['group'], 'delete');
     $json_request = array('status' => FALSE, 'responseText' => '');
     $element = $this->essence->find($id);
     if (is_object($element)) {
         $metas = $this->news_meta->where('news_id', $id)->get();
         if (count($metas)) {
             foreach ($metas as $meta) {
                 $meta->delete();
             }
         }
     }
     $element->delete();
     $json_request['responseText'] = 'Удалено';
     $json_request['status'] = TRUE;
     return Response::json($json_request, 200);
 }
示例#25
0
 <div class="row">
 	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-8">
 		<table class="table table-striped table-bordered">
 			<thead>
 				<tr>
 					<th class="col-lg-1 text-center">ID</th>
 					<th class="col-lg-1 text-center">Аватар</th>
 					<th class="col-lg-9 text-center" style="white-space:nowrap;">Данные пользователя</th>
 					<th class="col-lg-1 text-center">Действия</th>
 				</tr>
 			</thead>
 			<tbody>
 			@foreach($users as $user)
                 <?
                 #Helper::ta($user);
                 if ($user->group_id == 1 && !Allow::superuser())
                     continue;
                 ?>
 				<tr class="vertical-middle<? if($user->active == 0){ echo ' warning'; } ?>">
 					<td class="text-center">{{ $user->id }}</td>
 					<td class="text-center">
 					@if(!empty($user->thumbnail))
 						<figure class="avatar-container">
 							<img src="{{ url($user->thumbnail) }}" alt="{{ $user->name }} {{ $user->surname }}" class="avatar bordered circle">
 						</figure>
                     @else
                         <i class="fa fa-user" style="font-size:36px; color:#999"></i>
 					@endif
 					</td>
 					<td>
 						{{ $user->name }} {{ $user->surname }}
示例#26
0
 /**
  * @author Alexander Zelensky
  * @todo Возможно, в будущем здесь нужно будет добавить проверку параметра, использовать ли вообще мультиязычность по сегментам урла, или нет. Например, удобно будет отключить мультиязычность по сегментам при использовании разных доменных имен для каждой языковой версии.
  */
 public static function returnRoutes($prefix = null)
 {
     #Helper::dd(I18nPage::count());
     $class = __CLASS__;
     /**
      * Laravel не дает возможности переписывать пути (роуты), если они были зарегистрированы ранее.
      * А это значит, что если данный модуль активен и в нем создана хоть одна страница, то будет переписан корневой путь: /
      * Это не даст в будущем добавлять роуты от корня с помощью метода Route::controller('', '..@..'), придется все прописывать руками.
      * Надо бы подключать модуль страниц последним
      * [
      *     '/login' => Route object to /login,
      *     '{_missing}' => Fallthrough route object,
      *     '/' => Route object to /,
      * ]
      * Описание данной ситуации здесь:
      * http://stackoverflow.com/questions/20617244/laravel-4-1-controller-method-not-found?rq=1
      * https://github.com/laravel/framework/issues/2848
      * https://github.com/laravel/framework/pull/2850
      * https://github.com/laravel/framework/issues/2863
      * https://github.com/bencorlett/framework/pull/1
      * https://github.com/bencorlett/framework/commit/ac091a25465d070f8925a80b46eb237ef21ea912
      */
     if (!Allow::module(self::$group) || Config::get('site.pages.disabled')) {
         return false;
     }
     Page::preload();
     ##
     ## Add URL modifier for check SEO url of the page (custom UrlGenerator functionality)
     ##
     /*
     URL::add_url_modifier('page', function(&$name, &$parameters) use ($class) {
         #var_dump($class); die;
         #Helper::dd('Page url modifier!');
         #Helper::dd($parameters);
         #return;
         if (
             #is_string($parameters)
             #&&
             count(Config::get('app.locales')) > 1
             && !Config::get('pages.disable_url_modification')
             && Allow::module('seo')
         ) {
             $pages = new $class;
             $right_url = $pages->getRightPageUrl($parameters);
             #Helper::d("Change page URL: " . $parameters . " -> " . $right_url);
             #Helper::dd("Change page URL: " . $parameters . " -> " . $right_url);
             if (@$right_url)
                 $parameters = $right_url;
             #$parameters = '111';
         }
     });
     */
     #/*
     if (count(Config::get('app.locales')) > 1 && !Config::get('pages.disable_url_modification')) {
         ## Mainpage route modifier
         URL::add_url_modifier('mainpage', function (&$name, &$parameters) use($class) {
             #print_r($parameters);
             if (isset($parameters['lang']) && $parameters['lang'] == Config::get('app.default_locale')) {
                 unset($parameters['lang']);
             }
             #print_r($parameters);
         });
     }
     #*/
     ## Будем генерим отдельные роуты для "параметризированных" страниц: у которых в slug есть параметр(ы) (например: {city}/hello)
     ## Как будем искать страницы - в кеше или в БД?
     if (Config::get('pages.not_cached')) {
         ## Кеширование отключено (или не найдено ни одной страницы) - ищем в БД
         #$page = (new Page())->where('publication', 1)->where('version_of', NULL);
         $pages_parametrized = Page::where('parametrized', 1)->get();
     } else {
         $pages_parametrized = new Collection();
         ## Если страниц нет в кеше - показываем 404
         if (null != ($temp = Page::all_by_slug()) && count($temp)) {
             #Helper::tad($temp);
             foreach ($temp as $tmp) {
                 if ($tmp->parametrized) {
                     $pages_parametrized[$tmp->slug] = $tmp;
                 }
             }
         }
     }
     #Helper::tad($pages_parametrized);
     ## Если в конфиге прописано несколько языковых версий - генерим роуты с языковым префиксом
     if (is_array(Config::get('app.locales')) && count(Config::get('app.locales')) > 1) {
         $default_locale_mainpage = Config::get('app.default_locale') == Config::get('app.locale');
         #$locale_sign = Config::get('app.locale');
         ## Генерим роуты для всех языков с префиксом (первый сегмент), который будет указывать на текущую локаль
         Route::group(array('before' => 'i18n_url', 'prefix' => '{lang}'), function () use($class, $default_locale_mainpage, $pages_parametrized) {
             ## Генерим роуты для параметризированных страниц
             if ($pages_parametrized->count()) {
                 foreach ($pages_parametrized as $page) {
                     Route::any($page->slug, array('as' => 'page.' . $page->sysname, 'uses' => $class . '@showPageParametrize'));
                 }
             }
             ## Regular page
             Route::any('/{url}', array('as' => 'page', 'uses' => $class . '@showPage'));
             ## Main page for non-default locale
             #if (!Config::get('pages.disable_mainpage_route') && !$default_locale_mainpage)
             #    Route::any('/', array('as' => 'mainpage', 'uses' => $class.'@showPage'));
             ## Main page for current locale (non-default)
             #Route::any('/', array('as' => 'mainpage_i18n', 'uses' => $class.'@showPage'));
         });
         Route::any('{lang?}', array('as' => 'mainpage', 'uses' => $class . '@showPage'));
         ## Main page for default locale
         #if (!Config::get('pages.disable_mainpage_route') && $default_locale_mainpage)
         #    Route::any('/', array('as' => 'mainpage', 'uses' => $class.'@showPage'));
         ## Main page for default locale
         #Route::any('/', array('as' => 'mainpage_default', 'uses' => $class.'@showPage'));
     } else {
         ## Генерим роуты без языкового префикса
         Route::group(array('before' => 'pages_right_url'), function () use($class, $pages_parametrized) {
             ## Генерим роуты для параметризированных страниц
             if ($pages_parametrized->count()) {
                 foreach ($pages_parametrized as $page) {
                     Route::any($page->slug, array('as' => 'page.' . $page->sysname, 'uses' => $class . '@showPageSingleParametrize'));
                 }
             }
             ## Regular page
             Route::any('{url}', array('as' => 'page', 'uses' => $class . '@showPageSingle'));
             ## Main page
             if (!Config::get('pages.disable_mainpage_route')) {
                 Route::any('/', array('as' => 'mainpage', 'uses' => $class . '@showPageSingle'));
             }
         });
     }
     /*
             #dd(Route::getRoutes());
             $routes = Route::getRoutes();
             foreach($routes as $route) {
                 echo $route->getPath() . "<br/>";
             }
             die;
             #*/
 }