本文整理匯總了PHP中Backend\Core\Engine\Model::get方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model::get方法的具體用法?PHP Model::get怎麽用?PHP Model::get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Backend\Core\Engine\Model
的用法示例。
在下文中一共展示了Model::get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getUrl
/**
* Retrieve the unique URL for an teamMember
*
* @param string $url
* @param int $id The id of the teamMember to ignore.
* @return string
*/
public static function getUrl($url, $id = null)
{
$url = CommonUri::getUrl((string) $url);
$database = BackendModel::get('database');
if ($id === null) {
$urlExists = (bool) $database->getVar('SELECT 1
FROM team_members AS i
INNER JOIN meta AS m
ON i.meta_id = m.id
WHERE i.language = ? AND m.url = ?
LIMIT 1', [Language::getWorkingLanguage(), $url]);
} else {
$urlExists = (bool) $database->getVar('SELECT 1
FROM team_members AS i
INNER JOIN meta AS m
ON i.meta_id = m.id
WHERE i.language = ? AND m.url = ? AND i.id != ?
LIMIT 1', [Language::getWorkingLanguage(), $url, $id]);
}
if ($urlExists) {
$url = Model::addNumber($url);
return self::getUrl($url, $id);
}
return $url;
}
示例2: loadForm
/**
* Loads the settings form
*/
private function loadForm()
{
// init settings form
$this->frm = new BackendForm('settings');
$settings = BackendModel::get('fork.settings')->getForModule('Agenda');
$this->frm->addText('width1', $settings['width1']);
$this->frm->addText('height1', $settings['height1']);
$this->frm->addCheckbox('allow_enlargment1', $settings['allow_enlargment1']);
$this->frm->addCheckbox('force_aspect_ratio1', $settings['force_aspect_ratio1']);
$this->frm->addText('width1', $settings['width2']);
$this->frm->addText('height1', $settings['height2']);
$this->frm->addCheckbox('allow_enlargment2', $settings['allow_enlargment2']);
$this->frm->addCheckbox('force_aspect_ratio2', $settings['force_aspect_ratio2']);
$this->frm->addText('width3', $settings['width3']);
$this->frm->addText('height3', $settings['height3']);
$this->frm->addCheckbox('allow_enlargment3', $settings['allow_enlargment3']);
$this->frm->addCheckbox('force_aspect_ratio3', $settings['force_aspect_ratio3']);
$this->frm->addCheckbox('allow_subscriptions', $settings['allow_subscriptions']);
$this->frm->addCheckbox('moderation', $settings['moderation']);
$this->frm->addCheckbox('notify_by_email_on_new_subscription_to_moderate', $settings['notify_by_email_on_new_subscription_to_moderate']);
$this->frm->addCheckbox('notify_by_email_on_new_subscription', $settings['notify_by_email_on_new_subscription']);
$this->frm->addText('cache_timeout', $settings['cache_timeout']);
$this->frm->addDropdown('zoom_level', array_combine(array_merge(array('auto'), range(3, 18)), array_merge(array(BL::lbl('Auto', $this->getModule())), range(3, 18))), $this->get('fork.settings')->get($this->URL->getModule(), 'zoom_level_widget', 13));
$this->frm->addText('width', $this->get('fork.settings')->get($this->URL->getModule(), 'width'));
$this->frm->addText('height', $this->get('fork.settings')->get($this->URL->getModule(), 'height'));
$this->frm->addDropdown('map_type', array('ROADMAP' => BL::lbl('Roadmap', $this->getModule()), 'SATELLITE' => BL::lbl('Satellite', $this->getModule()), 'HYBRID' => BL::lbl('Hybrid', $this->getModule()), 'TERRAIN' => BL::lbl('Terrain', $this->getModule())), $this->get('fork.settings')->get($this->URL->getModule(), 'map_type_widget', 'roadmap'));
}
示例3: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// validate fields
$this->meta->validate();
if ($this->frm->isCorrect()) {
// build item
$item['language'] = BL::getWorkingLanguage();
$item['meta_id'] = $this->meta->save();
$item['sequence'] = BackendCatalogModel::getMaximumSpecificationSequence() + 1;
// save the data
$item['id'] = BackendCatalogModel::insertSpecification($item);
//--Add the languages
foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) {
$itemLanguage = array();
$itemLanguage['id'] = $item['id'];
$itemLanguage['language'] = $language;
$itemLanguage['title'] = $this->frm->getField('title_' . $language)->getValue();
BackendCatalogModel::insertSpecificationLanguage($itemLanguage);
}
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_specification', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('specifications') . '&report=added-specification&var=' . urlencode($this->frm->getField('title_nl')->getValue()) . '&highlight=row-' . $item['id']);
}
}
}
示例4: __construct
/**
* @param string $query The query to retrieve the data.
* @param array $parameters The parameters to be used inside the query.
* @param string $resultsQuery The optional count query, used to calculate the number of results.
* @param array $resultsParameters The parameters to be used inside the results query.
*/
public function __construct($query, $parameters = array(), $resultsQuery = null, $resultsParameters = array())
{
// results query?
$results = $resultsQuery !== null ? array($resultsQuery, $resultsParameters) : null;
// create a new source-object
$source = new \SpoonDatagridSourceDB(BackendModel::get('database'), array($query, (array) $parameters), $results);
parent::__construct($source);
}
示例5: execute
/**
* Execute the action
*/
public function execute()
{
// only one category allowed, so we redirect
if (!BackendModel::get('fork.settings')->getForModule('Agenda', 'allow_multiple_categories', true)) {
$this->redirect(BackendModel::createURLForAction('categories') . '&error=only-one-category-allowed');
}
parent::execute();
$this->loadForm();
$this->validateForm();
$this->parse();
$this->display();
}
示例6: configureOptions
public function configureOptions(OptionsResolver $optionsResolver)
{
$optionsResolver->setDefaults(['attr' => ['class' => 'inputEditor']]);
if (!Model::has('header')) {
return;
}
// add the needed javascript to the header;
$header = Model::get('header');
// we add JS because we need CKEditor
$header->addJS('ckeditor/ckeditor.js', 'Core', false);
$header->addJS('ckeditor/adapters/jquery.js', 'Core', false);
$header->addJS('ckfinder/ckfinder.js', 'Core', false);
// add the internal link lists-file
if (is_file(FRONTEND_CACHE_PATH . '/Navigation/editor_link_list_' . Language::getWorkingLanguage() . '.js')) {
$timestamp = @filemtime(FRONTEND_CACHE_PATH . '/Navigation/editor_link_list_' . Language::getWorkingLanguage() . '.js');
$header->addJS('/src/Frontend/Cache/Navigation/editor_link_list_' . Language::getWorkingLanguage() . '.js?m=' . $timestamp, null, false, true, false);
}
}
示例7: install
/**
* Install the module
*/
public function install()
{
// add the schema of the entity to the database
Model::get('fork.entity.create_schema')->forEntityClass(ContentBlock::class);
// add 'content_blocks' as a module
$this->addModule('ContentBlocks');
// import locale
$this->importLocale(__DIR__ . '/Data/locale.xml');
// general settings
$this->setSetting($this->getModule(), 'max_num_revisions', 20);
// module rights
$this->setModuleRights(1, $this->getModule());
// action rights
$this->setActionRights(1, $this->getModule(), 'Add');
$this->setActionRights(1, $this->getModule(), 'Delete');
$this->setActionRights(1, $this->getModule(), 'Edit');
$this->setActionRights(1, $this->getModule(), 'Index');
// set navigation
$navigationModulesId = $this->setNavigation(null, 'Modules');
$this->setNavigation($navigationModulesId, $this->getModule(), 'content_blocks/index', ['content_blocks/add', 'content_blocks/edit']);
}
示例8: mailEndUser
/**
* @param $email
* @param $postedFields
* @param $form
* @param $dataId
*/
public static function mailEndUser($email, $postedFields, $form, $dataId)
{
$field_info = '';
foreach ($postedFields as $field) {
$label = isset($field['label']) ? $field['label'] : '';
$value = isset($field['value']) ? unserialize($field['value']) : '';
$field_info .= $label . ': ' . $value . "\n";
}
$title = sprintf(BL::getLabel('Subject', self::MODULE_NAME), $form['name']);
$data = array('title' => $title, 'fields' => $field_info);
$translations = array('ReceivedData', 'Greetings');
foreach ($translations as $translation) {
$data[$translation] = BL::getLabel($translation, self::MODULE_NAME);
}
/** @var $mailer Mailer */
$mailer = BackendModel::get('mailer');
if ($mailer) {
// @TODO remove this when https://github.com/forkcms/forkcms/issues/716 is fixed.
define('FRONTEND_LANGUAGE', SITE_DEFAULT_LANGUAGE);
// work around
$result = $mailer->addEmail($title, BACKEND_MODULES_PATH . '/' . self::MODULE_NAME . '/Layout/Templates/Mails/Notification.tpl', $data, $email);
}
$useLog = BackendModel::getModuleSetting(self::MODULE_NAME, 'log', true);
if ($useLog) {
$logger = BackendModel::get('logger');
if ($logger) {
$logger->notice(sprintf('Sending email to %s, status %s', $email, $result ? 'OK' : 'FAILED'), $data);
}
}
$addExtraData = BackendModel::getModuleSetting(self::MODULE_NAME, 'add_data', true);
$error = BL::getLabel('Error', self::MODULE_NAME);
$success = BL::getLabel('OK', self::MODULE_NAME);
if ($addExtraData) {
$label = BL::getLabel('DataLabel', self::MODULE_NAME);
$item = array('data_id' => $dataId, 'label' => $label, 'value' => serialize($email . ' - ' . ($result ? $success : $error)));
/** @var $db SpoonDatabase */
$db = BackendModel::getContainer()->get('database');
$db->insert('forms_data_fields', $item);
}
}
示例9: loadDataGrid
/**
* Loads the dataGrid
*/
private function loadDataGrid()
{
// are multiple categories allowed?
$this->multipleCategoriesAllowed = BackendModel::get('fork.settings')->getForModule('Agenda', 'allow_multiple_categories', true);
// create dataGrid
$this->dataGrid = new BackendDataGridDB(BackendAgendaModel::QRY_DATAGRID_BROWSE_CATEGORIES, BL::getWorkingLanguage());
$this->dataGrid->setHeaderLabels(array('num_items' => ucfirst(BL::lbl('Amount'))));
if ($this->multipleCategoriesAllowed) {
$this->dataGrid->enableSequenceByDragAndDrop();
} else {
$this->dataGrid->setColumnsHidden(array('sequence'));
}
$this->dataGrid->setRowAttributes(array('id' => '[id]'));
$this->dataGrid->setPaging(false);
// check if this action is allowed
if (BackendAuthentication::isAllowedAction('Index')) {
$this->dataGrid->setColumnFunction(array(__CLASS__, 'setClickableCount'), array('[num_items]', BackendModel::createURLForAction('index') . '&category=[id]'), 'num_items', true);
}
// check if this action is allowed
if (BackendAuthentication::isAllowedAction('EditCategory')) {
$this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('edit_category') . '&id=[id]');
$this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit_category') . '&id=[id]', BL::lbl('Edit'));
}
}
示例10: getAllFolders
/**
* Fetches all selected folders
*
* @return array Selected folders and their path
*/
public static function getAllFolders()
{
return (array) BackendModel::get('database')->getRecords('SELECT i.id, i.title, i.path, UNIX_TIMESTAMP(i.created_on) AS created_on
FROM compression_folders AS i');
}
示例11: deleteLink
/**
* Delete a certain link to mediaitem
*
* @param int $id
*/
public static function deleteLink($id)
{
BackendModel::get('database')->delete("media_modules", "id=?", array($id));
}
示例12: linkMediaToModule
public function linkMediaToModule($media_id)
{
$exists = (bool) BackendModel::get('database')->getVar('SELECT 1
FROM media_modules AS i
WHERE i.module = ? AND other_id = ? AND type = ? AND i.media_id = ?
LIMIT 1', array((int) $this->module, $this->id, $this->type, $media_id));
if (!$exists) {
if ($this->module != "" && $this->id > 0) {
//--Calculate sequence
$sequence = (int) BackendModel::getContainer()->get('database')->getVar('SELECT MAX(i.sequence)
FROM media_modules AS i
WHERE i.module = ? AND other_id = ? AND type = ?', array((int) $this->module, $this->id, $this->type));
$sequence += 1;
$insert = array();
$insert["media_id"] = $media_id;
$insert["module"] = $this->module;
$insert["other_id"] = $this->id;
$insert["type"] = $this->type;
$insert["identifier"] = 0;
$insert["sequence"] = $sequence;
$insert["language"] = BackendLanguage::getWorkingLanguage();
$insert["title"] = "";
$insert["linktype"] = 0;
//--Add record to db
return BackendModel::getContainer()->get('database')->insert("media_modules", $insert);
}
}
return false;
}
示例13: array
ATTENTION: The trailing slash is required.
*/
$baseDir = $kernel->getContainer()->getParameter('site.path_www') . $baseUrl;
/*
* ### Advanced Settings
*/
/*
Thumbnails : thumbnails settings. All thumbnails will end up in the same
directory, no matter the resource type.
*/
$config['Thumbnails'] = array('url' => $baseUrl . '_thumbs', 'directory' => $baseDir . '_thumbs', 'enabled' => true, 'directAccess' => true, 'maxWidth' => 96, 'maxHeight' => 96, 'bmpSupported' => false, 'quality' => 100);
/*
Set the maximum size of uploaded images. If an uploaded image is larger, it
gets scaled down proportionally. Set to 0 to disable this feature.
*/
$config['Images'] = array('maxWidth' => BackendModel::get('fork.settings')->get('Core', 'ckfinder_image_max_width'), 'maxHeight' => BackendModel::get('fork.settings')->get('Core', 'ckfinder_image_max_height'), 'quality' => 100);
/*
RoleSessionVar : the session variable name that CKFinder must use to retrieve
the "role" of the current user. The "role", can be used in the "AccessControl"
settings (bellow in this page).
To be able to use this feature, you must initialize the session data by
uncommenting the following "session_start()" call.
*/
$config['RoleSessionVar'] = 'CKFinder_UserRole';
//session_start();
/*
AccessControl : used to restrict access or features to specific folders.
Many "AccessControl" entries can be added. All attributes are optional.
Subfolders inherit their default settings from their parents' definitions.
示例14: logout
/**
* Logout the current user
*/
public static function logout()
{
// remove all rows owned by the current user
BackendModel::get('database')->delete('users_sessions', 'session_id = ?', \SpoonSession::getSessionId());
// reset values. We can't destroy the session because session-data can be used on the site.
\SpoonSession::set('backend_logged_in', false);
\SpoonSession::set('backend_secret_key', '');
\SpoonSession::set('csrf_token', '');
}
示例15: getAccessToken
/**
* Get the access token from the settings
*
* @return String Access token
*/
private static function getAccessToken()
{
return BackendModel::get('fork.settings')->get('Instagram', 'access_token');
}