本文整理汇总了PHP中SpoonFilter::toCamelCase方法的典型用法代码示例。如果您正苦于以下问题:PHP SpoonFilter::toCamelCase方法的具体用法?PHP SpoonFilter::toCamelCase怎么用?PHP SpoonFilter::toCamelCase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpoonFilter
的用法示例。
在下文中一共展示了SpoonFilter::toCamelCase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseChartData
/**
* Parses the data to make the chart with
*/
private function parseChartData()
{
$maxYAxis = 2;
$metrics = array('visitors', 'pageviews');
$graphData = array();
$metricsPerDay = BackendAnalyticsModel::getMetricsPerDay($metrics, $this->startTimestamp, $this->endTimestamp);
foreach ($metrics as $i => $metric) {
$graphData[$i] = array();
$graphData[$i]['title'] = $metric;
$graphData[$i]['label'] = SpoonFilter::ucfirst(BL::lbl(SpoonFilter::toCamelCase($metric)));
$graphData[$i]['i'] = $i + 1;
$graphData[$i]['data'] = array();
foreach ($metricsPerDay as $j => $data) {
// cast SimpleXMLElement to array
$data = (array) $data;
// build array
$graphData[$i]['data'][$j]['date'] = (int) $data['timestamp'];
$graphData[$i]['data'][$j]['value'] = (string) $data[$metric];
}
}
// loop the metrics
foreach ($graphData as $metric) {
foreach ($metric['data'] as $data) {
// get the maximum value
if ((int) $data['value'] > $maxYAxis) {
$maxYAxis = (int) $data['value'];
}
}
}
$this->tpl->assign('maxYAxis', $maxYAxis);
$this->tpl->assign('tickInterval', $maxYAxis == 2 ? '1' : '');
$this->tpl->assign('graphData', $graphData);
}
示例2: loadConfig
/**
* Load the config file for the requested module.
* In the config file we have to find disabled actions, the constructor will read the folder
* and set possible actions. Other configurations will also be stored in it.
*/
public function loadConfig()
{
// check if module path is not yet defined
if (!defined('BACKEND_MODULE_PATH')) {
// build path for core
if ($this->getModule() == 'core') {
define('BACKEND_MODULE_PATH', BACKEND_PATH . '/' . $this->getModule());
} else {
define('BACKEND_MODULE_PATH', BACKEND_MODULES_PATH . '/' . $this->getModule());
}
}
// check if the config is present? If it isn't present there is a huge problem, so we will stop our code by throwing an error
if (!SpoonFile::exists(BACKEND_MODULE_PATH . '/config.php')) {
throw new BackendException('The configfile for the module (' . $this->getModule() . ') can\'t be found.');
}
// build config-object-name
$configClassName = 'Backend' . SpoonFilter::toCamelCase($this->getModule() . '_config');
// require the config file, we validated before for existence.
require_once BACKEND_MODULE_PATH . '/config.php';
// validate if class exists (aka has correct name)
if (!class_exists($configClassName)) {
throw new BackendException('The config file is present, but the classname should be: ' . $configClassName . '.');
}
// create config-object, the constructor will do some magic
$this->config = new $configClassName($this->getModule());
}
示例3: parseLineChartData
/**
* Parses the data to make the line chart
*
* @param array $metricsPerDay All needed metrics grouped by day.
*/
private function parseLineChartData($metricsPerDay)
{
$maxYAxis = 2;
$metrics = array('pageviews');
$graphData = array();
foreach ($metrics as $i => $metric) {
// build graph data array
$graphData[$i] = array();
$graphData[$i]['title'] = $metric;
$graphData[$i]['label'] = SpoonFilter::ucfirst(BL::lbl(SpoonFilter::toCamelCase($metric)));
$graphData[$i]['data'] = array();
foreach ($metricsPerDay as $j => $data) {
// cast SimpleXMLElement to array
$data = (array) $data;
$graphData[$i]['data'][$j]['date'] = (int) $data['timestamp'];
$graphData[$i]['data'][$j]['value'] = (string) $data[$metric];
}
}
// loop the metrics
foreach ($graphData as $metric) {
foreach ($metric['data'] as $data) {
// get the maximum value
if ((int) $data['value'] > $maxYAxis) {
$maxYAxis = (int) $data['value'];
}
}
}
$this->tpl->assign('maxYAxis', $maxYAxis);
$this->tpl->assign('tickInterval', $maxYAxis == 2 ? '1' : '');
$this->tpl->assign('lineGraphData', $graphData);
}
示例4: parse
/**
* Parse the correct messages into the template
*/
protected function parse()
{
parent::parse();
// grab the error-type from the parameters
$errorType = $this->getParameter('type');
// set correct headers
switch ($errorType) {
case 'module-not-allowed':
case 'action-not-allowed':
SpoonHTTP::setHeadersByCode(403);
break;
case 'not-found':
SpoonHTTP::setHeadersByCode(404);
break;
}
// querystring provided?
if ($this->getParameter('querystring') !== null) {
// split into file and parameters
$chunks = explode('?', $this->getParameter('querystring'));
// get extension
$extension = SpoonFile::getExtension($chunks[0]);
// if the file has an extension it is a non-existing-file
if ($extension != '' && $extension != $chunks[0]) {
// set correct headers
SpoonHTTP::setHeadersByCode(404);
// give a nice error, so we can detect which file is missing
echo 'Requested file (' . htmlspecialchars($this->getParameter('querystring')) . ') not found.';
// stop script execution
exit;
}
}
// assign the correct message into the template
$this->tpl->assign('message', BL::err(SpoonFilter::toCamelCase(htmlspecialchars($errorType), '-')));
}
示例5: loadForm
/**
* Loads the settings form
*/
private function loadForm()
{
// init settings form
$this->frm = new BackendForm('settings');
// get current settings
$this->settings = BackendSearchModel::getModuleSettings();
// add field for pagination
$this->frm->addDropdown('overview_num_items', array_combine(range(1, 30), range(1, 30)), BackendModel::getModuleSetting($this->URL->getModule(), 'overview_num_items', 20));
$this->frm->addDropdown('autocomplete_num_items', array_combine(range(1, 30), range(1, 30)), BackendModel::getModuleSetting($this->URL->getModule(), 'autocomplete_num_items', 20));
$this->frm->addDropdown('autosuggest_num_items', array_combine(range(1, 30), range(1, 30)), BackendModel::getModuleSetting($this->URL->getModule(), 'autosuggest_num_items', 20));
// modules that, no matter what, can not be searched
$disallowedModules = array('search');
// loop modules
foreach (BackendModel::getModulesForDropDown() as $module => $label) {
// check if module is searchable
if (!in_array($module, $disallowedModules) && is_callable(array('Frontend' . SpoonFilter::toCamelCase($module) . 'Model', 'search'))) {
// add field to decide wether or not this module is searchable
$this->frm->addCheckbox('search_' . $module, isset($this->settings[$module]) ? $this->settings[$module]['searchable'] == 'Y' : false);
// add field to decide weight for this module
$this->frm->addText('search_' . $module . '_weight', isset($this->settings[$module]) ? $this->settings[$module]['weight'] : 1);
// field disabled?
if (!isset($this->settings[$module]) || $this->settings[$module]['searchable'] != 'Y') {
$this->frm->getField('search_' . $module . '_weight')->setAttribute('disabled', 'disabled');
$this->frm->getField('search_' . $module . '_weight')->setAttribute('class', 'inputText disabled');
}
// add to list of modules
$this->modules[] = array('module' => $module, 'id' => $this->frm->getField('search_' . $module)->getAttribute('id'), 'label' => $label, 'chk' => $this->frm->getField('search_' . $module)->parse(), 'txt' => $this->frm->getField('search_' . $module . '_weight')->parse(), 'txtError' => '');
}
}
}
示例6: parse
/**
* Parse the correct messages into the template
*/
protected function parse()
{
parent::parse();
// grab the error-type from the parameters
$errorType = $this->getParameter('type');
// set correct headers
switch ($errorType) {
case 'module-not-allowed':
case 'action-not-allowed':
$this->statusCode = Response::HTTP_FORBIDDEN;
break;
case 'not-found':
$this->statusCode = Response::HTTP_NOT_FOUND;
break;
default:
$this->statusCode = Response::HTTP_BAD_REQUEST;
break;
}
// querystring provided?
if ($this->getParameter('querystring') !== null) {
// split into file and parameters
$chunks = explode('?', $this->getParameter('querystring'));
// get extension
$extension = pathinfo($chunks[0], PATHINFO_EXTENSION);
// if the file has an extension it is a non-existing-file
if ($extension != '' && $extension != $chunks[0]) {
// give a nice error, so we can detect which file is missing
throw new ExitException('File not found', 'Requested file (' . htmlspecialchars($this->getParameter('querystring')) . ') not found.', Response::HTTP_NOT_FOUND);
}
}
// assign the correct message into the template
$this->tpl->assign('message', BL::err(\SpoonFilter::toCamelCase(htmlspecialchars($errorType), '-')));
}
示例7: getData
/**
* Load the data, don't forget to validate the incoming data
*/
private function getData()
{
// validate incoming parameters
if ($this->URL->getParameter(1) === null) {
$this->redirect(FrontendNavigation::getURL(404));
}
// fetch record
$this->record = FrontendTagsModel::get($this->URL->getParameter(1));
// validate record
if (empty($this->record)) {
$this->redirect(FrontendNavigation::getURL(404));
}
// fetch modules
$this->modules = FrontendTagsModel::getModulesForTag($this->record['id']);
// loop modules
foreach ($this->modules as $module) {
// set module class
$class = 'Frontend' . SpoonFilter::toCamelCase($module) . 'Model';
// get the ids of the items linked to the tag
$otherIds = (array) FrontendModel::getDB()->getColumn('SELECT other_id
FROM modules_tags
WHERE module = ? AND tag_id = ?', array($module, $this->record['id']));
// set module class
$class = 'Frontend' . SpoonFilter::toCamelCase($module) . 'Model';
// get the items that are linked to the tags
$items = (array) FrontendTagsModel::callFromInterface($module, $class, 'getForTags', $otherIds);
// add into results array
if (!empty($items)) {
$this->results[] = array('name' => $module, 'label' => FL::lbl(SpoonFilter::ucfirst($module)), 'items' => $items);
}
}
}
示例8: loadDataGrid
/**
* Load the datagrid
*/
private function loadDataGrid()
{
// init var
$items = array();
// get modules
$modules = BackendModel::getModules();
// loop modules
foreach ($modules as $module) {
// build class name
$className = 'Backend\\Modules\\' . $module . '\\Engine\\Model';
if ($module == 'Core') {
$className = 'Backend\\Core\\Engine\\Model';
}
// check if the getByTag-method is available
if (is_callable(array($className, 'getByTag'))) {
// make the call and get the item
$moduleItems = (array) call_user_func(array($className, 'getByTag'), $this->id);
// loop items
foreach ($moduleItems as $row) {
// check if needed fields are available
if (isset($row['url'], $row['name'], $row['module'])) {
// add
$items[] = array('module' => \SpoonFilter::ucfirst(BL::lbl(\SpoonFilter::toCamelCase($row['module']))), 'name' => $row['name'], 'url' => $row['url']);
}
}
}
}
// create datagrid
$this->dgUsage = new BackendDataGridArray($items);
$this->dgUsage->setPaging(false);
$this->dgUsage->setColumnsHidden(array('url'));
$this->dgUsage->setHeaderLabels(array('name' => \SpoonFilter::ucfirst(BL::lbl('Title')), 'url' => ''));
$this->dgUsage->setColumnURL('name', '[url]', \SpoonFilter::ucfirst(BL::lbl('Edit')));
$this->dgUsage->addColumn('edit', null, \SpoonFilter::ucfirst(BL::lbl('Edit')), '[url]', BL::lbl('Edit'));
}
示例9: loadForm
/**
* Loads the form.
*/
private function loadForm()
{
// init var
$modules = array();
$checkedModules = SpoonSession::exists('modules') ? SpoonSession::get('modules') : array();
// loop required modules
foreach ($this->modules['required'] as $module) {
// add to the list
$modules[] = array('label' => SpoonFilter::toCamelCase($module), 'value' => $module, 'attributes' => array('disabled' => 'disabled'));
// update $_POST if needed
if (!isset($_POST['modules']) || !is_array($_POST['modules']) || !in_array($module, $_POST['modules'])) {
$_POST['modules'][] = $module;
}
}
// loop optional modules
foreach ($this->modules['optional'] as $module) {
// add to the list
$modules[] = array('label' => SpoonFilter::toCamelCase($module), 'value' => $module);
}
// add multi checkbox
$this->frm->addMultiCheckbox('modules', $modules, array_unique(array_merge($this->modules['required'], $checkedModules)));
// example data
$this->frm->addCheckbox('example_data', SpoonSession::exists('example_data') ? SpoonSession::get('example_data') : true);
// debug mode
$this->frm->addCheckbox('debug_mode', SpoonSession::exists('debug_mode') ? SpoonSession::get('debug_mode') : false);
// specific debug email address
$this->frm->addCheckbox('different_debug_email', SpoonSession::exists('different_debug_email') ? SpoonSession::get('different_debug_email') : false);
// specific debug email address text
$this->frm->addText('debug_email', SpoonSession::exists('debug_email') ? SpoonSession::get('debug_email') : '');
}
示例10: getWarnings
/**
* Get warnings for active modules
*
* @return array
*/
public static function getWarnings()
{
// init vars
$warnings = array();
$activeModules = BackendModel::getModules(true);
// add warnings
$warnings = array_merge($warnings, BackendModel::checkSettings());
// loop active modules
foreach ($activeModules as $module) {
// model class
$class = 'Backend' . SpoonFilter::toCamelCase($module) . 'Model';
// model file exists
if (SpoonFile::exists(BACKEND_MODULES_PATH . '/' . $module . '/engine/model.php')) {
// require class
require_once BACKEND_MODULES_PATH . '/' . $module . '/engine/model.php';
}
// method exists
if (is_callable(array($class, 'checkSettings'))) {
// add possible warnings
$warnings = array_merge($warnings, call_user_func(array($class, 'checkSettings')));
}
}
// return
return (array) $warnings;
}
示例11: parse
/**
* Parse into template
*
* @return void
*/
private function parse()
{
// init vars
$maxYAxis = 2;
$metrics = array('visitors', 'pageviews');
$graphData = array();
$startTimestamp = strtotime('-1 week -1 days', mktime(0, 0, 0));
$endTimestamp = mktime(0, 0, 0);
// get dashboard data
$dashboardData = BackendAnalyticsModel::getDashboardData($metrics, $startTimestamp, $endTimestamp, true);
// there are some metrics
if ($dashboardData !== false) {
// loop metrics
foreach ($metrics as $i => $metric) {
// build graph data array
$graphData[$i] = array();
$graphData[$i]['title'] = $metric;
$graphData[$i]['label'] = ucfirst(BL::lbl(SpoonFilter::toCamelCase($metric)));
$graphData[$i]['i'] = $i + 1;
$graphData[$i]['data'] = array();
// loop metrics per day
foreach ($dashboardData as $j => $data) {
// cast SimpleXMLElement to array
$data = (array) $data;
// build array
$graphData[$i]['data'][$j]['date'] = (int) $data['timestamp'];
$graphData[$i]['data'][$j]['value'] = (string) $data[$metric];
}
}
}
// loop the metrics
foreach ($graphData as $metric) {
// loop the data
foreach ($metric['data'] as $data) {
// get the maximum value
if ((int) $data['value'] > $maxYAxis) {
$maxYAxis = (int) $data['value'];
}
}
}
// parse
$this->tpl->assign('analyticsRecentVisitsStartDate', $startTimestamp);
$this->tpl->assign('analyticsRecentVisitsEndDate', $endTimestamp);
$this->tpl->assign('analyticsMaxYAxis', $maxYAxis);
$this->tpl->assign('analyticsMaxYAxis', $maxYAxis);
$this->tpl->assign('analyticsTickInterval', $maxYAxis == 2 ? '1' : '');
$this->tpl->assign('analyticsGraphData', $graphData);
}
示例12: parse
/**
* Parses the html for this filefield.
*
* @param \SpoonTemplate $template The template to parse the element in.
* @return string
*/
public function parse($template = null)
{
// get upload_max_filesize
$uploadMaxFilesize = ini_get('upload_max_filesize');
if ($uploadMaxFilesize === false) {
$uploadMaxFilesize = 0;
}
// reformat if defined as an integer
if (\SpoonFilter::isInteger($uploadMaxFilesize)) {
$uploadMaxFilesize = $uploadMaxFilesize / 1024 . 'MB';
}
// reformat if specified in kB
if (strtoupper(substr($uploadMaxFilesize, -1, 1)) == 'K') {
$uploadMaxFilesize = substr($uploadMaxFilesize, 0, -1) . 'kB';
}
// reformat if specified in MB
if (strtoupper(substr($uploadMaxFilesize, -1, 1)) == 'M') {
$uploadMaxFilesize .= 'B';
}
// reformat if specified in GB
if (strtoupper(substr($uploadMaxFilesize, -1, 1)) == 'G') {
$uploadMaxFilesize .= 'B';
}
// name is required
if ($this->attributes['name'] == '') {
throw new \SpoonFormException('A name is required for a file field. Please provide a name.');
}
// start html generation
$output = '<input type="file"';
// add attributes
$output .= $this->getAttributesHTML(array('[id]' => $this->attributes['id'], '[name]' => $this->attributes['name'])) . ' />';
// add help txt if needed
if (!$this->hideHelpTxt) {
if (isset($this->attributes['extension'])) {
$output .= '<span class="helpTxt">' . sprintf(Language::getMessage('HelpFileFieldWithMaxFileSize', 'core'), $this->attributes['extension'], $uploadMaxFilesize) . '</span>';
} else {
$output .= '<span class="helpTxt">' . sprintf(Language::getMessage('HelpMaxFileSize'), $uploadMaxFilesize) . '</span>';
}
}
// parse to template
if ($template !== null) {
$template->assign('file' . \SpoonFilter::toCamelCase($this->attributes['name']), $output);
$template->assign('file' . \SpoonFilter::toCamelCase($this->attributes['name']) . 'Error', $this->errors != '' ? '<span class="formError">' . $this->errors . '</span>' : '');
}
return $output;
}
示例13: validateForm
/**
* Validate the form.
*/
private function validateForm()
{
// is the form submitted
if ($this->frm->isSubmitted()) {
// get fields
$txtEmail = $this->frm->getField('email');
$txtPassword = $this->frm->getField('password');
$chkRemember = $this->frm->getField('remember');
// required fields
$txtEmail->isFilled(FL::getError('EmailIsRequired'));
$txtPassword->isFilled(FL::getError('PasswordIsRequired'));
// both fields filled in
if ($txtEmail->isFilled() && $txtPassword->isFilled()) {
// valid email?
if ($txtEmail->isEmail(FL::getError('EmailIsInvalid'))) {
// get the status for the given login
$loginStatus = FrontendProfilesAuthentication::getLoginStatus($txtEmail->getValue(), $txtPassword->getValue());
// valid login?
if ($loginStatus !== FrontendProfilesAuthentication::LOGIN_ACTIVE) {
// get the error string to use
$errorString = sprintf(FL::getError('Profiles' . SpoonFilter::toCamelCase($loginStatus) . 'Login'), FrontendNavigation::getURLForBlock('profiles', 'resend_activation'));
// add the error to stack
$this->frm->addError($errorString);
// add the error to the template variables
$this->tpl->assign('loginError', $errorString);
}
}
}
// valid login
if ($this->frm->isCorrect()) {
// get profile id
$profileId = FrontendProfilesModel::getIdByEmail($txtEmail->getValue());
// login
FrontendProfilesAuthentication::login($profileId, $chkRemember->getChecked());
// update salt and password for Dieter's security features
FrontendProfilesAuthentication::updatePassword($profileId, $txtPassword->getValue());
// trigger event
FrontendModel::triggerEvent('profiles', 'after_logged_in', array('id' => $profileId));
// querystring
$queryString = urldecode(SpoonFilter::getGetValue('queryString', null, SITE_URL));
// redirect
$this->redirect($queryString);
}
}
}
示例14: __construct
/**
* @param string $name Name of the form.
* @param string $action The action (URL) whereto the form will be submitted, if not provided it
* will be autogenerated.
* @param string $method The method to use when submitting the form, default is POST.
* @param bool $useToken Should we automagically add a formtoken?
* @param bool $useGlobalError Should we automagically show a global error?
*/
public function __construct($name = null, $action = null, $method = 'post', $useToken = true, $useGlobalError = true)
{
if (BackendModel::getContainer()->has('url')) {
$this->URL = BackendModel::getContainer()->get('url');
}
if (BackendModel::getContainer()->has('header')) {
$this->header = BackendModel::getContainer()->get('header');
}
$this->useGlobalError = (bool) $useGlobalError;
// build a name if there wasn't one provided
$name = $name === null ? \SpoonFilter::toCamelCase($this->URL->getModule() . '_' . $this->URL->getAction(), '_', true) : (string) $name;
// build the action if it wasn't provided
$action = $action === null ? '/' . $this->URL->getQueryString() : (string) $action;
// call the real form-class
parent::__construct($name, $action, $method, $useToken);
// add default classes
$this->setParameter('id', $name);
$this->setParameter('class', 'forkForms submitWithLink');
}
示例15: setAction
/**
* Set the action
*
* @param string $action The action to load.
* @param string $module The module to load.
*
* @throws Exception If module is not set or action is not allowed
*/
public function setAction($action, $module = null)
{
// set module
if ($module !== null) {
$this->setModule($module);
}
// check if module is set
if ($this->getModule() === null) {
throw new Exception('Module has not yet been set.');
}
// is this action allowed?
if (!Authentication::isAllowedAction($action, $this->getModule())) {
// set correct headers
header('HTTP/1.1 403 Forbidden');
// throw exception
throw new Exception('Action not allowed.');
}
// set property
$this->action = (string) \SpoonFilter::toCamelCase($action);
}