function displaySnippet($attr)
{
    return getSnippet($attr);
}
Пример #2
0
 /**
  * Returns a list of the most recent declarations of this person.
  *
  * @param {String} $query The query we are looking for.
  * @param {Number} $start Where to start the results from.
  * @param {Number} $count The number of declarations that we need.
  * @param {Boolean} $full_text Whether we want to return just snippets or
  *     the full text for each of the results.
  * @param {String} $restrict The category of declarations that I am looking
  *     for. Acceptable values for this are 'all', 'important' or 'mine'.
  * @return {Array} The array of results.
  */
 public function searchDeclarations($query, $start, $count, $full_text, $restrict, $justDeclarationId = 0)
 {
     $navigationalRestrict = $justDeclarationId ? "AND d.id={$justDeclarationId}" : "";
     if ($restrict == 'all') {
         $s = mysql_query("\n        SELECT d.id, d.source, d.declaration, d.time\n        FROM people_declarations AS d\n        WHERE d.idperson = {$this->id} AND\n            d.declaration LIKE '%{$query}%'\n            {$navigationalRestrict}\n        ORDER BY d.time DESC\n        LIMIT {$start}, {$count}\n      ");
     } else {
         if ($restrict == 'important') {
             $sql = "\n        SELECT d.id, h.source, d.declaration, d.time\n        FROM people_declarations AS d\n        LEFT JOIN people_declarations_highlights AS h ON h.source = d.source\n        WHERE idperson = {$this->id}\n        {$navigationalRestrict}\n        GROUP BY h.source\n        ORDER BY time DESC\n        LIMIT {$start}, {$count}\n      ";
             $s = mysql_query($sql);
         } else {
             if ($restrict == 'mine') {
                 $uid = is_user_logged_in() ? wp_get_current_user()->ID : 0;
                 $sql = "\n        SELECT d.id, h.source, d.declaration, d.time\n        FROM people_declarations AS d\n        LEFT JOIN people_declarations_highlights AS h ON h.source = d.source\n        WHERE\n            idperson = {$this->id} AND\n            h.user_id={$uid}\n            {$navigationalRestrict}\n        GROUP BY h.source\n        ORDER BY time DESC\n        LIMIT {$start}, {$count}\n      ";
                 $s = mysql_query($sql);
             } else {
                 return array();
             }
         }
     }
     $results = array();
     while ($r = mysql_fetch_array($s)) {
         if (!$r['source']) {
             continue;
         }
         // HACK: Because I know that the transcripts from cdep.ro have only this
         // one tag in them, I will manually replace it.
         $r['declaration'] = preg_replace('/<p align="justify">/', ' ', $r['declaration']);
         $r['declaration'] = strip_tags($r['declaration']);
         $r['declaration'] = stripslashes($r['declaration']);
         $r['snippet'] = $full_text ? $r['declaration'] : getSnippet($r['declaration'], $query, $full_text);
         $r['snippet'] = markDownTextBlock($r['snippet'], "");
         if ($query != '') {
             $r['snippet'] = highlightStr($r['snippet'], $query);
         }
         $results[] = $r;
     }
     return $results;
 }
Пример #3
0
<?php

require_once dirname(__FILE__) . '/../Lib/sfBundle.class.php';
echo getSnippet();
/**
 * Returns snippet for Class of the current file
 *
 * @param string $filename returns file name
 * @param string $filepath returns file path
 * @return string snippet
 * @author Konstantin Kudryashov <*****@*****.**>
 */
function getSnippet()
{
    $baseClass = sfBundle::getBaseClassForCurrentFile();
    $packageName = getPackageName($baseClass);
    $snippet = sprintf(<<<SNIPPET
/*
 * This file is part of the \$1.
 * (c) \${2:%s} \${3:\${TM_ORGANIZATION_NAME}}
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * \${4:%s} \${5:does things}.
 *
 * @package    \${6:\$1}
 * @subpackage \${7:%s}
 * @author     \$3