private function parseSettings() { $settings = SettingItem::hasInterface()->get(); $parsedSettings = array(); foreach ($settings as $setting) { if ($setting->isFile() || $setting->isImage()) { if (Input::has("setting.{$setting->setting_key}")) { $value = Input::get("setting.{$setting->setting_key}"); if (Input::hasFile($setting->setting_key)) { $subFolder = ($setting->isImage() ? "images" : "files") . "/"; $newFilename = uniqid() . "_" . time() . "." . Input::file($setting->setting_key)->getClientOriginalExtension(); $file = Input::file($setting->setting_key); $file->move(AssetsHelper::uploadPath($subFolder), $newFilename); $value = $subFolder . $newFilename; } $parsedSettings[$setting->setting_key] = $value; } } else { if ($setting->isMultipleChoice()) { $parsedSettings[$setting->setting_key] = implode("|||", Input::get("setting.{$setting->setting_key}")); } else { if (Input::has("setting.{$setting->setting_key}")) { $parsedSettings[$setting->setting_key] = Input::get("setting.{$setting->setting_key}"); } else { if (!$setting->isRequired()) { $parsedSettings[$setting->setting_key] = Input::get("setting.{$setting->setting_key}"); } } } } } return $parsedSettings; }
public static function addSetting($group, $key, $value, $lang_key, $autoload = 1, $required = 1, $desc_key = '', $type = 'text', $options = '', $mchoice = 0, $has_interface = true) { $settingGroup = SettingGroupItem::findSettingGroup($group); if ($settingGroup) { if ($type == "choices") { $mchoice = 1; } $new = false; $setting = self::findSetting($key); if (!$setting) { $new = true; $setting = new SettingItem(); $setting->setting_group_id = $settingGroup->id; } if ($setting->setting_group_id == $settingGroup->id) { $setting->setting_name_lang = $lang_key; $setting->setting_desc_lang = $desc_key; $setting->setting_key = $key; if ($new) { $setting->setting_value = $value; } $setting->setting_required = $required; $setting->setting_type = $type; $setting->setting_options = $options; $setting->setting_mchoice = (int) $mchoice; $setting->has_interface = (int) $has_interface; $setting->autoload = (int) $autoload; $setting->save(); } } }
<div class="page-head"> <h1 class="col-md-6"><?php echo trans("settings-module::label.manage_settings"); ?> </h1> <div class="clearfix"></div> </div> <?php if (\Developeryamhi\SettingsModule\SettingItem::count() < 1) { echo "<p>" . trans("settings-module::message.no_settings_available") . "</p>"; return; } ?> {{ Form::open(array('route' => 'save_settings', 'files' => true)) }} <div class="panel"> <div class="panel-body"> <ul class="nav nav-tabs"> <?php foreach ($groups as $i => $group) { ?> <?php if (!$group->hasSettings()) { continue; } ?> <li<?php echo $i == 0 ? ' class="active"' : ''; ?> title="<?php
/** * Get Setting * * @param type $key * @param type $def * @return type */ function getSetting($key, $def = null) { return \Developeryamhi\SettingsModule\SettingItem::getSetting($key, $def); }