public function category() { $this->category = MObject::get('category', $this->get_object()); if ($this->category && $this->category->get_id()) { $this->set_page_title($this->category->get_title()); $contents = $this->category->get_contents(); //getting language $language = new M_Language(); $lang = $language->getLanguage(); $filtered_contents = array(); foreach ($contents as $content) { if ($lang == $content->get_language()) { $mod = $content->modified(); $time = strtotime($mod['when']); $filtered_contents[$time] = $content; } } ksort($filtered_contents); $descending = array_reverse($filtered_contents); $this->view('default', array($descending, $this->category->get_title())); } else { header('Location: index.php?module=page404'); exit(0); } }
public function content() { $task = $this->get_task(); if (!$task) { //getting language $language = new M_Language(); $lang = $language->getLanguage(); $this->content = MObject::get('content', $this->get_object()); //print_r($this->content); die(); if ($lang == $this->content->get_language()) { //var_dump($lang); die();//megfelel a nyelv, kiolvassuk. $this->content = MObject::get('content', $this->get_object()); } else { //nem felel meg, megnezzuk van-e olyan nyelvu forditasa $this->content_id = $this->model('get_translation', array("content" => $this->get_object(), "lang" => strval($lang))); $this->content = MObject::get('content', intval($this->content_id)); } if ($this->content) { global $content; $content = $this->content; if ($this->content->is_enabled() == FALSE) { header('Location: index.php?module=page404'); exit(0); } global $coords; $coords['lat'] = $this->content->get_lat(); $coords['lng'] = $this->content->get_lng(); $this->set_page_title($this->content->get_title()); $content_meta = $content->get_meta(); if (sizeof($content_meta) > 0) { foreach ($content_meta as $meta) { switch ($meta->name) { case 'description': case 'keywords': case 'author': case 'robots': $this->add_page_meta($meta->name, $meta->value); break; } } } $this->model('add_hit', $content->get_id()); $this->view('default', $content); } else { header('Location: index.php?module=page404'); exit(0); } } }
function __($text) { $backtrace = debug_backtrace(); $rel_path = str_replace(APATH, "", $backtrace[0]["file"]); $path_elements = explode(DIRECTORY_SEPARATOR, $rel_path); $path_array = array_filter($path_elements); $ext_type = trim(reset($path_array)); //extension type next($path_array); $ext_name = trim(current($path_array)); //extension name $lang = new M_Language(); $language = $lang->getLanguage(); $lang_ini_file_path = $ext_type . "/" . $ext_name . "/lang/" . $language . ".ini"; $translation_string = $lang->getTranslation($text, $lang_ini_file_path); echo $translation_string; }
function mwidget_slider($slider_id) { $sid = intval($slider_id); if ($sid) { $contents = array(); $category = MObject::get('category', $sid); if ($category && $category->get_id()) { $contents = $category->get_contents(); } $filtered_contents = array(); $language = new M_Language(); $lang = $language->getLanguage(); //var_dump($contents);die(); if (sizeof($contents) > 0) { foreach ($contents as $content) { if ($lang == $content->get_language()) { $filtered_contents[] = $content; } } $filtered = false; if (sizeof($filtered_contents) > 0) { $contents = $filtered_contents; $filtered = true; } ?> <div id="carousel-captions" class="carousel slide" data-ride="carousel"> <ol class="carousel-indicators"> <?php $k = 0; foreach ($contents as $content) { ?> <li data-target="#carousel-captions" data-slide-to="<?php echo $k; ?> " class="<?php if (0 == $k) { echo "active"; } ?> "></li> <?php $k++; } ?> </ol> <div class="carousel-inner"> <?php $i = 0; foreach ($contents as $content) { if ($filtered && 3 == $i) { break; } $slide = $content->get_media(true); if (!is_object($slide)) { $slide = $content->get_media(); } if (is_array($slide)) { reset($slide); $slide = current($slide); } if (!is_object($slide)) { $slide = new stdClass(); $slide->url = mapi_install_url() . 'media/default_slider.jpg'; } ?> <div class="item<?php if (0 == $i) { echo ' active'; } ?> " style="cursor: pointer;" onclick="location.href='index.php?module=content&object=<?php echo intval($content->get_id()); ?> '"> <img class="carousel-image" src="<?php MPut::_link($slide->url); ?> " style="width: 100%;"> <div class="carousel-caption"> <h3 class="hidden-xs hidden-sm"><?php MPut::_html($content->get_title()); ?> </h3> <h4 class="hidden-md hidden-lg"><?php MPut::_html($content->get_title()); ?> </h4> <p class="hidden-xs hidden-sm"><?php echo mapi_short_description($content->get_text(), 1); ?> </p> </div> <?php $hashtag = $content->get_meta('slide-hashtag'); if ($hashtag->get_value()) { ?> <a class="carousel-red-label"> #<?php MPut::_html($hashtag->get_value()); ?> </a> <?php } ?> </div> <?php $i++; } ?> </div> <a class="left carousel-control" href="#carousel-captions" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left"></span> </a> <a class="right carousel-control" href="#carousel-captions" data-slide="next"> <span class="glyphicon glyphicon-chevron-right"></span> </a> <?php } } }
function mwidget_language_switch($id = null) { ?> <select class="languageswitch"> <?php $lang = new M_Language(); $language = $lang->getLanguage(); ?> <option value="hr" <?php if ("hr" == $language) { echo 'selected="selected"'; } ?> >Croatian</option> <option value="da" <?php if ("da" == $language) { echo 'selected="selected"'; } ?> >Danish</option> <option value="nl" <?php if ("nl" == $language) { echo 'selected="selected"'; } ?> >Dutch</option> <option value="en" <?php if ("en" == $language) { echo 'selected="selected"'; } ?> >English</option> <option value="fr" <?php if ("fr" == $language) { echo 'selected="selected"'; } ?> >French</option> <option value="de" <?php if ("de" == $language) { echo 'selected="selected"'; } ?> >German</option> <option value="gr" <?php if ("gr" == $language) { echo 'selected="selected"'; } ?> >Greece</option> <option value="hu" <?php if ("hu" == $language) { echo 'selected="selected"'; } ?> >Hungarian</option> <option value="it" <?php if ("it" == $language || !$language) { echo 'selected="selected"'; } ?> >Italian</option> <option value="ru" <?php if ("ru" == $language) { echo 'selected="selected"'; } ?> >Russian</option> <option value="sr" <?php if ("sr" == $language) { echo 'selected="selected"'; } ?> >Serbian</option> <option value="si" <?php if ("si" == $language) { echo 'selected="selected"'; } ?> >Slovenian</option> <option value="sv" <?php if ("sv" == $language) { echo 'selected="selected"'; } ?> >Swedish</option> </select> <script> function setGetParameter(paramName, paramValue) { var url = window.location.href; if (url.indexOf(paramName + "=") >= 0) { var prefix = url.substring(0, url.indexOf(paramName)); var suffix = url.substring(url.indexOf(paramName)).substring(url.indexOf("=") + 1); suffix = (suffix.indexOf("&") >= 0) ? suffix.substring(suffix.indexOf("&")) : ""; url = prefix + paramName + "=" + paramValue + suffix; } else { if (url.indexOf("?") < 0) url += "?" + paramName + "=" + paramValue; else url += "&" + paramName + "=" + paramValue; } window.location.href = url; } $(".languageswitch").on("change", function() { setGetParameter("lang",$(this).val()); }); </script> <?php }