示例#1
0
 public function postHandle()
 {
     $this->runDesign();
     $this->updateOnline();
     $this->setOutput($this->runCron(), 'runCron');
     //门户管理模式 编译目录切换
     if ($this->getRequest()->getPost('design')) {
         $loginUser = Wekit::getLoginUser();
         $designPermission = $loginUser->getPermission('design_allow_manage.push');
         if ($designPermission > 0) {
             $dir = Wind::getRealDir('DATA:design.template');
             if (is_dir($dir)) {
                 WindFolder::rm($dir, true);
             }
             $this->forward->getWindView()->compileDir = 'DATA:design.template';
         }
     }
     // SEO settings
     Wekit::setGlobal(NEXT_VERSION . ' ' . NEXT_RELEASE, 'version');
     $seo = Wekit::V('seo');
     Wekit::setGlobal($seo ? $seo->getData() : array('title' => Wekit::C('site', 'info.name')), 'seo');
     $this->setOutput($this->getRequest()->getIsAjaxRequest() ? '1' : '0', '_ajax_');
     /*[设置给PwGlobalFilters需要的变量]*/
     $_var = array('current' => $this->forward->getWindView()->templateName, 'a' => $this->router->getAction(), 'c' => $this->router->getController(), 'm' => $this->router->getModule());
     $this->getResponse()->setData($_var, '_aCloud_');
 }
示例#2
0
 public function postHandle()
 {
     //门户管理模式 编译目录切换
     if ($this->getRequest()->getPost('design')) {
         $loginUser = Wekit::getLoginUser();
         $designPermission = $loginUser->getPermission('design_allow_manage.push');
         if ($designPermission > 0) {
             $dir = Wind::getRealDir('DATA:design.template');
             if (is_dir($dir)) {
                 WindFolder::rm($dir, true);
             }
             $this->forward->getWindView()->compileDir = 'DATA:design.template';
         }
     }
     // SEO settings
     Wind::import('SRV:seo.bo.PwSeoBo');
     $sitename = Wekit::C('site', 'info.name');
     PwSeoBo::set('{sitename}', $sitename);
     Wekit::setGlobal(NEXT_VERSION . ' ' . NEXT_RELEASE, 'version');
     Wekit::setGlobal(PwSeoBo::getData(), 'seo');
     $this->setOutput($this->getRequest()->getIsAjaxRequest() ? '1' : '0', '_ajax_');
     /*[设置给PwGlobalFilters需要的变量]*/
     $_var = array('current' => $this->forward->getWindView()->templateName, 'a' => $this->router->getAction(), 'c' => $this->router->getController(), 'm' => $this->router->getModule());
     $this->getResponse()->setData($_var, '_aCloud_');
     Wekit::load('APPS:appcenter.service.srv.PwDebugApplication')->compile();
 }
 public function __construct($pageBo)
 {
     $this->pageid = $pageBo->pageid;
     $pageInfo = $pageBo->getPage();
     $this->folder = str_replace('/', '_', $pageInfo['page_router']);
     $this->dir = Wind::getRealDir('THEMES:portal.local.') . $pageBo->getTplPath() . '/';
 }
 public function run()
 {
     $this->project = new WindGenerateProject();
     $this->project->name = 'test';
     $this->project->dir = Wind::getRealDir('PROJ:' . $this->project->name);
     $this->project->setConfig($this->config);
     $r = $this->project->generate();
     if (!$r) {
         echo 'generate fail';
     } else {
         echo 'generate success';
     }
 }
示例#5
0
 /**
  * 检测路径
  *
  * @param string $projName        	
  * @return string
  */
 private function _checkDir($projName)
 {
     static $dir = '', $name = '';
     $name = $projName;
     $dir = Wind::getRealDir('PROJ:' . $name);
     if (is_dir($dir)) {
         $r = $this->getLine("The Project Folder [{$dir}] Already Exist, Are you sure to override it?(Yes|No)");
         if (strtolower($r[0]) != 'y') {
             $name = $this->getLine('Please input the project name:');
             $this->_checkDir($name);
         }
     }
     return array($name, $dir);
 }
示例#6
0
 public function doCompile()
 {
     $config = Wekit::load('APPCENTER:service.srv.PwInstallApplication')->getConfig('style-type');
     foreach ($config as $k => $v) {
         $dir = Wind::getRealDir('THEMES:' . $v[1]);
         $files = WindFolder::read($dir, WindFolder::READ_DIR);
         foreach ($files as $v) {
             $manifest = $dir . '/' . $v . '/' . $this->manifest;
             if (!WindFile::isFile($manifest)) {
                 continue;
             }
             if (($r = $this->_doCss($dir . '/' . $v)) instanceof PwError) {
                 return $r;
             }
         }
     }
 }
示例#7
0
 /**
  * 后台首页处理方法
  */
 public function run()
 {
     //TODO 后台默认首页内容扩展支持
     list($groupType) = $this->getInput(array('type'), 'get');
     $groupType or $groupType = 'member';
     $groups = $this->_getGroupDs()->getGroupsByTypeInUpgradeOrder($groupType);
     if ('member' == $groupType) {
         $points = array();
         $last = '';
         foreach ($groups as $gid => $_item) {
             $points[] = $_item['points'];
             $last = $_item['points'];
         }
         $points[] = 999999999;
         $this->setOutput($points, 'points');
     }
     //用户组类型
     $groupTypes = $this->_getGroupDs()->getGroupTypes();
     $typeClasses = array();
     foreach ($groupTypes as $v) {
         $typeClasses[$v] = $groupType == $v ? ' class="current"' : '';
         //TODO
     }
     //level images
     $imageDir = Wind::getRealDir('PUBLIC:res.images.level') . DIRECTORY_SEPARATOR;
     //$imageDir = sprintf('%s/www/res/images/level/',dirname(rtrim(WEKIT_PATH,DIRECTORY_SEPARATOR)));
     $imageUrl = sprintf('%s/level', Wekit::url()->images);
     $imageFiles = array();
     if (is_dir($imageDir)) {
         if (false !== ($dh = opendir($imageDir))) {
             while (($file = readdir($dh)) !== false) {
                 if (filetype($imageDir . $file) == 'dir') {
                     continue;
                 }
                 $imageFiles[] = $file;
             }
             closedir($dh);
         }
     }
     natcasesort($imageFiles);
     $this->setOutput($imageUrl, 'imageUrl');
     $this->setOutput($imageFiles, 'imageFiles');
     $this->setOutput($groupType, 'groupType');
     $this->setOutput($typeClasses, 'typeClasses');
     $this->setOutput($groups, 'groups');
 }
示例#8
0
 public function defaultAvatar($uid, $type = 'face')
 {
     Wind::import('WINDID:service.upload.WindidUpload');
     $_avatar = array('.jpg' => '_big.jpg', '_middle.jpg' => '_middle.jpg', '_small.jpg' => '_small.jpg');
     $defaultBanDir = Wind::getRealDir('PUBLIC:') . 'res/images/face/';
     Wind::import('WINDID:service.config.srv.WindidStoreService');
     $srv = new WindidStoreService();
     $store = $srv->getStore();
     $fileDir = '/avatar/' . Windid::getUserDir($uid) . '/';
     foreach ($_avatar as $des => $org) {
         $toPath = $store->getAbsolutePath($uid . $des, $fileDir);
         $fromPath = $defaultBanDir . $type . $org;
         WindidUpload::createFolder(dirname($toPath));
         WindidUpload::copyFile($fromPath, $toPath);
         $store->save($toPath, $fileDir . $uid . $des);
     }
     return true;
 }
示例#9
0
 /**
  * 安装过程中风格的初始化
  *
  */
 public function init()
 {
     $install = Wekit::load('APPS:appcenter.service.srv.PwInstallApplication');
     $configBo = new PwConfigSet('site');
     $config = $install->getConfig('style-type');
     foreach ($config as $k => $v) {
         $configBo->set("theme.{$k}.pack", $v[1]);
         $pack = Wind::getRealDir('THEMES:' . str_replace('/', '.', $v[1]) . '.default');
         $id = $this->install($pack);
         if (!$id) {
             continue;
         }
         $dm = new PwStyleDm();
         $dm->setAppid($id)->setIsCurrent(1);
         $this->_styleDs()->updateStyle($dm);
         $configBo->set("theme.{$k}.default", 'default');
     }
     $configBo->flush();
 }
示例#10
0
 public function getNavType()
 {
     $navType = array();
     $dir = Wind::getRealDir('SRV:nav.srv.navtype.');
     $list = WindFolder::read($dir, WindFolder::READ_FILE);
     foreach ($list as $v) {
         $v = $dir . $v;
         if (!is_file($v)) {
             continue;
         }
         $types = @(include $v);
         foreach ($types as $type) {
             if (!isset($type['type'])) {
                 continue;
             }
             $navType[$type['type']] = $type['name'];
         }
     }
     return $navType;
 }
示例#11
0
 public function doCompile()
 {
     $JS_DEV_PATH = Wind::getRealDir('PUBLIC:res.js.dev');
     $JS_BUILD_PATH = Wind::getRealDir('PUBLIC:res.js.build');
     Wind::import('Wind:utility.WindFolder');
     $files = $this->_getFiles($JS_DEV_PATH);
     foreach ($files as $file) {
         $newfile = $JS_BUILD_PATH . substr($file, strlen($JS_DEV_PATH));
         WindFolder::mkRecur(dirname($newfile));
         if (substr($file, -3) != '.js') {
             if (!copy($file, $newfile)) {
                 return new PwError('copy failed');
             }
             continue;
         }
         $content = WindFile::read($file);
         $compress = jscompress::pack($content);
         if (!WindFile::write($newfile, $compress)) {
             return new PwError('write failed');
         }
     }
 }
示例#12
0
 public function moduleAction()
 {
     $moduleId = (int) $this->getInput('moduleid', 'post');
     Wind::import('SRV:design.bo.PwDesignModuleBo');
     $bo = new PwDesignModuleBo($moduleId);
     $module = $bo->getModule();
     if ($module['isused']) {
         $this->setTemplate('');
     }
     $bo->setStdId();
     $key = Wekit::load('design.srv.display.PwDesignDisplay')->bindDataKey($moduleId);
     $data[$key] = $bo->getData(true, false);
     $this->setOutput($data, '__design_data');
     list($theme, ) = $this->getForward()->getWindView()->getTheme();
     if (is_array($theme)) {
         list($theme, $pack) = $theme;
     }
     if (!$theme) {
         $theme = 'default';
     }
     WindFolder::rm(Wind::getRealDir('DATA:compile.template.' . $theme . '.design.segment.'), true);
     $this->setTemplate('TPL:design.segment.module');
 }
示例#13
0
 /**
  * 查找未安装的风格
  *
  * @return array 未安装的风格名
  */
 public function getUnInstalledThemes()
 {
     $config = Wekit::load('APPCENTER:service.srv.PwInstallApplication')->getConfig('style-type');
     $themes = array();
     foreach ($config as $k => $v) {
         $dir = Wind::getRealDir('THEMES:' . $v[1]);
         $files = WindFolder::read($dir, WindFolder::READ_DIR);
         foreach ($files as $file) {
             if (WindFile::isFile($dir . '/' . $file . '/' . $this->manifest)) {
                 $themes[$k][] = $file;
             }
         }
     }
     if (empty($themes)) {
         return array();
     }
     $styles = array();
     foreach ($themes as $k => $v) {
         $r = $this->_styleDs()->fetchStyleByAliasAndType($v, $k, 'alias');
         $r = array_diff($v, array_keys($r));
         $r && ($styles[$k] = $r);
     }
     return $styles;
 }
示例#14
0
 private static function _setAudioPath()
 {
     self::$_audioPath = Wind::getRealDir(self::$path . 'audio');
 }
示例#15
0
 /**
  * 导出压缩包
  *
  */
 public function exportAction()
 {
     $alias = $this->getInput('alias', 'get');
     Wind::import('LIB:utility.PwZip');
     $dir = Wind::getRealDir('EXT:' . $alias);
     if (!is_dir($dir)) {
         $this->showError('fail');
     }
     $target = Wind::getRealPath('DATA:tmp.' . $alias . '.zip', true);
     PwApplicationHelper::zip($dir, $target);
     $timestamp = Pw::getTime();
     $this->getResponse()->setHeader('Last-Modified', gmdate('D, d M Y H:i:s', $timestamp + 86400) . ' GMT');
     $this->getResponse()->setHeader('Expires', gmdate('D, d M Y H:i:s', $timestamp + 86400) . ' GMT');
     $this->getResponse()->setHeader('Cache-control', 'max-age=86400');
     $this->getResponse()->setHeader('Content-type', 'application/x-zip-compressed');
     $this->getResponse()->setHeader('Content-Disposition', 'attachment; filename=' . $alias . '.zip');
     $this->getResponse()->sendHeaders();
     @readfile($target);
     WindFile::del($target);
     $this->getResponse()->sendBody();
     exit;
 }
示例#16
0
 /**
  * 自定义页面升级  start
  * 
  * @return boolean
  */
 protected function _designUpgrade()
 {
     Wind::import('SRV:design.srv.vo.PwDesignPortalSo');
     $vo = new PwDesignPortalSo();
     $vo->setIsopen(1);
     $list = $this->_getPortalDs()->searchPortal($vo, 0, 100);
     $dirList = array();
     foreach ($list as $k => $v) {
         if (empty($v['template'])) {
             $dirList[$k] = $v['id'];
         }
     }
     $dir = Wind::getRealDir('THEMES:portal.local.');
     $_dir = array();
     if (!is_dir($dir)) {
         return array();
     }
     if (!($handle = @opendir($dir))) {
         return array();
     }
     while (false !== ($file = @readdir($handle))) {
         if ('.' === $file || '..' === $file) {
             continue;
         }
         $fileName = $dir . $file;
         if (is_file($fileName)) {
             continue;
         } elseif (is_dir($fileName) && is_numeric($file)) {
             $key = array_search($file, $dirList);
             unset($dirList[$k]);
             if ((int) $file != $file) {
                 continue;
             }
             $tplPath = 'special_' . $file;
             Wind::import('SRV:design.dm.PwDesignPortalDm');
             $dm = new PwDesignPortalDm($file);
             $dm->setTemplate($tplPath);
             Wekit::load('design.PwDesignPortal')->updatePortal($dm);
             $this->copyRecur($fileName, $dir . $tplPath . '/');
         }
     }
     $srv = Wekit::load('design.srv.PwDesignService');
     foreach ($dirList as $k => $v) {
         $tplPath = 'special_' . $v;
         $result = $srv->defaultTemplate($k, $tplPath);
         if ($result) {
             WindFile::write($dir . $tplPath . '/template/index.htm', $this->_tpl());
             Wind::import('SRV:design.dm.PwDesignPortalDm');
             $dm = new PwDesignPortalDm($v);
             $dm->setTemplate($tplPath);
             Wekit::load('design.PwDesignPortal')->updatePortal($dm);
         }
     }
     @closedir($handle);
     return true;
 }
示例#17
0
 /**
  * 解析资源文件路径信息
  * 
  * @param string $package
  * @return string
  */
 protected function resolvedPath($package)
 {
     $this->path || ($this->path = Wind::getRootPath(Wind::getAppName()));
     $this->language || ($this->language = $this->getRequest()->getAcceptLanguage());
     $path = $this->path . '/' . $this->language . '/' . strtolower($package);
     $path = Wind::getRealDir(trim($path, '/'), true);
     return $path;
 }
示例#18
0
 /**
  * 获取水印文件列表
  *
  * @return array
  */
 protected static function getWaterMarkList()
 {
     $_path = Wind::getRealDir('REP:mark.');
     return WindFolder::read($_path);
 }
示例#19
0
 public function defaultAvatar($uid, $type = 'face')
 {
     Wind::import('LIB:upload.PwUpload');
     $_avatar = array('.jpg' => '_big.jpg', '_middle.jpg' => '_middle.jpg', '_small.jpg' => '_small.jpg');
     $defaultBanDir = Wind::getRealDir('RES:') . 'images/face/';
     $store = Wind::getComponent('storage');
     $fileDir = 'avatar/' . Pw::getUserDir($uid) . '/';
     foreach ($_avatar as $des => $org) {
         $toPath = $store->getAbsolutePath($uid . $des, $fileDir);
         $fromPath = $defaultBanDir . $type . $org;
         PwUpload::createFolder(dirname($toPath));
         PwUpload::copyFile($fromPath, $toPath);
         $store->save($toPath, $fileDir . $uid . $des);
     }
     return true;
 }
示例#20
0
 /**
  * 清除tpl缓存
  *
  * @return boolean
  */
 public function refreshTplCache()
 {
     WindFolder::rm(Wind::getRealDir('DATA:compile'), true);
     WindFolder::rm(Wind::getRealDir('DATA:design.template'), true);
     return true;
 }
示例#21
0
 protected function getRealPath($outFile)
 {
     if (!$this->store instanceof PwStorageLocal) {
         $localDir = Wind::getRealDir('PUBLIC:') . PUBLIC_ATTACH . '/_tmp/';
         $path = $this->getImage($this->store->get($this->image, 0), $localDir, $outFile);
     } else {
         $path = Wind::getRealDir('PUBLIC:') . PUBLIC_ATTACH . '/' . $this->image;
     }
     return $path;
 }
示例#22
0
 public static function log($msg, $version, $start = false)
 {
     static $log;
     if (!$log) {
         $log = Wind::getRealDir('DATA:upgrade.log', true) . '/' . $version . '.log';
         WindFolder::mkRecur(dirname($log));
     }
     $status = $start ? WindFile::READWRITE : WindFile::APPEND_WRITEREAD;
     WindFile::write($log, "\r\n" . date('Y-m-d H:i') . '   ' . $msg, $status);
 }
示例#23
0
 public function flushLog()
 {
     if ($this->target) {
         $logFile = Wind::getRealDir('DATA:upgrade.log', true) . '/' . $this->target . '.log';
         if (file_exists($logFile) && ($log = WindFile::read($logFile))) {
             Wekit::load('patch.PwUpgradeLog')->addLog($this->target, substr($log, 0, 60000));
         }
     }
 }
示例#24
0
 /**
  * 对模块进行删除
  * PS:不是真正的删除,记录为isused = 0状态
  */
 public function deleteAction()
 {
     $moduleid = (int) $this->getInput('moduleid', 'post');
     $module = $this->_getModuleDs()->getModule($moduleid);
     if (!$module || $module['page_id'] < 1) {
         $this->showError('operate.fail');
     }
     Wekit::load('design.PwDesignPermissions');
     $permissions = $this->_getPermissionsService()->getPermissionsForModule($this->loginUser->uid, $moduleid);
     if ($permissions < PwDesignPermissions::IS_DESIGN) {
         $this->showError("DESIGN:permissions.fail");
     }
     Wind::import('SRV:design.bo.PwDesignPageBo');
     $pageBo = new PwDesignPageBo($module['page_id']);
     if ($pageBo->getLock()) {
         $this->showError('DESIGN:page.edit.other.user');
     }
     Wind::import('SRV:design.dm.PwDesignModuleDm');
     $dm = new PwDesignModuleDm($moduleid);
     $dm->setIsused(0);
     $resource = $this->_getModuleDs()->updateModule($dm);
     if ($resource instanceof PwError) {
         $this->showError($resource->getError());
     }
     //if (!$this->_getModuleDs()->deleteModule($moduleid)) $this->showMessage("operate.fail");
     $this->_getDataDs()->deleteByModuleId($moduleid);
     Wekit::load('design.PwDesignPush')->deleteByModuleId($moduleid);
     //删除导入数据的模版内容
     $dir = Wind::getRealDir('THEMES:portal.local.');
     $path = $dir . $pageBo->getTplPath() . '/template/';
     $files = WindFolder::read($path, WindFolder::READ_FILE);
     foreach ($files as $file) {
         $filePath = $path . $file;
         $content = WindFile::read($filePath);
         if (!$content) {
             continue;
         }
         $tmp = preg_replace('/\\<pw-list\\s*id=\\"' . $moduleid . '\\"\\s*>(.+)<\\/pw-list>/isU', '', $content);
         if ($tmp != $content) {
             WindFile::write($filePath, $tmp);
         }
     }
     $this->showMessage("operate.success");
 }
示例#25
0
 /**
  * @param $dirName
  * @return unknown_type
  */
 public function __construct($fileName = null)
 {
     $this->_bsize = 1024;
     $this->_dirName = $fileName ? dirname($fileName) : Wind::getRealDir('REP:ipdata');
     $this->_indexFile = $this->_dirName . '/ipindex.dat';
 }
示例#26
0
 /**
  * 自定义页默认模版
  */
 public function defaultTemplate($pageid, $tplPath)
 {
     $fromDir = Wind::getRealDir('TPL:special.default');
     $toDir = Wind::getRealDir('THEMES:portal.local.' . $tplPath);
     if ($this->copyRecur($fromDir, $toDir)) {
         return true;
     }
     return false;
 }
示例#27
0
 /**
  * 更新成功后备份
  *
  * @return multitype:string
  */
 private function _backSuccess()
 {
     $data_dir = Wind::getRealDir('DATA:');
     $suffix = '[' . Pw::time2str(WEKIT_TIMESTAMP, 'Y-m-d Hi') . ']';
     $up_source = $data_dir . 'upgrade';
     $up_target = $data_dir . 'upgrade' . $suffix;
     PwApplicationHelper::copyRecursive($up_source, $up_target);
     $status = Wekit::cache()->get('system_upgrade');
     $ba_source = $data_dir . 'backup' . DIRECTORY_SEPARATOR . 'phpwind_' . str_replace('.', '', $status['oldversion']) . '_' . $status['oldrelease'];
     $ba_target = $data_dir . 'backup' . $suffix;
     PwApplicationHelper::copyRecursive($ba_source, $ba_target);
     WindFolder::clearRecur($up_source, true);
     WindFolder::clearRecur($ba_source, true);
     return array($up_target, $ba_target);
 }
示例#28
0
 public function generate()
 {
     $addons = Wekit::load('APPS:appcenter.service.srv.PwInstallApplication')->getConfig('style-type');
     $base = str_replace('/', '.', $addons[$this->style_type][1]);
     $this->defaultDir = Wind::getRealDir('THEMES:' . $base . '.default');
     if (!is_dir($this->defaultDir)) {
         return new PwError('APPCENTER:generate.style.unsupport');
     }
     $this->baseDir = Wind::getRealDir('THEMES:' . $base . '.' . $this->alias);
     if (is_dir($this->baseDir)) {
         return new PwError('APPCENTER:alias.exist');
     }
     WindFolder::mkRecur($this->baseDir);
     Wind::import('APPS:appcenter.service.srv.helper.PwSystemHelper');
     $writable = PwSystemHelper::checkWriteAble($this->baseDir . '/');
     if (!$writable) {
         return new PwError('APPCENTER:generate.copy.fail');
     }
     PwApplicationHelper::copyRecursive($this->defaultDir, $this->baseDir);
     $file = $this->baseDir . '/Manifest.xml';
     Wind::import('WIND:parser.WindXmlParser');
     $parser = new WindXmlParser();
     $manifest = $parser->parse($file);
     $manifest['application']['name'] = $this->name;
     $manifest['application']['alias'] = $this->alias;
     $manifest['application']['description'] = $this->description;
     $manifest['application']['version'] = $this->version;
     $manifest['application']['pw-version'] = $this->pwversion;
     $manifest['application']['website'] = $this->website;
     $manifest['application']['author-name'] = $this->author;
     $manifest['application']['author-email'] = $this->email;
     $parser = new WindXmlParser();
     $manifest = str_replace('><', ">\n\t<", $parser->parseToXml(array('manifest' => $manifest), Wind::getApp()->getResponse()->getCharset()));
     WindFile::write($this->baseDir . '/Manifest.xml', $manifest);
     return 'THEMES:' . $base . '.' . $this->alias;
 }
示例#29
0
 public function getAbsoluteFile()
 {
     return Wind::getRealDir('PUBLIC:') . PUBLIC_ATTACH . '/' . $this->dir . $this->filename;
 }
示例#30
0
 public function initWaterWay()
 {
     if ($this->type == 1) {
         $water = new PwImage(Wind::getRealDir('REP:mark') . '/' . $this->file);
         if (!$water->isImage() || !$water->getSource()) {
             return false;
         }
     } else {
         if (!$this->text || strlen($this->fontcolor) != 7) {
             return false;
         }
         empty($this->fontfamily) && ($this->fontfamily = 'en_arial.ttf');
         empty($this->fontsize) && ($this->fontsize = 12);
         $this->fontfile = Wind::getRealDir('REP:font') . '/' . $this->fontfamily;
         $temp = imagettfbbox($this->fontsize, 0, $this->fontfile, $this->text);
         //取得使用 TrueType 字体的文本的范围
         $water = new stdClass();
         $water->width = $temp[2] - $temp[6];
         $water->height = $temp[3] - $temp[7];
         unset($temp);
     }
     return $water;
 }