当前位置: 首页>>代码示例>>PHP>>正文


PHP cmsEventsManager::hookAll方法代码示例

本文整理汇总了PHP中cmsEventsManager::hookAll方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsEventsManager::hookAll方法的具体用法?PHP cmsEventsManager::hookAll怎么用?PHP cmsEventsManager::hookAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cmsEventsManager的用法示例。


在下文中一共展示了cmsEventsManager::hookAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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']));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:27,代码来源:camera.php

示例2: run

 public function run()
 {
     $form = $this->getForm('options');
     if (!$form) {
         cmsCore::error404();
     }
     $is_submitted = $this->request->has('submit');
     $options = cmsController::loadOptions($this->name);
     $source_controllers = cmsEventsManager::hookAll('sitemap_sources');
     if (is_array($source_controllers)) {
         foreach ($source_controllers as $controller) {
             foreach ($controller['sources'] as $id => $title) {
                 $form->addField('sources', new fieldCheckbox("sources:{$controller['name']}|{$id}", array('title' => $title)));
             }
         }
     }
     if ($is_submitted) {
         $options = $form->parse($this->request, $is_submitted);
         $errors = $form->validate($this, $options);
         if (!$errors) {
             cmsUser::addSessionMessage(LANG_CP_SAVE_SUCCESS, 'success');
             cmsController::saveOptions($this->name, $options);
             $this->redirectToAction('options');
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return cmsTemplate::getInstance()->render('backend/options', array('options' => $options, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:pin-git,项目名称:icms2,代码行数:30,代码来源:options.php

示例3: getWidget

 public function getWidget()
 {
     $comment_systems = cmsEventsManager::hookAll('comment_systems', $this, array());
     if (empty($this->options['disable_icms_comments']) || !$comment_systems) {
         array_unshift($comment_systems, $this->getNativeComments());
     }
     return $this->cms_template->renderInternal($this, 'tab_list', array('comment_systems' => $comment_systems));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:8,代码来源:frontend.php

示例4: run

 public function run()
 {
     //
     // формируем виджеты главной админки
     //
     // Виджет статистики
     $chart_nav = cmsEventsManager::hookAll('admin_dashboard_chart');
     $cookie = cmsUser::getCookie('dashboard_chart');
     $defaults = array('controller' => 'users', 'section' => 'reg', 'period' => 7);
     if ($cookie) {
         $cookie = json_decode($cookie, true);
         if (is_array($cookie)) {
             $defaults = array('controller' => $cookie['c'], 'section' => $cookie['s'], 'period' => $cookie['p']);
         }
     }
     $dashboard_blocks[] = array('title' => LANG_CP_DASHBOARD_STATS, 'class' => 'col3', 'html' => $this->cms_template->getRenderedChild('index_chart', array('chart_nav' => $chart_nav, 'defaults' => $defaults)));
     $uploader = new cmsUploader();
     $extensions = get_loaded_extensions();
     $sysinfo = array(LANG_CP_DASHBOARD_SI_PHP => phpversion(), LANG_CP_DASHBOARD_SI_ML => files_format_bytes(files_convert_bytes(@ini_get('memory_limit'))), LANG_CP_DASHBOARD_SI_MAX => $uploader->getMaxUploadSize(), LANG_CP_DASHBOARD_SI_IP => filter_input(INPUT_SERVER, 'SERVER_ADDR'), LANG_CP_DASHBOARD_SI_ROOT => ROOT, LANG_CP_DASHBOARD_SI_SESSION => session_save_path(), LANG_CP_DASHBOARD_SI_ION => in_array('ionCube Loader', $extensions), LANG_CP_DASHBOARD_SI_ZEND => in_array('Zend Optimizer', $extensions), LANG_CP_DASHBOARD_SI_ZENDG => in_array('Zend Guard Loader', $extensions));
     $dashboard_blocks[] = array('title' => LANG_CP_DASHBOARD_SYSINFO, 'html' => $this->cms_template->getRenderedChild('index_sysinfo', array('sysinfo' => $sysinfo)));
     $dashboard_blocks[] = array('title' => LANG_CP_DASHBOARD_RESOURCES, 'html' => $this->cms_template->getRenderedChild('index_resources', array()));
     $dashboard_blocks = array_merge($dashboard_blocks, cmsEventsManager::hookAll('admin_dashboard_block', false, array()));
     $_block_id = 0;
     foreach ($dashboard_blocks as $dashboard_block) {
         // в одном хуке можно создавать несколько виджетов админки
         // для этого хук должен вернуть массив виджетов
         if (!isset($dashboard_block['title'])) {
             foreach ($dashboard_block as $sub_dashboard_block) {
                 $sub_dashboard_block['id'] = $_block_id;
                 $result_dashboard_blocks[$_block_id] = $sub_dashboard_block;
                 $_block_id++;
             }
         } else {
             $dashboard_block['id'] = $_block_id;
             $result_dashboard_blocks[$_block_id] = $dashboard_block;
         }
         $_block_id++;
     }
     // формируем с учетом порядка
     if (!empty($this->options['dashboard_order'])) {
         $order_id = 1000;
         foreach ($result_dashboard_blocks as $block_id => $block) {
             if (isset($this->options['dashboard_order'][$block_id])) {
                 $order_id = $this->options['dashboard_order'][$block_id];
             } else {
                 $order_id += 1;
             }
             $_result_dashboard_blocks[$order_id] = $block;
         }
         ksort($_result_dashboard_blocks);
     } else {
         $_result_dashboard_blocks = $result_dashboard_blocks;
     }
     return $this->cms_template->render('index', array('dashboard_blocks' => $_result_dashboard_blocks));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:55,代码来源:index.php

示例5: init

 public function init()
 {
     return array(array('type' => 'fieldset', 'title' => LANG_SEARCH_IN_CTYPES, 'childs' => array(new fieldList('types', array('is_multiple' => true, 'generator' => function () {
         $search_controllers = cmsEventsManager::hookAll('fulltext_search');
         $items = array();
         foreach ($search_controllers as $controller) {
             $items = array_merge($items, $controller['sources']);
         }
         return $items;
     })), new fieldCheckbox('is_hash_tag', array('title' => LANG_SEARCH_IS_HASH_TAG)))), array('type' => 'fieldset', 'title' => LANG_SEARCH_PERPAGE, 'childs' => array(new fieldNumber('perpage', array('default' => 15, 'rules' => array(array('required')))))));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:11,代码来源:form_options.php

示例6: run

 public function run()
 {
     $chart_nav = cmsEventsManager::hookAll('admin_dashboard_chart');
     $uploader = new cmsUploader();
     $extensions = get_loaded_extensions();
     $sysinfo = array(LANG_CP_DASHBOARD_SI_PHP => phpversion(), LANG_CP_DASHBOARD_SI_ML => files_format_bytes(files_convert_bytes(@ini_get('memory_limit'))), LANG_CP_DASHBOARD_SI_MAX => $uploader->getMaxUploadSize(), LANG_CP_DASHBOARD_SI_IP => filter_input(INPUT_SERVER, 'SERVER_ADDR'), LANG_CP_DASHBOARD_SI_ROOT => ROOT, LANG_CP_DASHBOARD_SI_ION => in_array('ionCube Loader', $extensions), LANG_CP_DASHBOARD_SI_ZEND => in_array('Zend Optimizer', $extensions), LANG_CP_DASHBOARD_SI_ZENDG => in_array('Zend Guard Loader', $extensions));
     $cookie = cmsUser::getCookie('dashboard_chart');
     $defaults = array('controller' => 'users', 'section' => 'reg', 'period' => 7);
     if ($cookie) {
         $cookie = json_decode($cookie, true);
         if (is_array($cookie)) {
             $defaults = array('controller' => $cookie['c'], 'section' => $cookie['s'], 'period' => $cookie['p']);
         }
     }
     return cmsTemplate::getInstance()->render('index', array('dashboard_blocks' => cmsEventsManager::hookAll('admin_dashboard_block'), 'chart_nav' => $chart_nav, 'sysinfo' => $sysinfo, 'defaults' => $defaults));
 }
开发者ID:mafru,项目名称:icms2,代码行数:16,代码来源:index.php

示例7: run

 public function run($profile)
 {
     $user = cmsUser::getInstance();
     $template = cmsTemplate::getInstance();
     // проверяем наличие доступа
     if ($profile['id'] != $user->id && !$user->is_admin) {
         cmsCore::error404();
     }
     $pricacy_types = cmsEventsManager::hookAll('user_privacy_types');
     $form = new cmsForm();
     $fieldset_id = $form->addFieldset();
     $default_options = array('', 'anyone', 'friends');
     foreach ($pricacy_types as $list) {
         foreach ($list as $name => $type) {
             $options = array();
             if (!isset($type['options'])) {
                 $type['options'] = $default_options;
             }
             foreach ($type['options'] as $option) {
                 if (!$option) {
                     $options[''] = LANG_USERS_PRIVACY_FOR_NOBODY;
                 } else {
                     $options[$option] = constant('LANG_USERS_PRIVACY_FOR_' . mb_strtoupper($option));
                 }
             }
             $form->addField($fieldset_id, new fieldList($name, array('title' => $type['title'], 'default' => 'anyone', 'items' => $options)));
         }
     }
     // Форма отправлена?
     $is_submitted = $this->request->has('submit');
     $options = $this->model->getUserPrivacyOptions($profile['id']);
     if ($is_submitted) {
         // Парсим форму и получаем поля записи
         $options = array_merge($options, $form->parse($this->request, $is_submitted, $options));
         // Проверям правильность заполнения
         $errors = $form->validate($this, $options);
         if (!$errors) {
             // Обновляем профиль и редиректим на его просмотр
             $this->model->updateUserPrivacyOptions($profile['id'], $options);
             $this->redirectTo('users', $profile['id']);
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return $template->render('profile_edit_privacy', array('id' => $profile['id'], 'profile' => $profile, 'options' => $options, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:asphix,项目名称:icms2,代码行数:47,代码来源:profile_edit_privacy.php

示例8: run

 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     $id = $this->request->get('id');
     $section = $this->request->get('section');
     $period = $this->request->get('period');
     if (!$id || !$section || !is_numeric($period)) {
         cmsCore::error404();
     }
     $chart_nav = cmsEventsManager::hookAll('admin_dashboard_chart');
     $source = array();
     foreach ($chart_nav as $ctrl) {
         if ($ctrl['id'] == $id && isset($ctrl['sections'][$section])) {
             $source = $ctrl['sections'][$section];
         }
     }
     if (!$source) {
         cmsCore::error404();
     }
     $data = $this->getData($source, $period);
     $data_formatted = array();
     $result = array();
     if ($period < 300) {
         foreach ($data as $item) {
             $data_formatted[date('d.m', strtotime($item['date']))] = intval($item['count']);
         }
         for ($d = 0; $d <= $period; $d++) {
             $date = date('d.m', strtotime("-{$d} days"));
             $result[$date] = isset($data_formatted[$date]) ? $data_formatted[$date] : 0;
         }
     } else {
         foreach ($data as $item) {
             $data_formatted[date('m.Y', strtotime($item['date']))] = intval($item['count']);
         }
         for ($m = 0; $m <= 12; $m++) {
             $date = date('m.Y', strtotime("-{$m} months"));
             $result[$date] = isset($data_formatted[$date]) ? $data_formatted[$date] : 0;
         }
     }
     $result = array_reverse($result);
     cmsTemplate::getInstance()->renderJSON(array('labels' => array_keys($result), 'values' => array_values($result)));
 }
开发者ID:Alex-HAV,项目名称:icms2,代码行数:44,代码来源:index_chart_data.php

示例9:

            ?>
                        <?php 
        }
        ?>
                    <?php 
    }
    ?>
                </tbody>
            </table>
        </div>
    <?php 
}
?>

    <?php 
$hooks_html = cmsEventsManager::hookAll("content_{$ctype['name']}_item_html", $item);
if ($hooks_html) {
    echo html_each($hooks_html);
}
?>

    <?php 
$is_tags = $ctype['is_tags'] && !empty($ctype['options']['is_tags_in_item']) && $item['tags'];
?>

    <?php 
if ($is_tags) {
    ?>
        <div class="tags_bar">
            <?php 
    echo html_tags_bar($item['tags']);
开发者ID:dgolovanev,项目名称:icms2,代码行数:31,代码来源:default_item.tpl.php

示例10: run


//.........这里部分代码省略.........
     $photo = $this->model->getPhoto($slug);
     if (!$photo) {
         cmsCore::error404();
     }
     $album = $this->model->getAlbum($photo['album_id']);
     if (!$album) {
         cmsCore::error404();
     }
     $ctype = $album['ctype'];
     unset($album['ctype']);
     list($photo, $album, $ctype) = cmsEventsManager::hook('photos_before_item', array($photo, $album, $ctype));
     // Проверяем прохождение модерации
     $is_moderator = false;
     if (!$album['is_approved']) {
         $is_moderator = $this->cms_user->is_admin || cmsCore::getModel('content')->userIsContentTypeModerator($ctype['name'], $this->cms_user->id);
         if (!$is_moderator && $this->cms_user->id != $album['user_id']) {
             cmsCore::error404();
         }
     }
     // Проверяем приватность альбома
     if ($album['is_private'] == 1) {
         // доступ только друзьям
         $is_friend = $this->cms_user->isFriend($album['user_id']);
         $is_can_view_private = cmsUser::isAllowed($ctype['name'], 'view_all');
         if (!$is_friend && !$is_can_view_private && !$is_moderator) {
             // если в настройках указано скрывать, 404
             if (empty($ctype['options']['privacy_type']) || $ctype['options']['privacy_type'] == 'hide') {
                 cmsCore::error404();
             }
             // иначе пишем, к кому в друзья нужно проситься
             cmsUser::addSessionMessage(sprintf(LANG_CONTENT_PRIVATE_FRIEND_INFO, !empty($ctype['labels']['one']) ? $ctype['labels']['one'] : LANG_PAGE, href_to('users', $album['user_id']), htmlspecialchars($album['user']['nickname'])), 'info');
             $this->redirect(href_to($ctype['name']));
         }
     }
     // Проверяем приватность фото
     if ($photo['is_private'] == 1) {
         // доступ только друзьям
         $is_friend = $this->cms_user->isFriend($photo['user_id']);
         $is_can_view_private = cmsUser::isAllowed($ctype['name'], 'view_all');
         if (!$is_friend && !$is_can_view_private && !$is_moderator) {
             // иначе пишем, к кому в друзья нужно проситься
             cmsUser::addSessionMessage(sprintf(LANG_CONTENT_PRIVATE_FRIEND_INFO, LANG_PHOTOS_WP_ITEM, href_to('users', $photo['user_id']), htmlspecialchars($photo['user']['nickname'])), 'info');
             $this->redirect(href_to($ctype['name'], $album['slug'] . '.html'));
         }
     }
     // Проверяем ограничения доступа из других контроллеров
     if ($album['is_parent_hidden']) {
         $is_parent_viewable_result = cmsEventsManager::hook('content_view_hidden', array('viewable' => true, 'item' => $album, 'is_moderator' => $is_moderator));
         if (!$is_parent_viewable_result['viewable']) {
             if (isset($is_parent_viewable_result['access_text'])) {
                 cmsUser::addSessionMessage($is_parent_viewable_result['access_text'], 'error');
                 if (isset($is_parent_viewable_result['access_redirect_url'])) {
                     $this->redirect($is_parent_viewable_result['access_redirect_url']);
                 } else {
                     $this->redirect(href_to($ctype['name']));
                 }
             }
             cmsUser::goLogin();
         }
     }
     if ($this->cms_user->id != $photo['user_id']) {
         $this->model->incrementCounter($photo['id']);
     }
     // Рейтинг
     if ($ctype['is_rating'] && $this->isControllerEnabled('rating')) {
         $rating_controller = cmsCore::getController('rating', new cmsRequest(array('target_controller' => $this->name, 'target_subject' => $ctype['name']), cmsRequest::CTX_INTERNAL));
         $is_rating_allowed = cmsUser::isAllowed($ctype['name'], 'rate') && $photo['user_id'] != $this->cms_user->id;
         $photo['rating_widget'] = $rating_controller->getWidget($photo['id'], $photo['rating'], $is_rating_allowed);
     }
     // Комментарии
     if ($ctype['is_comments'] && $this->isControllerEnabled('comments')) {
         $comments_controller = cmsCore::getController('comments', new cmsRequest(array('target_controller' => $this->name, 'target_subject' => 'photo', 'target_id' => $photo['id']), cmsRequest::CTX_INTERNAL));
         $photo['comments_widget'] = $comments_controller->getWidget();
     }
     $is_can_edit = cmsUser::isAllowed($ctype['name'], 'edit', 'all') || cmsUser::isAllowed($ctype['name'], 'edit', 'own') && $album['user_id'] == $this->cms_user->id || $photo['user_id'] == $this->cms_user->id;
     $is_can_delete = cmsUser::isAllowed($ctype['name'], 'delete', 'all') || cmsUser::isAllowed($ctype['name'], 'delete', 'own') && $album['user_id'] == $this->cms_user->id || $photo['user_id'] == $this->cms_user->id;
     $downloads = $this->getDownloadImages($photo);
     $available_downloads = array_filter($downloads, function ($item) {
         return !empty($item['link']);
     });
     $full_size_img_preset = '';
     if ($available_downloads) {
         $download_photo_sizes = array();
         foreach ($available_downloads as $preset => $data) {
             $download_photo_sizes[$preset] = $photo['sizes'][$preset];
         }
         $full_size_img_preset = $this->getMaxSizePresetName($download_photo_sizes);
     }
     $next_photo = $this->model->filterEqual('album_id', $photo['album_id'])->getNextPhoto($photo, $this->options['ordering']);
     $prev_photo = $this->model->filterEqual('album_id', $photo['album_id'])->getPrevPhoto($photo, $this->options['ordering']);
     $tpl = 'view';
     $preset = $this->getBigPreset($photo['sizes']);
     if ($this->request->isAjax()) {
         $tpl = 'view_photo_container';
         if ($full_size_img_preset) {
             $preset = $full_size_img_preset;
         }
     }
     return $this->cms_template->render($tpl, array('next_photo' => $next_photo, 'prev_photo' => $prev_photo, 'downloads' => $downloads, 'is_can_edit' => $is_can_edit, 'is_can_delete' => $is_can_delete, 'user' => $this->cms_user, 'preset' => $preset, 'preset_small' => !empty($this->options['preset_related']) ? $this->options['preset_related'] : $this->options['preset_small'], 'photo' => $photo, 'photos' => $this->getRelatedPhoto($photo), 'related_title' => $this->related_title, 'album' => $album, 'ctype' => $ctype, 'photo_details' => $this->buildPhotoDetails($photo, $album, $ctype), 'hooks_html' => cmsEventsManager::hookAll('photos_item_html', $photo), 'full_size_img' => $full_size_img_preset ? $available_downloads[$full_size_img_preset]['image'] : ''));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:101,代码来源:view.php

示例11: empty

                });

        </script>
    <?php 
}
?>

    <?php 
if (!empty($attributes['hook'])) {
    ?>

        <?php 
    $param = empty($attributes['hook']['param']) ? false : $attributes['hook']['param'];
    ?>
        <?php 
    $hooks_html = cmsEventsManager::hookAll($attributes['hook']['event'], $param);
    ?>
        <?php 
    if ($hooks_html) {
        echo html_each($hooks_html);
    }
    ?>

    <?php 
}
?>

    <?php 
echo $append_html;
?>
开发者ID:asphix,项目名称:icms2,代码行数:30,代码来源:form.tpl.php

示例12: search

 public function search($query, $type, $date, $ctype_name, $page = 1)
 {
     $user = cmsUser::getInstance();
     $content_model = cmsCore::getModel('content');
     $ctypes = $content_model->getContentTypes();
     $results = array();
     if (!$this->model->setQuery($query)) {
         cmsUser::addSessionMessage(LANG_SEARCH_TOO_SHORT, 'error');
         return false;
     }
     $this->model->setSearchType($type);
     $this->model->setDateInterval($date);
     $this->model->limitPage($page, $this->options['perpage']);
     $is_results_found = false;
     $allowed_ctypes = $this->options['ctypes'];
     foreach ($ctypes as $ctype) {
         if (!in_array($ctype['name'], $allowed_ctypes)) {
             continue;
         }
         $result = array();
         $sql_fields = array();
         $default_fields = $this->default_sql_fields;
         $fields = $content_model->getContentFields($ctype['name']);
         foreach ($fields as $field) {
             // индексы создаются только на поля типа caption, text, html
             // в настройках полей должно быть включено их участие в индексе
             $is_text = in_array($field['type'], array('caption', 'text', 'html')) && $field['handler']->getOption('in_fulltext_search');
             if ($is_text && !$field['is_private'] && (!$field['groups_read'] || $user->isInGroups($field['groups_read']))) {
                 $sql_fields[] = $field['name'];
             }
             if ($field['name'] == 'photo' && !$field['is_private'] && (!$field['groups_read'] || $user->isInGroups($field['groups_read']))) {
                 $default_fields[] = $field['name'];
             }
         }
         // если нет полей для поиска, пропускаем
         if (!$sql_fields) {
             continue;
         }
         $table_name = $content_model->getContentTypeTableName($ctype['name']);
         $results_count = $this->model->getSearchResultsCount($table_name, $sql_fields);
         if ($results_count) {
             if ($ctype_name == $ctype['name'] || !$ctype_name && !$is_results_found) {
                 $result = $this->model->getSearchResults($table_name, $sql_fields, $default_fields, function ($item, $model) use($ctype) {
                     if (!empty($item['photo'])) {
                         $item['photo'] = html_image($item['photo'], 'small', $item['title']);
                         if (!$item['photo']) {
                             unset($item['photo']);
                         }
                     }
                     $item['url'] = href_to($ctype['name'], $item['slug'] . '.html');
                     return $item;
                 });
                 $result = cmsEventsManager::hook("content_{$ctype['name']}_search_list", $result);
                 $is_results_found = true;
             }
             $results[] = array('title' => $ctype['title'], 'name' => $ctype['name'], 'items' => $result, 'count' => $results_count);
         }
     }
     // результаты от других контроллеров
     $components_results = cmsEventsManager::hookAll('fulltext_search', array($this->model, $ctype_name));
     if ($components_results) {
         foreach ($components_results as $components_result) {
             $results[] = $components_result;
         }
     }
     return $results;
 }
开发者ID:pin-git,项目名称:icms2,代码行数:67,代码来源:index.php

示例13: run

 public function run($profile, $do = false)
 {
     if (!cmsUser::isLogged()) {
         cmsCore::error404();
     }
     $user = cmsUser::getInstance();
     // если нужно, передаем управление другому экшену
     if ($do) {
         $this->runAction('profile_edit_' . $do, array($profile) + array_slice($this->params, 2));
         return;
     }
     // проверяем наличие доступа
     if ($profile['id'] != $user->id && !$user->is_admin) {
         cmsCore::error404();
     }
     // Получаем поля
     $content_model = cmsCore::getModel('content');
     $content_model->setTablePrefix('');
     $content_model->orderBy('ordering');
     $fields = $content_model->getContentFields('{users}');
     // Строим форму
     $form = new cmsForm();
     // Разбиваем поля по группам
     $fieldsets = cmsForm::mapFieldsToFieldsets($fields, function ($field, $user) {
         // проверяем что группа пользователя имеет доступ к редактированию этого поля
         if ($field['groups_edit'] && !$user->isInGroups($field['groups_edit'])) {
             return false;
         }
         return true;
     });
     // Добавляем поля в форму
     foreach ($fieldsets as $fieldset) {
         $fieldset_id = $form->addFieldset($fieldset['title']);
         foreach ($fieldset['fields'] as $field) {
             // добавляем поле в форму
             $form->addField($fieldset_id, $field['handler']);
         }
     }
     // Добавляем поле выбора часового пояса
     $config = cmsConfig::getInstance();
     $fieldset_id = $form->addFieldset(LANG_TIME_ZONE);
     $form->addField($fieldset_id, new fieldList('time_zone', array('default' => $config->time_zone, 'generator' => function ($item) {
         return cmsCore::getTimeZones();
     })));
     // Форма отправлена?
     $is_submitted = $this->request->has('submit');
     if ($is_submitted) {
         // Парсим форму и получаем поля записи
         $new = $form->parse($this->request, $is_submitted, $profile);
         $old = $profile;
         $profile = array_merge($profile, $new);
         // Проверям правильность заполнения
         $errors = $form->validate($this, $profile);
         if (!$errors) {
             $is_allowed = cmsEventsManager::hookAll('user_profile_update', $profile, true);
             if ($is_allowed !== true && in_array(false, $is_allowed)) {
                 $errors = true;
             }
         }
         if (!$errors) {
             // Обновляем профиль и редиректим на его просмотр
             $this->model->updateUser($profile['id'], $profile);
             // Отдельно обновляем часовой пояс в сессии
             cmsUser::sessionSet('user_data:time_zone', $profile['time_zone']);
             // Постим уведомление о смене аватара в ленту
             if (!$this->model->isAvatarsEqual($new['avatar'], $old['avatar'])) {
                 $activity_controller = cmsCore::getController('activity');
                 $activity_controller->deleteEntry($this->name, "avatar", $profile['id']);
                 if (!empty($new['avatar'])) {
                     $activity_controller->addEntry($this->name, "avatar", array('user_id' => $profile['id'], 'subject_title' => $profile['nickname'], 'subject_id' => $profile['id'], 'subject_url' => href_to('users', $profile['id']), 'is_private' => 0, 'group_id' => null, 'images' => array(array('url' => href_to('users', $profile['id']), 'src' => html_image_src($new['avatar'], 'normal'))), 'images_count' => 1));
                 }
             }
             $this->redirectTo('users', $profile['id']);
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return cmsTemplate::getInstance()->render('profile_edit', array('do' => 'edit', 'id' => $profile['id'], 'profile' => $profile, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:dgolovanev,项目名称:icms2,代码行数:80,代码来源:profile_edit.php

示例14: array

</a>
                    <?php 
        }
        ?>
                </li>
            <?php 
    }
    ?>
        </ul>
    </div>
<?php 
}
?>

<div id="user_content_list">
    <?php 
echo $html;
?>
</div>

<?php 
$hooks_html = cmsEventsManager::hookAll("content_{$ctype['name']}_items_html", array('user_view', $ctype, $profile, !empty($current_folder) ? $current_folder : array()));
if ($hooks_html) {
    ?>
    <div class="sub_items_list">
        <?php 
    echo html_each($hooks_html);
    ?>
    </div>
<?php 
}
开发者ID:Val-Git,项目名称:icms2,代码行数:31,代码来源:profile_content.tpl.php

示例15: run

 public function run($target = false)
 {
     $query = $this->request->get('q', '');
     $type = $this->request->get('type', 'words');
     $date = $this->request->get('date', 'all');
     $page = $this->request->get('page', 1);
     if (!in_array($type, array('words', 'exact'), true)) {
         cmsCore::error404();
     }
     if (!in_array($date, array('all', 'w', 'm', 'y'), true)) {
         cmsCore::error404();
     }
     if (!is_numeric($page)) {
         cmsCore::error404();
     }
     if ($this->request->has('q')) {
         if (!$query || !$this->model->setQuery($query)) {
             cmsUser::addSessionMessage(LANG_SEARCH_TOO_SHORT, 'error');
             $this->redirectToAction('');
         }
         $this->model->setSearchType($type);
         $this->model->setDateInterval($date);
         $this->model->limitPage($page, $this->options['perpage']);
         $search_controllers = cmsEventsManager::hookAll('fulltext_search', false, array());
         if (!$target) {
             $page_url = href_to($this->name);
         } else {
             $page_url = href_to($this->name, 'index', $target);
         }
         // найден ли результат
         $is_results_found = false;
         foreach ($search_controllers as $search_controller) {
             $search_controller = cmsEventsManager::hook("search_{$search_controller['name']}_data", $search_controller);
             foreach ($search_controller['sources'] as $sources_name => $sources_title) {
                 // выключено?
                 if (!empty($this->options['types']) && !in_array($sources_name, $this->options['types'])) {
                     continue;
                 }
                 // есть поля для поиска?
                 if (empty($search_controller['match_fields'][$sources_name])) {
                     continue;
                 }
                 // есть ли что-то по поисковому запросу у этого назначения?
                 $results_count = $this->model->getSearchResultsCount($search_controller['table_names'][$sources_name], $search_controller['match_fields'][$sources_name], $search_controller['filters'][$sources_name]);
                 // сами результаты ищем только у первого найденного
                 // или у переданного
                 // для остальных считаем количество
                 if ($results_count) {
                     $result = array();
                     if (!$is_results_found && ($target && $target == $sources_name || !$target)) {
                         $result = $this->model->getSearchResults($search_controller['table_names'][$sources_name], $search_controller['match_fields'][$sources_name], $search_controller['select_fields'][$sources_name], $search_controller['filters'][$sources_name], $search_controller['item_callback'], $sources_name);
                         $result = cmsEventsManager::hook("content_{$sources_name}_search_list", $result);
                         $is_results_found = true;
                         $target = $sources_name;
                         $target_title = $sources_title;
                     }
                     $results[] = array('title' => $sources_title, 'name' => $sources_name, 'items' => $result, 'count' => $results_count);
                 }
             }
         }
     }
     // если есть отдельный шаблон, используем его
     $tpl = 'index_' . $target;
     if (!$this->cms_template->getTemplateFileName('controllers/search/' . $tpl, true)) {
         $tpl = 'index';
     }
     return $this->cms_template->render($tpl, array('user' => $this->cms_user, 'query' => $query, 'type' => $type, 'date' => $date, 'target' => $target, 'target_title' => !empty($target_title) ? mb_strtolower($target_title) : '', 'page' => $page, 'perpage' => $this->options['perpage'], 'results' => isset($results) ? $results : false, 'page_url' => isset($page_url) ? $page_url : false));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:68,代码来源:index.php


注:本文中的cmsEventsManager::hookAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。