Exemple #1
0
 public function export()
 {
     $postsList = $this->loadTopic($this->getTopicId());
     $topicInfo = get_topic_settings($this->getTopicId());
     $this->createPDF($topicInfo['topic_title']);
     $this->pdf->AddPage();
     $htmlContent = '<p>' . "\n" . '<table cellspacing="0" cellpadding="2" border="1">' . "\n" . '<tbody>' . "\n" . '<tr>' . "\n" . '<th colspan="2" style="font-weight: bold; background-color: #EDF1E3; color: #669933; border-bottom: 1px solid #96BB7A;">' . claro_utf8_encode($topicInfo['topic_title']) . '</th>' . '</tr>' . "\n";
     foreach ($postsList as $post) {
         $htmlContent .= '<tr>' . "\n" . '<td style="width: 150px; background-color: #EEEEEE;">' . "\n" . '<div style="font-weight: bold;">' . claro_utf8_encode($post['firstname'] . ' ' . $post['lastname'], get_conf('charset')) . '</div>' . "\n" . '<small>' . claro_html_localised_date(get_locale('dateTimeFormatLong'), datetime_to_timestamp($post['post_time'])) . '</small>' . "\n" . '</td>' . "\n" . '<td style="width: 354px;">' . claro_utf8_encode(claro_parse_user_text(strip_tags($post['post_text'])), get_conf('charset')) . '</td>' . "\n" . '</tr>' . "\n";
     }
     $htmlContent .= '</tbody>' . "\n" . '</table>' . "\n" . '</p>';
     //exit( claro_utf8_decode($htmlContent) );
     $this->pdf->writeHTML($htmlContent, true, 0, true, 0);
     switch ($this->output) {
         case 'screen':
             $this->pdf->Output(claro_utf8_encode($topicInfo['topic_id'] . '_' . $topicInfo['topic_title'] . '.pdf'), 'D');
             break;
         default:
             $path = get_conf('rootSys') . get_conf('tmpPathSys') . '/forum_export/';
             claro_mkdir($path);
             $this->pdf->Output($path . claro_utf8_encode(replace_dangerous_char($topicInfo['topic_id'] . '_' . $topicInfo['topic_title']) . '.pdf'), 'F');
             break;
     }
     return true;
 }
function smarty_resource_mt_timestamp($tpl_name, &$tpl_timestamp, &$ctx)
{
    #$tpl_timestamp = $ctx->stash('template_timestamp');
    #if (!$tpl_timestamp) {
    $blog = $ctx->stash('blog');
    $tpl_timestamp = datetime_to_timestamp($blog['blog_children_modified_on']);
    #}
    return true;
}
function smarty_resource_mt_timestamp($tpl_name, &$tpl_timestamp, &$ctx)
{
    #$tpl_timestamp = $ctx->stash('template_timestamp');
    #if (!$tpl_timestamp) {
    require_once 'MTUtil.php';
    $blog = $ctx->stash('blog');
    $tpl_timestamp = datetime_to_timestamp($blog->blog_children_modified_on);
    #}
    return true;
}
Exemple #4
0
 function api_attributes()
 {
     $api_attributes = array('id', 'tags', 'created_at', 'creator_id', 'author', 'change', 'source', 'score', 'md5', 'file_size', 'file_url', 'is_shown_in_index', 'preview_url', 'preview_width', 'preview_height', 'actual_preview_width', 'actual_preview_height', 'sample_url', 'sample_width', 'sample_height', 'sample_file_size', 'jpeg_url', 'jpeg_width', 'jpeg_height', 'jpeg_file_size', 'rating', 'has_children', 'parent_id', 'status', 'width', 'height', 'is_held', 'frames_pending_string', 'frames_string');
     $api_attributes = array_fill_keys($api_attributes, '');
     # Creating these manually because they're not implemented yet.
     $api_attributes['frames_pending'] = $api_attributes['frames'] = array();
     # Column ´change_seq´ still not created in database.
     $api_attributes['change'] = 0;
     foreach (array_keys(get_object_vars($this)) as $name) {
         if ($name == 'user_id') {
             $api_attributes['creator_id'] = $this->{$name};
         } elseif ($name == 'sample_size') {
             $api_attributes['sample_file_size'] = $this->{$name};
         } elseif ($name == 'jpeg_size') {
             $api_attributes['jpeg_file_size'] = $this->{$name};
         } elseif ($name == 'cached_tags') {
             $api_attributes['tags'] = $this->tags;
         } elseif ($name == 'created_at') {
             $api_attributes['created_at'] = datetime_to_timestamp($this->created_at);
         } elseif (array_key_exists($name, $api_attributes)) {
             $api_attributes[$name] = $this->{$name};
         }
     }
     if ($this->status == "deleted") {
         unset($api_attributes['sample_url']);
         unset($api_attributes['jpeg_url']);
         unset($api_attributes['file_url']);
     }
     if (($this->status == "flagged" or $this->status == "deleted" or $this->status == "pending") && $this->flag_detail) {
         $api_attributes['flag_detail'] = $this->flag_detail->api_attributes();
         $this->flag_detail->hide_user = ($this->status == "deleted" and !User::is('>=40'));
     }
     # For post/similar results:
     // if not similarity.nil?
     // ret[:similarity] = similarity
     // end
     return $api_attributes;
 }
function smarty_function_mtinclude($args, &$ctx)
{
    // status: partial
    // parameters: module, file
    // notes: file case needs work -- search through blog site archive path, etc...
    // push to ctx->vars
    $ext_args = array();
    while (list($key, $val) = each($args)) {
        if (!preg_match('/(^file$|^module$|^widget$|^blog_id$|^identifier$|^type$)/', $key)) {
            require_once "function.mtsetvar.php";
            smarty_function_mtsetvar(array('name' => $key, 'value' => $val), $ctx);
            $ext_args[] = $key;
        }
    }
    $blog_id = $args['blog_id'];
    $blog_id or $blog_id = $ctx->stash('blog_id');
    if ($args['local']) {
        $blog_id = $ctx->stash('local_blog_id');
    }
    $blog = $ctx->mt->db()->fetch_blog($blog_id);
    // When the module name starts by 'Widget', it converts to 'Widget' from 'Module'.
    if (isset($args['module']) && $args['module']) {
        $module = $args['module'];
        if (preg_match('/^Widget:/', $module)) {
            $args['widget'] = preg_replace('/^Widget: ?/', '', $module);
            unset($args['module']);
        }
    }
    // Fetch template meta data
    $load_type = null;
    $load_name = null;
    if (isset($args['module'])) {
        $load_type = 'custom';
        $load_name = $args['module'];
    } elseif (isset($args['widget'])) {
        $load_type = 'widget';
        $load_name = $args['widget'];
    } elseif (isset($args['identifier'])) {
        $load_type = 'identifier';
        $load_name = $args['identifier'];
    }
    $tmpl_meta = null;
    if (!empty($load_type)) {
        $is_global = isset($args['global']) && $args['global'] ? 1 : 0;
        if (isset($args['parent']) && $args['parent']) {
            if (isset($args['global']) && $args['global']) {
                return $ctx->error($ctx->mt->translate("'parent' modifier cannot be used with '[_1]'", 'global'));
            }
            if (isset($args['local']) && $args['local']) {
                return $ctx->error($ctx->mt->translate("'parent' modifier cannot be used with '[_1]'", 'global'));
            }
            $local_blog = $ctx->mt->db()->fetch_blog($ctx->stash('local_blog_id'));
            if ($local_blog->is_blog()) {
                $website = $local_blog->website();
                $blog_id = $website->id;
            } else {
                $blog_id = $local_blog->id;
            }
        }
        $tmpl_meta = $ctx->mt->db()->fetch_template_meta($load_type, $load_name, $blog_id, $is_global);
    }
    # Convert to phrase of PHP Include
    require_once 'MTUtil.php';
    $ssi_enable = false;
    $include_file = '';
    if (!empty($load_type) && isset($blog) && $blog->blog_include_system == 'php' && (isset($args['ssi']) && $args['ssi'] || $tmpl_meta->include_with_ssi)) {
        $ssi_enable = true;
        // Generates include path using Key
        $base_path = '';
        if (isset($args['key'])) {
            $base_path = $args['key'];
        } elseif (isset($args['cache_key'])) {
            $base_path or $base_path = $args['cache_key'];
        }
        $include_path_array = _include_path($base_path);
        $filename = dirify($tmpl_meta->template_name);
        $filename or $filename = 'template_' . $tmpl_meta->template_id;
        $filename .= '.' . $blog->blog_file_extension;
        $include_path = $blog->site_path();
        if (substr($include_path, strlen($include_path) - 1, 1) != DIRECTORY_SEPARATOR) {
            $include_path .= DIRECTORY_SEPARATOR;
        }
        foreach ($include_path_array as $p) {
            $include_path .= $p . DIRECTORY_SEPARATOR;
        }
        $include_file = $include_path . $filename;
    }
    # Try to read from cache
    $cache_enable = false;
    $cache_id = '';
    $cache_key = '';
    $cache_ttl = 0;
    $cache_expire_type = $tmpl_meta->cache_expire_type;
    if (!empty($load_type) && isset($blog) && $blog->blog_include_cache == 1 && ($cache_expire_type == '1' || $cache_expire_type == '2') || (isset($args['cache']) && $args['cache'] == '1' || isset($args['key']) || isset($args['cache_key']) || isset($args['ttl']))) {
        $cache_blog_id = isset($args['global']) && $args['global'] == 1 ? 0 : $blog_id;
        $mt = MT::get_instance();
        $cache_enable = true;
        $cache_key = isset($args['key']) ? $args['key'] : (isset($args['cache_key']) ? $args['cache_key'] : md5('blog::' . $cache_blog_id . '::template_' . $load_type . '::' . $load_name));
        if (isset($args['ttl'])) {
            $cache_ttl = $args['ttl'];
        } elseif (isset($cache_expire_type) && $cache_expire_type == '1') {
            $cache_ttl = $tmpl_meta->cache_expire_interval;
        } else {
            $cache_ttl = 60 * 60;
        }
        # default 60 min.
        if (isset($cache_expire_type) && $cache_expire_type == '2') {
            $expire_types = preg_split('/,/', $tmpl_meta->cache_expire_event, -1, PREG_SPLIT_NO_EMPTY);
            if (!empty($expire_types)) {
                $latest = $ctx->mt->db()->get_latest_touch($blog_id, $expire_types);
                if ($latest) {
                    $latest_touch = $latest->modified_on;
                    if ($ssi_enable) {
                        $file_stat = stat($include_file);
                        if ($file_stat) {
                            $file_stamp = gmdate("Y-m-d H:i:s", $file_stat[9]);
                            if (datetime_to_timestamp($latest_touch) > datetime_to_timestamp($file_stamp)) {
                                $cache_ttl = 1;
                            }
                        }
                    } else {
                        $cache_ttl = time() - datetime_to_timestamp($latest_touch, 'gmt');
                    }
                }
            }
        }
        $elapsed_time = time() - offset_time(datetime_to_timestamp($tmpl_meta->template_modified_on, 'gmt'), $blog, '-');
        if ($cache_ttl == 0 || $elapsed_time < $cache_ttl) {
            $cache_ttl = $elapsed_time;
        }
        $cache_driver = $mt->cache_driver($cache_ttl);
        $cached_val = $cache_driver->get($cache_key, $cache_ttl);
        if (!empty($cached_val)) {
            _clear_vars($ctx, $ext_args);
            if ($ssi_enable) {
                if (file_exists($include_file) && is_readable($include_file)) {
                    $content = file_get_contents($include_file);
                    if ($content) {
                        return $content;
                    }
                }
            } else {
                return $cached_val;
            }
        }
    }
    if ($ssi_enable && !$cache_enable) {
        if (file_exists($include_file) && is_readable($include_file)) {
            $content = file_get_contents($include_file);
            if ($content) {
                return $content;
            }
        }
    }
    # Compile template
    static $_include_cache = array();
    $_var_compiled = '';
    if (!empty($load_type)) {
        $cache_blog_id = isset($args['global']) && $args['global'] == 1 ? 0 : $blog_id;
        $cache_id = $load_type . '::' . $cache_blog_id . '::' . $load_name;
        if (isset($_include_cache[$cache_id])) {
            $_var_compiled = $_include_cache[$cache_id];
        } else {
            $tmpl = $ctx->mt->db()->get_template_text($ctx, $load_name, $blog_id, $load_type, $args['global']);
            if (!$ctx->_compile_source('evaluated template', $tmpl, $_var_compiled)) {
                _clear_vars($ctx, $ext_args);
                return $ctx->error("Error compiling template module '{$module}'");
            }
            $_include_cache[$cache_id] = $_var_compiled;
        }
    } elseif (isset($args['file']) && $args['file']) {
        $mt = MT::get_instance();
        if (!$mt->config('AllowFileInclude')) {
            return $ctx->error('File include is disabled by "AllowFileInclude" config directive.');
        }
        $file = $args['file'];
        $cache_id = 'file::' . $blog_id . '::' . $file;
        if (isset($_include_cache[$cache_id])) {
            $_var_compiled = $_include_cache[$cache_id];
        } else {
            $tmpl = _get_template_from_file($ctx, $file, $blog_id);
            if (!$ctx->_compile_source('evaluated template', $tmpl, $_var_compiled)) {
                _clear_vars($ctx, $ext_args);
                return $ctx->error("Error compiling template file '{$file}'");
            }
            $_include_cache[$cache_id] = $_var_compiled;
        }
    } elseif (isset($args['type']) && $args['type']) {
        $type = $args['type'];
        $cache_id = 'type::' . $blog_id . '::' . $type;
        if (isset($_include_cache[$cache_id])) {
            $_var_compiled = $_include_cache[$cache_id];
        } else {
            $tmpl = $ctx->mt->db()->load_special_template($ctx, null, $type, $blog_id);
            if ($tmpl) {
                if ($ctx->_compile_source('evaluated template', $tmpl->template_text, $_var_compiled)) {
                    $_include_cache[$cache_id] = $_var_compiled;
                } else {
                    if ($type != 'dynamic_error') {
                        _clear_vars($ctx, $ext_args);
                        return $ctx->error("Error compiling template module '{$module}'");
                    } else {
                        _clear_vars($ctx, $ext_args);
                        return null;
                    }
                }
            } else {
                _clear_vars($ctx, $ext_args);
                return null;
            }
        }
    }
    ob_start();
    $ctx->_eval('?>' . $_var_compiled);
    $_contents = ob_get_contents();
    ob_end_clean();
    _clear_vars($ctx, $ext_args);
    if ($cache_enable) {
        $cache_driver = $mt->cache_driver($cache_ttl);
        $cache_driver->set($cache_key, $_contents, $cache_ttl);
    }
    if ($ssi_enable) {
        $include_dir = dirname($include_file);
        if (!file_exists($include_dir) && !is_dir($include_dir)) {
            mkpath($include_dir, 0777);
        }
        if (is_writable($include_dir)) {
            if ($h_file = fopen($include_file, 'w')) {
                fwrite($h_file, $_contents);
                fclose($h_file);
            }
        }
    }
    return $_contents;
}
    function widget($args, $instance)
    {
        extract($args, EXTR_SKIP);
        echo $before_widget;
        $title = apply_filters('widget_title', $instance['title']);
        $esemenyek_szama = $instance['esemenyek_szama'];
        // Cím kiírása
        if (!empty($title)) {
            echo $before_title . '<a href="/esemenyek">' . $title . '</a>' . $after_title;
        }
        $esemenyek = new WP_Query();
        $opciok = array('post_type' => 'mw_esemeny', 'post_status' => 'publish', 'order' => 'ASC', 'orderby' => 'meta_value', 'meta_key' => 'esemeny-idopont-kezdo', 'meta_compare' => '>', 'meta_value' => date("Y-m-d H:i:s"), 'showposts' => $esemenyek_szama);
        $esemenyek->query($opciok);
        if ($esemenyek->have_posts()) {
            echo '<ul>';
            while ($esemenyek->have_posts()) {
                $esemenyek->the_post();
                $custom = get_post_custom($post->ID);
                $kezdes = $custom["esemeny-idopont-kezdo"][0];
                if (preg_match('/(\\d{4})(?:\\-)?([0]{1}\\d{1}|[1]{1}[0-2]{1})(?:\\-)?([0-2]{1}\\d{1}|[3]{1}[0-1]{1})(?:\\s)?([0-1]{1}\\d{1}|[2]{1}[0-3]{1})(?::)?([0-5]{1}\\d{1})(?::)?([0-5]{1}\\d{1})/', $kezdes)) {
                    $kezdes_timestamp = datetime_to_timestamp($kezdes);
                }
                ?>
                <li>
                    <span class="esemeny-cim summary">
                        <a href="<?php 
                echo get_permalink();
                ?>
"><?php 
                echo get_the_title();
                ?>
</a>
                    </span>
                    <span class="esemeny-meta">
                        <strong>Kezdődik:</strong> <span class="dtstart"><?php 
                echo date_i18n("Y. F j., l", $kezdes_timestamp);
                ?>
</span>
                    </span>
                </li>
                <?php 
            }
            echo '</ul>';
        } else {
            echo '<p>Jelenleg nem tervezünk semmit.</p>';
        }
        echo $after_widget;
    }
Exemple #7
0
 function view($blog_id = null)
 {
     require_once "MTUtil.php";
     $blog_id or $blog_id = $this->blog_id;
     $ctx =& $this->context();
     $this->init_plugins();
     $ctx->caching = $this->caching;
     // Some defaults...
     $mtdb =& $this->db();
     $ctx->mt->db =& $mtdb;
     // Set up our customer error handler
     set_error_handler(array(&$this, 'error_handler'));
     // User-specified request through request variable
     $path = $this->request;
     // Apache request
     if (!$path && $_SERVER['REQUEST_URI']) {
         $path = $_SERVER['REQUEST_URI'];
         // strip off any query string...
         $path = preg_replace('/\\?.*/', '', $path);
         // strip any duplicated slashes...
         $path = preg_replace('!/+!', '/', $path);
     }
     // IIS request by error document...
     if (preg_match('/IIS/', $_SERVER['SERVER_SOFTWARE'])) {
         // assume 404 handler
         if (preg_match('/^\\d+;(.*)$/', $_SERVER['QUERY_STRING'], $matches)) {
             $path = $matches[1];
             $path = preg_replace('!^http://[^/]+!', '', $path);
             if (preg_match('/\\?(.+)?/', $path, $matches)) {
                 $_SERVER['QUERY_STRING'] = $matches[1];
                 $path = preg_replace('/\\?.*$/', '', $path);
             }
         }
     }
     // now set the path so it may be queried
     $path = preg_replace('/\\\\/', '\\\\\\\\', $path);
     $this->request = $path;
     // When we are invoked as an ErrorDocument, the parameters are
     // in the environment variables REDIRECT_*
     if (isset($_SERVER['REDIRECT_QUERY_STRING'])) {
         // todo: populate $_GET and QUERY_STRING with REDIRECT_QUERY_STRING
         $_SERVER['QUERY_STRING'] = getenv('REDIRECT_QUERY_STRING');
     }
     if (preg_match('/\\.(\\w+)$/', $path, $matches)) {
         $req_ext = strtolower($matches[1]);
     }
     $this->blog_id = $blog_id;
     $data =& $this->resolve_url($path);
     if (!$data) {
         // 404!
         $this->http_error = 404;
         header("HTTP/1.1 404 Not found");
         return $ctx->error($this->translate("Page not found - [_1]", $path), E_USER_ERROR);
     }
     $info =& $data['fileinfo'];
     $fi_path = $info['fileinfo_url'];
     $fid = $info['fileinfo_id'];
     $at = $info['fileinfo_archive_type'];
     $ts = $info['fileinfo_startdate'];
     $tpl_id = $info['fileinfo_template_id'];
     $cat = $info['fileinfo_category_id'];
     $auth = $info['fileinfo_author_id'];
     $entry_id = $info['fileinfo_entry_id'];
     $blog_id = $info['fileinfo_blog_id'];
     $blog =& $data['blog'];
     if ($at == 'index') {
         $at = null;
         $ctx->stash('index_archive', true);
     } else {
         $ctx->stash('index_archive', false);
     }
     $tts = $data['template']['template_modified_on'];
     if ($tts) {
         $tts = offset_time(datetime_to_timestamp($tts), $blog);
     }
     $ctx->stash('template_timestamp', $tts);
     $ctx->stash('template_created_on', $data['template']['template_created_on']);
     $page_layout = $data['blog']['blog_page_layout'];
     $columns = get_page_column($page_layout);
     $vars =& $ctx->__stash['vars'];
     $vars['page_columns'] = $columns;
     $vars['page_layout'] = $page_layout;
     if (isset($data['template']['template_identifier'])) {
         $vars[$data['template']['template_identifier']] = 1;
     }
     $this->configure_paths($blog['blog_site_path']);
     // start populating our stash
     $ctx->stash('blog_id', $blog_id);
     $ctx->stash('local_blog_id', $blog_id);
     $ctx->stash('blog', $blog);
     $ctx->stash('build_template_id', $tpl_id);
     // conditional get support...
     if ($this->caching) {
         $this->cache_modified_check = true;
     }
     if ($this->conditional) {
         $last_ts = $blog['blog_children_modified_on'];
         $last_modified = $ctx->_hdlr_date(array('ts' => $last_ts, 'format' => '%a, %d %b %Y %H:%M:%S GMT', 'language' => 'en', 'utc' => 1), $ctx);
         $this->doConditionalGet($last_modified);
     }
     $cache_id = $blog_id . ';' . $fi_path . ';' . $_SERVER['QUERY_STRING'];
     if (!$ctx->is_cached('mt:' . $tpl_id, $cache_id)) {
         if (isset($at) && $at != 'Category') {
             global $_archivers;
             require_once "archive_lib.php";
             global $_archivers;
             if (!isset($_archivers[$at])) {
                 // 404
                 $this->http_errr = 404;
                 header("HTTP/1.1 404 Not Found");
                 return $ctx->error($this->translate("Page not found - [_1]", $at), E_USER_ERROR);
             }
             $archiver = $_archivers[$at];
             $archiver->template_params($ctx);
         }
         if ($cat) {
             $archive_category = $mtdb->fetch_category($cat);
             $ctx->stash('category', $archive_category);
             $ctx->stash('archive_category', $archive_category);
         }
         if ($auth) {
             $archive_author = $mtdb->fetch_author($auth);
             $ctx->stash('author', $archive_author);
             $ctx->stash('archive_author', $archive_author);
         }
         if (isset($at)) {
             if ($at != 'Category' && isset($ts)) {
                 list($ts_start, $ts_end) = $archiver->get_range($ctx, $ts);
                 $ctx->stash('current_timestamp', $ts_start);
                 $ctx->stash('current_timestamp_end', $ts_end);
             }
             $ctx->stash('current_archive_type', $at);
         }
         if (isset($entry_id) && $entry_id && ($at == 'Individual' || $at == 'Page')) {
             if ($at == 'Individual') {
                 $entry =& $mtdb->fetch_entry($entry_id);
             } elseif ($at == 'Page') {
                 $entry =& $mtdb->fetch_page($entry_id);
             }
             $ctx->stash('entry', $entry);
             $ctx->stash('current_timestamp', $entry['entry_authored_on']);
         }
         if ($at == 'Category') {
             $vars =& $ctx->__stash['vars'];
             $vars['archive_class'] = "category-archive";
             $vars['category_archive'] = 1;
             $vars['archive_template'] = 1;
             $vars['archive_listing'] = 1;
             $vars['module_category_archives'] = 1;
         }
     }
     $output = $ctx->fetch('mt:' . $tpl_id, $cache_id);
     $this->http_error = 200;
     header("HTTP/1.1 200 OK");
     // content-type header-- need to supplement with charset
     $content_type = $ctx->stash('content_type');
     if (!isset($content_type)) {
         $content_type = $this->mime_types['__default__'];
         if ($req_ext && isset($this->mime_types[$req_ext])) {
             $content_type = $this->mime_types[$req_ext];
         }
     }
     $charset = $this->config('PublishCharset');
     if (isset($charset)) {
         if (!preg_match('/charset=/', $content_type)) {
             $content_type .= '; charset=' . $charset;
         }
     }
     header("Content-Type: {$content_type}");
     // finally, issue output
     $output = preg_replace('/^\\s*/', '', $output);
     echo $output;
     // if warnings found, show it.
     if (!empty($this->warning)) {
         $this->_dump($this->warning);
     }
     if ($this->debugging) {
         $this->log("Queries: " . $mtdb->num_queries);
         $this->log("Queries executed:");
         $queries = $mtdb->savedqueries;
         foreach ($queries as $q) {
             $this->log($q);
         }
         $this->log_dump();
     }
     restore_error_handler();
 }
Exemple #8
0
ClaroBreadCrumbs::getInstance()->prepend(get_lang('Forums'), 'index.php');
CssLoader::getInstance()->load('clfrm', 'screen');
$noPHP_SELF = true;
$out = '';
$out .= claro_html_tool_title(get_lang('Forums'), $is_allowedToEdit ? get_help_page_url('blockForumsHelp', 'CLFRM') : false);
$out .= claro_html_menu_horizontal(disp_forum_toolbar($pagetype, null)) . disp_forum_breadcrumb($pagetype, null, null, null) . '<h4>' . get_lang('Search result') . ' : ' . (isset($_REQUEST['searchPattern']) ? claro_htmlspecialchars($_REQUEST['searchPattern']) : '') . '</h4>' . "\n";
if (count($searchResultList) < 1) {
    $out .= '<p>' . get_lang('No result') . '</p>';
} else {
    foreach ($searchResultList as $thisPost) {
        // PREVENT USER TO CONSULT POST FROM A GROUP THEY ARE NOT ALLOWED
        if (!is_null($thisPost['group_id']) && $is_groupPrivate && !(in_array($thisPost['group_id'], $userGroupList) || in_array($thisPost['group_id'], $tutorGroupList) || claro_is_course_manager())) {
            continue;
        } else {
            // notify if is new message
            $post_time = datetime_to_timestamp($thisPost['post_time']);
            if ($post_time < $last_visit) {
                $class = ' class="item"';
            } else {
                $class = ' class="item hot"';
            }
            // get user picture
            $userData = user_get_properties($thisPost['poster_id']);
            $picturePath = user_get_picture_path($userData);
            if ($picturePath && file_exists($picturePath)) {
                $pictureUrl = user_get_picture_url($userData);
            } else {
                $pictureUrl = null;
            }
            $out .= '<div id="post' . $thisPost['post_id'] . '" class="threadPost">' . '<div class="threadPostInfo">' . (!is_null($pictureUrl) ? '<div class="threadPosterPicture"><img src="' . $pictureUrl . '" alt=" " /></div>' : '') . "\n" . '<b>' . $thisPost['firstname'] . ' ' . $thisPost['lastname'] . '</b> ' . '<br />' . '<small>' . claro_html_localised_date(get_locale('dateTimeFormatLong'), $post_time) . '</small>' . "\n";
            $out .= '  </div>' . "\n" . '<div class="threadPostContent">' . "\n" . '<img src="' . get_icon_url('topic') . '" alt="" />' . '<a href="' . claro_htmlspecialchars(Url::Contextualize(get_module_url('CLFRM') . '/viewtopic.php?topic=' . $thisPost['topic_id'])) . '">' . claro_htmlspecialchars($thisPost['topic_title']) . '</a>' . "\n" . '<span class="threadPostIcon ' . $class . '"><img src="' . get_icon_url('post') . '" alt="" /></span><br />' . "\n" . claro_parse_user_text($thisPost['post_text']) . "\n";
Exemple #9
0
                </span><br />
                <span class="comment"><?php 
        echo $thisForum['forum_desc'];
        ?>
</span>
            </td>
            <td align="center"><small><?php 
        echo $thisForum['forum_topics'];
        ?>
</small></td>
            <td align="center"><small><?php 
        echo $thisForum['forum_posts'];
        ?>
</small></td>
            <td align="center"><small><?php 
        echo $thisForum['post_time'] > 0 ? claro_html_localised_date(get_locale('dateTimeFormatShort'), datetime_to_timestamp($thisForum['post_time'])) : get_lang('No post');
        ?>
</small></td>
            <?php 
        if ($this->is_allowedToEdit) {
            ?>
            <td align="center">
                <a href="<?php 
            echo get_lang(claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=rqEdForum&amp;forumId=' . $thisForum['forum_id'])));
            ?>
">
                <img src="<?php 
            echo get_icon_url('edit');
            ?>
" alt="<?php 
            echo get_lang('Edit');
Exemple #10
0
        echo $thisTopic['topic_replies'];
        ?>
</small></td>
                <td align="center">
                    <small>
                    <?php 
        echo 'anonymous' == $thisTopic['nom'] ? get_lang('Anonymous') : $thisTopic['prenom'] . '&nbsp;' . $thisTopic['nom'];
        ?>
                    </small>
                </td>
                <td align="center"><small><?php 
        echo $thisTopic['topic_views'];
        ?>
</small></td>
                <td align="center"><small><?php 
        echo claro_html_localised_date(get_locale('dateTimeFormatShort'), datetime_to_timestamp($thisTopic['post_time']));
        ?>
</small></td>
                <?php 
        if ($this->is_allowedToEdit) {
            ?>
                <td align="center">
                    <a href="<?php 
            echo claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=rqEditTopic&amp;forum=' . $this->forumId . '&amp;topic=' . $thisTopic['topic_id']));
            ?>
">
                    <img src="<?php 
            echo get_icon_url('edit');
            ?>
" alt="<?php 
            echo get_lang('Edit');
Exemple #11
0
        <span style="font-weight: bold;display:none;"><?php 
            echo $userData['firstname'] . '&nbsp;' . $userData['lastname'];
            ?>
</span><?php 
        }
    } else {
        ?>
<span style="font-weight: bold;"><?php 
        echo $thisPost['firstname'] . '&nbsp;' . $thisPost['lastname'];
        ?>
</span><?php 
    }
    ?>
    <br />
    <small><?php 
    echo claro_html_localised_date(get_locale('dateTimeFormatLong'), datetime_to_timestamp($thisPost['post_time']));
    ?>
</small>
  </div>
  <div class="threadPostContent">
    <?php 
    $itemClass = claro_is_user_authenticated() && $this->claro_notifier->is_a_notified_ressource(claro_get_current_course_id(), $this->claro_notifier->get_notification_date(claro_get_current_user_id()), claro_get_current_user_id(), claro_get_current_group_id(), claro_get_current_tool_id(), $this->forum_id . "-" . $this->topic_id . "-" . $thisPost['post_id']) ? 'item hot' : 'item';
    ?>
    <span class="threadPostIcon <?php 
    echo $itemClass;
    ?>
">
        <img src="<?php 
    echo get_icon_url('post');
    ?>
" alt="" />
      <div id="stats">
        <h5>Statistics</h5>
        <ul>
          <li>Id: <?php 
echo $post->id;
?>
</li>
          <li>Posted: <a href="/post?tags=date%3A<?php 
echo date('Y-m-d', datetime_to_timestamp($post->created_at));
?>
"><?php 
echo time_ago_in_words(date('Y-m-d H:i:s', datetime_to_timestamp($post->created_at)));
?>
 ago</a> by <a href="/user/show/<?php 
echo $post->user_id;
?>
"><?php 
echo $post->author;
?>
</a></li>
          <li>Size: <?php 
echo $post->width, 'x', $post->height;
?>
</li>
<?php 
if ($post->source) {
    ?>
          <li>Source: <?php 
    echo propper_source($post);
    ?>
</li>
Exemple #13
0
/**
* Conversion: datetime to descriptive
* Convert a database-compatible datetime string into a
* descriptive date/time format for the user display,
* using the given displayformat string.
* @param  string  $displayformat  See defined formats.
* @param  string  $datetime       Database datetime string
* @return string  The formatted descriptive datetime string
*/
function datetime_to_displaydate($displayformat, $datetime)
{
    if ($datetime == NULL) {
        return "";
    } else {
        return timestamp_to_displaydate($displayformat, datetime_to_timestamp($datetime));
    }
}