public function postAjaxCheckDicvalSlugUnique()
 {
     $input = Input::all();
     #Helper::dd(Input::all());
     $json_request = array('status' => FALSE, 'responseText' => '');
     $dic_id = Input::get('_dic_id');
     $dic = Dic::find($dic_id);
     /**
      * Если словарь не найден - сообщаем об ошибке
      */
     if (!is_object($dic)) {
         $json_request['responseText'] = 'Вы пытаетесь добавить запись в несуществующую сущность';
         return Response::json($json_request, 200);
     }
     $id = Input::get('_id');
     $slug = trim(Input::get('slug'));
     $name = Input::get('name');
     $element = new DicVal();
     if ($id) {
         $element = DicVal::find($id);
     }
     if (!is_object($element)) {
         $element = new DicVal();
     }
     switch ((int) $dic->make_slug_from_name) {
         case 1:
             $input['slug'] = Helper::translit($input['name']);
             break;
         case 2:
             if (!$dic->hide_slug && !@$input['slug']) {
                 $input['slug'] = Helper::translit($input['name']);
             }
             break;
         case 3:
             if ($dic->hide_slug && $element->slug == '') {
                 $input['slug'] = Helper::translit($input['name']);
             }
             break;
         case 4:
             $input['slug'] = Helper::translit($input['name'], false);
             break;
         case 5:
             if (!$dic->hide_slug && !@$input['slug']) {
                 $input['slug'] = Helper::translit($input['name'], false);
             }
             break;
         case 6:
             if ($dic->hide_slug && $element->slug == '') {
                 $input['slug'] = Helper::translit($input['name'], false);
             }
             break;
         case 7:
             $input['slug'] = $input['name'];
             break;
         case 8:
             if (!$dic->hide_slug && !@$input['slug']) {
                 $input['slug'] = $input['name'];
             }
             break;
         case 9:
             if ($dic->hide_slug && $element->slug == '') {
                 $input['slug'] = $input['name'];
             }
             break;
     }
     $new_slug = $input['slug'];
     $json_request['new_slug'] = $new_slug;
     #Helper::d($new_slug);
     #Helper::tad($input);
     /**
      * Ищем записи в текущем словаре с новым системным именем
      */
     $dicval = DicVal::where('slug', $new_slug)->where('dic_id', $dic_id);
     /**
      * Если мы редактируем существующую запись - исключаем ее ID из проверки
      */
     if ($element->id) {
         $dicval = $dicval->where('id', '!=', $element->id);
     }
     $dicval = $dicval->first();
     #Helper::ta($dicval);
     if (is_object($dicval)) {
         $json_request['responseText'] = 'Запись с таким системным именем уже существует';
         $json_request['also_exists'] = $dicval->id;
     } else {
         $json_request['status'] = TRUE;
     }
     return Response::json($json_request, 200);
 }
Esempio n. 2
0
 /**
  * !!! NEED TO ADD RELATED_DICVALS SUPPORT !!!
  *
  * @param $dic_slug
  * @param $dicval_id
  * @param $array
  *
  * @return bool|\Illuminate\Support\Collection|null|static
  */
 public static function refresh($dic_slug, $dicval_id, $array)
 {
     #Helper::d($dic_slug);
     #Helper::d($array);
     ## Find DIC
     $dic = Dic::where('slug', $dic_slug)->first();
     if (!is_object($dic)) {
         return false;
     }
     ## Find dicval
     $dicval = DicVal::find($dicval_id);
     if (!is_object($dicval)) {
         return false;
     }
     if ($dicval->dic_id != $dic->id) {
         $dicval->dic_id = $dic->id;
     }
     if (isset($array['slug'])) {
         $dicval->slug = $array['slug'];
     }
     if (isset($array['name'])) {
         $dicval->name = $array['name'];
     }
     $dicval->save();
     ## UPDATE FIELDS
     if (@isset($array['fields']) && is_array($array['fields']) && count($array['fields'])) {
         #$fields = new Collection();
         foreach ($array['fields'] as $key => $value) {
             $dicval_field_search_array = array('dicval_id' => $dicval->id, 'key' => $key);
             if (is_array($value) && isset($value['language'])) {
                 $dicval_field_search_array['language'] = @$value['language'] ?: NULL;
             }
             $dicval_field = DicFieldVal::firstOrNew($dicval_field_search_array);
             $dicval_field->value = is_array($value) ? @$value['value'] : $value;
             $dicval_field->save();
             #$fields[] = $dicval_field;
         }
         #$dicval->relations['fields'] = $fields;
     }
     ## CREATE FIELDS_I18N
     if (@isset($array['fields_i18n']) && is_array($array['fields_i18n']) && count($array['fields_i18n'])) {
         #$fields_i18n = new Collection();
         foreach ($array['fields_i18n'] as $locale_sign => $fields) {
             if (!@is_array($fields) || !@count($fields)) {
                 continue;
             }
             #$temp = new Collection();
             foreach ($fields as $key => $value) {
                 $dicval_field_search_array = array('dicval_id' => $dicval->id, 'language' => $locale_sign, 'key' => $key);
                 $dicval_field = DicFieldVal::firstOrNew($dicval_field_search_array);
                 $dicval_field->value = is_array($value) ? @$value['value'] : $value;
                 $dicval_field->save();
                 #$temp[] = $dicval_field_i18n;
             }
             #$fields_i18n[$locale_sign] = $temp;
         }
         #$dicval->relations['fields_i18n'] = $fields_i18n;
     }
     ## CREATE TEXT FIELDS
     if (@isset($array['textfields']) && is_array($array['textfields']) && count($array['textfields'])) {
         #$textfields = new Collection();
         foreach ($array['textfields'] as $key => $value) {
             $dicval_field_search_array = array('dicval_id' => $dicval->id, 'key' => $key);
             if (is_array($value) && isset($value['language'])) {
                 $dicval_field_search_array['language'] = @$value['language'] ?: NULL;
             }
             $dicval_field = DicTextFieldVal::firstOrNew($dicval_field_search_array);
             $dicval_field->value = is_array($value) ? @$value['value'] : $value;
             $dicval_field->save();
             #$textfields[] = $dicval_textfield;
         }
         #$dicval->relations['textfields'] = $textfields;
     }
     ## CREATE TEXT FIELDS_I18N
     if (@isset($array['textfields_i18n']) && is_array($array['textfields_i18n']) && count($array['textfields_i18n'])) {
         #$textfields_i18n = new Collection();
         foreach ($array['textfields_i18n'] as $locale_sign => $textfields) {
             if (!@is_array($textfields) || !@count($textfields)) {
                 continue;
             }
             #$temp = new Collection();
             foreach ($textfields as $key => $value) {
                 $dicval_field_search_array = array('dicval_id' => $dicval->id, 'language' => $locale_sign, 'key' => $key);
                 $dicval_field = DicTextFieldVal::firstOrNew($dicval_field_search_array);
                 $dicval_field->value = is_array($value) ? @$value['value'] : $value;
                 $dicval_field->save();
                 #$temp[] = $dicval_textfield_i18n;
             }
             #$textfields_i18n[$locale_sign] = $temp;
         }
         #$dicval->relations['textfields_i18n'] = $textfields_i18n;
     }
     ## CREATE META
     if (@isset($array['meta']) && is_array($array['meta']) && count($array['meta'])) {
         #$metas = new Collection();
         foreach ($array['meta'] as $locale_sign => $fields) {
             if (!@is_array($fields) || !@count($fields)) {
                 continue;
             }
             $temp = new Collection();
             foreach ($fields as $key => $value) {
                 $dicval_field_search_array = array('dicval_id' => $dicval->id, 'language' => $locale_sign);
                 $dicval_field = DicValMeta::firstOrNew($dicval_field_search_array);
                 $dicval_field->name = is_array($value) ? @$value['name'] : $value;
                 $dicval_field->save();
                 #$temp[] = $dicval_meta;
             }
             #$metas[$locale_sign] = $temp;
         }
         #$dicval->relations['metas'] = $metas;
     }
     $dicval->load('allfields', 'alltextfields', 'metas');
     ## RETURN DICVAL
     return $dicval;
 }
Esempio n. 3
0
    #Helper::ta($types);
    Config::set('temp.types', $types);
    /**
     * Создаем списки из полученных данных
     */
    $dic_ids = Dic::makeLists($dics, false, 'id');
    #Helper::d($dic_ids);
    $dicval_ids = Dic::makeLists($dicvals, false, 'id');
    #Helper::d($dicval_ids);
    /**
     * Получаем количество необходимых нам данных, одним SQL-запросом.
     * Сохраняем данные в конфиг - для дальнейшего использования в функции-замыкании actions (см. выше).
     */
    $counts = array();
    if (count($dic_ids) && count($dicval_ids)) {
        $counts = DicVal::counts_by_fields($dic_ids, array('course_id' => $dicval_ids));
    }
    #Helper::dd($counts);
    Config::set('temp.index_counts', $counts);
}, 'after_store_update_destroy_order' => function ($dic = NULL, $dicval = NULL) {
    Cache::forget('dic_' . $dic->slug);
}), 'second_line_modifier' => function ($line, $dic, $dicval) {
    #Helper::ta($dicval);
    ## Получаем списки с нужными индексами
    $cities = Config::get('temp.cities');
    #Helper::ta($cities);
    $types = Config::get('temp.types');
    #Helper::ta($types);
    $array = [];
    if (isset($cities[$dicval->city_id])) {
        $array[] = $cities[$dicval->city_id];
Esempio n. 4
0
 /**
  * Форма записи на курс
  * http://ikra.dev/city/msk/courses/18
  * + Сохраняется в БД
  * - Отправляется на почту
  * - Отправляется в битрикс24
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function formCourse()
 {
     #if (!Request::ajax())
     #    App::abort(404);
     $json_request = ['status' => FALSE, 'responseText' => ''];
     $data = Input::all();
     #$city = View::shared('dic_city');
     #$city = @$city[$data['city_id']];
     $city = View::shared('current_city');
     #Helper::tad($city);
     if (!is_object($city) || null == ($emails = $city->email_course)) {
         $json_request['errorText'] = 'Current city not found, or e-mail is nulled';
         return Response::json($json_request, 200);
     }
     $data['city'] = $city;
     $data['to'] = $emails;
     ## Find course
     $course = Dic::valueBySlugAndId('course', @$data['course_id'], 'all', true, true, true);
     #Helper::tad($course);
     if (!is_object($course)) {
         $json_request['errorText'] = 'Course not found';
         return Response::json($json_request, 200);
     }
     $data['course'] = $course;
     ## Find exist records - by email & course_id
     $record = Dic::valuesBySlug('leads', function ($query) use($data) {
         $query->filter_by_field('email', '=', $data['email']);
         $query->filter_by_field('course_id', '=', $data['course_id']);
     }, ['fields'], true, true, false);
     #Helper::tad($record);
     if (count($record) >= 1) {
         $json_request['status'] = true;
         $json_request['also'] = true;
         $json_request['responseText'] = 'Email also in DB';
         return Response::json($json_request, 200);
     }
     ## Create lead in bitrix24
     $answer = file_get_contents('https://ikrafamily.bitrix24.ru/crm/configs/import/lead.php?' . '&LOGIN='******'app.settings.main.bitrix24_login') . '&PASSWORD='******'app.settings.main.bitrix24_pass') . '&TITLE=' . @$data['name'] . ' - ' . $data['email'] . '&NAME=' . @$data['name'] . '&EMAIL_HOME=' . @$data['email'] . '&PHONE_MOBILE=' . @$data['phone'] . '&UF_CRM_1429722925=' . $course->name . ' (' . $city->name . ')');
     #Helper::tad($answer);
     ## Create record
     $temp = DicVal::inject('leads', array('slug' => NULL, 'name' => @$data['name'], 'fields' => array('city_id' => $city->id, 'course_id' => @$data['course_id'], 'email' => @$data['email'], 'phone' => @$data['phone'])));
     ## Send email
     $tpl = 'emails.lead';
     if (View::exists($tpl)) {
         Mail::send($tpl, $data, function ($message) use($data) {
             #$message->from(Config::get('mail.from.address'), Config::get('mail.from.name'));
             $from_email = Config::get('app.settings.main.feedback_from_email') ?: '*****@*****.**';
             $from_name = Config::get('app.settings.main.feedback_from_name') ?: 'No-reply';
             $message->from($from_email, $from_name);
             $message->subject('Заявка с сайта - запись на курс');
             #$email = Config::get('app.settings.main.feedback_address') ?: '*****@*****.**';
             $email = $data['to'];
             $emails = array();
             if (strpos($email, ',')) {
                 $emails = explode(',', $email);
                 foreach ($emails as $e => $email) {
                     $email = trim($email);
                     if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
                         $emails[$e] = $email;
                     }
                 }
                 $email = array_shift($emails);
             }
             $message->to($email);
             #$ccs = Config::get('mail.feedback.cc');
             $ccs = $emails;
             if (isset($ccs) && is_array($ccs) && count($ccs)) {
                 foreach ($ccs as $cc) {
                     $message->cc($cc);
                 }
             }
             /**
              * Прикрепляем файл
              */
             /*
                             if (Input::hasFile('file') && ($file = Input::file('file')) !== NULL) {
                                 #Helper::dd($file->getPathname() . ' / ' . $file->getClientOriginalName() . ' / ' . $file->getClientMimeType());
                                 $message->attach($file->getPathname(), array('as' => $file->getClientOriginalName(), 'mime' => $file->getClientMimeType()));
                             }
                             #*/
         });
         $json_request['status'] = TRUE;
     } else {
         $json_request['responseText'] = 'Template ' . $tpl . ' not found.';
     }
     $json_request['status'] = TRUE;
     #Helper::dd($result);
     return Response::json($json_request, 200);
 }
 public function postImport3($dic_id)
 {
     Allow::permission($this->module['group'], 'import');
     $dic = Dictionary::where(is_numeric($dic_id) ? 'id' : 'slug', $dic_id)->first();
     if (!is_object($dic)) {
         App::abort(404);
     }
     #Helper::tad($dic);
     ## Get also exists values
     #$exist_values = $dic->values;
     #Helper::ta($exist_values);
     $input = Input::all();
     /*
     foreach ($exist_values as $e => $exist_value) {
         if ($input['rewrite_mode'] == 1)
             $exist_values[$exist_value->name] = $exist_value;
         else
             $exist_values[$exist_value->slug] = $exist_value;
         unset($exist_values[$e]);
     }
     Helper::ta($exist_values);
     */
     $max = count($input['values'][0]);
     $fields = $input['fields'];
     $values = $input['values'];
     ## Filter fields & values
     foreach ($fields as $f => $field) {
         if (is_numeric($field) && $field == 0) {
             #Helper::d($f . " => " . $field . " = 0");
             unset($fields[$f]);
             unset($values[$f]);
         }
     }
     #Helper::d($fields);
     #Helper::d($values);
     ## Make insertions
     $find_key = $input['rewrite_mode'] == 1 ? 'name' : 'slug';
     $array = array();
     $count = count($values[0]);
     for ($i = 0; $i < $count; $i++) {
         $arr = array('dic_id' => $dic->id);
         foreach ($fields as $f => $field) {
             $arr[$field] = @trim($values[$f][$i]);
         }
         $find = array($find_key => @$arr[$find_key], 'dic_id' => $dic->id);
         #unset($arr[$find_key]);
         if (@$input['set_slug'] && ($input['set_slug_elements'] == 'all' || $input['set_slug_elements'] == 'empty' && !@$arr['slug'])) {
             $arr['slug'] = Helper::translit(@$arr['name']);
         }
         if (@$input['set_ucfirst'] && $arr['name']) {
             $arr['name'] = Helper::mb_ucfirst($arr['name']);
         }
         #Helper::dd($find);
         #/*
         $dicval = DicVal::firstOrCreate($find);
         $dicval->update($arr);
         #Helper::ta($dicval);
         #*/
         unset($dicval);
         #$array[] = $arr;
     }
     #Helper::d($array);
     return Redirect::route('dicval.index', $dic_id);
 }
Esempio n. 6
0
 /**
  * Возвращает записи из словаря по системному имени словаря и набору IDs нужных записей.
  * Третьим параметром можно передать метку, указывающую на необходимость сделать экстракт каждой записи.
  *
  * @param $slug
  * @param $val_ids
  * @param string $with
  * @param bool $extract
  * @param bool $unset
  * @return $this|Collection|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|null|static
  */
 public static function valuesBySlugAndIds($slug, $val_ids, $with = 'all', $extract = true, $unset = true, $extract_ids = false)
 {
     $return = new Collection();
     #$dic = Dic::where('slug', $slug)->first();
     #$dic = @Config::get(self::$cache_key)['by_slug'][$slug];
     $dic = Dic::by_slug($slug);
     if (!is_object($dic) || !is_array($val_ids) || !count($val_ids)) {
         return $return;
     }
     $values = DicVal::where('dic_id', $dic->id)->where('version_of', NULL)->whereIn('id', $val_ids);
     if ($with == 'all') {
         $with = ['meta', 'fields', 'textfields', 'seo', 'related_dicvals'];
     } else {
         $with = (array) $with;
     }
     $db_remember_timeout = Config::get('app.settings.main.db_remember_timeout');
     if (count($with)) {
         ##
         ## Cache relations
         ##
         if (NULL != $db_remember_timeout && is_numeric($db_remember_timeout) && $db_remember_timeout > 0) {
             $temp = [];
             foreach ($with as $relation) {
                 $temp[$relation] = function ($query) use($db_remember_timeout) {
                     $query->remember($db_remember_timeout);
                 };
             }
             $with = $temp;
         }
         $values = $values->with($with);
     }
     ##
     ## Cache query
     ##
     if (NULL != $db_remember_timeout && is_numeric($db_remember_timeout) && $db_remember_timeout > 0) {
         $values->remember($db_remember_timeout);
     }
     $values = $values->get();
     #Helper::tad($values);
     if ($extract) {
         $values = DicLib::extracts($values, null, $unset, $extract_ids);
     }
     #Helper::tad($values);
     return $values;
 }
Esempio n. 7
0
 public static function returnShortCodes()
 {
     $tpl = static::returnTpl();
     shortcode::add("news", function ($params = null) use($tpl) {
         #print_r($params); die;
         if (!Allow::module('news')) {
             return false;
         }
         ## Параметры по-умолчанию
         $default = array('tpl' => Config::get('app-default.news_template', 'default'), 'limit' => Config::get('app-default.news_count_on_page', 3), 'order' => Helper::stringToArray(News::$order_by), 'pagination' => 1, 'type' => false, 'exclude_type' => false, 'include' => false, 'exclude' => false);
         ## Применяем переданные настройки
         $params = $params + $default;
         #dd($params);
         #echo $tpl.$params['tpl'];
         if (empty($params['tpl']) || !View::exists($tpl . $params['tpl'])) {
             throw new Exception('Template [' . $tpl . $params['tpl'] . '] not found.');
         }
         $news = News::orderBy('news.published_at', 'desc')->with('meta.photo', 'meta.gallery.photos', 'meta.seo');
         /*
         ## Получаем новости, делаем LEFT JOIN с news_meta, с проверкой языка и тайтла
         $selected_news = News::where('news.publication', 1)
                                 ->leftJoin('news_meta', 'news_meta.news_id', '=', 'news.id')
                                 ->where('news_meta.language', Config::get('app.locale'))
                                 ->where('news_meta.title', '!=', '')
                                 ->select('*', 'news.id AS original_id', 'news.published_at AS created_at')
                                 ->orderBy('news.published_at', 'desc');
         
         #$selected_news = $selected_news->where('news_meta.wtitle', '!=', '');
         
         ## Получаем новости с учетом пагинации
         #echo $selected_news->toSql(); die;
         #var_dump($params['limit']);
         $news = $selected_news->paginate($params['limit']); ## news list with pagination
         #$news = $selected_news->get(); ## all news, without pagination
         */
         /**
          * Показываем новости только определенных типов
          */
         if (@$params['type']) {
             $params['types'] = (array) explode(',', $params['type']);
             #Helper::d($params);
             if (isset($params['types']) && is_array($params['types']) && count($params['types']) && Allow::module('dictionaries') && class_exists('DicVal')) {
                 $types = DicVal::whereIn('slug', $params['types'])->get();
                 #Helper::tad($types);
                 if ($types->count()) {
                     $types = $types->lists('id');
                     #Helper::tad($types);
                     if (count($types)) {
                         $news = $news->whereIn('type_id', $types);
                     }
                 }
             }
         }
         /**
          * Исключаем новости определенных типов
          */
         if (@$params['exclude_type']) {
             $params['exclude_types'] = (array) explode(',', $params['exclude_type']);
             #Helper::d($params);
             if (isset($params['exclude_types']) && is_array($params['exclude_types']) && count($params['exclude_types']) && Allow::module('dictionaries') && class_exists('DicVal')) {
                 $types = DicVal::whereIn('slug', $params['exclude_types'])->get();
                 #Helper::tad($types);
                 if ($types->count()) {
                     $types = $types->lists('id');
                     #Helper::tad($types);
                     if (count($types)) {
                         $news = $news->whereNotIn('type_id', $types);
                     }
                 }
             }
         }
         /**
          * Будем выводить только новости, ID которых указаны
          */
         if (@$params['include']) {
             $params['includes'] = (array) explode(',', $params['include']);
             if (isset($params['includes']) && is_array($params['includes']) && count($params['includes'])) {
                 $news = $news->whereIn('id', $params['includes']);
             }
         }
         /**
          * Исключаем новости с заданными ID
          */
         if (@$params['exclude']) {
             $params['excludes'] = (array) explode(',', $params['exclude']);
             if (isset($params['excludes']) && is_array($params['excludes']) && count($params['excludes'])) {
                 $news = $news->whereNotIn('id', $params['excludes']);
             }
         }
         $news = $news->paginate($params['limit']);
         #Helper::tad($news);
         /*
         foreach ($news as $n => $new) {
             #print_r($new); die;
             $gall = Rel_mod_gallery::where('module', 'news')->where('unit_id', $new->original_id)->first();
             #foreach ($gall->photos as $photo) {
             #	print_r($photo->path());
             #}
             #print_r($gall->photos); die;
             $new->gall = @$gall;
             $new->image = is_object(@$gall->photos[0]) ? @$gall->photos[0]->path() : "";
             $news[$n]->$new;
         }
         */
         #echo $news->count(); die;
         if (!$news->count()) {
             return false;
         }
         return View::make($tpl . $params['tpl'], compact('news'));
     });
 }
Esempio n. 8
0
    #Helper::tad($dics);
    Config::set('temp.index_dics', $dics);
    /**
     * Создаем списки из полученных данных
     */
    $dic_ids = Dic::makeLists($dics, false, 'id');
    #Helper::d($dic_ids);
    $dicval_ids = Dic::makeLists($dicvals, false, 'id');
    #Helper::d($dicval_ids);
    /**
     * Получаем количество необходимых нам данных, одним SQL-запросом.
     * Сохраняем данные в конфиг - для дальнейшего использования в функции-замыкании actions (см. выше).
     */
    $counts = array();
    if (count($dic_ids) && count($dicval_ids)) {
        $counts = DicVal::counts_by_fields($dic_ids, array('collection_id' => $dicval_ids));
    }
    #Helper::dd($counts);
    Config::set('temp.index_counts', $counts);
}, 'before_create_edit' => function ($dic) {
}, 'before_create' => function ($dic) {
}, 'before_edit' => function ($dic, $dicval) {
}, 'before_store_update' => function ($dic) {
}, 'before_store' => function ($dic) {
}, 'after_store' => function ($dic, $dicval) {
}, 'before_update' => function ($dic, $dicval) {
}, 'after_update' => function ($dic, $dicval) {
}, 'after_store_update' => function ($dic, $dicval) {
}, 'before_destroy' => function ($dic, $dicval) {
}, 'after_destroy' => function ($dic, $dicval) {
}, 'after_order' => function ($dic) {
Esempio n. 9
0
    $dics = Dic::modifyKeys($dics, 'slug');
    $lists = Dic::makeLists($dics, 'values', 'name', 'id');
    #Helper::tad($lists);
    
    #Helper::tad($dics);
    if (isset($lists['course']) && count($lists['course'])) {
        foreach ($lists['course'] as $id => $name) {
            $lists['course'][$id] = $name . ' (' . $dics['course'][$id]->name . ')';
        }
    }
    #Helper::tad($lists);
    */
    /**
     * Добавляем доп. элементы в меню, в данном случае: выпадающие поля для организации фильтрации записей по их свойствам
     */
    #$menus[] = Helper::getDicValMenuDropdown('course_id', 'Все курсы', $lists['course'], $dic);
    #$menus[] = Helper::getDicValMenuDropdown('format_id', 'Все форматы', $lists['format'], $dic);
    if (null != ($cid = Input::get('filter.fields.course_id')) && null !== ($course = DicVal::find($cid))) {
        #$course->load('fields');
        #$menus[] = array('raw' => '<strong>' . $course->name . '</strong>');
        $url = action('entity.edit', array('dic_id' => 'course', $course->id));
        $menus[] = ['link' => $url, 'title' => '<i class="fa fa-arrow-circle-left"></i> К курсу', 'class' => 'btn btn-default'];
        $url = action('entity.index', array('dic_id' => $dic->slug)) . '?' . urlencode('filter[fields][course_id]') . '=' . $course->id;
        $menus[] = ['link' => $url, 'title' => $course->name, 'class' => 'btn btn-default'];
    }
    return $menus;
}, 'hooks' => array('before_index_view' => function ($dic, &$dicvals) {
    #$dicvals = DicLib::loadImages($dicvals, ['image']);
}, 'after_store_update_destroy_order' => function ($dic = NULL, $dicval = NULL) {
    Cache::forget('dic_' . $dic->slug);
}), 'disable_listing_without_filter' => ['fields' => ['course_id'], 'message' => 'Сначала выберите курс.']);