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


PHP ET::trigger方法代码示例

本文整理汇总了PHP中ET::trigger方法的典型用法代码示例。如果您正苦于以下问题:PHP ET::trigger方法的具体用法?PHP ET::trigger怎么用?PHP ET::trigger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ET的用法示例。


在下文中一共展示了ET::trigger方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: trigger

 /**
  * Triggers an event, returning an array of return values from event handlers.
  *
  * Two events will actually be triggered: one prefixed with the name of this class,
  * one not. For example, if an instance of ETPluggable calls $this->trigger("eventName"),
  * both "ETPluggable_eventName" and "eventName" events will be triggered.
  *
  * The event handlers are called with $this as the first argument, and optionally any extra
  * $parameters. The return values from each handler are collected and then returned in an array.
  *
  * @param string $event The name of the event.
  * @param array $parameters An array of extra parameters to pass to the event handlers.
  */
 public function trigger($event, $parameters = array())
 {
     // Add the instance of this class to the parameters.
     array_unshift($parameters, $this);
     $return = array();
     // If we have a class name to use, trigger an event with that as the prefix.
     if ($this->className) {
         $return = ET::trigger($this->className . "_" . $event, $parameters);
     }
     // Trigger the event globally.
     $return = array_merge($return, ET::trigger($event, $parameters));
     return $return;
 }
开发者ID:19eighties,项目名称:esoTalk,代码行数:26,代码来源:ETPluggable.class.php

示例2: dispatch

 /**
  * Dispatch a request to $method, passing along $arguments.
  *
  * @param string $method The name of the controller method.
  * @param array $arguments An array of arguments to pass to the method.
  * @return void
  */
 public function dispatch($method, $arguments)
 {
     // Create an array of arguments where the first item is $this.
     $eventArguments = array_merge(array(&$this), $arguments);
     $eventName = $this->className . "_" . $method;
     // Trigger a "before" event for this method.
     ET::trigger($eventName . "_before", $eventArguments);
     // Go through plugins and look for a handler for this controller/method.
     $called = false;
     foreach (ET::$plugins as $plugin) {
         $actionName = "action_" . $eventName;
         if (method_exists($plugin, $actionName)) {
             call_user_func_array(array($plugin, $actionName), $eventArguments);
             $called = true;
             break;
         }
     }
     // If one wasn't found, call the method on $this.
     if (!$called) {
         call_user_func_array(array($this, "action_" . $method), $arguments);
     }
     // Trigger an "after" event for this method.
     ET::trigger($eventName . "_after", $eventArguments);
 }
开发者ID:davchezt,项目名称:fireside,代码行数:31,代码来源:ETController.class.php

示例3: slug

/**
 * Create a slug for use in URLs from a given string. Any non-alphanumeric characters will be converted to "-".
 *
 * @param string $string The string to convert.
 * @return string The slug.
 *
 * @package esoTalk
 */
function slug($string)
{
    // If there are any characters other than basic alphanumeric, space, punctuation, then we need to attempt transliteration.
    if (preg_match("/[^ -]/", $string)) {
        // Thanks to krakos for this code! http://esotalk.org/forum/582-unicode-in-usernames-and-url-s
        if (function_exists('transliterator_transliterate')) {
            // Unicode decomposition rules states that these cannot be decomposed, hence
            // we have to deal with them manually. Note: even though “scharfes s” is commonly
            // transliterated as “sz”, in this context “ss” is preferred, as it's the most popular
            // method among German speakers.
            $src = array('œ', 'æ', 'đ', 'ø', 'ł', 'ß', 'Œ', 'Æ', 'Đ', 'Ø', 'Ł');
            $dst = array('oe', 'ae', 'd', 'o', 'l', 'ss', 'OE', 'AE', 'D', 'O', 'L');
            $string = str_replace($src, $dst, $string);
            // Using transliterator to get rid of accents and convert non-Latin to Latin
            $string = transliterator_transliterate("Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();", $string);
        } else {
            // A fallback to old method.
            // Convert special Latin letters and other characters to HTML entities.
            $string = htmlentities($string, ENT_NOQUOTES, "UTF-8");
            // With those HTML entities, either convert them back to a normal letter, or remove them.
            $string = preg_replace(array("/&([a-z]{1,2})(acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);/i", "/&[^;]{2,6};/"), array("\$1", " "), $string);
        }
    }
    // Allow plugins to alter the slug.
    ET::trigger("slug", array(&$string));
    // Now replace non-alphanumeric characters with a hyphen, and remove multiple hyphens.
    $slug = str_replace(' ', '-', trim(preg_replace('~[^\\pL\\d]+~u', ' ', mb_strtolower($string, "UTF-8"))));
    return mb_substr($slug, 0, 63, "UTF-8");
}
开发者ID:xiaolvmu,项目名称:Techllage,代码行数:37,代码来源:functions.general.php

示例4: sendEmail

/**
 * Send an email with proper headers.
 *
 * @param string $to The address to send the email to.
 * @param string $subject The subject of the email.
 * @param string $body The body of the email.
 * @return bool Whether or not the mailing succeeded.
 */
function sendEmail($to, $subject, $body)
{
    if ($return = ET::trigger("sendEmailBefore", array(&$to, &$subject, &$body)) and !empty($return)) {
        return reset($return);
    }
    $headers = "From: " . sanitizeForHTTP(C("esoTalk.forumTitle") . " <" . C("esoTalk.emailFrom") . ">") . "\r\n" . 'X-Mailer: esoTalk' . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . "Content-Type: text/plain; charset=" . T("charset") . "";
    return mail($to, $subject, $body, $headers);
}
开发者ID:nowaym,项目名称:esoTalk,代码行数:16,代码来源:functions.general.php

示例5: sendEmail

/**
 * Send an email with proper headers.
 *
 * @param string $to The address to send the email to.
 * @param string $subject The subject of the email.
 * @param string $body The body of the email.
 * @return bool Whether or not the mailing succeeded.
 *
 * @package esoTalk
 */
function sendEmail($to, $subject, $body)
{
    $phpmailer = PATH_LIBRARY . '/vendor/class.phpmailer.php';
    require_once $phpmailer;
    $mail = new PHPMailer(true);
    if ($return = ET::trigger("sendEmailBefore", array($mail, &$to, &$subject, &$body)) and !empty($return)) {
        return reset($return);
    }
    $mail->IsHTML(true);
    $mail->AddAddress($to);
    $mail->SetFrom(C("esoTalk.emailFrom"), sanitizeForHTTP(C("esoTalk.forumTitle")));
    $mail->Subject = sanitizeForHTTP($subject);
    $mail->Body = $body;
    return $mail->Send();
}
开发者ID:AlexandrST,项目名称:esoTalk,代码行数:25,代码来源:functions.general.php


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