Пример #1
0
 public static function process($action = 'list', $id = null, $filters = array())
 {
     $sections = Model\Criteria::sections();
     if (!isset($sections[$filters['section']])) {
         unset($filters['section']);
     }
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         // instancia
         $criteria = new Model\Criteria(array('id' => $_POST['id'], 'section' => $_POST['section'], 'title' => $_POST['title'], 'description' => $_POST['description'], 'order' => $_POST['order'], 'move' => $_POST['move']));
         if ($criteria->save($errors)) {
             switch ($_POST['action']) {
                 case 'add':
                     Message::Info(Text::get('criteria-info-add-correctly'));
                     break;
                 case 'edit':
                     Message::Info(Text::get('criteria-info-edit-correctly'));
                     break;
             }
         } else {
             Message::Error(implode('<br />', $errors));
             return new View('view/admin/index.html.php', array('folder' => 'criteria', 'file' => 'edit', 'action' => $_POST['action'], 'criteria' => $criteria, 'sections' => $sections));
         }
     }
     switch ($action) {
         case 'up':
             Model\Criteria::up($id);
             break;
         case 'down':
             Model\Criteria::down($id);
             break;
         case 'add':
             $next = Model\Criteria::next($filters['section']);
             return new View('view/admin/index.html.php', array('folder' => 'criteria', 'file' => 'edit', 'action' => 'add', 'criteria' => (object) array('section' => $filters['section'], 'order' => $next, 'cuantos' => $next), 'sections' => $sections));
             break;
         case 'edit':
             $criteria = Model\Criteria::get($id);
             $cuantos = Model\Criteria::next($criteria->section);
             $criteria->cuantos = $cuantos - 1;
             return new View('view/admin/index.html.php', array('folder' => 'criteria', 'file' => 'edit', 'action' => 'edit', 'criteria' => $criteria, 'sections' => $sections));
             break;
         case 'remove':
             Model\Criteria::delete($id);
             break;
     }
     $criterias = Model\Criteria::getAll($filters['section']);
     return new View('view/admin/index.html.php', array('folder' => 'criteria', 'file' => 'list', 'criterias' => $criterias, 'sections' => $sections, 'filters' => $filters));
 }
Пример #2
0
 */

use Goteo\Core\View,
    Goteo\Model\Criteria,
    Goteo\Library\Text;


echo new View ('view/review/reviews/selector.html.php', $this);

$review   = $this['review'];
$evaluation = $this['evaluation'];

$sections = Criteria::sections();
$criteria = array();
foreach ($sections as $sectionId=>$sectionName) {
    $criteria[$sectionId] = Criteria::getAll($sectionId);
}

?>
<div class="widget">
    <?php echo Text::_('Puntuación de tu revisión: '); ?><span id="total-score"><?php echo $evaluation['score'] . '/' . $evaluation['max']; ?></span>
</div>
<?php foreach ($sections as $sectionId=>$sectionName) : ?>
<div class="widget">
    <h2 class="title"><?php echo $sectionName; ?></h2>
    <p>
        <?php echo Text::_('Otrogas puntos porque:'); ?><br />
        <blockquote>
        <?php foreach ($criteria[$sectionId] as $crit) :
            if ($evaluation['criteria'][$crit->id] > 0) echo '· ' . $crit->title . '<br />';
        endforeach; ?>