本文整理汇总了PHP中Hook::run方法的典型用法代码示例。如果您正苦于以下问题:PHP Hook::run方法的具体用法?PHP Hook::run怎么用?PHP Hook::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hook
的用法示例。
在下文中一共展示了Hook::run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logout
/**
* Logs the current user out
*
* @return void
*/
public static function logout()
{
// trigger a hook
Hook::run('auth', 'logout', 'call', null, Auth::getCurrentMember());
$app = \Slim\Slim::getInstance();
$app->deleteCookie('stat_auth_cookie');
}
示例2: load
/**
@param className name of the class and the name of the file without the ".php" extension
*/
function load($className)
{
$excludePaths = array();
//go throught all possible paths until either finding the class or failing
while (!class_exists($className, false)) {
if ($path = $this->findClass($className, $excludePaths)) {
require_once $path;
} else {
break;
}
}
if (class_exists($className, false)) {
//found the class, perhaps hooks
Hook::run('classLoaded', $className);
return array('found' => true);
}
return array('found' => false, 'searched' => $excludePaths);
}
示例3: init
function init()
{
$this->request = Yii::app()->request;
$AssetManager = Yii::app()->getAssetManager();
$AssetManager->setBasePath(base_path() . '/../public/_assets/');
$AssetManager->setBaseUrl(base_url() . '/_assets');
Yii::app()->theme = $this->theme;
if (!$this->hash) {
$this->hash = Yii::app()->params['hash'];
}
$this->securityManager = Yii::app()->securityManager;
$this->securityManager->encryptionKey = $this->hash;
//设置选中的菜单
Helper::set('activeMenu', $this->active);
//多语言
if (true == Yii::app()->params['checkBrowsLanguage']) {
$this->_check_language();
}
//加载hook
Hook::run('init[]');
}
示例4: humanize
?>
_container">
<label id="<?php
echo $input_id;
?>
_label"><?php
echo humanize($name);
?>
<br>
<?php
echo $field_str;
?>
</label>
</div>
<?php
}
//TODO Sort this out
Hook::run('form', 'post', array($db_object));
?>
<input type="submit" value="<?php
echo '<?php echo $action_name ?> <?php echo $action_subject ?>';
?>
" class=""/>
</form>
<?php
} else {
?>
No object
<?php
}
示例5: runHook
/**
* Runs a hook for this add-on
*
* @param string $hook Hook to run
* @param string $type Type of hook to run (cumulative|replace|call)
* @param mixed $return Pass-through values
* @param mixed $data Data to pass to hook method
* @return mixed
*/
public function runHook($hook, $type=null, $return=null, $data=null)
{
return Hook::run($this->addon_name, $hook, $type, $return, $data);
}
示例6: afterSave
function afterSave()
{
parent::afterSave();
Hook::run('model.NodeField_afterSave', $this);
}
示例7: form
/**
* Raven form tag pair
*
* {{ raven:form }} {{ /raven:form }}
*
* @return string
*/
public function form()
{
/*
|--------------------------------------------------------------------------
| Formset
|--------------------------------------------------------------------------
|
| Raven really needs a formset to make it useful and secure. We may even
| write a form decorator in the future to generate forms from formsets.
|
*/
$formset = $this->fetchParam('formset', false);
$return = $this->fetchParam('return', URL::getCurrent());
$error_return = $this->fetchParam('error_return', URL::getCurrent());
$multipart = ($this->fetchParam('files', false)) ? "enctype='multipart/form-data'" : '';
$old_values = array();
// Fetch the content if in edit mode
if ($edit = $this->fetchParam('edit')) {
$old_values = Content::get($edit, false, false);
// Throw exception if there's an invalid URL
if (count($old_values) == 0) {
throw new FatalException('Invalid URL for editing');
}
$entry_hash = Helper::encrypt($edit);
}
// Merge old values
$old_values = array_merge($this->flash->get('old_values', array()), $old_values);
// Sanitize data before returning it for display
// $old_values = array_map_deep($old_values, 'htmlspecialchars');
// Set old values to re-populate the form
$data = array();
array_set($data, 'value', $old_values);
array_set($data, 'old_values', $old_values);
/*
|--------------------------------------------------------------------------
| Form HTML
|--------------------------------------------------------------------------
|
| Raven writes a few hidden fields to the form to help processing data go
| more smoothly. Form attributes are accepted as colon/piped options:
| Example: attr="class:form|id:contact-form"
|
| Note: The content of the tag pair is inserted back into the template
|
*/
$form_id = $this->fetchParam('id', true);
$attributes_string = '';
if ($attr = $this->fetchParam('attr', false, null, false, false)) {
$attributes_array = Helper::explodeOptions($attr, true);
foreach ($attributes_array as $key => $value) {
$attributes_string .= " {$key}='{$value}'";
}
}
$html = "<form method='post' {$multipart} {$attributes_string}>\n";
$html .= "<input type='hidden' name='hidden[raven]' value='{$form_id}' />\n";
$html .= "<input type='hidden' name='hidden[formset]' value='{$formset}' />\n";
$html .= "<input type='hidden' name='hidden[return]' value='{$return}' />\n";
$html .= "<input type='hidden' name='hidden[error_return]' value='{$error_return}' />\n";
if ($edit) {
$html .= "<input type='hidden' name='hidden[edit]' value='{$entry_hash}' />\n";
}
/*
|--------------------------------------------------------------------------
| Hook: Form Begin
|--------------------------------------------------------------------------
|
| Occurs in the middle the form allowing additional fields to be added.
| Has access to the current fieldset. Must return HTML.
|
*/
$html .= Hook::run('raven', 'inside_form', 'cumulative', '');
/*
|--------------------------------------------------------------------------
| Hook: Content Preparse
|--------------------------------------------------------------------------
//.........这里部分代码省略.........
示例8: post_update
public function post_update($id)
{
$object = self::getObject(get_class($this), $id);
if (!$object instanceof DBObject) {
Controller::whoops('Invalid Object Returned');
return $object;
}
if (!$object->checkOwnership('update')) {
Backend::addError('Permission Denied');
return false;
}
if (!$object->array) {
Backend::addError('The ' . $object->getMeta('name') . ' does not exist');
return false;
}
$result = true;
//We need to check if the post data is valid in some way?
$data = $object->fromRequest();
$data = Hook::run('table_update', 'pre', array($data, $object), array('toret' => $data));
if ($object->update($data) !== false) {
$data = Hook::run('table_update', 'post', array($data, $object), array('toret' => $data));
$result = $object;
Backend::addSuccess($object->getMeta('name') . ' Modified');
} else {
if (Controller::$debug && !empty($object->error_msg)) {
Backend::addError('Could not update ' . $object->getMeta('name') . ': ' . $object->error_msg);
} else {
Backend::addError('Could not update ' . $object->getMeta('name'));
}
$result = false;
}
Backend::add('values', $data);
return $result;
}
示例9: function
<?php
/////////////////////////////////////////////////////////////////////////////////////////////////
// ROUTING HOOKS
/////////////////////////////////////////////////////////////////////////////////////////////////
$app->map('/TRIGGER/:namespace/:hook', function ($namespace, $hook) use($app) {
Hook::run($namespace, $hook);
})->via('GET', 'POST', 'HEAD');
/////////////////////////////////////////////////////////////////////////////////////////////////
// Static Asset Pipeline
/////////////////////////////////////////////////////////////////////////////////////////////////
$app->get('/assets/(:segments+)', function ($segments = array()) use($app) {
$file_requested = implode($segments, '/');
$file = Theme::getPath() . $file_requested;
# Routes only if the file doesn't already exist (e.g. /assets/whatever.ext)
if (!File::exists($file_requested) && File::exists($file)) {
$mime = File::resolveMime($file);
header("Content-type: {$mime}");
readfile($file);
exit;
}
});
/////////////////////////////////////////////////////////////////////////////////////////////////
// GLOBAL STATAMIC CONTENT ROUTING
/////////////////////////////////////////////////////////////////////////////////////////////////
$app->map('/(:segments+)', function ($segments = array()) use($app) {
$requesting_xml = false;
$content_found = false;
// segments
foreach ($segments as $key => $seg) {
$count = $key + 1;
示例10: _render_layout
/**
* _render_layout
* Renders the page
*
* @param string $_html HTML of the template to use
* @param string $template_type Content type of the template
* @return string
*/
public function _render_layout($_html, $template_type = 'html')
{
if (self::$_layout) {
$this->data['layout_content'] = $_html;
if ($template_type != 'html' or self::$_control_panel) {
extract($this->data);
ob_start();
require self::$_layout . ".php";
$html = ob_get_clean();
} else {
if (!File::exists(self::$_layout . ".html")) {
Log::fatal("Can't find the specified theme.", 'core', 'template');
return '<p style="text-align:center; font-size:28px; font-style:italic; padding-top:50px;">We can\'t find your theme files. Please check your settings.';
}
$this->appendNewData($this->data);
// Fetch layout and parse any front matter
$layout = Parse::frontMatter(File::get(self::$_layout . '.html'), false);
$html = Parse::template($layout['content'], Statamic_View::$_dataStore, array($this, 'callback'));
$html = Lex\Parser::injectNoparse($html);
}
} else {
$html = $_html;
}
// post-render hook
$html = \Hook::run('_render', 'after', 'replace', $html, $html);
return $html;
}
示例11: post_confirm
public function post_confirm($salt)
{
$user = self::checkSalt($salt);
$data = array('confirmed' => true);
$data = Hook::run('user_confirm', 'pre', array($user, $data), array('toret' => $data));
if (!$data) {
return false;
}
if ($user->update($data) === false) {
return false;
}
Hook::run('user_confirm', 'post', array($user), array('toret' => true));
return true;
}
示例12: endJson
static function endJson($content, $encode = true)
{
Hook::run('preHTTPMessageBody');
header('Content-type: application/json');
if ($encode) {
echo json_encode($content);
} else {
echo $content;
}
exit;
}
示例13: output
/**
* Actually output the information
*/
function output($to_print = null)
{
if (Controller::$mode == Controller::MODE_REQUEST) {
if (!headers_sent() && !Controller::$debug) {
$content_type = $this->mime_type;
if ($this->charset) {
$content_type .= '; charset=' . $this->charset;
}
header('Content-Type: ' . $content_type);
}
}
//Run the View first, so that the other hooks have the output to work on
if (method_exists($this, 'hook_output')) {
$to_print = $this->hook_output($to_print);
}
$to_print = Hook::run('output', 'pre', array($to_print), array('toret' => $to_print));
echo $to_print;
//Run the View first, so that the other hooks have the output to work on
if (method_exists($this, 'hook_post_output')) {
$to_print = $this->hook_post_output($to_print);
}
$to_print = Hook::run('output', 'post', array($to_print), array('toret' => $to_print));
}
示例14: _render_layout
/**
* _render_layout
* Renders the page
*
* @param string $_html HTML of the template to use
* @param string $template_type Content type of the template
* @return string
*/
public function _render_layout($_html, $template_type = 'html')
{
if (self::$_layout != '') {
$this->data['layout_content'] = $_html;
$layout_path = Path::assemble(BASE_PATH, Config::getTemplatesPath(), self::$_layout);
if ($template_type != 'html' or self::$_control_panel) {
extract($this->data);
ob_start();
require $layout_path . ".php";
$html = ob_get_clean();
} else {
if (!File::exists($layout_path . ".html")) {
Log::fatal("Can't find the specified theme.", 'core', 'template');
return '<p style="text-align:center; font-size:28px; font-style:italic; padding-top:50px;">We can\'t find your theme files. Please check your settings.';
}
$this->mergeNewData($this->data);
$html = Parse::template(File::get($layout_path . ".html"), Statamic_View::$_dataStore, array($this, 'callback'));
$html = Lex\Parser::injectNoparse($html);
}
} else {
$html = $_html;
}
// post-render hook
$html = \Hook::run('_render', 'after', 'replace', $html, $html);
return $html;
}
示例15: function
$admin_app->get('/images', function () use($admin_app) {
authenticateForRole('admin');
doStatamicVersionCheck($admin_app);
$path = $admin_app->request()->get('path');
$image_list = glob($path . "*.{jpg,jpeg,gif,png}", GLOB_BRACE);
$images = array();
if (count($image_list) > 0) {
foreach ($image_list as $image) {
$images[] = array('thumb' => '/' . $image, 'image' => '/' . $image);
}
}
echo json_encode($images);
})->name('images');
/*
|--------------------------------------------------------------------------
| Hook: Add Routes
|--------------------------------------------------------------------------
|
| Allows add-ons to add their own hooks to the control panel.
|
*/
Hook::run('control_panel', 'add_routes');
// GET: 404
// --------------------------------------------------------
$admin_app->notFound(function () use($admin_app) {
authenticateForRole('admin');
doStatamicVersionCheck($admin_app);
$admin_app->flash('error', Localization::fetch('admin_404'));
$redirect_to = Config::get('_admin_404_page', $admin_app->urlFor('pages'));
$admin_app->redirect($redirect_to);
});