コード例 #1
0
<?php

// initializes testing framework (change app name)
$app = 'fe';
include dirname(__FILE__) . '/../../../../test/bootstrap/functional.php';
include $sf_symfony_lib_dir . '/vendor/lime/lime.php';
// initialize database manager
$databaseManager = new sfDatabaseManager();
$databaseManager->initialize();
$con = Propel::getConnection();
$resource = 'test1';
// clean all the comments related to the test resource
$comments = sfEmendCommentPeer::getAllCommentsForResource($resource);
foreach ($comments as $comment) {
    $comment->delete($con);
}
$user_options = sfConfig::get('app_sfEmendPlugin_user');
$browser = new sfTestBrowser();
$browser->initialize();
// get empty comments list for the first resource
$browser->test()->comment('Get an empty comments list');
$browser->get("/emend.getComments/" . $resource)->isStatusCode(200)->isRequestParameter('module', 'sfEmendAPI')->isRequestParameter('action', 'getComments')->responseContains('"n_comments": 0');
// try to add a comment through an emulated POST, as an anonymous user with no author name
$browser->test()->comment('Try to add a comment as anonymous user');
$browser->post("/emend.addComment/" . $resource, array('title' => 'Prova', 'body' => 'Un commento di prova', 'selection' => '"s": []'))->isStatusCode(200);
if ($user_options['allow_anonymous'] == 1) {
    $browser->responseContains('Anonymous posting requires an author_name parameter');
} else {
    $browser->responseContains('Anonymous posting not allowed');
}
// add a comment through an emulated POST,
コード例 #2
0
 public function executeGetComments()
 {
     $resource = $this->_clearResource($this->getRequestParameter('url'));
     $this->comments = sfEmendCommentPeer::getAllCommentsForResource($resource);
     $this->n_comments = count($this->comments);
 }
コード例 #3
0
 
          <?php 
        foreach ($documenti as $documento) {
            ?>
	        <?php 
            if ($limit_count >= $limit) {
                ?>
	   		
              <tr>
                <th><?php 
                echo link_to('<strong>' . $i . '</strong>&nbsp;' . $documento->getTitolo(), 'atto/documento?id=' . $documento->getId());
                ?>
</th>
            <td>
            <?php 
                $num_comm = count(sfEmendCommentPeer::getAllCommentsForResource('atto_documento_id_' . $documento->getId()));
                ?>
            <?php 
                echo link_to($num_comm, 'atto/documento?id=' . $documento->getId());
                ?>
            <?php 
                switch ($num_comm) {
                    case 0:
                        $actvitity = 0;
                        break;
                    case $num_comm < 6:
                        $actvitity = 15;
                        break;
                    case $num_comm < 11:
                        $actvitity = 20;
                        break;