public static function sliderPhotoArray($text = true, $slide = true, $id = false) { $apartments = Apartment::sliderOrId($id)->active()->get(); $currency = Settings::item('currency'); $photos['path'] = []; $photos['slide'] = $slide; foreach ($apartments as $apartment) { if ($id) { $photos['path'] = array_pluck(self::photoArray($apartment->photos, $apartment->id), 'path'); // show apartment page } else { $photos['path'][] = self::firstPhoto($apartment->photos, $apartment->id, false); // home page } if ($text) { $photos['text'][] = '<a href="' . Url('/apartment/' . $apartment->id) . add_slug($apartment->slug) . '">' . $apartment->street . ', ' . $apartment->house . ' <br /> ' . $apartment->price . ' ' . trans('admin/settings.main.' . $currency) . '/' . trans('front/apartment.night') . '</a>'; } } $photos['count'] = count($photos['path']); return $photos; }
/** * Function used to update video */ function update_video($array = NULL) { global $eh, $Cbucket, $db, $Upload; $Upload->validate_video_upload_form(NULL, TRUE); if (empty($eh->error_list)) { $required_fields = $Upload->loadRequiredFields($array); $location_fields = $Upload->loadLocationFields($array); $option_fields = $Upload->loadOptionFields($array); $upload_fields = array_merge($required_fields, $location_fields, $option_fields); //Adding Custom Upload Fields if (count($Upload->custom_upload_fields) > 0) { $upload_fields = array_merge($upload_fields, $Upload->custom_upload_fields); } //Adding Custom Form Fields if (count($Upload->custom_form_fields) > 0) { $upload_fields = array_merge($upload_fields, $Upload->custom_form_fields); } //Adding custom fields from group if (count($Upload->custom_form_fields_groups) > 0) { $custom_fields_from_group_fields = array(); $custom_fields_from_group = $Upload->custom_form_fields_groups; foreach ($custom_fields_from_group as $cffg) { $custom_fields_from_group_fields = array_merge($custom_fields_from_group_fields, $cffg['fields']); } $upload_fields = array_merge($upload_fields, $custom_fields_from_group_fields); } if (!$array) { $array = $_POST; } $vid = $array['videoid']; $the_video = get_video_details($vid); if (is_array($_FILES)) { $array = array_merge($array, $_FILES); } foreach ($upload_fields as $field) { $name = formObj::rmBrackets($field['name']); $val = $array[$name]; if (empty($val) && $field['use_if_value']) { } else { if ($field['use_func_val']) { $val = $field['validate_function']($val); } if (!empty($field['db_field'])) { $query_field[] = $field['db_field']; } if (is_array($val)) { $new_val = ''; foreach ($val as $v) { $new_val .= "#" . $v . "# "; } $val = $new_val; } if (!$field['clean_func'] || !apply_func($field['clean_func'], $val) && !is_array($field['clean_func'])) { $val = $val; } else { $val = apply_func($field['clean_func'], sql_free('|no_mc|' . $val)); } if (!empty($field['db_field'])) { $query_val[] = $val; } } } #$query = "INSERT INTO video ("; $total_fields = count($query_field); /* for($key=0;$key<$total_fields;$key++) { $query .= query_field[$key]." = '".$query_val[$key]."'" ; if($key<$total_fields-1) $query .= ','; } */ if (has_access('admin_access', TRUE)) { if (!empty($array['status'])) { $query_field[] = 'status'; $query_val[] = $array['status']; } if (!empty($array['duration']) && is_numeric($array['duration']) && $array['duration'] > 0) { $query_field[] = 'duration'; $query_val[] = $array['duration']; } if (!empty($array['views'])) { $query_field[] = 'views'; $query_val[] = $array['views']; } if (!empty($array['rating'])) { $query_field[] = 'rating'; $rating = $array['rating']; if (!is_numeric($rating) || $rating < 0 || $rating > 10) { $rating = 1; } $query_val[] = $rating; } if (!empty($array['rated_by'])) { $query_field[] = 'rated_by'; $query_val[] = $array['rated_by']; } } if (!userid()) { e(lang("you_dont_have_permission_to_update_this_video")); } elseif (!$this->video_exists($vid)) { e(lang("class_vdo_del_err")); } elseif (!$this->is_video_owner($vid, userid()) && !has_access('admin_access', TRUE)) { e(lang("no_edit_video")); } else { //pr($upload_fields); //Updating Slug if (config('auto_update_slug') != 'no' || !$the_video['slug']) { if ($the_video['title'] != $array['title']) { $slug = slug($array['title']); if ($the_video['slug'] != $slug) { $db->update(tbl('slugs'), array('in_use'), array('no'), "object_id='{$vid}' AND object_type='v' "); $slug_arr = add_slug($slug, $vid, 'v'); $query_field[] = 'slug_id'; $query_val[] = $slug_arr['id']; } } } $db->update(tbl('video'), $query_field, $query_val, " videoid='{$vid}'"); call_actions('update_video', array('videoid' => $vid, 'data' => $array)); //echo $db->db_query; e(lang("class_vdo_update_msg"), 'm'); } } }
/** * Gets link of video * * Get video link depending how you have configured clipbucket * SEO or Non-Seo or change patterns. * * @param ARRAY video details or it can be INT videoid * @param STRING type , {link|download} */ function video_link($vdetails, $type = NULL) { global $myquery, $db; #checking what kind of input we have if (is_array($vdetails)) { if (empty($vdetails['title'])) { #check for videoid if (empty($vdetails['videoid']) && empty($vdetails['vid']) && empty($vdetails['videokey'])) { return BASEURL; } else { if (!empty($vdetails['videoid'])) { $vid = $vdetails['videoid']; } elseif (!empty($vdetails['vid'])) { $vid = $vdetails['vid']; } elseif (!empty($vdetails['videokey'])) { $vid = $vdetails['videokey']; } else { return BASEURL; } } } } else { if (is_numeric($vdetails)) { $vid = $vdetails; } else { return BASEURL; } } #checking if we have vid , so fetch the details if (!empty($vid)) { $vdetails = $myquery->get_video_details($vid); } //calling for custom video link functions $functions = cb_get_functions('video_link'); if ($functions) { foreach ($functions as $func) { $array = array('vdetails' => $vdetails, 'type' => $type); if (function_exists($func['func'])) { $returned = $func['func']($array); if ($returned) { $link = $returned; return $link; break; } } } } $plist = ""; if (SEO == 'yes') { if ($vdetails['slug']) { $slug = $vdetails['slug']; } else { //check if slug was recently added... if (!$vdetails['slug']) { $slug_arr = get_slug($vdetails['videoid'], 'v'); } else { $slug_arr = $vdetails; } if (!$slug_arr) { $slug_arr = add_slug(slug($vdetails['title']), $vdetails['videoid'], 'v'); $db->update(tbl('video'), array('slug_id', 'slug'), array($slug_arr['id'], $slug_arr['slug']), "videoid='" . $vdetails['videoid'] . "'"); } $slug = $slug_arr['slug']; } if ($vdetails['playlist_id']) { $plist = '?play_list=' . $vdetails['playlist_id']; } switch (config('seo_vido_url')) { default: $link = BASEURL . '/video/' . $vdetails['videokey'] . '/' . $slug . $plist; break; case 1: $link = BASEURL . '/' . $slug . '_v' . $vdetails['videoid'] . $plist; break; case 2: $link = BASEURL . '/video/' . $vdetails['videoid'] . '/' . $slug . $plist; break; case 3: $link = BASEURL . '/video/' . $vdetails['videoid'] . '_' . $slug . $plist; case 4: $link = BASEURL . '/video/' . $slug . $plist; break; } } else { if ($vdetails['playlist_id']) { $plist = '&play_list=' . $vdetails['playlist_id']; } $link = BASEURL . '/watch_video.php?v=' . $vdetails['videokey'] . $plist; } if (!$type || $type == 'link') { return $link; } elseif ($type == 'download') { return BASEURL . '/download.php?v=' . $vdetails['videokey']; } }