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


PHP Plugins::intercept方法代码示例

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


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

示例1: smile

 /**
  * @param string $str
  * @return string 
  *
  * smiles process 
  */
 public function smile($str)
 {
     $str = Plugins::intercept('before_smiles_parse', $str);
     $Register = Register::getInstance();
     $path = $Register['Config']->read('smiles_set');
     $path = ROOT . '/sys/img/smiles/' . (!empty($path) ? $path : 'fapos') . '/info.php';
     include $path;
     $from = array();
     $to = array();
     if (isset($smilesList) && is_array($smilesList)) {
         foreach ($smilesList as $smile) {
             $from[] = $smile['from'];
             $to[] = '<img alt="' . $smile['from'] . '" title="' . $smile['from'] . '" src="' . WWW_ROOT . '/sys/img/smiles/fapos/' . $smile['to'] . '" />';
         }
     }
     $str = str_replace($from, $to, $str);
     return $str;
 }
开发者ID:VictorSproot,项目名称:AtomXCMS-2,代码行数:24,代码来源:printtext.class.php

示例2: _view

 /**
  * @param string $content  data for parse and view
  * @access   protected
  */
 protected function _view($content)
 {
     $Register = Register::getInstance();
     if (!empty($this->template) && $this->wrap == true) {
         Plugins::intercept('before_parse_layout', $this);
         $this->View->setLayout($this->template);
         $markers = $this->getGlobalMarkers(file_get_contents($this->View->getTemplateFilePath('main.html')));
         $markers['content'] = $content;
         // Cache global markers
         if ($this->cached) {
             if ($this->Cache->check($this->cacheKey . '_global_markers')) {
                 $gdata = $this->Cache->read($this->cacheKey . '_global_markers');
                 $this->globalMarkers = array_merge($this->globalMarkers, unserialize($gdata));
             } else {
                 $gdata = serialize($this->globalMarkers);
                 $this->Cache->write($gdata, $this->cacheKey . '_global_markers', $this->cacheTags);
             }
         }
         $boot_time = round(getMicroTime() - $Register['fps_boot_start_time'], 4);
         $markers = array_merge($markers, array('boot_time' => $boot_time));
         $output = $this->render('main.html', $markers);
     } else {
         $output = $content;
     }
     $this->_afterRender();
     echo $output;
     if (Config::read('debug_mode') == 1) {
         echo AtmDebug::getBody();
     }
     die;
 }
开发者ID:VictorSproot,项目名称:AtomXCMS-2,代码行数:35,代码来源:module.class.php

示例3: add

 public function add()
 {
     //turn access
     $this->ACL->turn(array('foto', 'add_materials'));
     // Обрезаем переменные до длины, указанной в параметре maxlength тега input
     $title = trim(mb_substr($_POST['title'], 0, 128));
     $description = trim($_POST['main_text']);
     $in_cat = intval($_POST['cats_selector']);
     // Check fields
     $errors = $this->Register['Validate']->check($this->Register['action']);
     //categories list
     $className = $this->Register['ModManager']->getModelNameFromModule($this->module . 'Categories');
     $catModel = new $className();
     $sql = $catModel->getCollection(array('id' => $in_cat));
     if (empty($sql)) {
         $errors[] = __('Can not find category');
     }
     // errors
     if (!empty($errors)) {
         $data = array('title' => null, 'description' => $description, 'in_cat' => $in_cat);
         $data = array_merge($data, $_POST);
         $data['errors'] = $errors;
         $_SESSION['FpsForm'] = $data;
         redirect('/foto/add_form/');
     }
     // spam protected
     if (isset($_SESSION['unix_last_post']) and time() - $_SESSION['unix_last_post'] < 10) {
         return $this->showInfoMessage(__('Your message has been added'), '/foto/');
     }
     // Формируем SQL-запрос на добавление темы
     $description = mb_substr($description, 0, Config::read('description_lenght', 'foto'));
     $res = array('title' => $title, 'description' => $description, 'date' => new Expr('NOW()'), 'author_id' => $_SESSION['user']['id'], 'category_id' => $in_cat, 'filename' => '');
     try {
         $entity = new FotoEntity($res);
         $id = $entity->save();
         if (!$id) {
             throw new Exception('ERROR: SAVE_ERR');
         }
         $filename = $this->__saveFile($_FILES['foto'], $id);
         if (!$filename) {
             throw new Exception('ERROR: FILE_UPL');
         }
         $entity->setFilename($filename)->save();
     } catch (Exception $e) {
         $entity->delete();
         $data = array('title' => null, 'description' => null, 'in_cat' => $in_cat);
         $data = array_merge($data, $_POST);
         $data['errors'] = array(__('Some error occurred'));
         $_SESSION['FpsForm'] = $data;
         redirect('/foto/add_form/');
     }
     // hook for plugins
     Plugins::intercept('new_entity', array('entity' => $entity, 'module' => $this->module));
     //clean cache
     $this->Cache->clean(CACHE_MATCHING_TAG, array('module_foto'));
     $this->DB->cleanSqlCache();
     if ($this->Log) {
         $this->Log->write('adding foto', 'foto id(' . $id . ')');
     }
     return $this->showInfoMessage(__('Material successfully added'), '/foto/');
 }
开发者ID:VictorSproot,项目名称:AtomXCMS-2,代码行数:61,代码来源:index.php

示例4: getTemplateName

/**
* Get correct name of template for current user
*/
function getTemplateName()
{
    $template = Config::read('template');
    $template = Plugins::intercept('select_template', $template);
    return $template;
}
开发者ID:VictorSproot,项目名称:AtomXCMS-2,代码行数:9,代码来源:helpers.lib.php

示例5: view

 /**
  * @param null|int $id
  */
 public function view($id = null)
 {
     //turn access
     $this->ACL->turn(array($this->module, 'view_product'));
     $id = intval($id);
     if (empty($id) || $id < 1) {
         redirect('/');
     }
     $where = array("(quantity > 0 || hide_not_exists = '0')");
     $where['id'] = $id;
     $this->Model->bindModel('attributes_group');
     $this->Model->bindModel('attributes.content');
     $this->Model->bindModel('vendor');
     $this->Model->bindModel('category');
     $this->Model->bindModel('author');
     $this->Model->bindModel('attaches');
     $entity = $this->Model->getFirst($where);
     if (empty($entity)) {
         redirect('/error.php?ac=404');
     }
     if ($entity->getAvailable() == 0 && !$this->ACL->turn(array('other', 'can_see_hidden'), false)) {
         return $this->showInfoMessage(__('Permission denied'), '/' . $this->module . '/');
     }
     if (!$this->ACL->checkCategoryAccess($entity->getCategory()->getNo_access())) {
         return $this->showInfoMessage(__('Permission denied'), '/' . $this->module . '/');
     }
     Plugins::intercept('view_category', $entity->getCategory());
     // category block
     $this->_getCatsTree($entity->getCategory()->getId());
     // Comments && add comment form
     if (Config::read('comment_active', $this->module) == 1 && $this->ACL->turn(array($this->module, 'view_comments'), false) && $entity->getCommented() == 1) {
         if ($this->ACL->turn(array($this->module, 'add_comments'), false)) {
             $this->comments_form = $this->_add_comment_form($id);
         }
         $this->comments = $this->_get_comments($entity);
     }
     $tags = $entity->getTags();
     if (!empty($tags)) {
         $this->addToPageMetaContext('tags', h($tags));
     }
     $this->addToPageMetaContext('entity_title', h($entity->getTitle()));
     $this->addToPageMetaContext('category_title', h($entity->getCategory()->getTitle()));
     $navi = array();
     $navi['module_url'] = get_url('/' . $this->module . '/');
     $navi['category_url'] = get_url('/' . $this->module . '/category/' . $entity->getCategory()->getId());
     $navi['category_name'] = h($entity->getCategory()->getTitle());
     $navi['navigation'] = $this->_buildBreadCrumbs($entity->getCategory()->getId());
     $this->_globalize($navi);
     $filters = $this->__getProductsFilters($entity->getCategory()->getId());
     $filters .= $this->__getVendorsFilter($entity->getCategory()->getId());
     $this->_globalize(array('products_filters' => $filters));
     $markers = array();
     $markers['moder_panel'] = $this->_getAdminBar($entity);
     $entry_url = entryUrl($entity, $this->module);
     $markers['entry_url'] = $entry_url;
     $markers['main_text'] = $this->Textarier->parseBBCodes($entity->getDescription(), $entity);
     $entity->setAdd_markers($markers);
     $source = $this->render('material.html', array('context' => array('entity' => $entity)));
     return $this->_view($source);
 }
开发者ID:VictorSproot,项目名称:AtomShop,代码行数:63,代码来源:index.php

示例6: callAction

 /**
  * @param  $params
  * @return void
  */
 function callAction($params)
 {
     // if we have one argument, we get page if it exists or error
     if (!is_file(ROOT . '/modules/' . strtolower($params[0]) . '/index.php')) {
         $params = array(0 => 'pages', 1 => 'index', 2 => $params[0]);
     }
     include_once ROOT . '/modules/' . strtolower($params[0]) . '/index.php';
     $module = ucfirst($params[0]) . 'Module';
     if (!class_exists($module)) {
         $this->Register['DocParser']->showHttpError();
     }
     // Parse two and more arguments
     if (count($params) > 1) {
         // Human Like URL
         if ($this->Register['Config']->read('hlu_understanding') || $this->Register['Config']->read('hlu')) {
             if ($params[1] !== 'view' && (empty($params[2]) || !is_numeric($params[2]))) {
                 // Geting new HLU title if he was changed.
                 $mat_id = $this->getNewHLUTitle($params[1], $params[0]);
                 if ($mat_id) {
                     // redirect to new URL (might the title was changed)
                     redirect($params[0] . '/' . $mat_id, 301);
                 }
             }
         }
     }
     $this->Register['dispath_params'] = $params;
     if (count($params) == 1) {
         $params[] = 'index';
     }
     $this->module = new $module($params);
     // Parse second argument
     if (count($params) > 1) {
         if (preg_match('#^_+#', $params[1])) {
             $this->Register['DocParser']->showHttpError();
         }
         if (!method_exists($this->module, $params[1])) {
             if (method_exists($this->module, $params[0] === 'forum' ? 'view_theme' : 'view')) {
                 // geting entity ID by HLU title from URL
                 $params[2] = $this->module->getEntryId($params[1]);
                 $params[1] = $params[0] === 'forum' ? 'view_theme' : 'view';
             } else {
                 $this->Register['DocParser']->showHttpError();
             }
         }
     }
     $params = Plugins::intercept('before_call_module', $params);
     call_user_func_array(array($this->module, $params[1]), array_slice($params, 2));
 }
开发者ID:VictorSproot,项目名称:AtomXCMS-2,代码行数:52,代码来源:pather.class.php

示例7: index

 /**
  * @return string - $this->_view
  *
  * Doing search and build page with results
  */
 public function index()
 {
     //check index
     $this->__checkIndex();
     $minInput = $this->Register['Config']->read('min_lenght', $this->module);
     if (!empty($minInput)) {
         $this->minInputStr = (int) $minInput;
     }
     $html = null;
     $error = null;
     $results = null;
     if (isset($_POST['m'])) {
         $modules = array();
         foreach ($_POST['m'] as $m) {
             if ($m == 'forum' or $m == 'news' or $m == 'stat' or $m == 'loads') {
                 Array_push($modules, $m);
             }
         }
     } else {
         $modules = array('forum', 'news', 'stat', 'loads');
     }
     $_SESSION['m'] = $modules;
     if (isset($_POST['search']) || isset($_GET['search'])) {
         $str = isset($_POST['search']) ? h($_POST['search']) : '';
         if (empty($str)) {
             $str = isset($_GET['search']) ? h($_GET['search']) : '';
         }
         if (!is_string($str)) {
             $str = (string) $str;
         }
         $str = trim($str);
         if (empty($str) || mb_strlen($str) < $this->minInputStr) {
             $error = $error . '<li>' . sprintf(__('Very small query'), $this->minInputStr) . '</li>';
         }
         if ($this->cached) {
             $this->cacheKey .= '_' . md5($str);
             if ($this->Cache->check($this->cacheKey)) {
                 $html = $this->Cache->read($this->cacheKey);
                 return $this->_view($html);
             }
         }
         $_SESSION['search_query'] = $str;
         if (!empty($error)) {
             $_SESSION['FpsForm'] = array();
             $_SESSION['FpsForm']['errors'] = $error;
             redirect($this->getModuleURL());
         }
         $str = Plugins::intercept('before_search', $str);
         $results = $this->__search($str, $modules);
         $results = Plugins::intercept('search_results', $results);
         if (count($results) && is_array($results)) {
             foreach ($results as $result) {
                 if (preg_match('#(.{0,100}' . $str . '.{0,100})#miu', $result->getIndex(), $match)) {
                     $announce = $match[1];
                 } else {
                     $announce = mb_substr($result->getIndex(), 0, 150);
                 }
                 $title = h($result->getEntity_title());
                 $announce = str_replace($str, '<strong>' . $str . '</strong>', h($announce));
                 $entry_url = get_url('/' . $result->getModule() . $result->getEntity_view() . $result->getEntity_id());
                 $result->setEntry_url($entry_url);
                 $result->setTitle($title);
                 $result->setAnnounce($announce);
             }
         } else {
             $error = __('No results');
             // TODO
         }
     } else {
         $_SESSION['search_query'] = '';
     }
     // Nav block
     $nav = array();
     $nav['navigation'] = get_link(__('Home'), '/') . __('Separator') . $this->module_title;
     $this->_globalize($nav);
     if (!empty($str)) {
         $this->addToPageMetaContext('entity_title', $str);
     }
     $this->returnForm = false;
     $form = $this->form();
     $source = $this->render('search_list.html', array('context' => array('results' => $results, 'form' => $form, 'error' => $error)));
     //write into cache
     if ($this->cached && !empty($str)) {
         //set users_id that are on this page
         $this->setCacheTag(array('search_str_' . $str));
         $this->cacheKey .= '_' . md5($str);
         $this->Cache->write($source, $this->cacheKey, $this->cacheTags);
     }
     return $this->_view($source);
 }
开发者ID:VictorSproot,项目名称:AtomXCMS-2,代码行数:95,代码来源:index.php

示例8: redirect

    redirect('/' . $this->module);
}
$commModel = $this->Register['ModManager']->getModelInstance('Comments');
$comment = $commModel->getById($id);
if (!$comment) {
    return $this->showInfoMessage(__('Comment not found'), '/' . $this->module . '/');
}
// Categories tree
$this->Model->bindModel('category');
$entity = $this->Model->getById($comment->getEntity_id());
if ($entity && $entity->getCategory_id()) {
    $this->categories = $this->_getCatsTree($entity->getCategory_id());
} else {
    $this->categories = $this->_getCatsTree();
}
Plugins::intercept('view_category', $entity->getCategory());
$markers = array();
$markers['disabled'] = $comment->getUser_id() ? ' disabled="disabled"' : '';
// Если при заполнении формы были допущены ошибки
if (isset($_SESSION['FpsForm'])) {
    $errors = $_SESSION['FpsForm']['errors'];
    $message = $_SESSION['FpsForm']['message'];
    $name = $_SESSION['FpsForm']['name'];
    unset($_SESSION['FpsForm']);
} else {
    $errors = '';
    $message = $comment->getMessage();
    $name = $comment->getName();
}
$markers['action'] = get_url('/' . $this->module . '/update_comment/' . $id);
$markers['errors'] = $errors;
开发者ID:VictorSproot,项目名称:AtomXCMS-2,代码行数:31,代码来源:edit_comment_form.php

示例9: header

|  @copyright     ©Andrey Brykin 2010-2012       |
|  @last mod.     2012/04/29                     |
\-----------------------------------------------*/
/*-----------------------------------------------\
| 												 |
|  any partial or not partial extension          |
|  CMS AtomX,without the consent of the          |
|  author, is illegal                            |
|------------------------------------------------|
|  Любое распространение                         |
|  CMS AtomX или ее частей,                      |
|  без согласия автора, является не законным     |
\-----------------------------------------------*/
header('Content-Type: text/html; charset=utf-8');
if (file_exists('install')) {
    include_once 'sys/settings/config.php';
    if (!empty($set) && !empty($set['db']['name']) && (!empty($set['db']['user']) || !empty($set['db']['pass']))) {
        die('Before use your site, delete INSTALL dir! <br />Перед использованием удалите папку INSTALL');
    }
    header('Location: install');
    die;
}
include_once 'sys/boot.php';
Plugins::intercept('before_pather', array());
/**
 * Parser URL
 * Get params from URL and launch needed module and action
 */
new Pather($Register);
Plugins::intercept('after_pather', array());
//pr($Register);
开发者ID:VictorSproot,项目名称:AtomXCMS-2,代码行数:31,代码来源:index.php


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