本文整理汇总了PHP中cmsModel类的典型用法代码示例。如果您正苦于以下问题:PHP cmsModel类的具体用法?PHP cmsModel怎么用?PHP cmsModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了cmsModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: run
public function run($controller_name)
{
if (!$controller_name) {
cmsCore::error404();
}
$controller_info = $this->model->getControllerInfo($controller_name);
if (!$controller_info || !$controller_info['is_external']) {
cmsCore::error404();
}
if ($controller_info['is_backend']) {
$backend_context = $this->request->isAjax() ? cmsRequest::CTX_AJAX : cmsRequest::CTX_INTERNAL;
$backend_request = new cmsRequest($this->request->getData(), $backend_context);
$backend_controller = $this->loadControllerBackend($controller_info['name'], $backend_request);
// смотрим специальный экшен
if ($backend_controller->isActionExists('delete_component')) {
$backend_controller->redirectToAction('delete_component');
}
}
// нет бэкэенда или экшена, удаляем через метод модели контроллера
// если в модели контроллера нет метода deleteController
// будет использоваться из основной модели
// который просто удалит запись в cms_controllers
if (cmsCore::isModelExists($controller_info['name'])) {
cmsCore::getModel($controller_info['name'])->deleteController($controller_info['id']);
} else {
$model = new cmsModel();
$model->deleteController($controller_info['id']);
}
cmsUser::addSessionMessage(sprintf(LANG_CP_COMPONENT_IS_DELETED, $controller_info['title']), 'success');
$this->redirectToAction('controllers');
}
开发者ID:pin-git,项目名称:icms2,代码行数:31,代码来源:controllers_delete.php
示例2: getLocationTypeValue
private function getLocationTypeValue($id, $location_type)
{
$model = new cmsModel();
$item_name = $model->getField('geo_' . $location_type, $id, 'name');
if ($item_name) {
return $item_name;
}
return null;
}
开发者ID:Val-Git,项目名称:icms2,代码行数:9,代码来源:city.php
示例3: add_perms
function add_perms($data, $type, $options = null)
{
$model = new cmsModel();
foreach ($data as $controller => $names) {
foreach ($names as $name) {
if (!$model->db->getRowsCount('perms_rules', "controller = '{$controller}' AND name = '{$name}'", 1)) {
$model->insert('perms_rules', array('controller' => $controller, 'name' => $name, 'type' => $type, 'options' => $options));
}
}
}
}
开发者ID:Val-Git,项目名称:icms2,代码行数:11,代码来源:install.php
示例4: run
public function run($id)
{
if (!$id) {
cmsCore::error404();
}
$content_model = cmsCore::getModel('content');
$ctype = $content_model->getContentType($id);
$ctype = cmsEventsManager::hook("ctype_before_delete", $ctype);
$content_model->deleteContentType($id);
cmsEventsManager::hook("ctype_after_delete", $ctype);
cmsCore::getModel('widgets')->deletePagesByName('content', "{$ctype['name']}.*");
$binded_widgets = $content_model->get('widgets_bind', function ($item, $model) {
$item['options'] = cmsModel::yamlToArray($item['options']);
return $item;
});
if ($binded_widgets) {
foreach ($binded_widgets as $widget) {
if (isset($widget['options']['ctype_id']) && $ctype['id'] == $widget['options']['ctype_id']) {
$content_model->delete('widgets_bind', $widget['id']);
}
}
}
cmsCore::getController('activity')->deleteType('content', "add.{$ctype['name']}");
$this->redirectToAction('ctypes');
}
开发者ID:asphix,项目名称:icms2,代码行数:25,代码来源:ctypes_delete.php
示例5: getPresetByName
public function getPresetByName($name)
{
return $this->getItemByField('images_presets', 'name', $name, function ($item, $model) {
$item['wm_image'] = cmsModel::yamlToArray($item['wm_image']);
return $item;
});
}
开发者ID:asphix,项目名称:icms2,代码行数:7,代码来源:model.php
示例6: store
public function store($value, $is_submitted, $old_value = null)
{
$config = cmsConfig::getInstance();
$files_model = cmsCore::getModel('files');
if ($value) {
$file = cmsModel::yamlToArray($old_value);
$path = $config->upload_path . $file['path'];
@unlink($path);
$files_model->deleteFile($file['id']);
$old_value = null;
}
$uploader = new cmsUploader();
if (!$uploader->isUploaded($this->name)) {
return $old_value;
}
$allowed_extensions = $this->getOption('extensions');
$max_size_mb = $this->getOption('max_size_mb');
if (!trim($allowed_extensions)) {
$allowed_extensions = false;
}
if (!$max_size_mb) {
$max_size_mb = 0;
}
$result = $uploader->upload($this->name, $allowed_extensions, $max_size_mb * 1048576);
if (!$result['success']) {
if (!empty($result['path'])) {
$uploader->remove($result['path']);
}
cmsUser::addSessionMessage($result['error'], 'error');
return null;
}
$file = $files_model->registerFile($result['url'], $result['name']);
return array('id' => $file['id'], 'url_key' => $file['url_key'], 'name' => $result['name'], 'size' => $result['size'], 'path' => $result['url']);
}
开发者ID:asphix,项目名称:icms2,代码行数:34,代码来源:file.php
示例7: getControllerInfo
public function getControllerInfo($controller_name)
{
return $this->getItemByField('controllers', 'name', $controller_name, function ($item) {
$item['options'] = cmsModel::yamlToArray($item['options']);
return $item;
});
}
开发者ID:rookees,项目名称:icms2,代码行数:7,代码来源:model.php
示例8: routeAction
public function routeAction($action_name)
{
if (!is_numeric($action_name)) {
return $action_name;
}
$this->lock_explicit_call = false;
$group_id = $action_name;
$group = $this->model->getGroup($group_id);
if (!$group) {
cmsCore::error404();
}
// кешируем запись для получения ее в виджетах
cmsModel::cacheResult('current_group', $group);
cmsModel::cacheResult('group_model', $this->model);
$this->current_params = $this->cms_core->uri_params;
$this->current_params[0] = $group;
$membership = $this->model->getMembership($group['id'], $this->cms_user->id);
$is_member = $membership !== false;
if ($group['is_closed'] && !$is_member && !$this->cms_user->is_admin && (empty($this->cms_core->uri_params[0]) || $this->cms_core->uri_params[0] != 'join')) {
return 'group_closed';
}
if (!$this->cms_core->uri_params) {
return 'group';
}
$action_name = $this->cms_core->uri_params[0];
$action_name = 'group_' . $action_name;
return $action_name;
}
开发者ID:Val-Git,项目名称:icms2,代码行数:28,代码来源:frontend.php
示例9: getControllerInfo
public function getControllerInfo($controller_name)
{
return $this->getItemByField('controllers', 'name', $controller_name, function ($item) {
$item['options'] = cmsModel::yamlToArray($item['options']);
$item['title'] = string_lang($item['name'] . '_CONTROLLER', $item['title']);
return $item;
});
}
开发者ID:Val-Git,项目名称:icms2,代码行数:8,代码来源:model.php
示例10: getFeedByCtypeName
public function getFeedByCtypeName($ctype_name)
{
return $this->filterEqual('ctype_name', $ctype_name)->getItem('rss_feeds', function ($item, $model) {
$item['mapping'] = cmsModel::yamlToArray($item['mapping']);
$item['image'] = cmsModel::yamlToArray($item['image']);
return $item;
});
}
开发者ID:asphix,项目名称:icms2,代码行数:8,代码来源:model.php
示例11: feed
private function feed()
{
return $this->getItem('rss_feeds', function ($item, $model) {
$item['mapping'] = cmsModel::yamlToArray($item['mapping']);
$item['image'] = cmsModel::yamlToArray($item['image']);
return $item;
});
}
开发者ID:pin-git,项目名称:icms2,代码行数:8,代码来源:model.php
示例12: getPhoto
public function getPhoto($id)
{
$this->select('u.nickname', 'user_nickname');
$this->select('u.avatar', 'user_avatar');
$this->join('{users}', 'u', 'u.id = i.user_id');
return $this->getItemById('photos', $id, function ($item, $model) {
$item['user'] = array('id' => $item['user_id'], 'nickname' => $item['user_nickname'], 'avatar' => $item['user_avatar']);
$item['image'] = cmsModel::yamlToArray($item['image']);
return $item;
});
}
开发者ID:asphix,项目名称:icms2,代码行数:11,代码来源:model.php
示例13: getInput
public function getInput($value)
{
$users_model = cmsCore::getModel('users');
$items = $this->getProperty('show_all') ? array(0 => LANG_ALL) : array();
$is_show_guests = (bool) $this->getProperty('show_guests');
$groups = $users_model->getGroups($is_show_guests);
foreach ($groups as $group) {
$items[$group['id']] = $group['title'];
}
$this->data['groups'] = $items;
if (!is_array($value)) {
$value = cmsModel::yamlToArray($value);
}
return parent::getInput($value ? $value : array(0));
}
开发者ID:Val-Git,项目名称:icms2,代码行数:15,代码来源:listgroups.php
示例14: deleteGroup
public function deleteGroup($group)
{
$this->deleteGroupMemberships($group['id']);
$this->deleteGroupInvites($group['id']);
cmsCache::getInstance()->clean('groups.list');
if ($group['logo']) {
if (!is_array($group['logo'])) {
$group['logo'] = cmsModel::yamlToArray($group['logo']);
}
$config = cmsConfig::getInstance();
foreach ($group['logo'] as $image_url) {
$image_path = $config->upload_path . $image_url;
@unlink($image_path);
}
}
return $this->delete('groups', $group['id']);
}
开发者ID:Val-Git,项目名称:icms2,代码行数:17,代码来源:model.php
示例15: run
public function run()
{
$sources['photos'] = LANG_PHOTOS;
// по каким полям поиск
$match_fields['photos'] = array('title', 'content');
// какие поля получать
$select_fields['photos'] = array('id', 'content', 'image', 'slug', 'date_pub', 'title', 'rating', 'comments', 'user_id', 'sizes', 'hits_count');
// из каких таблиц выборка
$table_names['photos'] = 'photos';
// получаем тут высоту строк, чтобы в шаблоне потом забрать
$this->getRowHeight();
return array('name' => $this->name, 'sources' => $sources, 'table_names' => $table_names, 'match_fields' => $match_fields, 'select_fields' => $select_fields, 'filters' => array('photos' => array()), 'item_callback' => function ($item, $model, $sources_name, $match_fields, $select_fields) {
$item['image'] = cmsModel::yamlToArray($item['image']);
$item['sizes'] = cmsModel::yamlToArray($item['sizes']);
$item['title'] = strip_tags($item['title']);
return $item;
});
}
开发者ID:Val-Git,项目名称:icms2,代码行数:18,代码来源:fulltext_search.php
示例16: run
public function run()
{
$ctype = cmsModel::getCachedResult('current_ctype');
$ctype_name = $this->getOption('ctype_name');
$active_cat = false;
if (!$ctype_name) {
if (!$ctype) {
return false;
}
$ctype_name = $ctype['name'];
}
if ($ctype && $ctype['name'] == $ctype_name) {
if (strpos(cmsCore::getInstance()->uri, '.html') === false) {
$current_ctype_category = cmsModel::getCachedResult('current_ctype_category');
if (!empty($current_ctype_category['id'])) {
$active_cat = $current_ctype_category;
}
} else {
$item = cmsModel::getCachedResult('current_ctype_item');
if (!$item) {
return false;
}
if (!empty($item['category'])) {
$active_cat = $item['category'];
}
}
}
$model = cmsCore::getModel('content');
$cats = $model->getCategoriesTree($ctype_name, $this->getOption('is_root'));
if (!$cats) {
return false;
}
if ($active_cat) {
$path = array_filter($cats, function ($cat) use($active_cat) {
return $cat['ns_left'] <= $active_cat['ns_left'] && $cat['ns_level'] <= $active_cat['ns_level'] && $cat['ns_right'] >= $active_cat['ns_right'] && $cat['ns_level'] > 0;
});
}
return array('ctype_name' => $ctype_name, 'cats' => $cats, 'active_cat' => $active_cat, 'path' => !empty($path) ? $path : array());
}
开发者ID:Val-Git,项目名称:icms2,代码行数:39,代码来源:widget.php
示例17: run
public function run($id)
{
$menu_model = cmsCore::getModel('menu');
$form = $this->getForm('menu', array('edit'));
$menu = $menu_model->getMenu($id);
if ($menu['is_fixed']) {
$form->removeField('basic', 'name');
}
if ($this->request->has('submit')) {
$new_menu = $form->parse($this->request, true);
$errors = $form->validate($this, $new_menu);
if (!$errors) {
$menu_model->updateMenu($id, $new_menu);
cmsUser::setCookiePublic('menu_tree_path', "{$id}.0");
// обновление виджетов меню, в которых используется это меню
if ($menu['name'] !== $new_menu['name']) {
$widgets_model = cmsCore::getModel('widgets');
$w_binds = $widgets_model->join('widgets', 'w', 'w.id = i.widget_id')->filterEqual('w.name', 'menu')->get('widgets_bind', function ($item, $model) {
$item['options'] = cmsModel::yamlToArray($item['options']);
return $item;
});
foreach ($w_binds as $w_bind) {
if (isset($w_bind['options']['menu']) && $w_bind['options']['menu'] === $menu['name']) {
$new = array('options' => $w_bind['options']);
$new['options']['menu'] = $new_menu['name'];
$widgets_model->updateWidgetBinding($w_bind['id'], $new);
}
}
}
$this->redirectToAction('menu');
}
if ($errors) {
cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
}
$menu = $new_menu;
}
return $this->cms_template->render('menu_form', array('do' => 'edit', 'item' => $menu, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
}
开发者ID:Val-Git,项目名称:icms2,代码行数:38,代码来源:menu_edit.php
示例18: saveOptions
/**
* Сохраняет опции контроллера
* @param string $controller_name
* @param array $options
* @return boolean
*/
static function saveOptions($controller_name, $options)
{
$model = new cmsModel();
$model->filterEqual('name', $controller_name);
return $model->updateFiltered('controllers', array('options' => $options));
}
开发者ID:schednyj,项目名称:icms2,代码行数:12,代码来源:controller.php
示例19: prepareValue
/**
* Подготавливает значение $value поля $field для вставки в запрос
* @param string $field
* @param string $value
* @return string
*/
public function prepareValue($field, $value)
{
// если значение поля - массив,
// то преобразуем его в YAML
if (is_array($value)) {
$value = "'" . $this->escape(cmsModel::arrayToYaml($value)) . "'";
} else {
// если это поле даты публикации и оно не установлено,
// то используем текущее время
if (strpos($field, 'date_') === 0 && $value === false) {
$value = "NULL";
} else {
if (strpos($field, 'date_') === 0 && ($value == '' || is_null($value))) {
$value = "CURRENT_TIMESTAMP";
} else {
// если это поле булево,
// то преобразуем его в число
if (is_bool($value)) {
$value = (int) $value;
} else {
// если значение поля не задано,
// то запишем в базу NULL
if ($value === '' || is_null($value)) {
$value = 'NULL';
} else {
$value = $this->escape(trim($value));
$value = "'{$value}'";
}
}
}
}
}
return $value;
}
开发者ID:Val-Git,项目名称:icms2,代码行数:40,代码来源:database.php
示例20: getInput
public function getInput($value)
{
$this->data['images'] = false;
if ($value) {
$this->data['images'] = is_array($value) ? $value : cmsModel::yamlToArray($value);
}
$this->data['sizes'] = $this->getOption('sizes');
$this->data['images_controller'] = cmsCore::getController('images');
return parent::getInput($value);
}
开发者ID:rookees,项目名称:icms2,代码行数:10,代码来源:images.php
注:本文中的cmsModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论