Load() public static method

Load template. If the template is already compiled, just the compiled PHP file will be included an used. If the template is new, or it had changed, the Haanga compiler is loaded in memory, and the template is compiled.
public static Load ( string $file, array $vars = [], boolean $return = FALSE, array $blocks = [] ) : string | null
$file string @param array $vars @param bool $return @param array $blocks @return string|NULL
$vars array
$return boolean
$blocks array
return string | null
Example #1
0
function print_edit_form()
{
    global $link, $comment, $current_user, $site_key, $globals;
    if ($current_user->user_level != 'god' && time() - $comment->date > $globals['comment_edit_time']) {
        die;
    }
    // $rows = min(40, max(substr_count($comment->content, "\n") * 2, 8));
    echo '<div class="commentform">' . "\n";
    //echo '<form action="'.htmlspecialchars($_SERVER['PHP_SELF']).'" class="comment" method="post" enctype="multipart/form-data">'."\n";
    echo '<form action="' . htmlspecialchars($_SERVER['REQUEST_URI']) . '" class="comment" method="post" enctype="multipart/form-data">' . "\n";
    echo '<input type="hidden" name="process" value="editcomment" />' . "\n";
    echo '<input type="hidden" name="key" value="' . md5($comment->randkey . $site_key) . '" />' . "\n";
    echo '<input type="hidden" name="id" value="' . $comment->id . '" />' . "\n";
    echo '<fieldset><legend>' . _('editar comentario') . '</legend>' . "\n";
    print_simpleformat_buttons('edit-comment-' . $comment->id);
    echo '<div style="clear: right"><textarea name="comment_content" class="droparea" id="edit-comment-' . $comment->id . '" rows="5">' . $comment->content . '</textarea></div>' . "\n";
    echo '<input class="button" type="submit" name="submit" value="' . _('modificar comentario') . '" />' . "\n";
    // Allow gods to put "admin" comments which does not allow votes
    if ($current_user->user_level == 'god') {
        if ($comment->type == 'admin') {
            $checked = 'checked="true"';
        }
        echo '&nbsp;&nbsp;&nbsp;&nbsp;<label><strong>' . _('admin') . ' </strong><input name="type" type="checkbox" value="admin" ' . $checked . '/></label>' . "\n";
    }
    $vars = compact('link', 'comment');
    Haanga::Load('comment_edit.html', $vars);
    echo '</fieldset>' . "\n";
    echo '</form>' . "\n";
    echo "</div>\n";
}
Example #2
0
function create_form($view, $title, $data = array())
{
    global $site_key, $current_user;
    $time = microtime(true) * 1000;
    $form = array('title' => $title, 'hash' => sha1($site_key . $time . $current_user->user_id), 'time' => $time);
    Haanga::Load("league/form.{$view}.tpl", compact('form', 'data'));
}
Example #3
0
 public function display($template, $page_title = '', $meta_description = '', array $css_files = array(), array $js_files = array())
 {
     $this->vars['page_title'] = $page_title ? $page_title : DEFAULT_PAGE_TITLE;
     $this->vars['meta_description'] = $meta_description ? $meta_description : DEFAULT_META_DESCRIPTION;
     // Add CSS files from arguments
     if ($css_files) {
         foreach ($css_files as $css_file) {
             $this->css_files[] = $css_file;
         }
     }
     $this->vars['css_files'] = $this->css_files;
     // Add JS files from arguments
     if ($js_files) {
         foreach ($js_files as $js_file) {
             $this->js_files[] = $js_file;
         }
     }
     $this->vars['js_files'] = $this->js_files;
     // Add preloaded CSS files
     foreach ($this->preloaded_css_files as $css_file) {
         $this->vars['css_files'][] = $css_file;
     }
     // Add preloaded JS files
     foreach ($this->preloaded_js_files as $js_file) {
         $this->vars['js_files'][] = $js_file;
     }
     $this->vars['js_vars'] = $this->js_vars;
     $this->vars['breadcrumb'] = $this->breadcrumb;
     Haanga::Load($template, $this->vars);
 }
Example #4
0
function haanga_464bf9fc69ec3d748e58e59c7b427e138da5ab9b($vars, $return = FALSE, $blocks = array())
{
    global $test_global, $global1;
    extract($vars);
    if ($return == TRUE) {
        ob_start();
    }
    $buffer1 = '
';
    $buffer2 = '
this is inner1
';
    $blocks['inner1'] = isset($blocks['inner1']) ? strpos($blocks['inner1'], '{{block.1b3231655cebb7a1f783eddf27d254ca}}') === FALSE ? $blocks['inner1'] : str_replace('{{block.1b3231655cebb7a1f783eddf27d254ca}}', $buffer2, $blocks['inner1']) : $buffer2;
    $buffer1 .= $blocks['inner1'] . '
';
    $buffer2 = '
this is inner2
';
    $blocks['inner2'] = isset($blocks['inner2']) ? strpos($blocks['inner2'], '{{block.1b3231655cebb7a1f783eddf27d254ca}}') === FALSE ? $blocks['inner2'] : str_replace('{{block.1b3231655cebb7a1f783eddf27d254ca}}', $buffer2, $blocks['inner2']) : $buffer2;
    $buffer1 .= $blocks['inner2'] . '
';
    $blocks['outer'] = isset($blocks['outer']) ? strpos($blocks['outer'], '{{block.1b3231655cebb7a1f783eddf27d254ca}}') === FALSE ? $blocks['outer'] : str_replace('{{block.1b3231655cebb7a1f783eddf27d254ca}}', $buffer1, $blocks['outer']) : $buffer1;
    echo Haanga::Load('assert_templates/empty_block_base.tpl', $vars, TRUE, $blocks);
    if ($return == TRUE) {
        return ob_get_clean();
    }
}
Example #5
0
 /** 
  * @dataProvider tplProvider
  */
 public function testIsCached($test_file, $data, $expected)
 {
     /* same as above, but we ensure that the file wasn't compiled */
     $this->init($test_file, $expected);
     $output = Haanga::Load($test_file, $data, TRUE);
     $this->assertEquals($output, $expected);
     $this->assertFalse(Haanga::$has_compiled);
 }
Example #6
0
 function view($name, $base = null)
 {
     $this->set('controller', router::$controller);
     $this->set('route', router::$route);
     $this->set('session', $this->session);
     if ($base == null) {
         $base = router::$views_path;
     }
     Haanga::Load($base . '/' . $name, kernel::$haanga_var);
 }
Example #7
0
 /** 
  * @dataProvider tplProvider
  *  
  */
 public function testInvalidTemplates($tpl)
 {
     Haanga_Compiler::setOption('allow_exec', FALSE);
     try {
         Haanga::Load($tpl);
         $this->assertTrue(FALSE);
     } catch (Haanga_Compiler_Exception $e) {
         $i = preg_match("/in.*:[0-9]+/", $e->getMessage());
         $this->assertEquals(1, $i);
     }
 }
Example #8
0
 function print_summary($type = 'full', $karma_best_comment = 0, $show_tags = true)
 {
     global $current_user, $current_user, $globals, $db;
     if (!$this->read) {
         return;
     }
     $this->is_votable();
     switch ($this->status) {
         case 'queued':
             // another color box for not-published
             $box_class = 'mnm-queued';
             break;
         case 'abuse':
             // another color box for discarded
         // another color box for discarded
         case 'autodiscard':
             // another color box for discarded
         // another color box for discarded
         case 'discard':
             // another color box for discarded
             $box_class = 'mnm-discarded';
             break;
         case 'published':
             // default for published
         // default for published
         default:
             $box_class = 'mnm-published';
             break;
     }
     $this->has_warning = !(!$this->check_warn() || $this->is_discarded());
     $this->is_editable = $this->author == $current_user->user_id && $this->is_editable();
     $this->total_votes = $this->votes + $this->anonymous;
     $this->rpermalink = $this->get_relative_permalink();
     $this->author_html = '<a href="' . get_user_uri($this->username, 'history') . '">' . $this->username . '</a>';
     $this->normal_link = preg_replace('/\\/mobile\\//', '/', $this->get_relative_permalink());
     $this->show_shakebox = $type != 'preview' && $this->votes > 0;
     $this->thumb_url = $this->has_thumb();
     if ($this->status == 'abuse' || $this->has_warning) {
         $this->negative_text = FALSE;
         $negatives = $db->get_row("select SQL_CACHE vote_value, count(vote_value) as count from votes where vote_type='links' and vote_link_id={$this->id} and vote_value < 0 group by vote_value order by count desc limit 1");
         if ($negatives->count > 2 && $negatives->count >= $this->negatives / 2 && ($negatives->vote_value == -6 || $negatives->vote_value == -8)) {
             $this->negative_text = get_negative_vote($negatives->vote_value);
         }
     }
     $text = $this->content;
     $my_domain = get_server_name();
     $parent_domain = preg_replace('/m\\./', '', $my_domain);
     if ($parent_domain != $my_domain && preg_match('#[^\\.]' . preg_quote($parent_domain) . '/#', $text)) {
         $text = preg_replace('#([^\\.])' . preg_quote($parent_domain) . '/#', "\$1{$my_domain}/", $text);
     }
     $vars = compact('type', 'karma_best_comment', 'show_tags', 'box_class', 'nofollow', 'url', 'text');
     $vars['self'] = $this;
     return Haanga::Load('mobile/link_summary.html', $vars);
 }
Example #9
0
 public function render()
 {
     $config = array('template_dir' => $this->getTemplateDir(), 'cache_dir' => $this->getCacheDir(), 'debug' => $this->debug, 'compiler' => array('allow_exec' => true));
     if ($this->cache && is_callable('xcache_isset')) {
         /* don't check for changes in the template for the next 5 min */
         $config['check_ttl'] = 300;
         $config['check_get'] = 'xcache_get';
         $config['check_set'] = 'xcache_set';
     }
     \Haanga::configure($config);
     \Haanga::Load($this->getTpl(), $this->data);
 }
function haanga_d905488f199a96b638d52d62c0fc424fd291ed39($vars, $return = FALSE, $blocks = array())
{
    global $test_global, $global1;
    extract($vars);
    if ($return == TRUE) {
        ob_start();
    }
    $buffer1 = '
    2.1-overrided
';
    $blocks['inner2_1'] = isset($blocks['inner2_1']) ? strpos($blocks['inner2_1'], '{{block.1b3231655cebb7a1f783eddf27d254ca}}') === FALSE ? $blocks['inner2_1'] : str_replace('{{block.1b3231655cebb7a1f783eddf27d254ca}}', $buffer1, $blocks['inner2_1']) : $buffer1;
    echo Haanga::Load('assert_templates/nested_block_second_parent.tpl', $vars, TRUE, $blocks);
    if ($return == TRUE) {
        return ob_get_clean();
    }
}
function haanga_a2c536c1d9b6f09d66feff81ca9b1e993d15d32e($vars, $return = FALSE, $blocks = array())
{
    global $test_global, $global1;
    extract($vars);
    if ($return == TRUE) {
        ob_start();
    }
    $buffer1 = '
{{block.1b3231655cebb7a1f783eddf27d254ca}}
new stuff
';
    $blocks['outer'] = isset($blocks['outer']) ? strpos($blocks['outer'], '{{block.1b3231655cebb7a1f783eddf27d254ca}}') === FALSE ? $blocks['outer'] : str_replace('{{block.1b3231655cebb7a1f783eddf27d254ca}}', $buffer1, $blocks['outer']) : $buffer1;
    echo Haanga::Load('assert_templates/nested_block.tpl', $vars, TRUE, $blocks);
    if ($return == TRUE) {
        return ob_get_clean();
    }
}
Example #12
0
function haanga_8012978a44e77332b744185d044350c7eb89603f($vars, $return = FALSE, $blocks = array())
{
    global $test_global, $global1;
    extract($vars);
    if ($return == TRUE) {
        ob_start();
    }
    $buffer1 = 'My Title - {{block.1b3231655cebb7a1f783eddf27d254ca}}';
    $blocks['title'] = isset($blocks['title']) ? strpos($blocks['title'], '{{block.1b3231655cebb7a1f783eddf27d254ca}}') === FALSE ? $blocks['title'] : str_replace('{{block.1b3231655cebb7a1f783eddf27d254ca}}', $buffer1, $blocks['title']) : $buffer1;
    $buffer1 = '
    {{block.1b3231655cebb7a1f783eddf27d254ca}}

    :-)
';
    $blocks['main.menu'] = isset($blocks['main.menu']) ? strpos($blocks['main.menu'], '{{block.1b3231655cebb7a1f783eddf27d254ca}}') === FALSE ? $blocks['main.menu'] : str_replace('{{block.1b3231655cebb7a1f783eddf27d254ca}}', $buffer1, $blocks['main.menu']) : $buffer1;
    echo Haanga::Load('assert_templates/base.tpl', $vars, TRUE, $blocks);
    if ($return == TRUE) {
        return ob_get_clean();
    }
}
Example #13
0
function print_edit_form($comment, $link)
{
    global $current_user, $site_key, $globals, $reply_to;
    $data = array();
    $html = '';
    if ($comment->id == 0) {
        $comment->randkey = rand(1000000, 100000000);
    }
    $html .= '<div class="commentform">';
    $html .= '<form action="' . $globals['base_url'] . "comment_ajax?reply_to={$reply_to}&amp;link={$link->id}&amp;id={$comment->id}&amp;user={$current_user->user_id}" . '" class="comment" method="post" enctype="multipart/form-data" id="c_edit_form">';
    $html .= '<input type="hidden" name="randkey" value="' . $comment->randkey . '" />';
    $html .= '<input type="hidden" name="process" value="editcomment" />';
    $html .= '<input type="hidden" name="key" value="' . md5($comment->randkey . $site_key) . '" />';
    $html .= '<input type="hidden" name="id" value="' . $comment->id . '" />';
    $vars = compact('link', 'comment');
    $html .= Haanga::Load('comment_edit.html', $vars, true);
    $html .= '</form></div>';
    $data['html'] = $html;
    $data['error'] = '';
    echo json_encode($data);
}
Example #14
0
function haanga_f5ad40d56c2438ea6bb3882d3b5e5ebf18352938($vars, $return = FALSE, $blocks = array())
{
    global $test_global, $global1;
    extract($vars);
    if ($return == TRUE) {
        ob_start();
    }
    $foo = 5 + 1;
    $vars['foo'] = $foo;
    echo '
';
    $bar = 'testing';
    $vars['bar'] = $bar;
    echo '
' . htmlspecialchars($foo) . '
' . Haanga::Load('assert_templates/sub_set.tpl', $vars, TRUE, $blocks) . '
';
    if ($return == TRUE) {
        return ob_get_clean();
    }
}
function haanga_93071c9c441d1680a63883802200fe559306006e($vars, $return = FALSE, $blocks = array())
{
    global $test_global, $global1;
    extract($vars);
    if ($return == TRUE) {
        ob_start();
    }
    $buffer1 = '
    inner2\'s new value
    ';
    $buffer2 = '
        2.1
    ';
    $blocks['inner2_1'] = isset($blocks['inner2_1']) ? strpos($blocks['inner2_1'], '{{block.1b3231655cebb7a1f783eddf27d254ca}}') === FALSE ? $blocks['inner2_1'] : str_replace('{{block.1b3231655cebb7a1f783eddf27d254ca}}', $buffer2, $blocks['inner2_1']) : $buffer2;
    $buffer1 .= $blocks['inner2_1'] . '
';
    $blocks['inner2'] = isset($blocks['inner2']) ? strpos($blocks['inner2'], '{{block.1b3231655cebb7a1f783eddf27d254ca}}') === FALSE ? $blocks['inner2'] : str_replace('{{block.1b3231655cebb7a1f783eddf27d254ca}}', $buffer1, $blocks['inner2']) : $buffer1;
    echo Haanga::Load('assert_templates/nested_block.tpl', $vars, TRUE, $blocks);
    if ($return == TRUE) {
        return ob_get_clean();
    }
}
Example #16
0
function haanga_d2f931b3242b3187b9a3d407f38c7d9d691df84f($vars, $return = FALSE, $blocks = array())
{
    global $test_global, $global1;
    extract($vars);
    if ($return == TRUE) {
        ob_start();
    }
    echo '<html>
<head>
    <title>';
    $buffer1 = 'Default Title';
    echo (isset($blocks['title']) ? strpos($blocks['title'], '{{block.1b3231655cebb7a1f783eddf27d254ca}}') === FALSE ? $blocks['title'] : str_replace('{{block.1b3231655cebb7a1f783eddf27d254ca}}', $buffer1, $blocks['title']) : $buffer1) . '</title>
</head>

<body>
    <h1>Menu</h1>
    ';
    $buffer1 = '
    <ul>
        ';
    foreach ($menu as $item) {
        $buffer1 .= '
            <li><a href="' . $item['url'] . '">' . htmlspecialchars($item['name']) . '</a></li>
        ';
    }
    $buffer1 .= '
    </ul>
    ';
    echo (isset($blocks['main.menu']) ? strpos($blocks['main.menu'], '{{block.1b3231655cebb7a1f783eddf27d254ca}}') === FALSE ? $blocks['main.menu'] : str_replace('{{block.1b3231655cebb7a1f783eddf27d254ca}}', $buffer1, $blocks['main.menu']) : $buffer1) . '
    ';
    $buffer1 = '' . Haanga::Load('assert_templates/partial.tpl', $vars, TRUE, $blocks);
    echo (isset($blocks['main.include-end']) ? strpos($blocks['main.include-end'], '{{block.1b3231655cebb7a1f783eddf27d254ca}}') === FALSE ? $blocks['main.include-end'] : str_replace('{{block.1b3231655cebb7a1f783eddf27d254ca}}', $buffer1, $blocks['main.include-end']) : $buffer1) . '
</body>
</html>
';
    if ($return == TRUE) {
        return ob_get_clean();
    }
}
Example #17
0
 function print_summary($link = 0, $length = 0, $single_link = true)
 {
     global $current_user, $globals;
     if (!$this->read) {
         return;
     }
     if (!$link && $this->link > 0) {
         $link = new Link();
         $link->id = $this->link;
         $link->read();
         $this->link_object = $link;
     }
     $this->link_permalink = $link->get_relative_permalink();
     $this->check_visibility();
     if ($this->hidden) {
         $comment_meta_class = 'comment-meta-hidden';
         $comment_class = 'comment-body-hidden';
     } else {
         $comment_meta_class = 'comment-meta';
         $comment_class = 'comment-body';
         if ($this->karma > $globals['comment_highlight_karma']) {
             $comment_class .= ' high';
         }
     }
     $this->truncate($length);
     $this->txt_content = $this->to_html($this->content);
     if ($this->type == 'admin') {
         $author = '<strong>' . _('admin') . '</strong> ';
     } else {
         $author = '<a href="' . get_user_uri($this->username) . '" title="karma:&nbsp;' . $this->user_karma . '">' . $this->username . '</a> ';
     }
     if ($this->media_size > 0) {
         $this->media_thumb_dir = Upload::get_cache_relative_dir($this->id);
     }
     $vars = compact('comment_meta_class', 'comment_class', 'author');
     $vars['self'] = $this;
     return Haanga::Load('mobile/comment_summary.html', $vars);
 }
function haanga_2f06ae0d3b252465fa65c3a02cc1ebab4d90396f($vars, $return = FALSE, $blocks = array())
{
    global $test_global, $global1;
    extract($vars);
    if ($return == TRUE) {
        ob_start();
    }
    $buffer1 = '
{{block.1b3231655cebb7a1f783eddf27d254ca}}
new stuff
';
    $buffer2 = '
new inner2
';
    $blocks['inner2'] = isset($blocks['inner2']) ? strpos($blocks['inner2'], '{{block.1b3231655cebb7a1f783eddf27d254ca}}') === FALSE ? $blocks['inner2'] : str_replace('{{block.1b3231655cebb7a1f783eddf27d254ca}}', $buffer2, $blocks['inner2']) : $buffer2;
    $buffer1 .= $blocks['inner2'] . '
';
    $blocks['outer'] = isset($blocks['outer']) ? strpos($blocks['outer'], '{{block.1b3231655cebb7a1f783eddf27d254ca}}') === FALSE ? $blocks['outer'] : str_replace('{{block.1b3231655cebb7a1f783eddf27d254ca}}', $buffer1, $blocks['outer']) : $buffer1;
    echo Haanga::Load('assert_templates/nested_block.tpl', $vars, TRUE, $blocks);
    if ($return == TRUE) {
        return ob_get_clean();
    }
}
Example #19
0
            echo '</div>';
            // Print "conversation" for a given note
            $answers = $db->object_iterator("SELECT" . Post::SQL . ", conversations WHERE conversation_type='post' and conversation_to = {$post_id} and post_id = conversation_from ORDER BY conversation_from asc LIMIT 100", 'Post');
            if ($answers) {
                echo '<div style="padding-left: 40px; padding-top: 10px">';
                echo '<ol class="comments-list">';
                foreach ($answers as $answer) {
                    echo '<li>';
                    $answer->print_summary();
                    echo '</li>';
                    $ids[] = $answer->id;
                }
                echo "</ol>";
                echo '</div>' . "\n";
            }
        }
        Haanga::Load('get_total_answers_by_ids.html', array('type' => 'post', 'ids' => implode(',', $ids)));
        // Update conversation time
        if ($view == 3 && $time_read > 0 && $user->id == $current_user->user_id) {
            Post::update_read_conversation($time_read);
        }
    }
    echo '</div>';
    do_pages($rows, $page_size);
}
echo '</div>';
if ($rows > 15) {
    do_footer_menu();
}
do_footer();
exit(0);
Example #20
0
        $limit = 500;
    }
} else {
    $user = '';
}
header('Content-Type: text/html; charset=utf-8');
$media = $db->get_results("select type, id, version, unix_timestamp(date) as date, mime, user as uid, user_login as user from media, users where type in {$type_in} {$user} and version = 0 and user_id = media.user order by date desc limit {$limit}");
$images = array();
if ($media) {
    foreach ($media as $image) {
        if (!$show_all) {
            switch ($image->type) {
                case 'comment':
                    $karma = $db->get_var("select comment_karma from comments where comment_id = {$image->id}");
                    break;
                case 'post':
                    $karma = $db->get_var("select post_karma from posts where post_id = {$image->id}");
                    break;
                default:
                    $karma = 0;
            }
        }
        if ($show_all || $karma > -10) {
            $image->url = Upload::get_url($image->type, $image->id, $image->version, $image->date, $image->mime);
            $images[] = $image;
        }
    }
}
if ($images) {
    Haanga::Load("backend/gallery.html", compact('images'));
}
Example #21
0
 function output_rss()
 {
     global $session, $html;
     if (!$this->read) {
         $session->log('Eeeks! Trying to print a quote that haven\'t been read yet (id=%d)', $this->id);
         die;
     }
     $c = $this;
     $c->title = $this->text_clean($c->text, 'rss_title');
     $c->text = $this->text_clean($c->text, 'rss_body');
     $c->ts = date('r', $c->timestamp);
     $vars = compact('c');
     $html->output .= Haanga::Load('rss-quote.html', $vars, true);
     return true;
 }
Example #22
0
function print_tabs($option)
{
    global $current_user;
    if (SitesMgr::my_id() == 1 && SitesMgr::can_edit(0)) {
        $can_edit = true;
    } else {
        $can_edit = false;
    }
    $items = array();
    if ($current_user->user_id) {
        $items[] = array('id' => 0, 'url' => 'subs', 'title' => _('suscripciones'));
    }
    $items[] = array('id' => 1, 'url' => 'subs?active', 'title' => _('más activos'));
    $items[] = array('id' => 2, 'url' => 'subs?all', 'title' => _('todos'));
    if ($can_edit) {
        $items[] = array('id' => 3, 'url' => 'subedit', 'title' => _('crear sub'));
    }
    $vars = compact('items', 'option');
    return Haanga::Load('print_tabs.html', $vars);
}
Example #23
0
function print_answers($id, $level, $visited = false)
{
    // Print answers to the comment
    global $db, $page_size;
    if (!$visited) {
        $visited = array();
        $visited[] = $id;
    }
    $printed = array();
    $sql = "SELECT conversation_from FROM conversations, comments WHERE conversation_type='comment' and conversation_to = {$id} and comment_id = conversation_from ORDER BY conversation_from asc LIMIT {$page_size}";
    $answers = $db->get_col($sql);
    if ($answers) {
        $type = 'comment';
        echo '<div style="padding-left: 6%">' . "\n";
        echo '<ol class="comments-list">';
        foreach ($answers as $dbanswer) {
            if (in_array($dbanswer, $visited)) {
                continue;
            }
            $answer = Comment::from_db($dbanswer);
            $answer->url = $answer->get_relative_individual_permalink();
            echo '<li>';
            $answer->print_summary($link);
            if ($level > 0) {
                $res = print_answers($answer->id, $level - 1, array_merge($visited, $answers));
                $visited = array_merge($visited, $res);
            }
            $printed[] = $answer->id;
            $visited[] = $answer->id;
            echo '</li>';
        }
        echo "</ol>\n";
        echo '</div>' . "\n";
        if ($level == 0) {
            $ids = implode(',', $printed);
            Haanga::Load('get_total_answers_by_ids.html', compact('type', 'ids'));
        }
    }
    return $printed;
}
Example #24
0
<?php

include '../config.php';
header('Content-Type: application/x-javascript; charset=utf-8');
header('Cache-Control: public, max-age=864000');
header("Expires: " . gmdate("r", $globals['now'] + 864000));
Haanga::Load('js/general.js');
Example #25
0
$results['tags'] = count($a);
foreach ($a as $w) {
    $w = trim($w);
    $r = array();
    $r['w'] = $w;
    $r['len'] = mb_strlen($w);
    $r['hits'] = $h = min($results['docs'], intval(sphinx_doc_hits($w)));
    $r['freq'] = round(100 * $h / $results['docs'], 1);
    if ($r['freq'] < $results['min_freq']) {
        $results['min_freq'] = $r['freq'];
    }
    if ($r['freq'] > $results['max_freq']) {
        $results['max_freq'] = $r['freq'];
    }
    if ($r['freq'] > 1) {
        $results['highs'] += 1;
    }
    if (preg_match('/ /', $w)) {
        $results['phrases'] += 1;
        $r['phrase'] = true;
    } else {
        $r['phrase'] = false;
    }
    if (preg_match('/' . preg_quote($w, '/') . '/ui', $link->title)) {
        $results['in_title'] += 1;
        $r['in_title'] = true;
    }
    $words[$w] = $r;
}
Haanga::Load('backend/tags_analysis.html', compact('results', 'words'));
Example #26
0
function do_subs()
{
    global $db, $user, $current_user;
    $sql = "select subs.* from subs, prefs where pref_user_id = {$user->id} and pref_key = 'sub_follow' and subs.id = pref_value order by name asc";
    $subs = $db->get_results($sql);
    if ($subs) {
        $title = _('suscripciones');
        Haanga::Load('subs_simple.html', compact('title', 'subs'));
    }
    if ($current_user->admin && $user->id == $current_user->user_id) {
        $sql = "select subs.* from subs where subs.sub = 1 and (subs.owner = {$user->id} or subs.owner = 0)";
    } else {
        $sql = "select subs.* from subs where subs.sub = 1 and subs.owner = {$user->id}";
    }
    $subs = $db->get_results($sql);
    if ($subs) {
        $title = _('subs de') . " {$user->username}";
        if ($current_user->user_id > 0 && $user->id == $current_user->user_id && SitesMgr::can_edit(0)) {
            $can_edit = true;
        } else {
            $can_edit = false;
        }
        Haanga::Load('subs.html', compact('title', 'subs', 'can_edit'));
    }
}
Example #27
0
 public function print_summary()
 {
     Haanga::Load('league/match.tpl', array('match' => $this));
 }
Example #28
0
 function print_edit_form()
 {
     global $globals, $current_user;
     if ($this->id == 0) {
         $this->randkey = rand(1000000, 100000000);
     }
     $this->body_left = $globals['posts_len'] - mb_strlen(html_entity_decode($this->content, ENT_COMPAT, 'UTF-8'), 'UTF-8');
     $vars = array();
     $vars['self'] = $this;
     return Haanga::Load('post_edit.html', $vars);
 }
Example #29
0
function print_follow_sub($id)
{
    global $current_user;
    if ($current_user->user_id) {
        Haanga::Load('sub_follow.html', array('id' => $id));
    }
}
Example #30
0
function do_user_subheader($options, $selected = false, $rss = false, $rss_title = '')
{
    global $globals;
    // arguments: hash array with "button text" => "button URI"; Nº of the selected button
    $vars = compact('options', 'selected', 'rss', 'rss_title');
    return Haanga::Load('/user/subheader.html', $vars);
}