Deprecated: Optional parameter $page declared before required parameter $totalrecords is implicitly treated as a required parameter in /home/demoweb/public_html/bigan/php/PDOModel.php on line 1462
$max) { $string = wordwrap($string, $max); $string = substr($string, 0, strpos($string, "\n")); $string.= '...'; } return $string; } function formatSizeUnits($bytes) { if ($bytes >= 1073741824) { $bytes = number_format($bytes / 1073741824, 2) . ' GB'; } elseif ($bytes >= 1048576) { $bytes = number_format($bytes / 1048576, 2) . ' MB'; } elseif ($bytes >= 1024) { $bytes = number_format($bytes / 1024, 2) . ' KB'; } elseif ($bytes > 1) { $bytes = $bytes . ' bytes'; } elseif ($bytes == 1) { $bytes = $bytes . ' byte'; } else { $bytes = '0 bytes'; } return $bytes; } function getLastPathSegment($url) { $path = parse_url($url, PHP_URL_PATH); // to get the path from a whole URL $pathTrimmed = trim($path, '/'); // normalise with no leading or trailing slash $pathTokens = explode('/', $pathTrimmed); // get segments delimited by a slash if (substr($path, -1) !== '/') { array_pop($pathTokens); } return end($pathTokens); // get the last segment } function fecha_lng($date,$lng) { if ($lng=="es" or $lng=="ca") { $dia = explode("-", $date, 3); $year = $dia[0]; $month = (string)(int)$dia[1]; $day = (string)(int)$dia[2]; return $day."/".$month."/".$year; } else { return $year."/".$month."/".$day; } } function fecha_mes($mes,$lng) { $mes = intval($mes); switch ($lng) { case 'ca': $mesesN=array(1=>"Gener","Febrer","Març","Abril","Maig","Juny","Juliol", "Agost","Setembre","Octubre","Novembre","Desembre"); break; case 'es': $mesesN=array(1=>"Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio", "Agosto","Septiembre","Octubre","Noviembre","Diciembre"); break; case 'en': $mesesN=array(1=>"January","February","March","April","May","June","July", "August","September","October","November","December"); break; } return $mesesN[$mes]; } // Originally found here: http://blog.maverickgroups.com/php/parse-youtube-url-to-get-video-id-thumbnail-image-or-embed-code/ // Modified for use in WordPress /* * parse_youtube_url() PHP function * @param string $url URL to be parsed, eg: * http://youtu.be/BLxI_1iKYgc, * http://www.youtube.com/embed/BLxI_1iKYgc * http://www.youtube.com/watch?v=BLxI_1iKYgc * @param string $return what to return * - embed, return embed code * - thumb, return URL to thumbnail image * - hqthumb, return URL to high quality thumbnail image. * @param string $width width of embeded video, default 560 * @param string $height height of embeded video, default 349 * @param string $rel whether embeded video to show related video after play or not. * How to Use... * // return thumb image echo parse_youtube_url('http://youtu.be/ML2KAaR26Pk','mqthumb'); * // return embed url echo parse_youtube_url('http://www.youtube.com/watch?v=ML2KAaR26Pk','embedurl'); */ function parse_youtube_url($url,$return='embed',$width='',$height='',$rel=0){ $urls = parse_url($url); // url is http://youtu.be/abcd if($urls['host'] == 'youtu.be'){ $id = ltrim($urls['path'],'/'); } // url is http://www.youtube.com/embed/abcd else if(strpos($urls['path'],'embed') == 1){ $id = end(explode('/',$urls['path'])); } // url is xxxx only else if(strpos($url,'/')===false){ $id = $url; } // http://www.youtube.com/watch?feature=player_embedded&v=ML2KAaR26Pk // url is http://www.youtube.com/watch?v=ML2KAaR26Pk else{ parse_str($urls['query']); $id = $v; if(!empty($feature)){ $id = end(explode('v=',$urls['query'])); } } // return embed iframe if($return == 'embed'){ return ''; } // return embed only else if($return == 'embedurl'){ return '//www.youtube.com/embed/'.$id; } // return normal thumb else if($return == 'thumb'){ return '//i1.ytimg.com/vi/'.$id.'/default.jpg'; } // return mqthumb else if($return == 'mqthumb'){ return '//i1.ytimg.com/vi/'.$id.'/mqdefault.jpg'; } // else return id else{ return $id; } } function truncate_html($html, $length = 100, $ending = '...') { if (!is_string($html)) { trigger_error('Function \'truncate_html\' expects argument 1 to be an string', E_USER_ERROR); return false; } if (mb_strlen(strip_tags($html)) <= $length) { return $html; } $total = mb_strlen($ending); $open_tags = array(); $return = ''; $finished = false; $final_segment = ''; $self_closing_elements = array( 'area', 'base', 'br', 'col', 'frame', 'hr', 'img', 'input', 'link', 'meta', 'param' ); $inline_containers = array( 'a', 'b', 'abbr', 'cite', 'em', 'i', 'kbd', 'span', 'strong', 'sub', 'sup' ); while (!$finished) { if (preg_match('/^<(\w+)[^>]*>/', $html, $matches)) { // Does the remaining string start in an opening tag? // If not self-closing, place tag in $open_tags array: if (!in_array($matches[1], $self_closing_elements)) { $open_tags[] = $matches[1]; } // Remove tag from $html: $html = substr_replace($html, '', 0, strlen($matches[0])); // Add tag to $return: $return .= $matches[0]; } elseif (preg_match('/^<\/(\w+)>/', $html, $matches)) { // Does the remaining string start in an end tag? // Remove matching opening tag from $open_tags array: $key = array_search($matches[1], $open_tags); if ($key !== false) { unset($open_tags[$key]); } // Remove tag from $html: $html = substr_replace($html, '', 0, strlen($matches[0])); // Add tag to $return: $return .= $matches[0]; } else { // Extract text up to next tag as $segment: if (preg_match('/^([^<]+)(<\/?(\w+)[^>]*>)?/', $html, $matches)) { $segment = $matches[1]; // Following code taken from https://trac.cakephp.org/browser/tags/1.2.1.8004/cake/libs/view/helpers/text.php?rev=8005. // Not 100% sure about it, but assume it deals with utf and html entities/multi-byte characters to get accureate string length. $segment_length = mb_strlen(preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i', ' ', $segment)); // Compare $segment_length + $total to $length: if ($segment_length + $total > $length) { // Truncate $segment and set as $final_segment: $remainder = $length - $total; $entities_length = 0; if (preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i', $segment, $entities, PREG_OFFSET_CAPTURE)) { foreach($entities[0] as $entity) { if ($entity[1] + 1 - $entities_length <= $remainder) { $remainder--; $entities_length += mb_strlen($entity[0]); } else { break; } } } // Otherwise truncate $segment and set as $final_segment: $finished = true; $final_segment = mb_substr($segment, 0, $remainder + $entities_length); } else { // Add $segment to $return and increase $total: $return .= $segment; $total += $segment_length; // Remove $segment from $html: $html = substr_replace($html, '', 0, strlen($segment)); } } else { $finshed = true; } } } // Check for spaces in $final_segment: if (strpos($final_segment, ' ') === false && preg_match('/<(\w+)[^>]*>$/', $return)) { // If none and $return ends in an opening tag: (we ignore $final_segment) // Remove opening tag from end of $return: $return = preg_replace('/<(\w+)[^>]*>$/', '', $return); // Remove opening tag from $open_tags: $key = array_search($matches[3], $open_tags); if ($key !== false) { unset($open_tags[$key]); } } else { // Otherwise, truncate $final_segment to last space and add to $return: // $spacepos = strrpos($final_segment, ' '); $return .= mb_substr($final_segment, 0, mb_strrpos($final_segment, ' ')); } $return = trim($return); $len = strlen($return); $last_char = substr($return, $len - 1, 1); if (!preg_match('/[a-zA-Z0-9]/', $last_char)) { $return = substr_replace($return, '', $len - 1, 1); } // Add closing tags: $closing_tags = array_reverse($open_tags); $ending_added = false; foreach($closing_tags as $tag) { if (!in_array($tag, $inline_containers) && !$ending_added) { $return .= $ending; $ending_added = true; } $return .= ''; } if ($ending_added) { return $return; } else { return $return . $ending; } } function cons_contenido($idContenido,$class=NULL,$data=NULL,$type=NULL) { global $pdo; $query="SELECT * FROM web_bloques_contenidos WHERE (id_contenido='$id_contenido' OR slug='$idContenido') AND visible='1'"; $data=$pdo->executeQuery($query); $data=$data[0]; $idioma=$_SESSION['w_idioma']; $idiomadef=$_SESSION['w_idiomadef']; switch ($data['cfg_tipo']) { case 'img': global $IMG_ROOT; if ($data['cfg_multilang']==1) { $alt=$data['titulo_'.$idioma]; $src=$data['contenido_'.$idioma]; } else { $alt=$data['titulo_'.$idiomadef]; $src=$data['contenido_'.$idiomadef]; } if ($type=="plain") { $contenido=$src; } else { $contenido=''.$alt.''; } break; default: if ($data['cfg_multilang']==1) { $contenido=$data['contenido_'.$idioma]; } else { $contenido=$data['contenido_'.$idiomadef]; } break; } if (session_id()=="SONOSMEDIA_AUTH_SSID") { return '
Editar
'.$contenido.'
'; } else { return $contenido; } } function cons_seccion($pdo,$slug) { $data=cons_table_one('web_secciones',"WHERE slug='$slug'"); if($data){ return($data); } else { //exit; } } ?> Bigan - BIGAN