예제 #1
0
 public function fieldcreateAction()
 {
     $conn = Common_Db_Doctrine::getConnection(Common_Config::get('common')->database->master->dsn);
     $field_table = 'field_data_' . $this->_params['typeid'];
     $table_column = 'field_' . $this->_params['field_name'];
     $_fc = new Common_Data_Field_Config();
     $conf = array('entity_type' => $this->_params['typeid'], 'field_name' => $this->_params['field_name']);
     $count = $_fc->getCount($conf);
     if ($count == 0) {
         $conf['field_type'] = $this->_params['field_type'];
         $conf['field_label'] = $this->_params['field_label'];
         $conf['storage_type'] = $field_table;
         $_fc->insert($conf);
     }
     try {
         if (!$conn->import->tableExists($field_table)) {
             $cols = array('entityid' => array('type' => 'string', 'length' => 36, 'primary' => true), "{$table_column}" => array('type' => 'string'));
             $sql = $conn->export->createTableSql($field_table, $cols);
             $_fc->getAdapter()->query($sql[0]);
         } else {
             $cols = $conn->import->listTableColumns($field_table);
             if (!isset($cols[$table_column])) {
                 $alter = array("add" => array("{$table_column}" => array('type' => 'string')));
                 $sql = $conn->export->alterTableSql($field_table, $alter);
                 $_fc->getAdapter()->query($sql);
             }
         }
     } catch (Exception $e) {
     } catch (PDOException $e) {
     }
     return $this->fieldsAction();
 }
예제 #2
0
파일: Video.php 프로젝트: krisrita/udo
 /**
  * 视频信息
  */
 public function getVideo($videoId)
 {
     $tblVideo = new DB_Haodu_CourseVideo();
     $video = $tblVideo->fetchRow($videoId);
     if ($video) {
         $video['url'] = Common_Config::getVideoUrl($videoId);
         $video['image'] = Common_Config::getVideoImageUrl($video['image']);
         $video['duration_fmt'] = sprintf("%'.02d", floor($video['duration'] / 60)) . ":" . sprintf("%'.02d", $video['duration'] % 60);
         $video['comment_num'] = $this->getVideoCommentNum($video['id']);
         return $video;
     }
     return false;
 }
예제 #3
0
 public function indexAction()
 {
     $type = $this->_request->getParam('type');
     $cfg = Common_Config::get("cm/{$type}.ini")->index->index;
     if (isset($cfg->session)) {
         $this->view->session = Common_Session::getInstance();
     }
     foreach ($cfg->datax as $k => $v) {
         $items = Cm_Model_Datax::getFeed($v->query);
         $block = APPLICATION_PATH . '/modules/cm/views/blocks/' . $v->block;
         $out = Cm_Model_Datax::getBlock($block, $items);
         $this->view->{'datax_' . $k} = $out;
     }
     $this->render('layout/simple', null, true);
 }
예제 #4
0
파일: School.php 프로젝트: krisrita/udo
 /**
  * 学校列表
  */
 function getSchoolList($cityId = 0, $uid = 0)
 {
     $schoolIds = $this->getUserSchoolIds($uid);
     if ($schoolIds) {
         $where = "where (open_mode = 0 or id in (" . implode(",", $schoolIds) . "))";
     } else {
         $where = "where open_mode = 0";
     }
     if ($cityId > 0) {
         $where .= " and city_id={$cityId}";
     }
     $tbl = new DB_Haodu_School();
     $list = $tbl->fetchAll("id,name,title,image,flag", $where, "order by id desc");
     foreach ($list as &$school) {
         $school["image"] = Common_Config::getShoolImageUrl($school['image'], $school['flag']);
         unset($school['flag']);
     }
     unset($school);
     return $list;
 }
예제 #5
0
파일: Config.php 프로젝트: OuHaixiong/img
 /**
  * 通过键名读取图片缩略图配置文件
  * @param string $key
  * @return array | null 没有找到该项返回null
  */
 public static function getImgThumbnail($key)
 {
     // 其实以下代码可以提取出来成一个公共方法,供多个配置使用 TODO
     if (self::$_imgThumbnail === null) {
         $configPath = CONFIG_PATH . '/ImgThumbnail.php';
         //             if (!(is_file($configPath))) {
         //                 $configPath = APP_PATH . '/Configs/ImgThumbnail.php';
         //             }
         if (is_file($configPath)) {
             self::$_imgThumbnail = (require_once $configPath);
         } else {
             return null;
         }
     }
     if (isset(self::$_imgThumbnail[$key])) {
         return self::$_imgThumbnail[$key];
     } else {
         return null;
     }
 }
예제 #6
0
파일: Practise.php 프로젝트: krisrita/udo
 /**
  * 错题解析
  */
 function wrongAction()
 {
     $seq = (int) $this->get('seq', 0);
     $practiseModel = new PractiseModel();
     $uPractise = $practiseModel->getUserPractiseReport($this->uid, $this->sectionId);
     $wrongSeqList = $practiseModel->getUserWrongPractise($this->uid, $this->sectionId);
     //需要验证是否有错题
     if (!$wrongSeqList) {
         $this->redirect("/error/?errno=" . Common_Error::ERROR_PRACTISE_NO_WRONG_PARSE);
     }
     $seq = $seq == 0 ? $wrongSeqList[0] : $seq;
     $practise = $practiseModel->getPractiseBySeq($this->sectionId, $seq);
     $tree = $practise['nested_node_tree'];
     $data = array("subject_id" => $practise["item_id"], "subject_title" => $tree["node_content"], "subject_seq" => $seq, "answer" => $practise['answer'], "parse" => $practise['parse'], 'video_id' => $practise['video_id'], "create_time_fmt" => $uPractise["create_time_fmt"], "spend_time_fmt" => $uPractise["spend_time_fmt"]);
     foreach ($wrongSeqList as $wrong) {
         $data['wrong_practise_seq_list'][] = $wrong['seq'];
     }
     //上一题下一题
     $index = array_search($seq, $wrongSeqList);
     $prev = $index - 1;
     $next = $index + 1;
     if ($prev >= 0 && isset($wrongSeqList[$prev])) {
         $data['prev_seq'] = $wrongSeqList[$prev];
     }
     if (isset($wrongSeqList[$next])) {
         $data['next_seq'] = $wrongSeqList[$next];
     }
     $practiseNum = $practiseModel->getSectionPractiseNum($this->sectionId);
     $data["subject_num"] = $practiseNum;
     $data["section_id"] = $this->sectionId;
     $data["video_url"] = Common_Config::getVideoUrl($this->section['video_id']);
     foreach ($tree['nested_node_children'] as $option) {
         $letter = chr(320 + $option["node_index"]);
         $data['option_list'][] = array("id" => $option["node_index"], "letter_seq" => $letter, "content" => $option["node_content"]);
     }
     $statistic = $practiseModel->getPractiseStatistic($this->uid, $practise['item_id'], $this->sectionId);
     $data = array_merge($statistic, $data);
     if ($this->ajax) {
         $this->displayJson(Common_Error::ERROR_SUCCESS, $data);
     }
     $this->assign("practise", $data);
     $this->assign("section", $this->section);
     $this->assign("course", $this->course);
     if ($this->platform == 'ios' || $this->platform == 'android') {
         $this->getView()->display("practise/wrong-app.phtml");
         exit;
     }
 }
예제 #7
0
파일: index.php 프로젝트: OuHaixiong/img
$extension = pathinfo($filePath, PATHINFO_EXTENSION);
// 后缀,不包括点
$dirname = pathinfo($filePath, PATHINFO_DIRNAME);
// 文件目录,最后不包括斜杠/
$path = trim($filePath, '/');
$position = strpos($path, '/');
$module = substr($path, 0, $position);
$arrayFileName = explode('_', $fileName);
$size = count($arrayFileName);
if ($size < 2) {
    // 原图的缩略图(不符合规范)
    // TODO 抛404错误页面
    die('不符合规范!!!!');
}
// 查找对应的模块是否有该缩略图尺寸的配置
$moduleConfig = Common_Config::getImgThumbnail($module);
if (empty($moduleConfig)) {
    // TODO 抛404错误页面
    exit('不存在此模块的缩略图配置或配置为空');
}
$isExist = false;
$arrayFileName[1] = str_replace('X', W_JOIN_H, $arrayFileName[1]);
foreach ($moduleConfig as $k => $v) {
    if (is_array($v)) {
        // 有裁剪的,取“键”
        $k = str_replace('X', W_JOIN_H, $k);
        if ($k == $arrayFileName[1]) {
            $isExist = true;
            break;
        }
    } else {
예제 #8
0
파일: Course.php 프로젝트: krisrita/udo
 /**
  * 获得一门课的数据
  */
 public function getCourse($cid)
 {
     $tblCourse = new DB_Haodu_Course();
     $course = $tblCourse->fetchRow($cid);
     if ($course) {
         $course['image'] = Common_Config::getCourseImageUrl($course['image']);
         $course['duration'] = $course['duration'] > 0 ? $course['duration'] : $this->getCourseDuration($cid);
     }
     return $course;
 }
/**
 * 根据一组key依次取得数组的索引。
 * @param string|array $configKey 取得的数组索引的数组
 * @return null|mixed|array 如果索引存在,则返回对应的值的数组,否则返回null
 * @see Common_Config::getConfigBySearch
 */
function libConfigSearchConfig($configKey, $keys)
{
    return Common_Config::getConfigBySearch($configKey, $keys);
}