<?php
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 );
$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') {
$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
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 );
$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') {
$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