/** * 电子邮件用户激活 */ public function emailAction() { list($page, $perpage) = $this->getInput(array('page', 'perpage')); $page = $page ? $page : 1; $perpage = $perpage ? $perpage : $this->perpage; $count = $this->_getDs()->countUnActived(); $list = array(); if ($count > 0) { $totalPage = ceil($count / $perpage); $page > $totalPage && ($page = $totalPage); $result = $this->_getDs()->getUnActivedList($perpage, intval(($page - 1) * $perpage)); /* @var $userDs PwUser */ $userDs = Wekit::load('user.PwUser'); $list = $userDs->fetchUserByUid(array_keys($result), PwUser::FETCH_MAIN); $list = WindUtility::mergeArray($result, $list); } $this->setOutput($count, 'count'); $this->setOutput($page, 'page'); $this->setOutput($perpage, 'perpage'); $this->setOutput(array('perpage' => $perpage), 'args'); $this->setOutput($list, 'list'); // seo设置 Wind::import('SRV:seo.bo.PwSeoBo'); $seoBo = PwSeoBo::getInstance(); $lang = Wind::getComponent('i18n'); $seoBo->setCustomSeo($lang->getMessage('SEO:manage.user.email.title'), '', ''); Wekit::setV('seo', $seoBo); }
/** * 关注-首页 */ public function run() { $type = $this->getInput('type'); $page = intval($this->getInput('page')); $page < 1 && ($page = 1); $perpage = 20; list($start, $limit) = Pw::page2limit($page, $perpage); $url = $classCurrent = array(); $typeCounts = $this->_getTypeDs()->countUserType($this->loginUser->uid); if ($type) { $tmp = $this->_getTypeDs()->getUserByType($this->loginUser->uid, $type, $limit, $start); $follows = $this->_getDs()->fetchFollows($this->loginUser->uid, array_keys($tmp)); $count = $typeCounts[$type] ? $typeCounts[$type]['count'] : 0; $url['type'] = $type; $classCurrent[$type] = 'current'; } else { $follows = $this->_getDs()->getFollows($this->loginUser->uid, $limit, $start); $count = $this->loginUser->info['follows']; $classCurrent[0] = 'current'; } $uids = array_keys($follows); $fans = $this->_getDs()->fetchFans($this->loginUser->uid, $uids); $userList = Wekit::load('user.PwUser')->fetchUserByUid($uids, PwUser::FETCH_MAIN | PwUser::FETCH_DATA | PwUser::FETCH_INFO); $service = $this->_getService(); $typeArr = $service->getAllType($this->loginUser->uid); $userType = $service->getUserType($this->loginUser->uid, $uids); foreach ($userType as $key => $value) { $tmp = array(); foreach ($value as $k => $v) { $tmp[$v] = $typeArr[$v]; } ksort($tmp); $userType[$key] = $tmp; } $follows = WindUtility::mergeArray($follows, $userList); if (!$type && !$follows) { $num = 30; $uids = $this->_getRecommendService()->getOnlneUids($num); $uids = array_slice($uids, 0, 24); $this->setOutput($this->_getRecommendService()->buildUserInfo($this->loginUser->uid, $uids, $num), 'recommend'); } $this->setOutput($follows, 'follows'); $this->setOutput($typeArr, 'typeArr'); $this->setOutput($type, 'type'); $this->setOutput($userType, 'userType'); $this->setOutput($typeCounts, 'typeCounts'); $this->setOutput($fans, 'fans'); $this->setOutput($classCurrent, 'classCurrent'); $this->setOutput($page, 'page'); $this->setOutput($perpage, 'perpage'); $this->setOutput($count, 'count'); $this->setOutput($url, 'url'); // seo设置 Wind::import('SRV:seo.bo.PwSeoBo'); $seoBo = PwSeoBo::getInstance(); $lang = Wind::getComponent('i18n'); $seoBo->setCustomSeo($lang->getMessage('SEO:bbs.follow.run.title'), '', ''); Wekit::setV('seo', $seoBo); }
public function getDetailList($notice) { $list = $uids = array(); $extendParams = $notice['extend_params']; $uids = array_keys($extendParams); $userList = Wekit::load('user.PwUser')->fetchUserByUid($uids, PwUser::FETCH_MAIN); $list['follows'] = $this->_getAttention()->fetchFollows($notice['uid'], array_keys($userList)); $list['fans'] = WindUtility::mergeArray(array_unique($extendParams), $userList); return $list; }
/** * 运行当前应用 * * @param string $name 应用名称默认‘phpwind’ * @param array $components 组建配置信息 该组建配置将会覆盖原组建配置,默认为空 */ public static function run($name = 'phpwind', $components = array()) { $config = WindUtility::mergeArray(include WEKIT_PATH . '../conf/application/default.php', include WEKIT_PATH . '../conf/application/' . $name . '.php'); if (!empty($components)) { $config['components'] = (array) $components + $config['components']; } /* @var $application WindWebFrontController */ $application = Wind::application($name, $config); $application->registeFilter(new PwFrontFilters($application)); $application->run(); }
/** * manifest path * * @param string $manifest */ public function __construct($manifest, $extends = array()) { is_string($manifest) && ($manifest = Wind::getComponent('configParser')->parse($manifest)); if ($extends) { $manifest = WindUtility::mergeArray($manifest, $extends); $charset = isset($manifest['application']['charset']) ? $manifest['application']['charset'] : 'utf-8'; } else { $charset = Wekit::app()->charset; } strncasecmp($charset, 'utf', 3) && ($manifest = WindConvert::convert($manifest, $charset, 'utf-8')); $this->manifest = $manifest; }
/** * 关注-首页 */ public function run() { $type = $this->getInput('type'); $page = intval($this->getInput('page')); $page < 1 && ($page = 1); $perpage = 20; list($start, $limit) = Pw::page2limit($page, $perpage); $args = $classCurrent = array(); /* $typeCounts = $this->_getTypeDs()->countUserType($this->space->spaceUid); if ($type) { $tmp = $this->_getTypeDs()->getUserByType($this->space->spaceUid, $type, $limit, $start); $follows = $this->_getDs()->fetchFollows($this->space->spaceUid, array_keys($tmp)); $count = $typeCounts[$type] ? $typeCounts[$type]['count'] : 0; $classCurrent[$type] = 'current'; $args = array('type' => $type); } else {*/ $follows = $this->_getDs()->getFollows($this->space->spaceUid, $limit, $start); $count = $this->space->spaceUser['follows']; $classCurrent[0] = 'current'; //} $uids = array_keys($follows); $fans = $this->_getDs()->fetchFans($this->loginUser->uid, $uids); $myfollows = $this->_getDs()->fetchFollows($this->loginUser->uid, $uids); $userList = Wekit::load('user.PwUser')->fetchUserByUid($uids, PwUser::FETCH_ALL); $service = $this->_getService(); $args['uid'] = $this->space->spaceUid; $follows = WindUtility::mergeArray($follows, $userList); if (!$follows && $this->space->tome == PwSpaceBo::MYSELF) { $num = 20; $uids = $this->_getRecommendService()->getRecommendAttention($this->loginUser->uid, $num); $this->setOutput($this->_getRecommendService()->buildUserInfo($this->loginUser->uid, $uids, $num), 'recommend'); } $this->setOutput($fans, 'fans'); $this->setOutput($follows, 'follows'); $this->setOutput($myfollows, 'myfollows'); $this->setOutput($classCurrent, 'classCurrent'); $this->setOutput($args, 'args'); $this->setOutput($page, 'page'); $this->setOutput($perpage, 'perpage'); $this->setOutput($count, 'count'); $this->setOutput('follows', 'src'); // seo设置 Wind::import('SRV:seo.bo.PwSeoBo'); $seoBo = PwSeoBo::getInstance(); $lang = Wind::getComponent('i18n'); $seoBo->setCustomSeo($lang->getMessage('SEO:space.follows.run.title', array($this->space->spaceUser['username'], $this->space->space['space_name'])), '', $lang->getMessage('SEO:space.follows.run.description', array($this->space->spaceUser['username']))); Wekit::setV('seo', $seoBo); }
public function initConfig($config, $factory) { is_array($config) || ($config = $factory->getInstance('configParser')->parse($config)); foreach ($config['web-apps'] as $key => $value) { if (isset($this->_config['web-apps'][$key])) { continue; } $rootPath = empty($value['root-path']) ? dirname($_SERVER['SCRIPT_FILENAME']) : Wind::getRealPath($value['root-path'], true); Wind::register($rootPath, $key, true); if ('default' !== $key && !empty($config['default'])) { $value = WindUtility::mergeArray($config['default'], $value); } $this->setConfig($key, $value); } $this->_config['router'] = isset($config['router']) ? $config['router'] : array(); }
/** * 电子邮件用户激活 */ public function emailAction() { list($page, $perpage) = $this->getInput(array('page', 'perpage')); $page = $page ? $page : 1; $perpage = $perpage ? $perpage : $this->perpage; $count = $this->_getDs()->countUnActived(); $list = array(); if ($count > 0) { $totalPage = ceil($count / $perpage); $page > $totalPage && ($page = $totalPage); $result = $this->_getDs()->getUnActivedList($perpage, intval(($page - 1) * $perpage)); /* @var $userDs PwUser */ $userDs = Wekit::load('user.PwUser'); $list = $userDs->fetchUserByUid(array_keys($result), PwUser::FETCH_MAIN); $list = WindUtility::mergeArray($result, $list); } $this->setOutput($count, 'count'); $this->setOutput($page, 'page'); $this->setOutput($perpage, 'perpage'); $this->setOutput($list, 'list'); }
public function run() { $page = intval($this->getInput('page')); $page < 1 && ($page = 1); $perpage = 20; list($start, $limit) = Pw::page2limit($page, $perpage); $count = $this->loginUser->info['fans']; $fans = $this->_getDs()->getFans($this->loginUser->uid, $limit, $start); $uids = array_keys($fans); $follows = $this->_getDs()->fetchFollows($this->loginUser->uid, $uids); $userList = Wekit::load('user.PwUser')->fetchUserByUid($uids, PwUser::FETCH_MAIN | PwUser::FETCH_DATA | PwUser::FETCH_INFO); $this->setOutput(WindUtility::mergeArray($fans, $userList), 'fans'); $this->setOutput($follows, 'follows'); $this->setOutput($page, 'page'); $this->setOutput($perpage, 'perpage'); $this->setOutput($count, 'count'); //$this->setOutput($url, 'url'); // seo设置 Wind::import('SRV:seo.bo.PwSeoBo'); $lang = Wind::getComponent('i18n'); PwSeoBo::setCustomSeo($lang->getMessage('SEO:bbs.fans.run.title'), '', ''); }
public function run() { $page = intval($this->getInput('page')); $page < 1 && ($page = 1); $perpage = 20; list($start, $limit) = Pw::page2limit($page, $perpage); $fans = $this->_getDs()->getFans($this->space->spaceUid, $limit, $start); $uids = array_keys($fans); $count = $this->space->spaceUser['fans']; $follows = $this->_getDs()->fetchFollows($this->loginUser->uid, $uids); $userList = Wekit::load('user.PwUser')->fetchUserByUid($uids, PwUser::FETCH_ALL); $this->setOutput(WindUtility::mergeArray($fans, $userList), 'fans'); $this->setOutput($follows, 'follows'); $this->setOutput($page, 'page'); $this->setOutput($perpage, 'perpage'); $this->setOutput($count, 'count'); $this->setOutput('fans', 'src'); // seo设置 Wind::import('SRV:seo.bo.PwSeoBo'); $lang = Wind::getComponent('i18n'); PwSeoBo::setCustomSeo($lang->getMessage('SEO:space.fans.run.title', array($this->space->spaceUser['username'], $this->space->space['space_name'])), '', $lang->getMessage('SEO:space.fans.run.description', array($this->space->spaceUser['username']))); }
/** * 获取用户组根权限配置 * * @param array $config * @return multitype:multitype:string */ public function getPermissionCategoryConfig($config) { $markconfig = array('other' => array('sub' => array('mark' => array('name' => '评分', 'items' => array('app_mark_open', 'app_mark_credits')))), 'manage_bbs' => array('sub' => array('mark' => array('name' => '评分管理权限', 'items' => array('app_mark_manage'))))); return WindUtility::mergeArray($config, $markconfig); }
/** * 加载系统配置 */ protected static function _loadSystemConfig($name) { self::$_sc = WindUtility::mergeArray(include WEKIT_PATH . '../conf/application/default.php', include WEKIT_PATH . '../conf/application/' . $name . '.php'); }
/** * * @see PwNoticeAction::formatExtendParams() */ public function formatExtendParams($extendParams, $aggregatedNotice = null) { $oldExtendParams = $aggregatedNotice ? unserialize($aggregatedNotice['extend_params']) : $extendParams; return WindUtility::mergeArray($oldExtendParams, $extendParams); }
/** * 获得module配置,$name为空时返回当前module配置 * * @param string $name * module名称 默认为空 * @param boolean $merge * 合并默认值 * @return array * @throws WindActionException * @throws WindException */ public function getModules($name = '') { if ($name === '') { $name = $this->handlerAdapter->getModule(); } if ($name === 'pattern') { $name = $this->handlerAdapter->getDefaultModule(); } $_module = $this->getConfig('modules', $name, array()); if (!isset($_module['_verified']) || $_module['_verified'] !== true) { if (empty($_module) && !empty($this->_config['modules']['pattern'])) { $_module = $this->_config['modules']['pattern']; } $_flag = empty($_module); $_module = WindUtility::mergeArray($this->_config['modules']['default'], $_module); $_module_str = implode('#', $_module); if (strpos($_module_str, '{') !== false) { preg_match_all('/{(\\w+)}/i', $_module_str, $matches); if (!empty($matches[1])) { $_replace = array(); foreach ($matches[1] as $key => $value) { if ($value === $this->handlerAdapter->getModuleKey()) { $_replace['{' . $value . '}'] = $this->handlerAdapter->getModule(); } elseif ($value === $this->handlerAdapter->getControllerKey()) { $_replace['{' . $value . '}'] = $this->handlerAdapter->getController(); } elseif ($value === $this->handlerAdapter->getActionKey()) { $_replace['{' . $value . '}'] = $this->handlerAdapter->getAction(); } else { $_replace['{' . $value . '}'] = $this->request->getGet($value); } } $_module_str = strtr($_module_str, $_replace); $_module = array_combine(array_keys($_module), explode('#', $_module_str)); } } elseif ($_flag) { throw new WindException('Your request was not found on this server.', 404); } $_module['_verified'] = true; $this->_config['modules'][$name] = $_module; } return $_module; }
/** * 获得菜单数据table,该菜单节点table并不展示节点间的层级关系. * * 该方法解析所有扩展菜单表或者扩展菜单配置文件,并将菜单合并为一份完整的菜单table并返回. * * @example <code> 节点列表'admin' => array('admin', array()), * 'admin_install' => array('应用菜单安装', 'install/run', '', '', * 'admin'), * 'admin_auth' => array('菜单权限', 'auth/*', '', '', 'admin'),</code> * @return array */ private function _getMenuTable() { if ($this->menuTable === null) { /* @var $_configParser WindConfigParser */ $_configParser = Wind::getComponent('configParser'); // 'ADMIN:conf.mainmenu.php' $mainMenuConfFile = Wind::getRealPath(Wekit::app()->menuPath, true); $menus = $_configParser->parse($mainMenuConfFile); /* extend menus by file */ if (isset($menus['_extensions'])) { $_extensions = $menus['_extensions']; foreach ($_extensions as $_extName => $_ext) { if (!isset($_ext['resource'])) { continue; } $_tmp = Wind::getRealPath($_ext['resource'], true); $cacheKey .= filemtime($_tmp); $_extensions[$_extName]['resource'] = $_tmp; } unset($menus['_extensions']); } else { $_extensions = array(); } $menus = PwSimpleHook::getInstance('admin_menu')->runWithFilters($menus); foreach ($_extensions as $key => $value) { if (!isset($value['resource'])) { continue; } $_tmp = $_configParser->parse($value['resource']); $menus = WindUtility::mergeArray($menus, $_tmp); } AdminMenuHelper::verifyMenuConfig($menus, $menus, $this->menuTable); } return $this->menuTable; }
/** * 加载类定义 * 调用该方法加载组件定义,如果merge为true,则覆盖原有配置信息. * * @param array $classDefinitions * @param boolean $merge * 是否进行merge操作,默认为true * @return void */ public function loadClassDefinitions($classDefinitions, $merge = true) { foreach ((array) $classDefinitions as $alias => $definition) { if (!is_array($definition)) { continue; } if (isset($this->instances[$alias]) || isset($this->prototype[$alias])) { continue; } if (!isset($this->classDefinitions[$alias]) || $merge === false) { $this->classDefinitions[$alias] = $definition; } else { $this->classDefinitions[$alias] = WindUtility::mergeArray($this->classDefinitions[$alias], $definition); } } }
/** * 初始化配置信息 * * @param array|string $config * @param WindFactory $factory */ protected function _initConfig($config, $factory) { if (!$config) { return; } if (is_string($config)) { $config = $factory->getInstance('configParser')->parse($config); } $this->_config = WindUtility::mergeArray($this->_config, $config); }
<?php error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING); require './src/wekit.php'; /* @var $application WindWebFrontController */ Wind::application('install', WindUtility::mergeArray(include WEKIT_PATH . '../conf/application/default.php', include WEKIT_PATH . '../conf/application/install.php'))->run();
/** * 设置地区显示 * * @return array */ private function _buildArea($areaid) { $default = array(array('areaid' => '', 'name' => ''), array('areaid' => '', 'name' => ''), array('areaid' => '', 'name' => '')); if (!$areaid) { return $default; } $rout = WindidApi::api('area')->getAreaRout($areaid); return WindUtility::mergeArray($default, $rout); }
/** * 设置当前forward对象中存储的变量 * * 设置当前forward对象中存储的变量,设置到forward中的所有变量都可以在模板页面中被直接访问到 * @param string|array|object $vars * @param string $key 默认为空字符串 * @return void */ public function setVars($vars, $key = '', $merge = false) { if (!$key) { if (is_object($vars)) { $vars = get_object_vars($vars); } if (is_array($vars)) { $this->vars = array_merge($this->vars, $vars); } } elseif ($merge && !empty($this->vars[$key])) { $this->vars[$key] = WindUtility::mergeArray((array) $this->vars[$key], (array) $vars); } else { $this->vars[$key] = $vars; } }
/** * 获得module配置,$name为空时返回当前module配置 * * @param string $name module名称 默认为空 * @param boolean $merge 合并默认值 * @return array * @throws WindActionException * @throws WindException */ public function getModules($name = '') { if ($name === '') { $name = $this->handlerAdapter->getModule(); } $_module = $this->getConfig('modules', $name, array()); if (!isset($_module['_verified']) || $_module['_verified'] !== true) { if (empty($_module)) { $_module = $this->getConfig('modules', 'pattern', array()); $_pattern = !empty($_module); } $_module = WindUtility::mergeArray($this->defaultModule, $_module); if (isset($_pattern) && $_pattern) { $_keys = array_keys($_module); $_replace = array('{' . $this->handlerAdapter->getModuleKey() . '}' => $this->handlerAdapter->getModule(), '{' . $this->handlerAdapter->getControllerKey() . '}' => $this->handlerAdapter->getController(), '{' . $this->handlerAdapter->getActionKey() . '}' => $this->handlerAdapter->getAction()); foreach ($_keys as $_key) { if (strrchr($_key, '-') !== '-path') { continue; } $_module[$_key] = strtr($_module[$_key], $_replace); } } $_module['_verified'] = true; $this->_config['modules'][$name] = $_module; } return $_module; }
/** * 获得module配置,$name为空时返回当前module配置 * * @param string $name module名称 默认为空 * @return array * @throws WindActionException * @throws WindException */ public function getModules($name = '') { if ($name === '') { $name = $this->handlerAdapter->getModule(); } $_module = $this->getConfig('modules', $name, array()); if (!isset($_module['_verified'])) { $_module = WindUtility::mergeArray($this->defaultModule, $_module); $_module['_verified'] = true; $this->_config['modules'][$name] = $_module; } return $_module; }
public function setData($data, $key = '', $merge = false) { if ($key) { if ($merge && !empty($this->_data[$key])) { $this->_data[$key] = WindUtility::mergeArray((array) $this->_data[$key], (array) $data); } else { $this->_data[$key] = $data; } } else { if (is_object($data)) { $data = get_object_vars($data); } if (is_array($data)) { $this->_data = array_merge($this->_data, $data); } } }
/** * 设置地区显示 * * @return array */ private function _buildArea($areaid) { $default = array(array('areaid' => '', 'name' => ''), array('areaid' => '', 'name' => ''), array('areaid' => '', 'name' => '')); if (!$areaid) { return $default; } /* @var $areaSrv PwAreaService */ $areaSrv = Wekit::load('area.srv.PwAreaService'); $rout = $areaSrv->getAreaRout($areaid); return WindUtility::mergeArray($default, $rout); }
/** * 获取搜索用户组根权限配置 * * @param array $config * @return multitype:multitype:string */ public function getPermissionCategoryConfig($config) { $searchconfig = array('other' => array('sub' => array('tag' => array('name' => '本地搜索', 'items' => array('app_search_open', 'app_search_time_interval'))))); return WindUtility::mergeArray($config, $searchconfig); }
/** * 创建并返回应用实例 * * @deprecated * @return WindWebApplication */ public function createApplication() { if ($this->_app === null) { $application = $this->_createApplication(); /* @var $application WindWebApplication */ if (!empty($this->_config['web-apps'][$this->_appName])) { if ($this->_appName !== 'default' && isset($this->_config['web-apps']['default']) && !isset($this->_config['web-apps'][$this->_appName]['_merged'])) { $this->_config['web-apps'][$this->_appName] = WindUtility::mergeArray($this->_config['web-apps']['default'], $this->_config['web-apps'][$this->_appName]); $this->_config['web-apps'][$this->_appName]['_merged'] = true; } $application->setConfig($this->_config['web-apps'][$this->_appName]); } $this->_app = $application; } return $this->_app; }