diff --git a/Resources/templates/responsive/project/layout.php b/Resources/templates/responsive/project/layout.php index 948d651315..0fcb4f5dd0 100644 --- a/Resources/templates/responsive/project/layout.php +++ b/Resources/templates/responsive/project/layout.php @@ -95,8 +95,7 @@ - - isPermanent()):?> + isHighlightedRewardsActive()): ?>
insert('project/partials/highlighted_rewards') ?>
diff --git a/Resources/templates/responsive/project/partials/highlighted_rewards.php b/Resources/templates/responsive/project/partials/highlighted_rewards.php new file mode 100644 index 0000000000..83464dc535 --- /dev/null +++ b/Resources/templates/responsive/project/partials/highlighted_rewards.php @@ -0,0 +1,12 @@ +project; +?> + +
+
+ insert('project/partials/reward_widget', ['reward' => $this->individual_rewards[0]]) ?> + insert('project/partials/reward_widget', ['reward' => $this->individual_rewards[1]]) ?> + insert('project/partials/reward_widget', ['reward' => $this->individual_rewards[2]]) ?> +
+
+ diff --git a/Resources/templates/responsive/project/partials/reward_widget.php b/Resources/templates/responsive/project/partials/reward_widget.php new file mode 100644 index 0000000000..bd1aaac797 --- /dev/null +++ b/Resources/templates/responsive/project/partials/reward_widget.php @@ -0,0 +1,26 @@ +project; + $reward = $this->reward +?> + +
+
+

reward ?>

+
+
+
+ amount) ?> +
+ +

+ markdown($reward->description) ?> +

+
+ +
diff --git a/db/migrations/20230608111241_goteo_highlighted_rewards.php b/db/migrations/20230608111241_goteo_highlighted_rewards.php new file mode 100644 index 0000000000..830687f714 --- /dev/null +++ b/db/migrations/20230608111241_goteo_highlighted_rewards.php @@ -0,0 +1,50 @@ +getOption('account'); $builder = $this->getBuilder(); + $admin = Session::isAdmin(); if ($admin) { $builder @@ -63,6 +64,16 @@ public function createForm(): ProjectCampaignForm ], 'color' => 'cyan', 'required' => false + ]) + ->add('highlighted_rewards', BooleanType::class, [ + 'label' => 'project-campaign-highlighted-rewards', + 'row_class' => 'extra', + 'data' => $project->isHighlightedRewardsActive(), + 'attr' => [ + 'help' => Text::get('project-campaign-activate-highlighted-rewards') + ], + 'color' => 'cyan', + 'required' => false ]); } @@ -108,7 +119,6 @@ public function createForm(): ProjectCampaignForm ]) ; - return $this; } @@ -171,17 +181,20 @@ public function save(FormInterface $form = null, $force_save = false) { if (isset($data['type'])) { $conf->setType($data['type']); } + + $conf->setHighlightedRewards($data['highlighted_rewards']); + $errors = []; if (!$conf->save($errors)) { throw new FormModelException(Text::get('form-sent-error', implode(', ', $errors))); } } catch (Exception $e) { - throw new FormModelException($e->getMessage()); - } + throw new FormModelException($e->getMessage()); } } if(!$form->isValid()) throw new FormModelException(Text::get('form-has-errors')); return $this; } + } diff --git a/src/Goteo/Model/Project.php b/src/Goteo/Model/Project.php index 8c50fa8f59..33f510c038 100644 --- a/src/Goteo/Model/Project.php +++ b/src/Goteo/Model/Project.php @@ -3628,6 +3628,15 @@ public function isImpactCalcActive():bool } } + public function isHighlightedRewardsActive(): bool + { + try { + return ProjectConf::get($this->id)->isHighlightedRewards(); + } catch(\Goteo\Core\Exception $e) { + return false; + } + } + /* * Para saber si un proyecto tiene traducción en cierto idioma * @return: boolean diff --git a/src/Goteo/Model/Project/Conf.php b/src/Goteo/Model/Project/Conf.php index a7da2fafba..402d34f6da 100644 --- a/src/Goteo/Model/Project/Conf.php +++ b/src/Goteo/Model/Project/Conf.php @@ -38,11 +38,10 @@ class Conf extends Model $help_license, $mincost_estimation, $publishing_estimation, - $hide_exhausted_rewards - ; + $hide_exhausted_rewards; private bool $impact_calculator = false; - + private bool $highlighted_rewards = false; private string $type = self::TYPE_CAMPAIGN; /** @@ -96,10 +95,25 @@ public function save(&$errors = array()) if (!$this->validate($errors)) return false; try { - $sql = "REPLACE INTO project_conf (project, noinvest, watch, days_round1, days_round2, one_round, help_cost, help_license, mincost_estimation, publishing_estimation, hide_exhausted_rewards, impact_calculator, `type`) VALUES(:project, :noinvest, :watch, :round1, :round2, :one, :helpcost, :helplicense, :mincost_estimation, :publishing_estimation, :hide_exhausted_rewards, :impact_calculator, :type)"; - $values = [':project' => $this->project, ':noinvest' => $this->noinvest, ':watch' => $this->watch, - ':round1' => $this->days_round1, ':round2' => $this->days_round2, ':one' => $this->one_round, ':helpcost' => $this->help_cost, ':helplicense' => $this->help_license, ':mincost_estimation' => $this->mincost_estimation, ':publishing_estimation' => $this->publishing_estimation, ':hide_exhausted_rewards' => $this->hide_exhausted_rewards, ':impact_calculator' => $this->impact_calculator, ':type' => $this->type]; - return self::query($sql, $values)?true:false; + $sql = "REPLACE INTO project_conf (project, noinvest, watch, days_round1, days_round2, one_round, help_cost, help_license, mincost_estimation, publishing_estimation, hide_exhausted_rewards, impact_calculator, `type`, highlighted_rewards) VALUES(:project, :noinvest, :watch, :round1, :round2, :one, :helpcost, :helplicense, :mincost_estimation, :publishing_estimation, :hide_exhausted_rewards, :impact_calculator, :type, :highlighted_rewards)"; + $values = [ + ':project' => $this->project, + ':noinvest' => $this->noinvest, + ':watch' => $this->watch, + ':round1' => $this->days_round1, + ':round2' => $this->days_round2, + ':one' => $this->one_round, + ':helpcost' => $this->help_cost, + ':helplicense' => $this->help_license, + ':mincost_estimation' => $this->mincost_estimation, + ':publishing_estimation' => $this->publishing_estimation, + ':hide_exhausted_rewards' => $this->hide_exhausted_rewards, + ':impact_calculator' => $this->impact_calculator, + ':type' => $this->type, + ':highlighted_rewards' => $this->highlighted_rewards + ]; + + return (bool)self::query($sql, $values); } catch (\PDOException $e) { $errors[] = "La configuración del proyecto no se ha guardado correctamente. Por favor, revise los datos." . $e->getMessage(); return false; @@ -376,6 +390,16 @@ public function deactivateImpactCalculator() $this->impact_calculator = false; } + public function isHighlightedRewards(): bool + { + return $this->highlighted_rewards; + } + + public function setHighlightedRewards(bool $highlighted_rewards): void + { + $this->highlighted_rewards = $highlighted_rewards; + } + public function getType(): string { return $this->type; diff --git a/translations/ca/project.yml b/translations/ca/project.yml index 31052396db..94cdba62f5 100644 --- a/translations/ca/project.yml +++ b/translations/ca/project.yml @@ -162,6 +162,8 @@ project-impact-calculator-card-impact-description: "Amb un pressupost de %s aspi project-create-continue-impact: "Desar i calcular impacte" project-campaign-impact-calculator: "Calculadora d'Impacte" project-campaign-activate-impact-calculator: "Al activar la calculadora d'impacte, l'impulsora del projecte podrà accedir al módul de les Dades d'Impacte del Projecte, així com també es veurà el seu impacte a la pàgina principal del projecte." +project-campaign-highlighted-rewards: "Recompenses destacades" +project-campaign-activate-highlighted-rewards: "Al activar les recompenses destacades, la visualització de les recompenses canvia. Es mostraran les recompenses destacades a la part superior de la pàgina del projecte." project-campaign-type-label: "Escull tipus de campanya" project-campaign-type-campaign: "Campanya" project-campaign-type-permanent: "Permanent" diff --git a/translations/en/project.yml b/translations/en/project.yml index 6721d72704..b91b323d46 100644 --- a/translations/en/project.yml +++ b/translations/en/project.yml @@ -159,6 +159,8 @@ project-impact-calculator-card-impact-description: "With a budget of %s we want project-create-continue-impact: "Save and calculate impact" project-campaign-impact-calculator: "Impact Calculator" project-campaign-activate-impact-calculator: "By activating the impact calculator, the project promoter will be able to access the project impact data module, as well as see their impact on the main project page." +project-campaign-highlighted-rewards: "Highlighted rewards" +project-campaign-activate-highlighted-rewards: "When activating the highlighted rewards, the visualization of the rewards will change. The rewards will be shown at the top of the project page." project-campaign-type-label: "Choose type of Campaign" project-campaign-type-campaign: "Campaign" project-campaign-type-permanent: "Permanent" diff --git a/translations/es/project.yml b/translations/es/project.yml index e897a97099..34ffa52b78 100644 --- a/translations/es/project.yml +++ b/translations/es/project.yml @@ -181,6 +181,8 @@ project-impact-calculator-card-impact-description: "Con un presupuesto de %s asp project-create-continue-impact: "Guardar y calcular impacto" project-campaign-impact-calculator: "Calculadora de Impacto" project-campaign-activate-impact-calculator: "Al activar la calculadora de impacto, la impulsora del proyecto podrá acceder al modulo de los Datos de Impacto del Proyecto, así como también se verá su impacto en la página principal del proyecto." +project-campaign-highlighted-rewards: "Recompensas destacadas" +project-campaign-activate-highlighted-rewards: "Al activar las recompensas destacadas, la visualización de las recompensas cambia. Se mostrarán las recompensas destacadas en la parte superior de la página del proyecto." project-campaign-type-label: "Escoge tipo de campaña" project-campaign-type-campaign: "Campaña" project-campaign-type-permanent: "Permanente"