本文整理汇总了PHP中Goteo\Library\Text::shareLinks方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::shareLinks方法的具体用法?PHP Text::shareLinks怎么用?PHP Text::shareLinks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Goteo\Library\Text
的用法示例。
在下文中一共展示了Text::shareLinks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toInvestors
public static function toInvestors($type, $project, $post = null)
{
// notificación
$notif = $type == 'update' ? 'updates' : 'rounds';
$anyfail = false;
$tpl = null;
// para cada inversor que no tenga bloqueado esta notificacion
$sql = "\n SELECT\n invest.user as id,\n user.name as name,\n user.email as email,\n invest.method as method,\n IFNULL(user.lang, 'es') as lang\n FROM invest\n INNER JOIN user\n ON user.id = invest.user\n AND user.active = 1\n LEFT JOIN user_prefer\n ON user_prefer.user = invest.user\n WHERE invest.project = ?\n AND invest.status IN ('0', '1', '3', '4')\n AND (user_prefer.{$notif} = 0 OR user_prefer.{$notif} IS NULL)\n GROUP BY user.id\n ";
if ($query = Model\Invest::query($sql, array($project->id))) {
foreach ($query->fetchAll(\PDO::FETCH_OBJ) as $investor) {
/// tipo de envio
switch ($type) {
case 'r1_pass':
// template 15,
$tpl = 15;
$search = array('%USERNAME%', '%PROJECTNAME%', '%PROJECTURL%');
$replace = array($investor->name, $project->name, SITE_URL . '/project/' . $project->id);
break;
case 'fail':
// template 17 (paypalistas) / 35 (tpvistas) , caduca sin conseguir el mínimo
$tpl = $investor->method == 'paypal' ? 17 : 35;
$search = array('%USERNAME%', '%PROJECTNAME%', '%DISCOVERURL%');
$replace = array($investor->name, $project->name, SITE_URL . '/discover');
break;
case 'r2_pass':
// template 16, finaliza segunda ronda
$tpl = 16;
$search = array('%USERNAME%', '%PROJECTNAME%', '%PROJECTURL%');
$replace = array($investor->name, $project->name, SITE_URL . '/project/' . $project->id);
break;
case 'update':
// template 18, publica novedad
$tpl = 18;
$search = array('%USERNAME%', '%PROJECTNAME%', '%UPDATEURL%', '%POST%', '%SHAREFACEBOOK%', '%SHARETWITTER%');
$post_url = SITE_URL . '/project/' . $project->id . '/updates/' . $post->id;
// contenido del post
$post_content = "<p><strong>{$post->title}</strong><br />" . nl2br(Text::recorta($post->text, 500)) . "</p>";
// y preparar los enlaces para compartir en redes sociales
$share_urls = Text::shareLinks($post_url, $post->title);
$replace = array($investor->name, $project->name, $post_url, $post_content, $share_urls['facebook'], $share_urls['twitter']);
break;
}
if (!empty($tpl)) {
// Obtenemos la plantilla para asunto y contenido
// en el idioma del usuario
$template = Template::get($tpl, $investor->lang);
// Sustituimos los datos
if (!empty($post)) {
$subject = str_replace(array('%PROJECTNAME%', '%OWNERNAME%', '%P_TITLE%'), array($project->name, $project->user->name, $post->title), $template->title);
} else {
$subject = str_replace('%PROJECTNAME%', $project->name, $template->title);
}
$content = \str_replace($search, $replace, $template->text);
// iniciamos mail
$mailHandler = new Mail();
$mailHandler->to = $investor->email;
$mailHandler->toName = $investor->name;
$mailHandler->subject = $subject;
$mailHandler->content = $content;
$mailHandler->html = true;
$mailHandler->template = $template->id;
if ($mailHandler->send()) {
} else {
$anyfail = true;
@mail(\GOTEO_FAIL_MAIL, 'Fallo al enviar email automaticamente al cofinanciador ' . SITE_URL, 'Fallo al enviar email automaticamente al cofinanciador: <pre>' . print_r($mailHandler, 1) . '</pre>');
}
unset($mailHandler);
}
}
// fin bucle inversores
} else {
echo '<p>' . str_replace('?', $project->id, $sql) . '</p>';
$anyfail = true;
}
if ($anyfail) {
return false;
} else {
return true;
}
}