08 2024
This commit is contained in:
parent
04d677d37a
commit
bfa3bb1df4
1191 changed files with 637397 additions and 10619 deletions
108
app/Services/DcHelper.php
Normal file
108
app/Services/DcHelper.php
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Tag;
|
||||
use App\Models\DcTag;
|
||||
use App\Models\FileTag;
|
||||
use App\Models\DcFileTag;
|
||||
|
||||
class DcHelper {
|
||||
|
||||
|
||||
public static $points;
|
||||
|
||||
public static function getTransChange(){
|
||||
|
||||
$langs = [
|
||||
'de' => ['name' => 'German', 'script' => 'Latn', 'native' => 'Deutsch', 'regional' => 'de_DE'],
|
||||
'en' => ['name' => 'English', 'script' => 'Latn', 'native' => 'English', 'regional' => 'en_GB'],
|
||||
'es' => ['name' => 'Spanish', 'script' => 'Latn', 'native' => 'español', 'regional' => 'es_ES'],
|
||||
];
|
||||
|
||||
$ret = [];
|
||||
foreach($langs as $code => $lang){
|
||||
$ret[strtolower($code)] = strtolower($lang['native']);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function makeNestableList($category_id){
|
||||
$tags = DcTag::where('category_id', $category_id)->orderBy('pos')->get();
|
||||
$out = "";
|
||||
foreach ($tags as $tag){
|
||||
|
||||
$out .= '<li class="dd-item" data-id="'.$tag->id.'">
|
||||
<span class="pull-right">
|
||||
<a href="#" class="btn btn-sm mt-1 nestable_update_btn" data-action="update-tag-active" data-target="self" data-id="'.$tag->id.'" data-url="'.route('admin_downloadcenter_item_store', ['update_ajax']).'">
|
||||
' . ($tag->active ? '<i class="fa fa-eye text-success"></i>' : '<i class="fa fa-eye-slash text-danger"></i>') . '
|
||||
</a>
|
||||
<a href="'.route('admin_downloadcenter_item_delete', ['obj' => 'tag', 'id'=> $tag->id]).'" class="btn btn-sm mt-1 nestable_list_delete"><i class="fa fa-trash text-danger"></i></a>
|
||||
</span>
|
||||
<div class="dd-handle">
|
||||
'.$tag->name.'
|
||||
</div>
|
||||
</li>';
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
public static function makeNestableListCheckbox($category_id, $file_id){
|
||||
|
||||
$tags = DcTag::where('category_id', $category_id)->orderBy('pos')->get();
|
||||
$file_tags = DcFileTag::where('file_id', $file_id)->get();
|
||||
|
||||
$search = array();
|
||||
foreach ($file_tags as $file_tag) {
|
||||
$search[] = $file_tag->tag_id;
|
||||
}
|
||||
|
||||
$out = "";
|
||||
foreach ($tags as $tag){
|
||||
$out .= '<li class="dd-item" data-id="'.$tag->id.'">
|
||||
<div class="dd-handle dd-nodrag">
|
||||
<label class="custom-control custom-checkbox m-0" for="nestable_check_'.$tag->id.'">
|
||||
<input type="checkbox" class="custom-control-input" name="nestable_check[]" id="nestable_check_'.$tag->id.'" value="'.$tag->id.'" '.(array_search($tag->id, $search) !== FALSE ? 'checked="checked"' : '').'>
|
||||
<span class="custom-control-label"> '.$tag->name.' </span>
|
||||
</label>
|
||||
</div>
|
||||
</li>';
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function makeFilterList($filter_list, $split = false, $chunk = false){
|
||||
|
||||
$out = "";
|
||||
$splitOn = 0;
|
||||
if($split){
|
||||
$count = count($filter_list);
|
||||
if($count > 0){
|
||||
$splitOn = intval(ceil($count / $split));
|
||||
$filter_chunk = array_chunk($filter_list, $splitOn, true);
|
||||
$filter_list = $filter_chunk[$chunk];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach($filter_list as $category_id => $value){
|
||||
$out .= '<label class="form-label" for="category_'.$category_id.'">'.$value['name'].'</label>';
|
||||
$out .= '<select class="selectpicker category-filter" name="categories['.$category_id.'][]" id="category_'.$category_id.'" data-style="btn-light" data-live-search="true" multiple>';
|
||||
foreach($value['items'] as $tag){
|
||||
$out .= '<option value="'.$tag->id.'">'.$tag->name.' ('.$tag->count.')</option>';
|
||||
|
||||
}
|
||||
$out .= '</select>';
|
||||
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
private function getAttributesOptions($ids = array(), $all = true){
|
||||
$ret = "";
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue