本文整理汇总了PHP中BL类的典型用法代码示例。如果您正苦于以下问题:PHP BL类的具体用法?PHP BL怎么用?PHP BL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BL类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// validate fields
$this->frm->getField('title')->isFilled(BL::err('QuestionIsRequired'));
$this->frm->getField('answer')->isFilled(BL::err('AnswerIsRequired'));
$this->frm->getField('category_id')->isFilled(BL::err('CategoryIsRequired'));
$this->meta->validate();
if ($this->frm->isCorrect()) {
// build item
$item['meta_id'] = $this->meta->save();
$item['category_id'] = $this->frm->getField('category_id')->getValue();
$item['user_id'] = BackendAuthentication::getUser()->getUserId();
$item['language'] = BL::getWorkingLanguage();
$item['question'] = $this->frm->getField('title')->getValue();
$item['answer'] = $this->frm->getField('answer')->getValue(true);
$item['created_on'] = BackendModel::getUTCDate();
$item['hidden'] = $this->frm->getField('hidden')->getValue();
$item['sequence'] = BackendFaqModel::getMaximumSequence($this->frm->getField('category_id')->getValue()) + 1;
// save the data
$item['id'] = BackendFaqModel::insert($item);
BackendTagsModel::saveTags($item['id'], $this->frm->getField('tags')->getValue(), $this->URL->getModule());
BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item));
// add search index
BackendSearchModel::saveIndex('faq', $item['id'], array('title' => $item['question'], 'text' => $item['answer']));
$this->redirect(BackendModel::createURLForAction('index') . '&report=added&var=' . urlencode($item['question']) . '&highlight=row-' . $item['id']);
}
}
}
示例2: loadDataGrid
/**
* Loads the datagrid with the groups
*
* @return void
*/
private function loadDataGrid()
{
// create datagrid
$this->dataGrid = new BackendDataGridDB(BackendMailmotorModel::QRY_DATAGRID_BROWSE_GROUPS);
$this->dataGrid->setColumnsHidden(array('language', 'is_default'));
// sorting columns
$this->dataGrid->setSortingColumns(array('name', 'created_on'), 'created_on');
$this->dataGrid->setSortParameter('desc');
// set colum URLs
$this->dataGrid->setColumnURL('name', BackendModel::createURLForAction('addresses') . '&group_id=[id]');
// set the datagrid ID so we don't run into trouble with multiple datagrids that use mass actions
$this->dataGrid->setAttributes(array('id' => 'dgGroups'));
// add the multicheckbox column
$this->dataGrid->setMassActionCheckboxes('checkbox', '[id]', BackendMailmotorModel::getDefaultGroupIds());
$this->dataGrid->setColumnsSequence('checkbox', 'name', 'created_on', 'language');
// add mass action dropdown
$ddmMassAction = new SpoonFormDropdown('action', array('delete' => BL::lbl('Delete')), 'delete');
$this->dataGrid->setMassAction($ddmMassAction);
// set column functions
$this->dataGrid->setColumnFunction(array('BackendDataGridFunctions', 'getTimeAgo'), array('[created_on]'), 'created_on', true);
// add delete column
$this->dataGrid->addColumnAction('custom_fields', null, BL::lbl('CustomFields'), BackendModel::createURLForAction('custom_fields') . '&group_id=[id]', BL::lbl('CustomFields'), array('class' => 'button icon iconEdit linkButton'));
$this->dataGrid->addColumnAction('export', null, BL::lbl('Export'), BackendModel::createURLForAction('export_addresses') . '&id=[id]', BL::lbl('Export'), array('class' => 'button icon iconExport linkButton'));
$this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit_group') . '&id=[id]', BL::lbl('Edit'));
// add styles
$this->dataGrid->setColumnAttributes('name', array('class' => 'title'));
// set paging limit
$this->dataGrid->setPagingLimit(self::PAGING_LIMIT);
}
示例3: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// validate fields
$this->frm->getField('author')->isFilled(BL::err('AuthorIsRequired'));
$this->frm->getField('email')->isEmail(BL::err('EmailIsInvalid'));
$this->frm->getField('text')->isFilled(BL::err('FieldIsRequired'));
if ($this->frm->getField('website')->isFilled()) {
$this->frm->getField('website')->isURL(BL::err('InvalidURL'));
}
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item['id'] = $this->id;
$item['status'] = $this->record['status'];
$item['author'] = $this->frm->getField('author')->getValue();
$item['email'] = $this->frm->getField('email')->getValue();
$item['website'] = $this->frm->getField('website')->isFilled() ? $this->frm->getField('website')->getValue() : null;
$item['text'] = $this->frm->getField('text')->getValue();
// insert the item
BackendBlogModel::updateComment($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_edit_comment', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('comments') . '&report=edited-comment&id=' . $item['id'] . '&highlight=row-' . $item['id'] . '#tab' . SpoonFilter::toCamelCase($item['status']));
}
}
}
示例4: validateForm
/**
* Validate the form
*
* @return void
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// set callback for generating an unique URL
$this->meta->setURLCallback('BackendBlogModel', 'getURLForCategory');
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// validate fields
$this->frm->getField('title')->isFilled(BL::err('TitleIsRequired'));
// validate meta
$this->meta->validate();
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item['title'] = $this->frm->getField('title')->getValue();
$item['language'] = BL::getWorkingLanguage();
$item['meta_id'] = $this->meta->save();
// insert the item
$item['id'] = BackendBlogModel::insertCategory($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_category', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('categories') . '&report=added-category&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']);
}
}
}
示例5: execute
/**
* Execute the action
*
* @return void
*/
public function execute()
{
// get parameters
$this->id = $this->getParameter('id', 'int');
// does the item exist
if ($this->id !== null && BackendPagesModel::existsTemplate($this->id)) {
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// init var
$success = false;
// get template (we need the title)
$item = BackendPagesModel::getTemplate($this->id);
// valid template?
if (!empty($item)) {
// delete the page
$success = BackendPagesModel::deleteTemplate($this->id);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_delete_template', array('id' => $this->id));
// build cache
BackendPagesModel::buildCache(BL::getWorkingLanguage());
}
// page is deleted, so redirect to the overview
if ($success) {
$this->redirect(BackendModel::createURLForAction('templates') . '&theme=' . $item['theme'] . '&report=deleted-template&var=' . urlencode($item['label']));
} else {
$this->redirect(BackendModel::createURLForAction('templates') . '&error=non-existing');
}
} else {
$this->redirect(BackendModel::createURLForAction('templates') . '&error=non-existing');
}
}
示例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':
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), '-')));
}
示例7: validateForm
/**
* Validate the form.
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// get field
$txtName = $this->frm->getField('name');
// name filled in?
if ($txtName->isFilled(BL::getError('NameIsRequired'))) {
// name exists?
if (BackendProfilesModel::existsGroupName($txtName->getValue())) {
// set error
$txtName->addError(BL::getError('GroupNameExists'));
}
}
// no errors?
if ($this->frm->isCorrect()) {
// build item
$values['name'] = $txtName->getValue();
// insert values
$id = BackendProfilesModel::insertGroup($values);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_group', array('item' => $values));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('groups') . '&report=group-added&var=' . urlencode($values['name']) . '&highlight=row-' . $id);
}
}
}
示例8: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// get parameters
$mailingId = SpoonFilter::getPostValue('mailing_id', null, '', 'int');
$sendOnDate = SpoonFilter::getPostValue('send_on_date', null, BackendModel::getUTCDate('d/m/Y'));
$sendOnTime = SpoonFilter::getPostValue('send_on_time', null, BackendModel::getUTCDate('H:i'));
$messageDate = $sendOnDate;
// validate mailing ID
if ($mailingId == '') {
$this->output(self::BAD_REQUEST, null, 'Provide a valid mailing ID');
}
if ($sendOnDate == '' || $sendOnTime == '') {
$this->output(self::BAD_REQUEST, null, 'Provide a valid send date date provided');
}
// record is empty
if (!BackendMailmotorModel::existsMailing($mailingId)) {
$this->output(self::BAD_REQUEST, null, BL::err('MailingDoesNotExist', 'mailmotor'));
}
// reverse the date and make it a proper
$explodedDate = explode('/', $sendOnDate);
$sendOnDate = $explodedDate[2] . '-' . $explodedDate[1] . '-' . $explodedDate[0];
// calc full send timestamp
$sendTimestamp = strtotime($sendOnDate . ' ' . $sendOnTime);
// build data
$item['id'] = $mailingId;
$item['send_on'] = BackendModel::getUTCDate('Y-m-d H:i:s', $sendTimestamp);
$item['edited_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
// update mailing
BackendMailmotorModel::updateMailing($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_edit_mailing_step4', array('item' => $item));
// output
$this->output(self::OK, array('mailing_id' => $mailingId, 'timestamp' => $sendTimestamp), sprintf(BL::msg('SendOn', $this->getModule()), $messageDate, $sendOnTime));
}
示例9: execute
/**
* Execute the action
*
* @return void
*/
public function execute()
{
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// get parameters
$id = SpoonFilter::getPostValue('id', null, '', 'int');
$name = trim(SpoonFilter::getPostValue('value', null, '', 'string'));
// validate
if ($name == '') {
$this->output(self::BAD_REQUEST, null, 'no name provided');
}
// get existing id
$existingId = BackendMailmotorModel::getCampaignId($name);
// existing campaign
if ($existingId !== 0 && $id !== $existingId) {
$this->output(self::ERROR, array('id' => $existingId, 'error' => true), BL::err('CampaignExists', $this->getModule()));
}
// build array
$item = array();
$item['id'] = $id;
$item['name'] = $name;
$item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
// get page
$rows = BackendMailmotorModel::updateCampaign($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'edited_campaign', array('item' => $item));
// output
if ($rows !== 0) {
$this->output(self::OK, array('id' => $id), BL::msg('CampaignEdited', $this->getModule()));
} else {
$this->output(self::ERROR, null, BL::err('CampaignNotEdited', $this->getModule()));
}
}
示例10: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// validate fields
$this->frm->getField('title')->isFilled(BL::err('TitleIsRequired'));
if ($this->frm->isCorrect()) {
// build item
$item['id'] = BackendContentBlocksModel::getMaximumId() + 1;
$item['user_id'] = BackendAuthentication::getUser()->getUserId();
$item['template'] = count($this->templates) > 1 ? $this->frm->getField('template')->getValue() : $this->templates[0];
$item['language'] = BL::getWorkingLanguage();
$item['title'] = $this->frm->getField('title')->getValue();
$item['text'] = $this->frm->getField('text')->getValue();
$item['hidden'] = $this->frm->getField('hidden')->getValue() ? 'N' : 'Y';
$item['status'] = 'active';
$item['created_on'] = BackendModel::getUTCDate();
$item['edited_on'] = BackendModel::getUTCDate();
// insert the item
$item['revision_id'] = BackendContentBlocksModel::insert($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('index') . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']);
}
}
}
示例11: loadDataGrids
/**
* Load the datagrids
*
* @return void
*/
private function loadDataGrids()
{
// load all categories
$categories = BackendFaqModel::getCategories();
// run over categories and create datagrid for each one
foreach ($categories as $category) {
// create datagrid
$dataGrid = new BackendDataGridDB(BackendFaqModel::QRY_DATAGRID_BROWSE, array(BL::getWorkingLanguage(), $category['id']));
// set attributes
$dataGrid->setAttributes(array('class' => 'dataGrid sequenceByDragAndDrop'));
// disable paging
$dataGrid->setPaging(false);
// set colum URLs
$dataGrid->setColumnURL('question', BackendModel::createURLForAction('edit') . '&id=[id]');
// set colums hidden
$dataGrid->setColumnsHidden(array('category_id', 'sequence'));
// add edit column
$dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]', BL::lbl('Edit'));
// add a column for the handle, so users have something to hold while draging
$dataGrid->addColumn('dragAndDropHandle', null, '<span>' . BL::lbl('Move') . '</span>');
// make sure the column with the handler is the first one
$dataGrid->setColumnsSequence('dragAndDropHandle');
// add a class on the handler column, so JS knows this is just a handler
$dataGrid->setColumnAttributes('dragAndDropHandle', array('class' => 'dragAndDropHandle'));
// our JS needs to know an id, so we can send the new order
$dataGrid->setRowAttributes(array('id' => '[id]'));
// add datagrid to list
$this->dataGrids[] = array('id' => $category['id'], 'name' => $category['name'], 'content' => $dataGrid->getContent());
}
}
示例12: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// redefine fields
$fileFile = $this->frm->getField('file');
$chkOverwrite = $this->frm->getField('overwrite');
// name checks
if ($fileFile->isFilled(BL::err('FieldIsRequired'))) {
// only xml files allowed
if ($fileFile->isAllowedExtension(array('xml'), sprintf(BL::getError('ExtensionNotAllowed'), 'xml'))) {
// load xml
$xml = @simplexml_load_file($fileFile->getTempFileName());
// invalid xml
if ($xml === false) {
$fileFile->addError(BL::getError('InvalidXML'));
}
}
}
if ($this->frm->isCorrect()) {
// import
$statistics = BackendLocaleModel::importXML($xml, $chkOverwrite->getValue());
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_import', array('statistics' => $statistics));
// everything is imported, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('index') . '&report=imported&var=' . ($statistics['imported'] . '/' . $statistics['total']) . $this->filterQuery);
}
}
}
示例13: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// get parameters
$categoryTitle = trim(SpoonFilter::getPostValue('value', null, '', 'string'));
// validate
if ($categoryTitle === '') {
$this->output(self::BAD_REQUEST, null, BL::err('TitleIsRequired'));
}
// get the data
// build array
$item['title'] = SpoonFilter::htmlspecialchars($categoryTitle);
$item['language'] = BL::getWorkingLanguage();
$meta['keywords'] = $item['title'];
$meta['keywords_overwrite'] = 'N';
$meta['description'] = $item['title'];
$meta['description_overwrite'] = 'N';
$meta['title'] = $item['title'];
$meta['title_overwrite'] = 'N';
$meta['url'] = BackendBlogModel::getURLForCategory(SpoonFilter::urlise($item['title']));
// update
$item['id'] = BackendBlogModel::insertCategory($item, $meta);
// output
$this->output(self::OK, $item, vsprintf(BL::msg('AddedCategory'), array($item['title'])));
}
示例14: validateForm
/**
* Validate the form
*
* @return void
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// validate field
$this->frm->getField('synonym')->isFilled(BL::err('SynonymIsRequired'));
$this->frm->getField('term')->isFilled(BL::err('TermIsRequired'));
if (BackendSearchModel::existsSynonymByTerm($this->frm->getField('term')->getValue())) {
$this->frm->getField('term')->addError(BL::err('TermExists'));
}
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item = array();
$item['term'] = $this->frm->getField('term')->getValue();
$item['synonym'] = $this->frm->getField('synonym')->getValue();
$item['language'] = BL::getWorkingLanguage();
// insert the item
$id = BackendSearchModel::insertSynonym($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_synonym', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('synonyms') . '&report=added-synonym&var=' . urlencode($item['term']) . '&highlight=row-' . $id);
}
}
}
示例15: validateForm
private function validateForm()
{
if ($this->form->isSubmitted()) {
$fields = $this->form->getFields();
if (!$fields['start_date']->isFilled(Language::err('FieldIsRequired')) || !$fields['end_date']->isFilled(Language::err('FieldIsRequired'))) {
return;
}
if (!$fields['start_date']->isValid(Language::err('DateIsInvalid')) || !$fields['end_date']->isValid(Language::err('DateIsInvalid'))) {
return;
}
$newStartDate = Model::getUTCTimestamp($fields['start_date']);
$newEndDate = Model::getUTCTimestamp($fields['end_date']);
// startdate cannot be before 2005 (earliest valid google startdate)
if ($newStartDate < mktime(0, 0, 0, 1, 1, 2005)) {
$fields['start_date']->setError(BL::err('DateRangeIsInvalid'));
}
// enddate cannot be in the future
if ($newEndDate > time()) {
$fields['start_date']->setError(BL::err('DateRangeIsInvalid'));
}
// enddate cannot be before the startdate
if ($newStartDate > $newEndDate) {
$fields['start_date']->setError(BL::err('DateRangeIsInvalid'));
}
if ($this->form->isCorrect()) {
$this->startDate = $newStartDate;
$this->endDate = $newEndDate;
}
}
}