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


PHP Trigger类代码示例

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


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

示例1: actionStructure

 /**
  * Shows the table structure
  */
 public function actionStructure()
 {
     $table = $this->loadTable();
     if (!$table instanceof Table) {
         $response = new AjaxResponse();
         $response->addNotification("error", Yii::t("core", "tableLoadErrorTitle", array("{table}" => $this->table)), Yii::t("core", "tableLoadErrorMessage", array("{table}" => $this->table)));
         $response->executeJavaScript("sideBar.loadTables(schema)");
         $this->sendJSON($response);
     }
     // Constraints
     if (StorageEngine::check($table->ENGINE, StorageEngine::SUPPORTS_FOREIGN_KEYS)) {
         $foreignKeys = array();
         $sql = 'SELECT * FROM KEY_COLUMN_USAGE ' . 'WHERE TABLE_SCHEMA = :tableSchema ' . 'AND TABLE_NAME = :tableName ' . 'AND REFERENCED_TABLE_SCHEMA IS NOT NULL';
         $table->foreignKeys = ForeignKey::model()->findAllBySql($sql, array('tableSchema' => $table->TABLE_SCHEMA, 'tableName' => $table->TABLE_NAME));
         foreach ($table->foreignKeys as $key) {
             $foreignKeys[] = $key->COLUMN_NAME;
         }
     } else {
         $foreignKeys = false;
     }
     // Indices
     $sql = 'SELECT * FROM STATISTICS ' . 'WHERE TABLE_SCHEMA = :tableSchema ' . 'AND TABLE_NAME = :tableName ' . 'GROUP BY INDEX_NAME ' . 'ORDER BY INDEX_NAME = \'PRIMARY\' DESC, INDEX_NAME';
     $table->indices = Index::model()->findAllBySql($sql, array('tableSchema' => $table->TABLE_SCHEMA, 'tableName' => $table->TABLE_NAME));
     foreach ($table->indices as $index) {
         $index->columns = IndexColumn::model()->findAllByAttributes(array('TABLE_SCHEMA' => $table->TABLE_SCHEMA, 'TABLE_NAME' => $table->TABLE_NAME, 'INDEX_NAME' => $index->INDEX_NAME));
     }
     // Indices (seperate for each column)
     $indicesRaw = Index::model()->findAllByAttributes(array('TABLE_SCHEMA' => $table->TABLE_SCHEMA, 'TABLE_NAME' => $table->TABLE_NAME));
     // Triggers
     $table->triggers = Trigger::model()->findAllByAttributes(array('EVENT_OBJECT_SCHEMA' => $table->TABLE_SCHEMA, 'EVENT_OBJECT_TABLE' => $table->TABLE_NAME));
     $this->render('structure', array('table' => $table, 'canAlter' => Yii::app()->user->privileges->checkTable($table->TABLE_SCHEMA, $table->TABLE_NAME, 'ALTER'), 'foreignKeys' => $foreignKeys, 'indicesRaw' => $indicesRaw));
 }
开发者ID:cebe,项目名称:chive,代码行数:35,代码来源:TableController.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: 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

示例4: fireEvent

 /**
  * (non-PHPdoc)
  * @see Db_Object_Event_Manager::fireEvent()
  */
 public function fireEvent($code, Db_Object $object)
 {
     $objectName = ucfirst($object->getName());
     $triggerClass = Utils_String::classFromString('Trigger_' . $objectName);
     if (class_exists($triggerClass) && method_exists($triggerClass, $code)) {
         $trigger = new $triggerClass();
         if ($this->_cache) {
             $trigger->setCache($this->_cache);
         }
         $trigger->{$code}($object);
     } elseif (method_exists('Trigger', $code)) {
         $trigger = new Trigger();
         if ($this->_cache) {
             $trigger->setCache($this->_cache);
         }
         $trigger->{$code}($object);
     }
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:22,代码来源:Eventmanager.php

示例5: testGetCreateTrigger

 /**
  * tests return value of getCreateTrigger method
  * and tries to insert a triggesr
  */
 public function testGetCreateTrigger()
 {
     $triggerObj = Trigger::model()->findByPk(array('TRIGGER_SCHEMA' => 'triggertest', 'TRIGGER_NAME' => 'trigger1'));
     $createTrigger = $triggerObj->getCreateTrigger();
     $this->assertType('string', $createTrigger);
     $this->assertType('string', $triggerObj->delete());
     $cmd = Trigger::$db->createCommand($createTrigger);
     $this->assertEquals(0, $cmd->execute());
     $triggerObj = Trigger::model()->findByPk(array('TRIGGER_SCHEMA' => 'triggertest', 'TRIGGER_NAME' => 'trigger1'));
     $this->assertType('Trigger', $triggerObj);
 }
开发者ID:cebe,项目名称:chive,代码行数:15,代码来源:TriggerTest.php

示例6: 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

示例7: 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

示例8: upgradeTrigger

/**
* Upgrade the Set Future Permissions and Set Future Status trigger actions
* present in existing Trigger assets to the new values expected in version 0.2
* of these assets
*
* @param Trigger	&$trigger	The Trigger Asset to upgrade
*
* @return void
* @access public
*/
function upgradeTrigger(Trigger &$trigger)
{
    $trigger_actions = $trigger->attr('actions');
    $trigger_modified = FALSE;
    foreach ($trigger_actions as $key => &$trigger_action) {
        $trigger_action_data =& $trigger_action['data'];
        // Set Future Permissions and Status triggers < v0.2 will not have an "offset_used" value
        if (($trigger_action['type'] == 'trigger_action_set_future_permissions' || $trigger_action['type'] == 'trigger_action_set_future_status') && !isset($trigger_action_data['offset_used'])) {
            // Modify data associated with the Trigger Action (using a reference for ease and fun)
            // Add new "offset_used" value
            $trigger_action_data['offset_used'] = FALSE;
            // Convert to new "by_attr_value" when_type and enable offset if one was specified
            if ($trigger_action_data['when_type'] == 'attr_interval' || $trigger_action_data['when_type'] == 'attr_exact') {
                $trigger_action_data['when_type'] = 'by_attr_value';
                $trigger_action_data['offset_used'] = $trigger_action_data['when_type'] == 'attr_interval';
            }
            // Convert "explicit_interval" to "explicit_exact", as the offset is now handled separately
            if ($trigger_action_data['when_type'] == 'explicit_interval') {
                $trigger_action_data['when_type'] = 'explicit_exact';
                $trigger_action_data['offset_used'] = TRUE;
            }
            // Restock the main Trigger Actions array for this Trigger
            $trigger_actions[$key] = $trigger_action;
            $trigger_modified = TRUE;
        }
    }
    if ($trigger_modified) {
        // Supply the new Trigger Actions values and save the Trigger if it was modified
        echo "\n- Upgrading Trigger " . $trigger->id . '... ';
        // Ok we need the Attributes lock now...
        $GLOBALS['SQ_SYSTEM']->acquireLock($trigger->id, 'attributes');
        $trigger->setAttrValue('actions', $trigger_actions);
        $trigger->saveAttributes();
        $GLOBALS['SQ_SYSTEM']->releaseLock($trigger->id, 'attributes');
        echo 'done';
    }
}
开发者ID:joshgillies,项目名称:mysource-matrix,代码行数:47,代码来源:upgrade_future_trigger_actions.php

示例9: 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

示例10: connectDb

 /**
  * Connects to the specified schema and assigns it to all models which need it.
  *
  * @param	$schema				schema
  * @return	CDbConnection
  */
 protected function connectDb($schema)
 {
     // Assign request
     $this->request = Yii::app()->getRequest();
     // Check parameter
     if (is_null($schema)) {
         $this->db = null;
         return null;
     }
     // Connect to database
     $connectionString = 'mysql:host=' . Yii::app()->user->host . ';port=' . Yii::app()->user->port . ';dbname=' . $schema . '; charset=utf8';
     $this->db = new CDbConnection($connectionString, utf8_decode(Yii::app()->user->name), utf8_decode(Yii::app()->user->password));
     $this->db->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, 'SET NAMES \'utf8\'');
     $this->db->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, 'SET CHARACTER SET \'utf8\'');
     $this->db->charset = 'utf8';
     $this->db->emulatePrepare = true;
     $this->db->active = true;
     // Schema name is set in connection string
     // $this->db->createCommand('USE ' . $this->db->quoteTableName($schema))->execute();
     // Assign to all models which need it
     ActiveRecord::$db = Routine::$db = Row::$db = Trigger::$db = View::$db = $this->db;
     // Return connection
     return $this->db;
 }
开发者ID:cebe,项目名称:chive,代码行数:30,代码来源:Controller.php

示例11: destroy

 /**
  * Function: delete
  * Deletes a given object. Calls the @delete_(model)@ trigger with the objects ID.
  *
  * Parameters:
  *     $model - The model name.
  *     $id - The ID of the object to delete.
  */
 protected static function destroy($model, $id)
 {
     $model = strtolower($model);
     if (Trigger::current()->exists("delete_" . $model)) {
         Trigger::current()->call("delete_" . $model, new $model($id));
     }
     SQL::current()->delete(pluralize($model), array("id" => $id));
 }
开发者ID:homebru,项目名称:bandb,代码行数:16,代码来源:Model.php

示例12: 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

示例13: trigger

 public function trigger($field, Trigger $trigger)
 {
     // Allow the context to be this field
     $context = $field !== NULL ? $this->find($field) : $this;
     // Set the context of the trigger
     $trigger->context($context);
     // Add the trigger to the bunch
     $context->add_validator('triggers', $trigger);
     return $this;
 }
开发者ID:vitch,项目名称:kohana-formo,代码行数:10,代码来源:core.php

示例14: 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

示例15: fix

<?php

$config = Config::current();
$trigger = Trigger::current();
$theme = Theme::current();
$title = !empty($_GET['title']) ? ": " . html_entity_decode($_GET['title']) : "";
echo "<" . '?xml version="1.0" encoding="utf-8"?' . ">\r";
?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title><?php 
echo $config->name . $title;
?>
</title>
<?php 
if (!empty($config->description)) {
    ?>
    <subtitle><?php 
    echo fix($config->description);
    ?>
</subtitle>
<?php 
}
?>
    <id><?php 
echo fix(self_url());
?>
</id>
    <updated><?php 
echo date("c", $latest_timestamp);
?>
</updated>
开发者ID:quanganhdo,项目名称:chyrp,代码行数:31,代码来源:feed.php


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