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


PHP Trigger::current方法代码示例

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


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

示例1: swfupload

 public function swfupload($admin, $post = null)
 {
     if (isset($post) and $post->feather != "audio" or isset($_GET['feather']) and $_GET['feather'] != "audio") {
         return;
     }
     Trigger::current()->call("prepare_swfupload", "audio", "*.mp3");
 }
开发者ID:eadz,项目名称:chyrp,代码行数:7,代码来源:audio.php

示例2: set

 /**
  * Function: set
  * Adds or replaces a configuration setting with the given value.
  *
  * Parameters:
  *     $setting - The setting name.
  *     $value - The value.
  *     $overwrite - If the setting exists and is the same value, should it be overwritten?
  */
 public function set($setting, $value, $overwrite = true)
 {
     if (isset($this->{$setting}) and $this->{$setting} == $value and !$overwrite) {
         return false;
     }
     if (isset($this->file) and file_exists($this->file)) {
         $contents = str_replace("<?php header(\"Status: 403\"); exit(\"Access denied.\"); ?>\n", "", file_get_contents($this->file));
         $this->yaml = YAML::load($contents);
     }
     # Add the setting
     $this->yaml[$setting] = $this->{$setting} = $value;
     if (class_exists("Trigger")) {
         Trigger::current()->call("change_setting", $setting, $value, $overwrite);
     }
     # Add the PHP protection!
     $contents = "<?php header(\"Status: 403\"); exit(\"Access denied.\"); ?>\n";
     # Generate the new YAML settings
     $contents .= YAML::dump($this->yaml);
     if (!@file_put_contents(INCLUDES_DIR . "/config.yaml.php", $contents)) {
         Flash::warning(_f("Could not set \"<code>%s</code>\" configuration setting because <code>%s</code> is not writable.", array($setting, "/includes/config.yaml.php")));
         return false;
     } else {
         return true;
     }
 }
开发者ID:betsyzhang,项目名称:chyrp,代码行数:34,代码来源:Config.php

示例3: prepare_cache_updaters

 public function prepare_cache_updaters()
 {
     $regenerate = array("add_post", "add_page", "update_post", "update_page", "delete_post", "delete_page", "change_setting");
     Trigger::current()->filter($regenerate, "cacher_regenerate_triggers");
     foreach ($regenerate as $action) {
         $this->addAlias($action, "regenerate");
     }
     $post_triggers = array();
     foreach (Trigger::current()->filter($post_triggers, "cacher_regenerate_posts_triggers") as $action) {
         $this->addAlias($action, "remove_post_cache");
     }
 }
开发者ID:betsyzhang,项目名称:chyrp,代码行数:12,代码来源:cacher.php

示例4: twig_missing_filter

/**
 * This is called like an ordinary filter just with the name of the filter
 * as first argument.  Currently we just raise an exception here but it
 * would make sense in the future to allow dynamic filter lookup for plugins
 * or something like that.
 */
function twig_missing_filter($name)
{
    $args = func_get_args();
    array_shift($args);
    $text = $args[0];
    array_shift($args);
    array_unshift($args, $name);
    unretarded_array_unshift($args, $text);
    $trigger = Trigger::current();
    if ($trigger->exists($name)) {
        return call_user_func_array(array($trigger, "filter"), $args);
    }
    return $text;
}
开发者ID:betsyzhang,项目名称:chyrp,代码行数:20,代码来源:runtime.php

示例5: update

 public function update($filename = null, $path = null, $entity_type = null, $entity_id = null)
 {
     if ($this->no_results) {
         return false;
     }
     $sql = SQL::current();
     $trigger = Trigger::current();
     $old = clone $this;
     foreach (array("filename", "path", "entity_type", "entity_id") as $attr) {
         if ($attr == "updated_at" and $updated_at === null) {
             $this->updated_at = $updated_at = datetime();
         } else {
             $this->{$attr} = ${$attr} = ${$attr} === null ? $this->{$attr} : ${$attr};
         }
     }
     $sql->update("attachments", array("id" => $this->id), array("filename" => $filename, "path" => $path, "entity_type" => $entity_type, "entity_id" => $entity_id));
     $trigger->call("update_attachment", $this, $old);
 }
开发者ID:vito,项目名称:chyrp-site,代码行数:18,代码来源:model.Attachment.php

示例6: display

 /**
  * Function: display
  * Display the page.
  *
  * If "posts" is in the context and the visitor requested a feed, they will be served.
  *
  * Parameters:
  *     $file - The theme file to display.
  *     $context - The context for the file.
  *     $title - The title for the page.
  */
 public function display($file, $context = array(), $title = "")
 {
     if (is_array($file)) {
         for ($i = 0; $i < count($file); $i++) {
             $check = ($file[$i][0] == "/" or preg_match("/[a-zA-Z]:\\\\/", $file[$i])) ? $file[$i] : THEME_DIR . "/" . $file[$i];
             if (file_exists($check . ".twig") or $i + 1 == count($file)) {
                 return $this->display($file[$i], $context, $title);
             }
         }
     }
     $this->displayed = true;
     $route = Route::current();
     $trigger = Trigger::current();
     # Serve feeds.
     if ($this->feed) {
         if ($trigger->exists($route->action . "_feed")) {
             return $trigger->call($route->action . "_feed", $context);
         }
         if (isset($context["posts"])) {
             return $this->feed($context["posts"]);
         }
     }
     $this->context = array_merge($context, $this->context);
     $visitor = Visitor::current();
     $config = Config::current();
     $theme = Theme::current();
     $theme->title = $title;
     $this->context["theme"] = $theme;
     $this->context["flash"] = Flash::current();
     $this->context["trigger"] = $trigger;
     $this->context["modules"] = Modules::$instances;
     $this->context["feathers"] = Feathers::$instances;
     $this->context["title"] = $title;
     $this->context["site"] = $config;
     $this->context["visitor"] = $visitor;
     $this->context["route"] = Route::current();
     $this->context["hide_admin"] = isset($_COOKIE["hide_admin"]);
     $this->context["version"] = CHYRP_VERSION;
     $this->context["now"] = time();
     $this->context["debug"] = DEBUG;
     $this->context["POST"] = $_POST;
     $this->context["GET"] = $_GET;
     $this->context["sql_queries"] =& SQL::current()->queries;
     $this->context["visitor"]->logged_in = logged_in();
     $this->context["enabled_modules"] = array();
     foreach ($config->enabled_modules as $module) {
         $this->context["enabled_modules"][$module] = true;
     }
     $context["enabled_feathers"] = array();
     foreach ($config->enabled_feathers as $feather) {
         $this->context["enabled_feathers"][$feather] = true;
     }
     $this->context["sql_debug"] =& SQL::current()->debug;
     $trigger->filter($this->context, array("main_context", "main_context_" . str_replace("/", "_", $file)));
     $file = ($file[0] == "/" or preg_match("/[a-zA-Z]:\\\\/", $file)) ? $file : THEME_DIR . "/" . $file;
     if (!file_exists($file . ".twig")) {
         error(__("Template Missing"), _f("Couldn't load template: <code>%s</code>", array($file . ".twig")));
     }
     try {
         return $this->twig->getTemplate($file . ".twig")->display($this->context);
     } catch (Exception $e) {
         $prettify = preg_replace("/([^:]+): (.+)/", "\\1: <code>\\2</code>", $e->getMessage());
         $trace = debug_backtrace();
         $twig = array("file" => $e->filename, "line" => $e->lineno);
         array_unshift($trace, $twig);
         error(__("Error"), $prettify, $trace);
     }
 }
开发者ID:vito,项目名称:chyrp-site,代码行数:79,代码来源:Main.php

示例7: addAlias

 /**
  * Function: addAlias
  * Allows a module to respond to a trigger with multiple functions and custom priorities.
  *
  * Parameters:
  *     $name - Name of the trigger to respond to.
  *     $function - Name of the class function to respond with.
  *     $priority - Priority of the response.
  */
 protected function addAlias($name, $function, $priority = 10)
 {
     Trigger::current()->priorities[$name][] = array("priority" => $priority, "function" => array($this, $function));
 }
开发者ID:betsyzhang,项目名称:chyrp,代码行数:13,代码来源:Modules.php

示例8: email

/**
 * Function: email
 * Send an email. Function arguments are exactly the same as the PHP mail() function.
 *
 * This is intended so that modules can provide an email method if the server cannot use mail().
 */
function email()
{
    $function = "mail";
    Trigger::current()->filter($function, "send_mail");
    $args = func_get_args();
    # Looks redundant, but it must be so in order to meet PHP's retardation requirements.
    return call_user_func_array($function, $args);
}
开发者ID:homebru,项目名称:bandb,代码行数:14,代码来源:helpers.php

示例9: update

 /**
  * Function: update
  * Updates the milestone.
  *
  * Parameters:
  *     $name - The new name.
  *     $description - The new description.
  */
 public function update($name = null, $description = null, $due = null)
 {
     if ($this->no_results) {
         return false;
     }
     $old = clone $this;
     $this->name = $name === null ? $this->name : $name;
     $this->description = $description === null ? $this->description : $description;
     $this->due = $due === null ? $this->due : $due;
     $sql = SQL::current();
     $sql->update("milestones", array("id" => $this->id), array("name" => $this->name, "description" => $this->description, "due" => $this->due));
     Trigger::current()->call("update_milestone", $this, $old);
     if (module_enabled("cacher")) {
         Modules::$instances["cacher"]->regenerate();
     }
 }
开发者ID:vito,项目名称:chyrp-site,代码行数:24,代码来源:Milestone.php

示例10: mt_setPostCategories

 public function mt_setPostCategories($args)
 {
     $this->auth($args[1], $args[2], 'edit');
     global $user;
     $post = new Post($args[0], array('filter' => false));
     if ($post->no_results) {
         return new IXR_Error(500, __("Post not found."));
     } else {
         if (!$post->deletable($user)) {
             return new IXR_Error(500, __("You don't have permission to edit this post."));
         }
     }
     Trigger::current()->call('mt_setPostCategories', $args[3], $post);
     return true;
 }
开发者ID:relisher,项目名称:chyrp,代码行数:15,代码来源:xmlrpc.php

示例11: from_url

 /**
  * Function: from_url
  * Attempts to grab a post from its clean URL.
  */
 static function from_url($attrs = null, $options = array())
 {
     fallback($attrs, $_GET);
     $where = array();
     $times = array("year", "month", "day", "hour", "minute", "second");
     preg_match_all("/\\(([^\\)]+)\\)/", Config::current()->post_url, $matches);
     $params = array();
     foreach ($matches[1] as $attr) {
         if (in_array($attr, $times)) {
             $where[strtoupper($attr) . "(created_at)"] = $attrs[$attr];
         } elseif ($attr == "author") {
             $user = new User(array("login" => $attrs['author']));
             $where["user_id"] = $user->id;
         } elseif ($attr == "feathers") {
             $where["feather"] = depluralize($attrs['feathers']);
         } else {
             $tokens = array($where, $params, $attr);
             Trigger::current()->filter($tokens, "post_url_token");
             list($where, $params, $attr) = $tokens;
             if ($attr !== null) {
                 if (!isset($attrs[$attr])) {
                     continue;
                 }
                 $where[$attr] = $attrs[$attr];
             }
         }
     }
     return new self(null, array_merge($options, array("where" => $where, "params" => $params)));
 }
开发者ID:relisher,项目名称:chyrp,代码行数:33,代码来源:Post.php

示例12: delete

 static function delete($comment_id)
 {
     $trigger = Trigger::current();
     if ($trigger->exists("delete_comment")) {
         $trigger->call("delete_comment", new self($comment_id));
     }
     SQL::current()->delete("comments", array("id" => $comment_id));
 }
开发者ID:homebru,项目名称:bandb,代码行数:8,代码来源:model.Comment.php

示例13: function

        $.post("<?php 
echo $config->chyrp_url;
?>
/includes/ajax.php", { action: "delete_comment", id: id }, function(response){
            $("#comment_"+id).loader(true)
            if (isError(response)) return

            if (Comment.delete_wrap != "")
                $("#comment_"+id).wrap(Comment.delete_wrap).parent().animate(Comment.delete_animations, function(){
                    $(this).remove()
                })
            else
                $("#comment_"+id).animate(Comment.delete_animations, function(){
                    $(this).remove()
                })

            if ($(".comment_count").size() && $(".comment_plural").size()) {
                var count = parseInt($(".comment_count:first").text())
                count--
                $(".comment_count").text(count)
                var plural = (count == 1) ? "" : "s"
                $(".comment_plural").text(plural)
            }
        }, "html")
    }
}
<?php 
Trigger::current()->call("comments_javascript");
?>
<!-- --></script>
开发者ID:betsyzhang,项目名称:chyrp,代码行数:30,代码来源:javascript.php

示例14: update

 /**
  * Function: update
  * Updates the extension.
  *
  * Parameters:
  *     $title - The new title.
  *     $description - The new description.
  */
 public function update($name = null, $clean = null, $url = null, $type = null, $user = null)
 {
     if ($this->no_results) {
         return false;
     }
     $sql = SQL::current();
     $trigger = Trigger::current();
     $old = clone $this;
     foreach (array("name", "clean", "url", "type_id", "user_id") as $attr) {
         if (substr($attr, -3) == "_id") {
             $arg = ${substr($attr, 0, -3)};
             $this->{$attr} = ${$attr} = oneof($arg instanceof Model ? $arg->id : $arg, $this->{$attr});
         } elseif ($attr == "updated_at" and ${$attr} === null) {
             $this->{$attr} = ${$attr} = datetime();
         } else {
             $this->{$attr} = ${$attr} = ${$attr} !== null ? ${$attr} : $this->{$attr};
         }
     }
     $sql->update("extensions", array("id" => $this->id), array("name" => $name, "clean" => $clean, "url" => $url, "type_id" => $type_id, "user_id" => $user_id));
     $trigger->call("update_extension", $this, $old);
     if (module_enabled("cacher")) {
         Modules::$instances["cacher"]->regenerate();
     }
 }
开发者ID:vito,项目名称:chyrp-site,代码行数:32,代码来源:Extension.php

示例15: update

 /**
  * Function: update
  * Updates the page.
  * 
  * Calls the @update_page@ trigger with the updated <Page> and the original <Page>.
  *
  * Parameters:
  *     $title - The new Title.
  *     $body - The new Body.
  *     $body - The <User> or <User.id> of the page's author.
  *     $parent_id - The new parent ID.
  *     $show_in_list - Whether or not to show it in the pages list.
  *     $clean - The page's clean URL.
  *     $url - The page's unique URL.
  *     $created_at - The page's "created" timestamp.
  *     $updated_at - The page's "last updated" timestamp.
  */
 public function update($title = null, $body = null, $user = null, $parent_id = null, $show_in_list = null, $list_order = null, $clean = null, $url = null, $created_at = null, $updated_at = null)
 {
     if ($this->no_results) {
         return false;
     }
     $user_id = $user instanceof User ? $user->id : $user;
     $sql = SQL::current();
     $trigger = Trigger::current();
     $old = clone $this;
     foreach (array("title", "body", "user_id", "parent_id", "show_in_list", "list_order", "clean", "url", "created_at", "updated_at") as $attr) {
         if ($attr == "updated_at" and ${$attr} === null) {
             $this->{$attr} = ${$attr} = datetime();
         } else {
             $this->{$attr} = ${$attr} = ${$attr} !== null ? ${$attr} : $this->{$attr};
         }
     }
     $new_values = array("title" => $title, "body" => $body, "user_id" => $user_id, "parent_id" => $parent_id, "show_in_list" => $show_in_list, "list_order" => $list_order, "clean" => $clean, "url" => $url, "created_at" => $created_at, "updated_at" => $updated_at);
     $trigger->filter($new_values, "before_update_page");
     $sql->update("pages", array("id" => $this->id), $new_values);
     $trigger->call("update_page", $this, $old);
 }
开发者ID:homebru,项目名称:bandb,代码行数:38,代码来源:Page.php


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