Example #1
0
function snip($section_count, $content, $keywords, $length)
{
    // shortens text without breaking whole words
    $keywords = explode(' ', $keywords);
    $sections = array();
    $end = strrpos(substr($content, 0, $length), ' ');
    $sections[] = highlight_keywords(trim(substr($content, 0, $end)), $keywords);
    $next = $length;
    foreach (range(0, $section_count) as $count) {
        if ($next > strlen($content)) {
            break;
        }
        $begin = strlen($content);
        foreach ($keywords as $term) {
            $begin = min($begin, stripos($content, $term, $next));
        }
        $begin = strrpos(substr($content, 0, $begin - 11), ' ');
        $section = trim(substr($content, $begin, $length + 10));
        $char_positions = array();
        $chars = '" $ % & * ( ) ; < > ! : ,';
        $chars = explode(' ', $chars);
        $position = strrpos($section, ' ');
        $char_positions[] = $position;
        foreach ($chars as $char) {
            $position = strrpos($section, $char);
            if ($position) {
                $char_positions[] = $position;
            }
        }
        $last_char = 0;
        foreach (range(0, count($char_positions) - 1) as $index) {
            if ($char_positions[$index] > $last_char) {
                $last_char = $char_positions[$index];
            }
            if ($char_positions[$index] == $last_char - 1) {
                $last_char--;
            }
        }
        $section = substr($section, 0, $last_char);
        $next = $begin + $length;
        $sections[] = highlight_keywords($section, $keywords);
    }
    return implode(' &hellip; ', $sections);
}
<?php

$documento = OppDocumentoPeer::retrieveByPK($result->propel_id);
$atto = $documento->getOppAtto();
$tipo_atto = $atto->getOppTipoAtto();
?>


<?php 
echo link_to_in_mail(highlight_keywords($tipo_atto->getDescrizione() == 'comunicato del governo' ? sprintf("Comunicato del governo - %s", $atto->getTitolo()) : sprintf("%s", $documento->getTitoloCompleto()), $term, sfConfig::get('app_lucene_result_highlighter', '<strong class="highlight">%s</strong>')), add_highlight_qs($result->getInternalUri(), $term));
?>
 -
presentato il <?php 
echo $atto->getDataPres('d/m/Y');
?>

<?php

/*
 * This file is part of the sfLucenePlugin package
 * (c) 2007 - 2008 Carl Vondrick <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
/**
 * @package sfLucenePlugin
 * @subpackage Test
 * @author Carl Vondrick
 * @version SVN: $Id$
 */
require dirname(__FILE__) . '/../../bootstrap/unit.php';
require dirname(__FILE__) . '/../../../lib/helper/sfLuceneHelper.php';
$t = new limeade_test(7, limeade_output::get());
$t->diag('testing highlighting');
$t->is(highlight_result_text('Hello.  This is a pretty <em class="thing">awesome</em> thing to be talking about.', 'thing talking'), 'Hello.  This is a pretty awesome <strong class="highlight">thing</strong> to be <strong class="highlight">talking</strong> about.', 'highlight_result_text() highlights text and strips out HTML');
$t->is(highlight_result_text('Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. This is a pretty <em class="thing">awesome</em> thing to be talking about.  Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. Foo bar. ', 'thing talking', 50), '...is is a pretty awesome <strong class="highlight">thing</strong> to be <strong class="highlight">talking</strong> about....', 'highlight_result_text() highlights and truncates text');
$t->is(highlight_keywords('Hello.  This is a pretty <em class="thing">awesome</em> thing to be talking about.', 'thing talking'), 'Hello.  This is a pretty <em class="thing">awesome</em> <strong class="highlight">thing</strong> to be <strong class="highlight">talking</strong> about.', 'highlight_kewyords() highlights text');
$t->diag('testing query string manipulation');
$t->is(add_highlight_qs('test/model', 'foo bar'), 'test/model?sf_highlight=foo bar', 'add_highlight_qs() adds a query string correctly');
$t->is(add_highlight_qs('test/model?a=b', 'foo bar'), 'test/model?a=b&sf_highlight=foo bar', 'add_highlight_qs() handles existing query strings');
$t->is(add_highlight_qs('test/model#anchor', 'foo bar'), 'test/model?sf_highlight=foo bar#anchor', 'add_highlight_qs() handles anchors');
$t->is(add_highlight_qs('test/model?a=b#anchor', 'foo bar'), 'test/model?a=b&sf_highlight=foo bar#anchor', 'add_highlight_qs() handles anchors and existing query strings');
Example #4
0
    }
    $preview_text = '';
    $preview_text .= !empty($result[0]['cover_note']) && !is_null($result[0]['cover_note']) ? $result[0]['cover_note'] . "\n\n" : '';
    $preview_text .= !empty($result[0]['qualification']) && !is_null($result[0]['qualification']) ? $result[0]['qualification'] . "\n\n" : '';
    $preview_text .= !empty($result[0]['work_summary']) && !is_null($result[0]['work_summary']) ? $result[0]['work_summary'] . "\n\n" : '';
    $preview_text .= !empty($result[0]['skill']) && !is_null($result[0]['skill']) ? $result[0]['skill'] . "\n\n" : '';
    $preview_text .= !empty($result[0]['technical_skill']) && !is_null($result[0]['technical_skill']) ? $result[0]['technical_skill'] . "\n\n" : '';
    $preview_text .= !empty($result[0]['file_text']) && !is_null($result[0]['file_text']) ? $result[0]['file_text'] : '';
    $preview_text = trim($preview_text);
    if (is_null($preview_text) || empty($preview_text)) {
        echo '-1';
        exit;
    }
    $preview_text = htmlspecialchars_decode(stripslashes($preview_text));
    if (!is_null($keywords) && !empty($keywords)) {
        $preview_text = highlight_keywords($_POST['keywords'], $preview_text, $use_and_op);
    }
    $response = array('resume' => array('member' => htmlspecialchars_decode($result[0]['member']), 'email_addr' => $result[0]['email_addr'], 'preview_text' => $preview_text));
    header('Content-type: text/xml');
    echo $xml_dom->get_xml_from_array($response);
    exit;
}
if ($_POST['action'] == 'get_available_industries') {
    $mysqli = Database::connect();
    $query = "SELECT DISTINCT industries.id, industries.industry FROM \n              (SELECT email_addr, primary_industry AS industry \n               FROM members \n               WHERE primary_industry IS NOT NULL \n               UNION \n               SELECT email_addr, secondary_industry \n               FROM members \n               WHERE secondary_industry IS NOT NULL) AS member_industry \n              LEFT JOIN industries ON industries.id = member_industry.industry \n              LEFT JOIN resumes ON resumes.member = member_industry.email_addr \n              WHERE resumes.private = 'N' \n              ORDER BY industries.industry";
    $result = $mysqli->query($query);
    $industries = array();
    foreach ($result as $i => $row) {
        $industries[$i]['id'] = $row['id'];
        $industries[$i]['industry_name'] = $row['industry'];
    }
Example #5
0
<?php

/**
 * @package sfLucenePlugin
 * @subpackage Module
 * @author Carl Vondrick <*****@*****.**>
 * @version SVN: $Id$
 */
?>

<?php 
echo link_to(highlight_keywords($result->getInternalTitle(), $query, sfConfig::get('app_lucene_result_highlighter', '<strong class="highlight">%s</strong>')), add_highlight_qs($result->getInternalUri(), $query));
?>
 (<?php 
echo $result->getScore();
?>
%)
<p><?php 
echo highlight_result_text($result->getInternalDescription(), $query, sfConfig::get('app_lucene_result_size', 200), sfConfig::get('app_lucene_result_highlighter', '<strong class="highlight">%s</strong>'));
?>
</p>
<?php

$atto = OppAttoPeer::retrieveByPK($result->propel_id);
$tipo_atto = OppTipoAttoPeer::retrieveByPK($result->tipo_atto_id);
?>

<?php 
echo $tipo_atto->getDescrizione();
?>
 - 
<?php 
echo link_to_in_mail(highlight_keywords($atto->getTitoloCompleto(), $term, sfConfig::get('app_lucene_result_highlighter', '<strong class="highlight">%s</strong>')), add_highlight_qs($result->getInternalUri(), $term));
?>
-
presentato il <?php 
echo $atto->getDataPres('d/m/Y');
?>

Example #7
0
                do {
                    format_date($row_name = 'date');
                    $tmp_date = $formatted_date;
                    if ($title_date != $tmp_date) {
                        $new_title_date = $tmp_date;
                        $section_content .= '</div><!-- End .section -->' . "\n\n" . '<div class="section">' . "\n" . '<h2 class="date-title">' . $new_title_date . "</h2>\n";
                    }
                    $row = highlight_keywords('log');
                    $row = convert_to_utf8($row);
                    $section_content .= display_article_box($row);
                } while ($row = mysql_fetch_array($res));
                //------------- WITHOUT-DATE-TITLE MODE --------------
            } else {
                $section_content = '';
                while ($row = mysql_fetch_array($res)) {
                    $row = highlight_keywords('log');
                    $row = convert_to_utf8($row);
                    $section_content .= display_article_box($row);
                }
            }
        } else {
            $flip_link = '';
            $section_content = '<h2>' . $lang['no_matches'] . "</h2>";
        }
    }
} else {
    $hit_result = '';
    $flip_link = '';
    $section_content = '<h2>' . $lang['search'] . "</h2>\n" . '<p>' . $lang['status_idle'] . "</p>\n";
}
$contents = <<<EOD
Example #8
0
                do {
                    format_date($row_name = 'date');
                    $tmp_date = $formatted_date;
                    if ($title_date != $tmp_date) {
                        $new_title_date = $tmp_date;
                        $section_content .= '</div><!-- End .section -->' . "\n\n" . '<div class="section">' . "\n" . '<h2 class="date-title">' . $new_title_date . "</h2>\n";
                    }
                    $row = highlight_keywords('log');
                    $row = convert_to_utf8($row);
                    $section_content .= display_article_box($row);
                } while ($row = mysql_fetch_array($res));
                //------------- WITHOUT-DATE-TITLE MODE --------------
            } else {
                $section_content = '';
                while ($row = mysql_fetch_array($res)) {
                    $row = highlight_keywords($row, 'log');
                    $row = convert_to_utf8($row);
                    $section_content .= display_article_box($row);
                }
            }
        } else {
            $flip_link = '';
            $section_content = '<h3>' . $lang['no_matches'] . "</h3>\n";
            $section_content .= display_search_plus();
        }
    } else {
        $hit_result = '';
        $flip_link = '';
        $section_content = no_keywords_error($mode = 'log');
    }
} else {
Example #9
0
                do {
                    format_date($row_name = 'bindate');
                    $tmp_date = $formatted_date;
                    if ($title_date != $tmp_date) {
                        $new_title_date = $tmp_date;
                        $section_content .= '</div><!-- End .section -->' . "\n\n" . '<div class="section">' . "\n" . '<h2 class="date-title">' . $new_title_date . "</h2>\n";
                    }
                    $row = highlight_keywords('file');
                    $row = convert_to_utf8($row);
                    $section_content .= display_binary_box($row, $data_table);
                } while ($row = mysql_fetch_array($res));
                //------------- WITHOUT-DATE-TITLE MODE --------------
            } else {
                $section_content = '';
                while ($row = mysql_fetch_array($res)) {
                    $row = highlight_keywords('file');
                    $row = convert_to_utf8($row);
                    $section_content .= display_binary_box($row, $data_table);
                }
            }
        } else {
            $flip_link = '';
            $section_content = '<h2>' . $lang['no_matches'] . "</h2>";
        }
    }
} else {
    $hit_result = '';
    $flip_link = '';
    $section_content = '<h2>' . $lang['search'] . "</h2>\n" . '<p>' . $lang['status_idle'] . "</p>\n";
}
$contents = <<<EOD
<?php

$resoconto = OppResocontoPeer::retrieveByPK($result->propel_id);
$num_seduta = $resoconto->getNumSeduta();
?>

<a href="<?php 
echo $resoconto->getUrl();
?>
">
  <?php 
echo highlight_keywords(sprintf("resoconto %s della seduta %s del %s", $resoconto->getStenografico() ? 'stenografico' : 'sommario', $num_seduta ? ' n. ' . $num_seduta : '', $resoconto->getData('d/m/Y')), $term, sfConfig::get('app_lucene_result_highlighter', '<strong class="highlight">%s</strong>'));
?>
</a>
- <?php 
echo $resoconto->getNota();
?>
.