public static function fillWithContentFor($user, $content)
{
$content = self::fillWithRegex($user, $content, '/\{\{[^(% )]*\}\}/', '{{', '}}');
- return self::fillWithRegex($user, $content, '/%[^(% )]*%/', '%', '%');
+ $content = self::fillWithRegex($user, $content, '/%[^(% )]*%/', '%', '%');
+ return self::processLinks($user, $content);
+ }
+
+
+ public static function processLinks($user, $content)
+ {
+ return preg_replace_callback('/data-href-variable="([^(" )]*)"/', function($matches) use($user){
+ $match = $matches[1];
+ $url = $user->templateAttribute($match, null) ?? $matches[1];
+ return sprintf('href="%s"', $url);
+
+ }, $content);
}
/**
return $user->templateAttribute($match, null) ?? $matches[0];
}, $content);
-
-
}
/**
* @param null $color
* @return string
* @throws \Throwable
+ * @todo remove
+ * @deprecated
*/
public static function button($url, $label, $color = null)
{
'name' => 'Contact',
'href' => route('contact.index')
],
-
],
+ 'tools' => [
+ 'custom#variable' => [
+ 'properties' => [
+ 'url_slug' => [
+ 'editor' => [
+ 'data' => [
+ 'options' => [
+ [
+ 'label' => 'Accueil',
+ 'value' => 'home_url'
+ ],
+ [
+ 'label' => 'Mon compte',
+ 'value' => 'my_account_url'
+ ],
+ [
+ 'label' => 'Création mot de passe',
+ 'value' => 'complete_registration_url'
+ ],
+ [
+ 'label' => 'Formulaire Contact',
+ 'value' => 'contact_url'
+ ],
+ [
+ 'label' => 'Demander PDF',
+ 'value' => 'ask_pdf_url'
+ ]
+ ],
+ ]
+ ]
+ ]
+ ]
+
+ ]
+ ]
])->savingCallback(function ($request, $attribute, $model, $html)
{
$model->update([
}
+
/**
* Get the value of a template attribute using its getter.
*
}
+ /**
+ * @return string
+ * @throws \Throwable
+ */
+ public function getHomeUrlTemplate()
+ {
+ return url('/');
+ }
+
+ /**
+ * @return string
+ * @throws \Throwable
+ */
+ public function getMyAccountUrlTemplate()
+ {
+ return $this->routeWithToken('account.index', [], now()->addDays(7));
+ }
+
+
+ /**
+ * @return string
+ * @throws \Throwable
+ */
+ public function getCompleteRegistrationUrlTemplate()
+ {
+ return $this->routeWithToken('account.complete-reg', [], now()->addDays(7));
+
+ }
+
+
+ /**
+ * @return string
+ * @throws \Throwable
+ */
+ public function getContactUrlTemplate()
+ {
+ return route('contact.index');
+
+ }
+
+ /**
+ * @return string
+ * @throws \Throwable
+ */
+ public function getAskPdfUrlTemplate()
+ {
+ return\URL::signedRoute('account.ask-pdf', ['user' => $this->id]);
+ }
+
+
+
+
+
/**
* @return string
* @throws \Throwable
<a href="{!! $url !!}" target="_blank" class="v-size-width" style="box-sizing: border-box;display: inline-block;font-family:'Open Sans',sans-serif;text-decoration: none;-webkit-text-size-adjust: none;text-align: center;color: #FFFFFF; background-color: #3AAEE0; border-radius: 4px; -webkit-border-radius: 4px; -moz-border-radius: 4px; width:auto; max-width:100%; overflow-wrap: break-word; word-break: break-word; word-wrap:break-word; mso-border-alt: none;">
<span class="v-padding" style="display:block;padding:10px 20px;line-height:120%;"><span style="font-size: 14px; line-height: 16.8px;">{{$slot}}</span></span>
</a>
- <!--[if mso]></center></td></tr></table><![endif]-->
+ <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
</div>
</td>