本文整理汇总了PHP中cmsCore类的典型用法代码示例。如果您正苦于以下问题:PHP cmsCore类的具体用法?PHP cmsCore怎么用?PHP cmsCore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了cmsCore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search_faq
function search_faq($query, $look) {
global $_LANG;
$sql = "SELECT con.*, cat.title cat_title, cat.id cat_id
FROM cms_faq_quests con
INNER JOIN cms_faq_cats cat ON cat.id = con.category_id AND cat.published = 1
WHERE MATCH(con.quest, con.answer) AGAINST ('". $query ."' IN BOOLEAN MODE) AND con.published = 1 LIMIT 100";
$result = cmsCore::c('db')->query($sql);
if (cmsCore::c('db')->num_rows($result)) {
cmsCore::loadLanguage('components/faq');
while($item = cmsCore::c('db')->fetch_assoc($result)) {
$result_array = array(
'link' => '/faq/quest'. $item['id'] .'.html',
'place' => $_LANG['FAQ'] .' → '. $item['cat_title'],
'placelink' => '/faq/'. $item['cat_id'],
'description' => cmsCore::m('search')->getProposalWithSearchWord($item['answer']),
'title' => mb_substr($item['quest'], 0, 70) .'...',
'pubdate' => $item['pubdate']
);
cmsCore::m('search')->addResult($result_array);
}
}
return;
}
示例2: run
public function run()
{
if (!$this->request->isAjax()) {
cmsCore::error404();
}
if (!$this->cms_user->is_logged) {
return $this->cms_template->renderJSON(array('error' => true));
}
if (cmsUser::isPermittedLimitHigher('comments', 'karma', $this->cms_user->karma)) {
return $this->cms_template->renderJSON(array('error' => true));
}
$target_controller = $this->request->get('tc', '');
$target_subject = $this->request->get('ts', '');
$target_id = $this->request->get('ti', 0);
$is_track = $this->request->get('is_track', 0);
if (!$target_controller || !$target_subject || !$target_id) {
return $this->cms_template->renderJSON(array('error' => true));
}
$is_valid = $this->validate_sysname($target_controller) === true && $this->validate_sysname($target_subject) === true && is_numeric($target_id) && is_numeric($is_track);
if (!$is_valid) {
return $this->cms_template->renderJSON(array('error' => true));
}
$success = $this->model->filterEqual('target_controller', $target_controller)->filterEqual('target_subject', $target_subject)->filterEqual('target_id', $target_id)->toggleTracking($is_track, $this->cms_user->id, $target_controller, $target_subject, $target_id);
return $this->cms_template->renderJSON(array('error' => !$success));
}
示例3: run
public function run($id)
{
if (!$id) {
cmsCore::error404();
}
$form = $this->getForm('preset', array('edit'));
$is_submitted = $this->request->has('submit');
$preset = $original_preset = $this->model->getPreset($id);
if ($preset['is_internal']) {
$form->removeFieldset('basic');
}
if ($is_submitted) {
$preset = $form->parse($this->request, $is_submitted);
$errors = $form->validate($this, $preset);
if (!$errors) {
$this->model->updatePreset($id, $preset);
$this->createDefaultImages(array_merge($original_preset, $preset));
$this->redirectToAction('presets');
}
if ($errors) {
cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
}
}
return cmsTemplate::getInstance()->render('backend/preset', array('do' => 'edit', 'preset' => $preset, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
}
示例4: run
public function run()
{
if (!$this->options['is_reg_invites']) {
return false;
}
if (!$this->options['is_invites']) {
return false;
}
$period = $this->options['invites_period'];
$qty = $this->options['invites_qty'];
$min_karma = $this->options['invites_min_karma'];
$min_rating = $this->options['invites_min_rating'];
$min_days = $this->options['invites_min_days'];
$users_model = cmsCore::getModel('users');
$users_model->filterIsNull('is_locked');
$users_model->filterStart()->filterDateOlder('date_invites', $period)->filterOr()->filterIsNull('date_invites')->filterEnd();
$users_model->filterGtEqual('karma', $min_karma);
$users_model->filterGtEqual('rating', $min_rating);
$users_model->filterDateOlder('date_reg', $min_days);
$users = $users_model->getUsers();
if (!$users) {
return false;
}
foreach ($users as $user) {
$this->model->addInvites($user['id'], $qty);
}
}
示例5: f_banners
function f_banners(&$text)
{
$phrase = 'БАННЕР';
if (mb_strpos($text, $phrase) === false) {
return true;
}
if (!cmsCore::getInstance()->isComponentEnable('banners')) {
return true;
}
$regex = '/{(' . $phrase . '=)\\s*(.*?)}/i';
$matches = array();
preg_match_all($regex, $text, $matches, PREG_SET_ORDER);
if (!$matches) {
return true;
}
cmsCore::loadModel('banners');
foreach ($matches as $elm) {
$elm[0] = str_replace('{', '', $elm[0]);
$elm[0] = str_replace('}', '', $elm[0]);
mb_parse_str($elm[0], $args);
$position = @$args[$phrase];
if ($position) {
$output = cms_model_banners::getBannerHTML($position);
} else {
$output = '';
}
$text = str_replace('{' . $phrase . '=' . $position . '}', $output, $text);
}
return true;
}
示例6: run
public function run($profile)
{
$user = cmsUser::getInstance();
// проверяем наличие доступа
if ($profile['id'] != $user->id && !$user->is_admin) {
cmsCore::error404();
}
$template = cmsTemplate::getInstance();
if (!$template->hasProfileThemesOptions()) {
cmsCore::error404();
}
$form = $template->getProfileOptionsForm();
// Форма отправлена?
$is_submitted = $this->request->has('submit');
$theme = $profile['theme'];
if ($is_submitted) {
// Парсим форму и получаем поля записи
$theme = array_merge($theme, $form->parse($this->request, $is_submitted, $theme));
// Проверям правильность заполнения
$errors = $form->validate($this, $theme);
if (!$errors) {
// Обновляем профиль и редиректим на его просмотр
$this->model->updateUserTheme($profile['id'], $theme);
$this->redirectTo('users', $profile['id']);
}
if ($errors) {
cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
}
}
return $template->render('profile_edit_theme', array('id' => $profile['id'], 'profile' => $profile, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
}
示例7: polls
function polls()
{
$model = new cms_model_polls();
global $_LANG;
$do = cmsCore::getInstance()->do;
//========================================================================================================================//
//========================================================================================================================//
if ($do == 'view') {
$answer = cmsCore::request('answer', 'str', '');
$poll_id = cmsCore::request('poll_id', 'int');
if (!$answer || !$poll_id) {
if (cmsCore::isAjax()) {
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['SELECT_THE_OPTION']));
} else {
cmsCore::error404();
}
}
$poll = $model->getPoll($poll_id);
if (!$poll) {
cmsCore::jsonOutput(array('error' => true, 'text' => ''));
}
if ($model->isUserVoted($poll_id)) {
cmsCore::jsonOutput(array('error' => true, 'text' => ''));
}
if (!cmsUser::checkCsrfToken()) {
cmsCore::halt();
}
$model->votePoll($poll, $answer);
cmsCore::jsonOutput(array('error' => false, 'text' => $_LANG['VOTE_ACCEPTED']));
}
}
示例8: run
public function run()
{
$new_values = $this->request->get('value', array());
$group_id = $this->request->get('group_id', 0);
if (!$new_values || !$group_id) {
cmsCore::error404();
}
$controllers = cmsPermissions::getControllersWithRules();
$owners = array();
foreach ($controllers as $controller_name) {
$controller = cmsCore::getController($controller_name);
$subjects = $controller->getPermissionsSubjects();
$rules = cmsPermissions::getRulesList($controller_name);
$values = array();
foreach ($subjects as $subject) {
$values[$subject['name']] = cmsPermissions::getPermissions($subject['name']);
}
$owners[$controller_name] = array('subjects' => $subjects, 'rules' => $rules, 'values' => $values);
}
foreach ($owners as $controller_name => $controller) {
foreach ($controller['subjects'] as $subject) {
$formatted_values = array();
foreach ($controller['rules'] as $rule) {
$value = isset($new_values[$rule['id']][$subject['name']]) ? $new_values[$rule['id']][$subject['name']] : null;
$formatted_values[$rule['id']][$group_id] = $value;
}
cmsPermissions::savePermissions($subject['name'], $formatted_values);
}
}
cmsUser::addSessionMessage(LANG_CP_PERMISSIONS_SUCCESS, 'success');
$this->redirectBack();
}
示例9: applet_filters
function applet_filters()
{
global $_LANG;
global $adminAccess;
if (!cmsUser::isAdminCan('admin/plugins', $adminAccess)) {
cpAccessDenied();
}
if (!cmsUser::isAdminCan('admin/filters', $adminAccess)) {
cpAccessDenied();
}
$GLOBALS['cp_page_title'] = $_LANG['AD_FILTERS'];
cpAddPathway($_LANG['AD_FILTERS'], 'index.php?view=filters');
$do = cmsCore::request('do', 'str', 'list');
$id = cmsCore::request('id', 'int', -1);
if ($do == 'hide') {
dbHide('cms_filters', $id);
echo '1';
exit;
}
if ($do == 'show') {
dbShow('cms_filters', $id);
echo '1';
exit;
}
if ($do == 'list') {
$fields[] = array('title' => 'id', 'field' => 'id', 'width' => '30');
$fields[] = array('title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '250');
$fields[] = array('title' => $_LANG['DESCRIPTION'], 'field' => 'description', 'width' => '');
$fields[] = array('title' => $_LANG['AD_ENABLE'], 'field' => 'published', 'width' => '100');
$actions = array();
cpListTable('cms_filters', $fields, $actions);
}
}
示例10: run
public function run()
{
$camera = urldecode($this->request->get('name', ''));
if (!$camera) {
cmsCore::error404();
}
if (cmsUser::isAllowed('albums', 'view_all')) {
$this->model->disablePrivacyFilter();
}
$this->model->filterEqual('camera', $camera);
$page = $this->request->get('photo_page', 1);
$perpage = empty($this->options['limit']) ? 16 : $this->options['limit'];
$this->model->limitPagePlus($page, $perpage);
$this->model->orderBy($this->options['ordering'], 'desc');
$photos = $this->getPhotosList();
if (!$photos) {
cmsCore::error404();
}
if ($photos && count($photos) > $perpage) {
$has_next = true;
array_pop($photos);
} else {
$has_next = false;
}
$ctype = cmsCore::getModel('content')->getContentTypeByName('albums');
$this->cms_template->render('camera', array('page_title' => sprintf(LANG_PHOTOS_CAMERA_TITLE, $camera), 'ctype' => $ctype, 'page' => $page, 'row_height' => $this->getRowHeight(), 'user' => $this->cms_user, 'item' => array('id' => 0, 'user_id' => 0, 'url_params' => array('camera' => $camera), 'base_url' => href_to('photos', 'camera-' . urlencode($camera))), 'item_type' => 'camera', 'photos' => $photos, 'is_owner' => cmsUser::isAllowed('albums', 'delete', 'all'), 'has_next' => $has_next, 'hooks_html' => cmsEventsManager::hookAll('photo_camera_html', $camera), 'preset_small' => $this->options['preset_small']));
}
示例11: applet_filters
function applet_filters() {
global $_LANG;
global $adminAccess;
if (!cmsUser::isAdminCan('admin/plugins', $adminAccess)) { cpAccessDenied(); }
if (!cmsUser::isAdminCan('admin/filters', $adminAccess)) { cpAccessDenied(); }
cmsCore::c('page')->setTitle($_LANG['AD_FILTERS']);
cpAddPathway($_LANG['AD_FILTERS'], 'index.php?view=filters');
$do = cmsCore::request('do', 'str', 'list');
$id = cmsCore::request('id', 'int', -1);
if ($do == 'hide') {
cmsCore::c('db')->setFlag('cms_filters', $id, 'published', '0');
cmsCore::halt('1');
}
if ($do == 'show') {
cmsCore::c('db')->setFlag('cms_filters', $id, 'published', '1');
cmsCore::halt('1');
}
if ($do == 'list') {
$fields = array(
array( 'title' => 'id', 'field' => 'id', 'width' => '40' ),
array( 'title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '250' ),
array( 'title' => $_LANG['DESCRIPTION'], 'field' => 'description', 'width' => '' ),
array( 'title' => $_LANG['AD_ENABLE'], 'field' => 'published', 'width' => '100' )
);
cpListTable('cms_filters', $fields, array());
}
}
示例12: run
public function run($id)
{
if (!$id) {
cmsCore::error404();
}
$users_model = cmsCore::getModel('users');
$group = $users_model->getGroup($id);
if (!$group) {
cmsCore::error404();
}
$controllers = cmsPermissions::getControllersWithRules();
$owners = array();
foreach ($controllers as $controller_name) {
$controller = cmsCore::getController($controller_name);
$subjects = $controller->getPermissionsSubjects();
$rules = cmsPermissions::getRulesList($controller_name);
$values = array();
foreach ($subjects as $subject) {
$values[$subject['name']] = cmsPermissions::getPermissions($subject['name']);
}
$owners[$controller_name] = array('subjects' => $subjects, 'rules' => $rules, 'values' => $values);
}
$template = cmsTemplate::getInstance();
$template->setMenuItems('users_group', array(array('title' => LANG_CONFIG, 'url' => href_to($this->name, 'users', array('group_edit', $id))), array('title' => LANG_PERMISSIONS, 'url' => href_to($this->name, 'users', array('group_perms', $id)))));
return $template->render('users_group_perms', array('group' => $group, 'owners' => $owners));
}
示例13: mod_pogoda_current
function mod_pogoda_current($mod, $cfg)
{
$inCore = cmsCore::getInstance();
//Загрузка настроек компонента
$component = $inCore->loadComponentConfig('pogoda');
$component["name_en"] = $component["name_en"] ? $component["name_en"] . '_' : '';
// Проверяем включен ли компонент и установлен ли city_id
if (!$component['component_enabled'] || !$component['city_id']) {
return false;
}
cmsCore::loadModel('pogoda');
$model = new cms_model_pogoda();
$model->setTable('current');
$dbWeather = $model->getWeather();
$xml = simplexml_load_string($dbWeather["xml"]);
if (!$xml) {
return true;
}
$current = array();
$current["temperature"] = round($xml->temperature["value"]) . ' °C';
$current["weather"]["value"] = $xml->weather["value"];
$current["weather"]["icon"] = $xml->weather["icon"];
cmsPage::initTemplate('modules', $cfg['tpl'])->assign('current', $current)->display($cfg['tpl']);
return true;
}
示例14: run
public function run($id = false)
{
if (!$id) {
cmsCore::error404();
}
$widgets_model = cmsCore::getModel('widgets');
cmsCore::loadAllControllersLanguages();
$page = $widgets_model->getPage($id);
if (!$page) {
cmsCore::error404();
}
$form = $this->getForm('widgets_page');
if (!$page['is_custom']) {
$form->removeField('title', 'title');
}
$is_submitted = $this->request->has('submit');
if ($is_submitted) {
$page = $form->parse($this->request, $is_submitted);
$errors = $form->validate($this, $page);
if (!$errors) {
$widgets_model->updatePage($id, $page);
$this->redirectToAction('widgets');
}
if ($errors) {
cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
}
}
return cmsTemplate::getInstance()->render('widgets_page', array('do' => 'edit', 'page' => $page, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
}
示例15: run
public function run()
{
if (!$this->request->isAjax()) {
cmsCore::error404();
}
$template = cmsTemplate::getInstance();
$entry_id = $this->request->get('id');
// Проверяем валидность
$is_valid = is_numeric($entry_id);
if (!$is_valid) {
$result = array('error' => true, 'message' => LANG_ERROR);
$template->renderJSON($result);
}
$user = cmsUser::getInstance();
$entry = $this->model->getEntry($entry_id);
$replies = $this->model->getReplies($entry_id);
if (!$replies) {
$result = array('error' => true, 'message' => LANG_ERROR);
$template->renderJSON($result);
}
$permissions = array('add' => $user->is_logged, 'delete' => $user->is_admin || $user->id == $entry['profile_id']);
$html = $template->renderInternal($this, 'entry', array('entries' => $replies, 'user' => $user, 'permissions' => $permissions));
// Формируем и возвращаем результат
$result = array('error' => false, 'html' => $html);
$template->renderJSON($result);
}