当前位置: 首页>>代码示例>>PHP>>正文


PHP Text::shareLinks方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:kenjs,项目名称:Goteo,代码行数:80,代码来源:send.php


注:本文中的Goteo\Library\Text::shareLinks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。