本文整理汇总了PHP中F::Hook方法的典型用法代码示例。如果您正苦于以下问题:PHP F::Hook方法的具体用法?PHP F::Hook怎么用?PHP F::Hook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类F
的用法示例。
在下文中一共展示了F::Hook方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Check', function ($Call) {
$Filters = F::Run('IO', 'Read', ['Storage' => 'Web', 'Format' => 'Formats.JSON', 'RTTL' => 86400, 'Where' => ['ID' => $Call['IDS']['Filters URL']]]);
$Filters = array_pop($Filters);
$Score = 0;
F::Log('*' . count($Filters['filters']['filter']) . '* filters loaded', LOG_INFO, 'Security');
foreach ($Filters['filters']['filter'] as $Filter) {
if (preg_match('/' . $Filter['rule'] . '/Ssu', $Call['HTTP']['URI'])) {
F::Log('IDS-' . $Filter['id'] . ': ' . $Filter['description'] . ' with impact ' . $Filter['impact'], LOG_NOTICE - $Filter['impact'], 'Security');
$Score += $Filter['impact'];
}
}
$Verbose = LOG_INFO;
if ($Score > $Call['IDS']['Impact Levels']['Red']) {
$Call = F::Hook('onRedImpactLevel', $Call);
$Verbose = LOG_ERR;
} elseif ($Score > $Call['IDS']['Impact Levels']['Yellow']) {
$Call = F::Hook('onYellowImpactLevel', $Call);
$Verbose = LOG_WARNING;
}
F::Log('Overall IDS Impact: ' . $Score, $Verbose, 'Security');
return $Call;
});
示例2: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Length', function ($Call) {
if (isset($Call['View']['HTML']['Keywords']) && is_string($Call['View']['HTML']['Keywords'])) {
$Length = mb_strlen($Call['View']['HTML']['Keywords']);
if ($Length > $Call['SEO']['Audit']['Keywords']['Length']['Maximum']) {
$Call = F::Hook('SEO.Audit.Keywords.TooLong', $Call);
F::Log('SEO Keywords is too long *' . $Length . ' chars* over *' . $Call['SEO']['Audit']['Keywords']['Length']['Maximum'] . '*', LOG_WARNING, 'Marketing');
} elseif ($Length < $Call['SEO']['Audit']['Keywords']['Length']['Minimum']) {
$Call = F::Hook('SEO.Audit.Keywords.TooShort', $Call);
F::Log('SEO Keywords is too short *' . $Length . ' chars* over *' . $Call['SEO']['Audit']['Keywords']['Length']['Minimum'] . '*', LOG_WARNING, 'Marketing');
} else {
F::Log('SEO Keywords length is optimal ', LOG_NOTICE, 'Marketing');
}
}
return $Call;
});
示例3: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 7.6,2
*/
setFn('Widget', function ($Call) {
return F::Apply($Call['Modes'][$Call['Mode']], 'Widget', $Call);
});
setFn('Check', function ($Call) {
if (!isset($Call['CAPTCHA']['Bypass'])) {
if (!F::Run($Call['Modes'][$Call['Mode']], 'Check', $Call)) {
F::Log('CAPTCHA Failed from IP ' . F::Live($Call['HTTP']['IP']), LOG_ERR, 'Security');
$Call['Failure'] = true;
$Call = F::Hook('CAPTCHA.Failed', $Call);
}
}
return $Call;
});
示例4: isset
}
}
}
// Вывести
$Call['Output']['Content']['Form Widget']['Action'] = isset($Call['Action']) ? $Call['Action'] : '';
}
$Call = F::Hook('afterVerifyGet', $Call);
return $Call;
});
setFn('POST', function ($Call) {
if (isset($Call['Request']['Data'])) {
$Call['Data'] = $Call['Request']['Data'];
} else {
$Call['Data'] = [];
}
$Call = F::Hook('beforeVerifyPost', $Call);
// Отправляем в Entity.Verify
$Call['Data'] = F::Merge(F::Run('Entity', 'Read', $Call, ['Time' => microtime(true)]), F::Apply('Entity', 'Update', $Call));
// Выводим результат
if (empty($Call['Errors'])) {
$Call = F::Hook('afterVerifyPost', $Call);
} else {
foreach ($Call['Errors'] as $Name => $Node) {
foreach ($Node as $Error) {
$Call['Output']['Message'][] = ['Type' => 'Block', 'Class' => 'alert alert-danger', 'Value' => '<l>' . $Call['Entity'] . '.Error:' . $Name . '.' . $Error . '</l>'];
}
}
$Call = F::Apply(null, 'GET', $Call);
}
return $Call;
});
示例5: foreach
} else {
$Table = [];
}
foreach ($Call['Nodes'] as $Name => $Node) {
$NewValue = F::Dot($New, $Name);
$OldValue = F::Dot($Old[$IX], $Name);
if ($OldValue == $NewValue || $Name == 'ID') {
} else {
$Table[] = ['<l>' . $Call['Entity'] . '.Entity:' . $Name . '</l>', $OldValue, $NewValue];
}
}
$Call['Output']['Content'][] = ['Type' => 'Table', 'Value' => $Table];
}
$Call['Output']['Content'][] = ['Type' => 'Block', 'Class' => 'alert alert-success', 'Value' => count($New) . ' object touched'];
}
$Call = F::Hook('afterTouch', $Call);
return $Call;
});
setFn('All', function ($Call) {
$Call = F::Apply('Entity', 'Load', $Call);
$Total = F::Run('Entity', 'Count', $Call);
$Amount = ceil($Total / $Call['All']['Limit']);
set_time_limit(10 * $Total);
$Call = F::Apply('Code.Progress', 'Start', $Call);
$Call['Progress']['Max'] = $Amount;
for ($i = 0; $i < $Amount; $i++) {
F::Run('Entity', 'Update', ['Entity' => $Call['Entity'], 'Where' => $Call['Where'], 'Data' => [], 'One' => false, 'Limit' => ['From' => $i * $Call['All']['Limit'], 'To' => ($i + 1) * $Call['All']['Limit']]]);
$Call['Progress']['Now']++;
$Call = F::Apply('Code.Progress', 'Log', $Call);
F::Log('Touch Iteration № ' . ($i + 1) / $Amount, LOG_NOTICE);
}
示例6: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Do', function ($Call) {
F::Log('User ' . $Call['Session']['User']['ID'] . ' logged in ' . $Call['Where'], LOG_INFO, 'Security');
$Call = F::Apply('Session', 'Write', $Call, ['Session Data' => ['Secondary' => $Call['Where']]]);
$Call = F::Apply('Entity', 'Load', $Call, ['Entity' => 'User']);
$Call = F::Hook('afterLogin', $Call);
return $Call;
});
示例7:
$XML->text(date(DATE_RSS, $Element['Data']['Created']));
$XML->endElement();
// description
if (isset($Element['Data']['Description'])) {
$XML->startElement('description');
$XML->writeCdata($Element['Data']['Description']);
$XML->endElement();
// description
}
$XML->startElement('link');
if (isset($Element['Data']['Slug'])) {
$XML->text($Call['HTTP']['Proto'] . $Call['HTTP']['Host'] . '/' . $Call['Slug']['Entity'] . '/' . $Element['Data']['Slug'] . '?Channel=RSS');
} else {
$XML->text($Call['HTTP']['Proto'] . $Call['HTTP']['Host'] . '/' . $Call['Slug']['Entity'] . '/' . $Element['Data']['ID'] . '?Channel=RSS');
}
// FIXME It's double shit!
$XML->endElement();
// title
$XML->endElement();
// item
}
}
$XML->endElement();
// Channel
$XML->endElement();
// rss
$XML->endDocument();
$Call['Output'] = $XML->outputMemory(true);
$Call = F::Hook('afterRSSPipeline', $Call);
return $Call;
});
示例8: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Run', function ($Call) {
F::Log('API Call *' . $Call['Run']['Service'] . ':' . $Call['Run']['Method'] . '* started', LOG_NOTICE);
$Call = F::Hook('beforeAPIRun', $Call);
// В этом месте, практически всегда, происходит роутинг.
if (F::Dot($Call, 'API.Run.' . $Call['Run']['Service'] . '.' . $Call['Run']['Method'] . '.Allowed')) {
$AllowedCall = F::Dot($Call, 'API.Run.' . $Call['Run']['Service'] . '.' . $Call['Run']['Method'] . '.Params');
$Call['Run']['Call'] = $Call['Request'];
$Run = [];
foreach ($AllowedCall as $Key) {
if (isset($Call['Run']['Call'][$Key])) {
$Run[$Key] = $Call['Run']['Call'][$Key];
}
}
$Call = F::Run($Call['Run']['Service'], $Call['Run']['Method'], $Call, $Run);
}
$Call = F::Hook('afterAPIRun', $Call);
// А здесь - рендеринг
F::Log('Application *' . $Call['Run']['Service'] . ':' . $Call['Run']['Method'] . '* finished', LOG_INFO);
return $Call;
});
示例9: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Write', function ($Call) {
$Call['Value'] = $_FILES['file'];
$Call['ID'] = F::Run('Security.UID', 'Get', $Call);
$Call['Data'] = file_get_contents($_FILES['file']['tmp_name']);
$Call['Name'] = F::Live($Call['Naming'], $Call);
F::Run('IO', 'Write', $Call, ['Storage' => 'Uploader', 'Scope' => 'wysiwyg', 'Where' => $Call['Name']]);
$Call['Output']['Content']['filelink'] = '/uploads/wysiwyg/' . $Call['Name'];
// FIXME Scope support
return $Call;
});
setFn('Read', function ($Call) {
$Call['Output']['Content'] = F::Run('IO', 'Read', $Call, ['Storage' => 'Upload', 'Scope' => 'WYSIWYG']);
if (empty($Call['Output']['Content'])) {
$Call = F::Hook('onUploaderNotFound', $Call);
}
return $Call;
});
示例10: setFn
* @description
* @package Codeine
* @version 8.x
*/
setFn('Detect', function ($Call) {
$Call = F::Hook('beforeLocaleDetect', $Call);
if (isset($Call['Locale'])) {
F::Log('Locale selected: *' . $Call['Locale'] . '*', LOG_INFO);
} else {
$Call['Locale'] = $Call['Default']['Locale'];
if (F::Dot($Call, 'Locales.Detect.Accept-language')) {
$Call = F::Apply(null, 'Check Accept-language', $Call);
}
}
setlocale(LC_ALL, $Call['Locales']['PHP'][$Call['Locale']]);
$Call = F::Hook('afterLocaleDetect', $Call);
return $Call;
});
setFn('Check Accept-language', function ($Call) {
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\\s*(;\\s*q\\s*=\\s*(1|0\\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $Parsed);
$Locales = array_combine($Parsed[1], $Parsed[4]);
foreach ($Locales as $Locale => $Q) {
if ($Q === '') {
$Locales[$Locale] = 1;
}
}
arsort($Locales, SORT_NUMERIC);
foreach ($Locales as $Locale => $Quality) {
if (isset($Call['Accept-Language'][$Locale])) {
$Call['Locale'] = $Call['Accept-Language'][$Locale];
示例11: setFn
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Do', function ($Call) {
F::Log('CLI Interface Started', LOG_NOTICE);
$Call = F::Hook('beforeInterfaceRun', $Call);
$Call['HTTP']['IP'] = F::Live($Call['HTTP']['IP'], $Call);
if (isset($Call['Project']['Hosts'][F::Environment()])) {
$Call['HTTP']['Host'] = $Call['Project']['Hosts'][F::Environment()];
}
$Call['HTTP']['Proto'] = 'https';
$Call['HTTP']['URL'] = '/';
if (isset($Call['Skip Run'])) {
F::Log('Run Skipped, because ' . $Call['Skip Run'], LOG_INFO);
} else {
F::Log($Call['Service'] . ':' . $Call['Method'] . ' started', LOG_NOTICE);
$Call = F::Apply($Call['Service'], $Call['Method'], $Call);
}
$Call = F::Hook('afterInterfaceRun', $Call);
if (is_array($Call) && isset($Call['Output'])) {
F::Run('IO', 'Write', $Call, ['Storage' => 'Output', 'Where' => $Call['Service'] . ':' . $Call['Method'], 'Data' => $Call['Output']]);
if (isset($Call['Failure']) && $Call['Failure']) {
$Call['Return Code'] = 1;
}
}
F::Log('CLI Finished', LOG_NOTICE);
return $Call;
});
示例12: setFn
return $Call;
});
setFn('Do', function ($Call) {
$Call = F::Hook('beforeShow', $Call);
$Call = F::Hook('beforeShowDo', $Call);
/*foreach ($Call['Data'] as $Node => $Value)
{
if (isset($Call['Nodes'][$Node]['Widgets']))
;
else
unset ($Call['Data'][$Node]);
}*/
if (isset($Call['Data']['Redirect']) && !empty($Call['Data']['Redirect'])) {
$Call = F::Apply('System.Interface.HTTP', 'Redirect', $Call, ['Redirect' => $Call['Data']['Redirect']]);
} else {
$Call['Layouts'][] = ['Scope' => $Call['Entity'], 'ID' => 'Show', 'Context' => $Call['Context']];
$Call['Scope'] = isset($Call['Scope']) ? $Call['Entity'] . '/' . $Call['Scope'] : $Call['Entity'];
if (empty($Call['Data'])) {
$Call = F::Hook('onShowNotFound', $Call);
} else {
$Call['Output']['Content'][] = array('Type' => 'Template', 'Scope' => $Call['Scope'], 'ID' => 'Show/' . (isset($Call['Template']) ? $Call['Template'] : 'Full'), 'Data' => $Call['Data']);
$Call = F::Hook('afterShow', $Call);
}
}
/* if (isset($Call['Data']['Modified']))
$Call['HTTP']['Headers']['Last-Modified:'] = date(DATE_RFC2822, $Call['Data']['Modified']);
else
$Call['HTTP']['Headers']['Last-Modified:'] = date(DATE_RFC2822, $Call['Data']['Created']);*/
F::Log($Call['Data'], LOG_DEBUG);
return $Call;
});
示例13: j
F::Log($Request . j($Result), LOG_ERR, 'Administrator');
}
unset($Call['Data']['_id']);
// Mongo, are you kiddin'me?
} else {
$Request = 'db.*' . $Call['Scope'] . '*.remove()';
$Result = $Call['Link']->{$Call}['Scope']->remove([], ['justOne' => $Call['Mongo']['Just One'], 'w' => $Call['Mongo']['Write Concerns']]);
if ($Result) {
F::Log($Request, LOG_INFO, 'Administrator');
} else {
F::Log($Request . j($Result), LOG_ERR, 'Administrator');
}
}
}
} catch (MongoException $e) {
return F::Hook('IO.Mongo.Write.Failed', $Call);
}
return isset($Call['Data']) ? $Call['Data'] : null;
});
setFn('Close', function ($Call) {
return true;
});
setFn('Execute', function ($Call) {
F::Log($Call['Command'], LOG_INFO);
return $Call['Link']->execute($Call['Command']);
});
setFn('Count', function ($Call) {
$Call['Scope'] = strtr($Call['Scope'], '.', '_');
if (isset($Call['Where']) and $Call['Where'] !== null) {
$Call = F::Apply(null, 'Where', $Call);
if (isset($Call['Distinct']) && $Call['Distinct']) {
示例14: foreach
foreach ($Call['Latency']['Audit']['Limits'] as $Limit => $Value) {
if ($Total >= $Value) {
$Decision = $Limit;
}
}
$Verbose = LOG_DEBUG;
switch ($Decision) {
case 'Green':
$Verbose = PHP_INT_MAX;
break;
case 'Orange':
$Verbose = LOG_DEBUG;
break;
case 'Yellow':
$Verbose = LOG_INFO;
break;
case 'Red':
$Verbose = LOG_NOTICE;
break;
case 'Black':
$Verbose = LOG_ERR;
break;
}
F::Log('Latency level is *' . $Decision . '*, because total page time *' . $Total . '* ms', $Verbose, 'Performance');
if ($Verbose <= LOG_NOTICE) {
self::$_Performance = true;
}
$Call = F::Hook('Latency.Audit.' . $Decision, $Call);
}
return $Call;
});
示例15: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Render', function ($Call) {
$Call = F::Hook('beforeJSONRender', $Call);
$Call = F::Run('View.Pipeline', 'Do', $Call);
$Call['Output'] = j($Call['Output']['Content']);
$Call = F::Hook('afterJSONRender', $Call);
return $Call;
});