长代码

<?php
/**
 * Ajax提交代码以运行
 * @author wangpd
 * modified : 2014/12/24
 */
class ResetcodeAction extends Ap_Base_Action {
    public function execute(){
        //是否登录
        $uid = $this->getUid();
        if ( !$uid && $this->checkLogin ) {
            $this->displayJson( NULL, Ap_Common_ErrorDef::ERROR_NOT_LOGIN );
        }
        
        $sdMedia = new Ap_Service_Data_Media();
        $mid = isset( $_REQUEST['mid'] ) ? intval( $_REQUEST['mid'] ) : 0;
        $step = isset( $_REQUEST['step'] ) ? intval( $_REQUEST['step'] ) : 1;

        $media = $sdMedia->getMedia( $mid , $step );  
        /*if(!$media){
            $this->displayJson('', Ap_Common_ErrorDef::ERROR_PARAM );
        }*/
        
        $files = $this->getFiles($media['type_id']);

        $_files = array();
        $_codes = array();
        $_langs = array();
        $_uid = intval( $uid );
        $_mid = intval( $mid );
        $bSrcFileExists = false;
        foreach ($files as $file) {
            if (!empty($file['content']) || count($files)==1) {
            	$srcFile = 'http://mcode.mukewang.com/' . $_mid .'/'. $file['filename'];
            	$file['src'] = $srcFile;
                $media['files'][] = $file;
                $_files[] = $file['filename'];
                $_codes[] = $file['content'];
                $_langs[] = $file['lang'];
            } else if (strtolower($file['lang']) == 'html') { //@todo 对于内容为空的文件不显示 暂时必须依赖html文件
                $media['files'][] = $file;
            }
        }

        $this->displayJson($media['files'], Ap_Common_ErrorDef::ERROR_SUCCESS );
    }
    
     private function getFiles($pid){
    	$sdProgram = new Ap_Service_Data_Program();
        $files = $sdProgram->getProgramFilesContent( $pid );
        
    	return $files;
    }
}
```php
<?php
/**
 * Ajax提交代码以运行
 * @author wangpd
 * modified : 2014/12/24
 */
class ResetcodeAction extends Ap_Base_Action {
    public function execute(){
        //是否登录
        $uid = $this->getUid();
        if ( !$uid && $this->checkLogin ) {
            $this->displayJson( NULL, Ap_Common_ErrorDef::ERROR_NOT_LOGIN );
        }
        
        $sdMedia = new Ap_Service_Data_Media();
        $mid = isset( $_REQUEST['mid'] ) ? intval( $_REQUEST['mid'] ) : 0;
        $step = isset( $_REQUEST['step'] ) ? intval( $_REQUEST['step'] ) : 1;

        $media = $sdMedia->getMedia( $mid , $step );  
        /*if(!$media){
            $this->displayJson('', Ap_Common_ErrorDef::ERROR_PARAM );
        }*/
        
        $files = $this->getFiles($media['type_id']);

        $_files = array();
        $_codes = array();
        $_langs = array();
        $_uid = intval( $uid );
        $_mid = intval( $mid );
        $bSrcFileExists = false;
        foreach ($files as $file) {
            if (!empty($file['content']) || count($files)==1) {
            	$srcFile = 'http://mcode.mukewang.com/' . $_mid .'/'. $file['filename'];
            	$file['src'] = $srcFile;
                $media['files'][] = $file;
                $_files[] = $file['filename'];
                $_codes[] = $file['content'];
                $_langs[] = $file['lang'];
            } else if (strtolower($file['lang']) == 'html') { //@todo 对于内容为空的文件不显示 暂时必须依赖html文件
                $media['files'][] = $file;
            }
        }

        $this->displayJson($media['files'], Ap_Common_ErrorDef::ERROR_SUCCESS );
    }
    
     private function getFiles($pid){
    	$sdProgram = new Ap_Service_Data_Program();
        $files = $sdProgram->getProgramFilesContent( $pid );
        
    	return $files;
    }
}
复制代码
复制代码

转载于:https://juejin.im/post/5b86682be51d4538e01902cf

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值