Example #1
0
 public function save($con = null)
 {
     $highlighted = myUtils::highlight($this->getRawBody());
     $this->setBody($highlighted['body']);
     $summarizer = new Summarizer(200);
     $this->setSummary($summarizer->summarize($this->getBody()));
     parent::save();
 }
 public function execute($filterChain)
 {
     $probability = sfConfig::get('app_tipFilter_probability');
     srand(myUtils::makeSeed());
     $genProb = rand(0, 100) / 100;
     // put random message to request
     if ($genProb <= $probability) {
         $tip = $this->getTip();
         $this->getContext()->getRequest()->setParameter('tip', array($tip['place'] => $tip['text']));
     }
     // Execute next filter in the chain
     $filterChain->execute();
 }
 public function executeEdit()
 {
     $id = $this->getRequestParameter('id');
     $this->forward404Unless($id);
     if (!myUtils::isUserRecord('SnippetPeer', $id, $this->getUser()->getId())) {
         $this->setFlash('error', 'You don\'t have enough credentials to edit this snippet.');
         $this->forward('site', 'message');
     }
     $code = SnippetPeer::retrieveByPk($id);
     $this->getRequest()->setParameter('title', $code->getTitle());
     $this->getRequest()->setParameter('raw_body', $code->getRawBody());
     $this->getRequest()->setParameter('tags', $code->getTag());
     $this->getRequest()->setParameter('managed_content', $code->getManagedContent());
     $this->getRequest()->setParameter('draft', $code->getDraft());
 }
Example #4
0
 public function save($con = null)
 {
     $highlighted = myUtils::highlight($this->getRawBody());
     $this->setBody($highlighted['body']);
     foreach ($this->getSnippetLanguages() as $language) {
         $language->delete();
     }
     foreach ($highlighted['langs'] as $lang => $count) {
         $sl = new SnippetLanguage();
         $sl->setName($lang);
         $sl->setSnippet($this);
         $this->addSnippetLanguage($sl);
     }
     $summarizer = new Summarizer(400);
     $this->setSummary($summarizer->summarize($this->getBody()));
     parent::save();
 }
Example #5
0
 protected function buildQuery(sfWebRequest $request)
 {
     $tableMethod = $this->configuration->getTableMethod();
     $this->filterForm = $this->configuration->getFilterForm(array());
     $this->filterForm->setTableMethod($tableMethod);
     $filters = $this->getFilters();
     $query = $this->filterForm->buildQuery($filters);
     $rootAlias = $query->getRootAlias();
     if ($request->hasParameter('filters__identification__name')) {
         $filters['name'] = $request->getParameter('filters__identification__name');
     }
     $new_query = IdentificationTable::addFilterQuery($filters, $query, $rootAlias);
     $this->addSortQuery($new_query);
     myUtils::logIt('la requête des bâtiments');
     myUtils::logIt($new_query->getSql());
     return $new_query;
 }
Example #6
0
$databaseManager->initialize();
//$data = new sfPropelData();
//$data->loadData(sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'fixtures');
//$code = CodePeer::retrieveByPK(1);
//$code->setRating(4, 1);
//$code->save();
//$tag = new Tag();
//$tag->setTag('Hede');
//$tag->setTagNormalized(Tag::normalize('Hede'));
//$tag->save();
//$soap = new SoapClient("http://localhost:8080/axis2/services/CodesnippetService?wsdl");
//print_r($soap);
//$func = $soap->__getFunctions();
//print_r($func);
//$rtn = $soap->highlight(array("language"=>"c", "code"=>"deneme"));
//print_r($rtn);
//echo $rtn->return;
$languages = CodeLanguagePeer::doSelect(new Criteria());
foreach ($languages as $language) {
    $c = new Criteria();
    //$c->add(CommentPeer::ID, 8);
    $comments = CommentPeer::doSelect($c);
    foreach ($comments as $comment) {
        echo '<' . $language->getTag() . '\\-code>(.|\\r|\\n)+<\\/' . $language->getTag() . '\\-code>' . "\n";
        $arr = array();
        preg_match_all("/<" . $language->getTag() . "\\-code>(.+)<\\/" . $language->getTag() . "\\-code>/isU", $comment->getComment(), $arr, PREG_SET_ORDER);
        print_r($arr);
    }
}
print_r(myUtils::highlightSnippet('deneme'));
    <span><?php 
echo $code->getTitle();
?>
</span>
    <?php 
if ($code->getMC() == 'true') {
    ?>
    <?php 
    echo image_tag('flag_blue.png', array('alt' => __('Managed Content'), 'title' => __('Managed Content')));
    ?>
    <?php 
}
?>

    <?php 
if ($sf_user->isAuthenticated() && myUtils::isUserRecord('SnippetPeer', $code->getId(), $sf_user->getGuardUser()->getId())) {
    ?>
    <?php 
    echo link_to(image_tag('page_edit.png', array('alt' => __('Edit'), 'title' => __('Edit'))), 'snippet/edit?id=' . $code->getId());
    ?>

    <?php 
    echo link_to(image_tag('page_delete.png', array('alt' => __('Delete'), 'title' => __('Delete'))), 'snippet/delete?id=' . $code->getId(), array('confirm' => 'Are you sure you want to delete this snippet?'));
    ?>
    <?php 
}
?>
</h1>

<?php 
include_partial('snippet/show', array('code' => $code));
 public static function getTip()
 {
     $holder = tipHolder::getInstance();
     srand(myUtils::makeSeed());
     return $holder->tips[rand(0, sizeof($holder->tips) - 1)];
 }