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


PHP waSystem::setActive方法代码示例

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


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

示例1: execute

 public function execute()
 {
     $cache = null;
     if ($cache_time = $this->getConfig()->getOption('cache_time')) {
         //$cache = new waSerializeCache('pages/'.$domain.$url.'page');
     }
     $page = array();
     if ($cache && $cache->isCached()) {
         $page = $cache->get();
     } else {
         $site = new siteFrontend();
         if (waRequest::param('error')) {
             $page = array();
         } else {
             $page = $site->getPage(waRequest::param('url', ''));
         }
         if ($page && $cache) {
             $cache->set($page);
         }
     }
     if (!waRequest::isXMLHttpRequest()) {
         $this->setLayout(new siteFrontendLayout());
     }
     try {
         $this->executeAction(new siteFrontendAction($page));
     } catch (Exception $e) {
         if (waSystemConfig::isDebug()) {
             echo $e;
         } else {
             waSystem::setActive('site');
             $this->executeAction(new siteFrontendAction($e));
         }
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:34,代码来源:siteFrontend.controller.php

示例2: execute

 public function execute()
 {
     $route_id = waRequest::get('route');
     $routes = wa()->getRouting()->getRoutes(siteHelper::getDomain());
     if (!isset($routes[$route_id])) {
         throw new waException('Route not found', 404);
     }
     $route = $routes[$route_id];
     $app_id = $routes[$route_id]['app'];
     $path = $this->getConfig()->getAppsPath($app_id, 'lib/config/site.php');
     $app = wa()->getAppInfo($app_id);
     if (file_exists($path)) {
         // load locale of the app
         if ($app_id != 'site') {
             waSystem::getInstance($app_id)->setActive($app_id);
         }
         $app['site'] = (include $path);
         // return old locale of the site
         if ($app_id != 'site') {
             waSystem::setActive('site');
         }
     }
     if (isset($app['site']['params'])) {
         $params = $this->getParams($route_id, $app['site']['params'], $route);
     } else {
         $params = array();
     }
     $themes = siteHelper::getThemes($app_id);
     if (!isset($route['theme']) && $themes) {
         $route['theme'] = 'default';
     }
     if (!isset($route['theme_mobile']) && $themes) {
         $route['theme_mobile'] = $route['theme'];
     }
     if (!isset($route['locale'])) {
         $route['locale'] = '';
     }
     if (!isset($route['_name'])) {
         if ($app_id == 'site') {
             if ($title = siteHelper::getDomain('title')) {
                 $route['_name'] = $title;
             } else {
                 $app_settings_model = new waAppSettingsModel();
                 $route['_name'] = $app_settings_model->get('webasyst', 'name', 'Webasyst');
             }
         } else {
             $route['_name'] = $app['name'];
         }
     }
     $this->view->assign('route_id', $route_id);
     $this->view->assign('route', $route);
     $this->view->assign('params', $params);
     $this->view->assign('app_id', $app_id);
     $this->view->assign('app', $app);
     $this->view->assign('domain_id', siteHelper::getDomainId());
     $this->view->assign('domain', siteHelper::getDomain());
     $this->view->assign('locales', array('' => _w('Auto')) + waLocale::getAll('name'));
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:58,代码来源:siteRoutingEdit.action.php

示例3: execute

 public function execute()
 {
     // only allowed to global admin
     if (!wa()->getUser()->getRights('webasyst', 'backend')) {
         throw new waRightsException(_w('Access denied'));
     }
     $contact_id = waRequest::get('id');
     $group_ids = null;
     if ($contact_id > 0) {
         $user_groups_model = new waUserGroupsModel();
         $group_ids = $user_groups_model->getGroupIds($contact_id);
         $group_ids[] = 0;
     }
     $app_id = waRequest::get('app');
     $right_model = new waContactRightsModel();
     $rights = $right_model->get($contact_id, $app_id, null, false);
     $group_rights = null;
     if ($group_ids) {
         $group_rights = $right_model->get(array_map(wa_lambda('$a', 'return -$a;'), $group_ids), $app_id, null, false);
     }
     // Check custom rights items
     $app_config = SystemConfig::getAppConfig($app_id);
     $class_name = $app_config->getPrefix() . "RightConfig";
     $file_path = $app_config->getAppPath('lib/config/' . $class_name . ".class.php");
     if (file_exists($file_path)) {
         // Init app
         waSystem::getInstance($app_id, $app_config, true);
         include $file_path;
         /**
          * @var waRightConfig $right_config
          */
         $right_config = new $class_name();
         $rights += $right_config->getRights($contact_id);
         if ($group_ids) {
             $group_rights += $right_config->getRights(array_map(wa_lambda('$a', 'return -$a;'), $group_ids));
         }
         $this->view->assign('html', $right_config->getHTML($rights, $group_rights));
         waSystem::setActive('contacts');
     } else {
         $this->view->assign('html', '');
     }
     if ($contact_id > 0) {
         $this->view->assign('user', new waContact($contact_id));
     } else {
         $gm = new waGroupModel();
         $this->view->assign('group', $gm->getById(-$contact_id));
     }
     $app = wa()->getAppInfo($app_id);
     $app['id'] = $app_id;
     $this->view->assign('app', $app);
     $this->view->assign('rights', $rights);
     $this->view->assign('group_rights', $group_rights);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:53,代码来源:contactsRights.action.php

示例4: smarty_function_wa_action

/**
 * @param $params
 * @param $smarty
 * @return string|void
 */
function smarty_function_wa_action($params, &$smarty)
{
    $current_app = waSystem::getInstance()->getApp();
    $app = $params['app'];
    waSystem::getInstance($app)->setActive($app);
    if (isset($params['action'])) {
        $type = 'action';
        $class_name = $app . ucfirst($params['module']) . ucfirst($params['action']) . 'Action';
    } elseif (isset($params['controller'])) {
        $type = 'controller';
        $class_name = $app . ucfirst($params['module']) . ucfirst($params['controller']) . 'Controller';
    }
    $var = isset($params['var']) ? $params['var'] : false;
    if ($var) {
        unset($params['var']);
    }
    unset($params['app']);
    unset($params['module']);
    unset($params['action']);
    foreach ($params as $key => $value) {
        waRequest::setParam($key, $value);
    }
    $result = '';
    try {
        if ($type == 'action') {
            $action = new $class_name();
            $result = $action->display();
        } elseif ($type == 'controller') {
            $controller = new $class_name();
            $result = $controller->execute();
        }
    } catch (Exception $e) {
        $result = $e->getMessage();
    }
    waSystem::setActive($current_app);
    if ($var) {
        $smarty->assign($var, $result);
    } else {
        return $result;
    }
}
开发者ID:Lazary,项目名称:webasyst,代码行数:46,代码来源:function.wa_action.php

示例5: getAdapter

 /**
  *
  * @throws waException
  * @return waAppPayment
  */
 protected final function getAdapter()
 {
     if (!$this->app_adapter) {
         if (!$this->app_id) {
             throw new waException('Unknown current application');
         }
         #Init application
         waSystem::getInstance($this->app_id);
         waSystem::setActive($this->app_id);
         #check adapter class
         $app_class = $this->app_id . 'Shipping';
         if (!class_exists($app_class)) {
             throw new waException(sprintf('Application adapter %s not found for %s', $app_class, $this->app_id));
         }
         $instance = new $app_class();
         if (!$instance instanceof waAppShipping) {
             throw new waException(sprintf('Application adapter %s not found for %s', $app_class, $this->app_id));
         }
         $this->app_adapter = $instance;
     }
     return $this->app_adapter;
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:27,代码来源:waShipping.class.php

示例6: execute

 public function execute()
 {
     $this->response = array();
     // Initialize all needed post vars as $vars in current namespace
     foreach (array('x1', 'y1', 'x2', 'y2', 'w', 'h', 'ww', 'orig') as $var) {
         if (null === (${$var} = (int) waRequest::post($var))) {
             // $$ black magic...
             $this->response['error'] = 'wrong parameters';
             return;
         }
     }
     $id = $this->getId();
     $contact = new waContact($id);
     // Path to file we need to crop
     $rand = mt_rand();
     $dir = waContact::getPhotoDir($id, true);
     $filename = wa()->getDataPath("{$dir}{$rand}.original.jpg", true, 'contacts');
     $oldDir = wa()->getDataPath("{$dir}", true, 'contacts');
     $no_old_photo = false;
     if (!$orig) {
         // Delete the old photos if they exist
         if (file_exists($oldDir)) {
             waFiles::delete($oldDir);
             $no_old_photo = true;
         }
         waFiles::create($oldDir);
         // Is there an uploaded file in session?
         $photoEditors = $this->getStorage()->read('photoEditors');
         if (!isset($photoEditors[$id]) || !file_exists($photoEditors[$id])) {
             $this->response['error'] = 'Photo editor session is not found or already expired.';
             return;
         }
         $newFile = $photoEditors[$id];
         // Save the original image in jpeg for future use
         try {
             $img = waImage::factory($newFile)->save($filename);
         } catch (Exception $e) {
             $this->response['error'] = 'Unable to save new file ' . $filename . ' (' . pathinfo($filename, PATHINFO_EXTENSION) . ') as jpeg: ' . $e->getMessage();
             return;
         }
         // Remove uploaded file
         unset($photoEditors[$id]);
         $this->getStorage()->write('photoEditors', $photoEditors);
         unlink($newFile);
     } else {
         // cropping an old file. Move it temporarily to temp dir to delete all cached thumbnails
         $oldFile = wa()->getDataPath("{$dir}{$contact['photo']}.original.jpg", TRUE, 'contacts');
         $tempOldFile = wa()->getTempPath("{$id}/{$rand}.original.jpg", 'contacts');
         waFiles::move($oldFile, $tempOldFile);
         // Delete thumbnails
         if (file_exists($oldDir)) {
             waFiles::delete($oldDir);
         }
         waFiles::create($oldDir);
         // return original image to its proper place
         waFiles::move($tempOldFile, $filename);
     }
     if (!file_exists($filename)) {
         $this->response['error'] = 'Image to crop not found (check directory access rights).';
         return;
     }
     // Crop and save selected area
     $croppedFilename = wa()->getDataPath("{$dir}{$rand}.jpg", TRUE, 'contacts');
     try {
         $img = waImage::factory($filename);
         $scale = $img->width / $ww;
         $img->crop(floor($w * $scale), floor($h * $scale), floor($x1 * $scale), floor($y1 * $scale))->save($croppedFilename);
     } catch (Exception $e) {
         $this->response['error'] = 'Unable to crop an image: ' . $e->getMessage();
         return;
     }
     // Update record in DB for this user
     $contact['photo'] = $rand;
     $contact->save();
     if ($no_old_photo) {
         $old_app = null;
         if (wa()->getApp() !== 'contacts') {
             $old_app = wa()->getApp();
             waSystem::setActive('contacts');
         }
         $this->logAction('photo_add', null, $contact->getId());
         if ($old_app) {
             waSystem::setActive($old_app);
         }
     }
     // Update recent history to reload thumbnail correctly (if not called from personal account)
     if (wa()->getUser()->get('is_user')) {
         $history = new contactsHistoryModel();
         $history->save('/contact/' . $id, null, null, '--');
     }
     $this->response = array('url' => $contact->getPhoto());
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:92,代码来源:contactsPhotoCrop.controller.php

示例7: execute

 public function execute()
 {
     // only allowed to global admin
     if (!wa()->getUser()->getRights('webasyst', 'backend')) {
         throw new waRightsException('Access denied.');
     }
     $app_id = waRequest::post('app_id');
     $name = waRequest::post('name');
     $value = (int) waRequest::post('value');
     $contact_id = waRequest::get('id');
     $has_backend_access_old = $this->hasBackendAccess($contact_id);
     if (!$name && !$value) {
         $values = waRequest::post('app');
         if (!is_array($values)) {
             throw new waException('Bad values for access rights.');
         }
     } else {
         $values = array($name => $value);
     }
     $right_model = new waContactRightsModel();
     $is_admin = $right_model->get($contact_id, 'webasyst', 'backend', false);
     if ($is_admin && $app_id != 'webasyst') {
         throw new waException('Cannot change application rights for global admin.');
     }
     // If $contact_id used to have limited access and we're changing global admin privileges,
     // then need to notify all applications to remove their custom access records.
     if (!$is_admin && $app_id == 'webasyst' && $name == 'backend') {
         foreach (wa()->getApps() as $aid => $app) {
             try {
                 if (isset($app['rights']) && $app['rights']) {
                     $app_config = SystemConfig::getAppConfig($aid);
                     $class_name = $app_config->getPrefix() . "RightConfig";
                     $file_path = $app_config->getAppPath('lib/config/' . $class_name . ".class.php");
                     $right_config = null;
                     if (!file_exists($file_path)) {
                         continue;
                     }
                     waSystem::getInstance($aid, $app_config);
                     include_once $file_path;
                     /**
                      * @var waRightConfig
                      */
                     $right_config = new $class_name();
                     $right_config->clearRights($contact_id);
                 }
             } catch (Exception $e) {
                 // silently ignore other applications errors
             }
         }
     }
     // Update $app_id access records
     $app_config = SystemConfig::getAppConfig($app_id);
     $class_name = $app_config->getPrefix() . "RightConfig";
     $file_path = $app_config->getAppPath('lib/config/' . $class_name . ".class.php");
     $right_config = null;
     if (file_exists($file_path)) {
         // Init app
         waSystem::getInstance($app_id, $app_config);
         include_once $file_path;
         /**
          * @var waRightConfig
          */
         $right_config = new $class_name();
     }
     foreach ($values as $name => $value) {
         if ($right_config && $right_config->setRights($contact_id, $name, $value)) {
             // If we've got response from custom rights config, then no need to update main rights table
             continue;
         }
         // Set default limited rights
         if ($right_config && $name == 'backend' && $value == 1) {
             /**
              * @var $right_config waRightConfig
              */
             foreach ($right_config->setDefaultRights($contact_id) as $n => $v) {
                 $right_model->save($contact_id, $app_id, $n, $v);
             }
         }
         $right_model->save($contact_id, $app_id, $name, $value);
     }
     waSystem::setActive('contacts');
     if ($contact_id) {
         // TODO: use waContact method for disabling
         $is_user = waRequest::post('is_user', null, 'int');
         if ($is_user === -1 || $is_user === 0 || $is_user === 1) {
             $contact = new waContact($contact_id);
             $contact->save(array('is_user' => $is_user));
             $this->response['access_disable_msg'] = contactsHelper::getAccessDisableMsg($contact);
         }
     }
     $has_backend_access_new = $this->hasBackendAccess($contact_id);
     if ($has_backend_access_new !== $has_backend_access_old) {
         if ($has_backend_access_new) {
             $this->logAction("grant_backend_access", null, $contact_id);
         } else {
             $this->logAction("revoke_backend_access", null, $contact_id);
         }
     }
 }
开发者ID:Favorskij,项目名称:webasyst-framework,代码行数:99,代码来源:contactsRightsSave.controller.php


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