Example #1
0
 /**
  * @brief Button to output
  **/
 function printBtn()
 {
     if ($this->nextUrl) {
         $url = $this->nextUrl;
         printf('<a href="%s">%s</a><br>%s', $url->url, $url->text, "\n");
     }
     if ($this->prevUrl) {
         $url = $this->prevUrl;
         printf('<a href="%s">%s</a><br>%s', $url->url, $url->text, "\n");
     }
     // Select Language
     if (!parent::isLangChange()) {
         $url = getUrl('', 'lcm', '1', 'sel_lang', Context::getLangType(), 'return_uri', Context::get('current_url'));
         printf('<a href="%s">%s</a><br>%s', $url, 'Language : ' . Context::getLang('select_lang'), "\n");
     } else {
         printf('<a href="%s">%s</a><br>%s', Context::get('return_uri'), Context::getLang('lang_return'), "\n");
     }
     if ($this->upperUrl) {
         $url = $this->upperUrl;
         printf('<btn href="%s" name="%s">%s', $url->url, $url->text, "\n");
     }
     if ($this->homeUrl) {
         $url = $this->homeUrl;
         printf('<a btn="%s" href="%s">%s</a><br>%s', $url->text, $url->url, $url->text, "\n");
     }
 }
Example #2
0
 /**
  * @brief Display license messages
  */
 function dispInstallIntroduce()
 {
     $install_config_file = FileHandler::getRealPath('./config/install.config.php');
     if (file_exists($install_config_file)) {
         include $install_config_file;
         if (is_array($install_config)) {
             foreach ($install_config as $k => $v) {
                 $v = $k == 'db_table_prefix' ? $v . '_' : $v;
                 Context::set($k, $v, true);
             }
             unset($GLOBALS['__DB__']);
             Context::set('install_config', true, true);
             $oInstallController = getController('install');
             $output = $oInstallController->procInstall();
             if (!$output->toBool()) {
                 return $output;
             }
             header("location: ./");
             Context::close();
             exit;
         }
     }
     Context::set('l', Context::getLangType());
     $this->setTemplateFile('introduce');
 }
Example #3
0
 function _getWidgetContent()
 {
     // Arrange a widget ryeolro
     if ($this->module_info->mcontent) {
         $cache_file = sprintf("%sfiles/cache/page/%d.%s.m.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType());
         $interval = (int) $this->module_info->page_caching_interval;
         if ($interval > 0) {
             if (!file_exists($cache_file) || filesize($cache_file) < 1) {
                 $mtime = 0;
             } else {
                 $mtime = filemtime($cache_file);
             }
             if ($mtime + $interval * 60 > $_SERVER['REQUEST_TIME']) {
                 $page_content = FileHandler::readFile($cache_file);
                 $page_content = preg_replace('@<\\!--#Meta:@', '<!--Meta:', $page_content);
             } else {
                 $oWidgetController = getController('widget');
                 $page_content = $oWidgetController->transWidgetCode($this->module_info->mcontent);
                 FileHandler::writeFile($cache_file, $page_content);
             }
         } else {
             if (file_exists($cache_file)) {
                 FileHandler::removeFile($cache_file);
             }
             $page_content = $this->module_info->mcontent;
         }
     } else {
         $page_content = $this->module_info->content;
     }
     return $page_content;
 }
Example #4
0
 function _getWidgetContent()
 {
     // Arrange a widget ryeolro
     if ($this->module_info->mcontent) {
         $cache_file = sprintf("%sfiles/cache/page/%d.%s.m.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType());
         $interval = (int) $this->module_info->page_caching_interval;
         if ($interval > 0) {
             if (!file_exists($cache_file) || filesize($cache_file) < 1) {
                 $mtime = 0;
             } else {
                 $mtime = filemtime($cache_file);
             }
             if ($mtime + $interval * 60 > time()) {
                 $page_content = FileHandler::readFile($cache_file);
                 $page_content = preg_replace('@<\\!--#Meta:@', '<!--Meta:', $page_content);
             } else {
                 $oWidgetController =& getController('widget');
                 $page_content = $oWidgetController->transWidgetCode($this->module_info->mcontent);
                 FileHandler::writeFile($cache_file, $page_content);
             }
         } else {
             if (file_exists($cache_file)) {
                 FileHandler::removeFile($cache_file);
             }
             $page_content = $this->module_info->mcontent;
         }
     } else {
         preg_match_all('!(<img)([^\\>]*)(widget=)([^\\>]*?)(\\>)!is', $this->module_info->content, $matches);
         $page_content = '';
         for ($i = 0, $c = count($matches[0]); $i < $c; $i++) {
             $page_content .= preg_replace('/ style\\=\\"([^\\"]+)\\" /i', ' style="overflow:hidden;clear:both;margin:0 0 20px 0; _margin-right:10px;" ', $matches[0][$i]) . "\n\n";
         }
     }
     return $page_content;
 }
Example #5
0
 /**
  * @brief 버튼을 출력함
  **/
 function printBtn()
 {
     if ($this->nextUrl) {
         $url = $this->nextUrl;
         printf('<do type="vnd.next" label="%s"><go href="%s"/></do>%s', $url->text, $url->url, "\n");
     }
     if ($this->prevUrl) {
         $url = $this->prevUrl;
         printf('<do type="vnd.prev" label="%s"><go href="%s"/></do>%s', $url->text, $url->url, "\n");
     }
     // 기타 해당사항 없는 버튼 출력 담당 (array로 전달) type??
     if ($this->etcBtn) {
         if (is_array($this->etcBtn)) {
             foreach ($this->etcBtn as $key => $val) {
                 printf('<do type="vnd.btn%s" label="%s"><go href="%s"/></do>%s', $key, $val['text'], $val['url'], "\n");
             }
         }
     }
     // 언어선택
     if (!parent::isLangChange()) {
         $url = getUrl('', 'lcm', '1', 'sel_lang', Context::getLangType(), 'return_uri', Context::get('current_url'));
         printf('<do type="vnd.lang" label="%s"><go href="%s"/></do>%s', 'Language : ' . Context::getLang('select_lang'), $url, "\n");
     } else {
         printf('<do type="vnd.lang" label="%s"><go href="%s"/></do>%s', Context::getLang('lang_return'), Context::get('return_uri'), "\n");
     }
     if ($this->homeUrl) {
         $url = $this->homeUrl;
         printf('<do type="access" label="%s"><go href="%s"/></do>%s', $url->text, $url->url, "\n");
     }
     if ($this->upperUrl) {
         $url = $this->upperUrl;
         printf('<do type="vnd.up" label="%s"><go href="%s"/></do>%s', $url->text, $url->url, "\n");
     }
 }
Example #6
0
 /**
  * @brief 일반 요청시 출력
  **/
 function dispPageIndex()
 {
     // 템플릿에서 사용할 변수를 Context::set()
     if ($this->module_srl) {
         Context::set('module_srl', $this->module_srl);
     }
     // 캐시 파일 지정
     $cache_file = sprintf("%sfiles/cache/page/%d.%s.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType());
     $interval = (int) $this->module_info->page_caching_interval;
     if ($interval > 0) {
         if (!file_exists($cache_file)) {
             $mtime = 0;
         } else {
             $mtime = filemtime($cache_file);
         }
         if ($mtime + $interval * 60 > time()) {
             $page_content = FileHandler::readFile($cache_file);
         } else {
             $oWidgetController =& getController('widget');
             $page_content = $oWidgetController->transWidgetCode($this->module_info->content);
             FileHandler::writeFile($cache_file, $page_content);
         }
     } else {
         if (file_exists($cache_file)) {
             FileHandler::removeFile($cache_file);
         }
         $page_content = $this->module_info->content;
     }
     Context::set('module_info', $this->module_info);
     Context::set('page_content', $page_content);
     $this->setTemplateFile('content');
 }
Example #7
0
 /**
  * @brief Button to output
  */
 function printBtn()
 {
     if ($this->nextUrl) {
         $url = $this->nextUrl;
         printf('<do type="vnd.next" label="%s"><go href="%s"/></do>%s', $url->text, $url->url, "\n");
     }
     if ($this->prevUrl) {
         $url = $this->prevUrl;
         printf('<do type="vnd.prev" label="%s"><go href="%s"/></do>%s', $url->text, $url->url, "\n");
     }
     // Others are not applicable in charge of the button output (array passed) type??
     if ($this->etcBtn) {
         if (is_array($this->etcBtn)) {
             foreach ($this->etcBtn as $key => $val) {
                 printf('<do type="vnd.btn%s" label="%s"><go href="%s"/></do>%s', $key, $val['text'], $val['url'], "\n");
             }
         }
     }
     // Select Language
     if (!parent::isLangChange()) {
         $url = getUrl('', 'lcm', '1', 'sel_lang', Context::getLangType(), 'return_uri', Context::get('current_url'));
         printf('<do type="vnd.lang" label="%s"><go href="%s"/></do>%s', 'Language : ' . lang('select_lang'), $url, "\n");
     } else {
         printf('<do type="vnd.lang" label="%s"><go href="%s"/></do>%s', lang('lang_return'), Context::get('return_uri'), "\n");
     }
     if ($this->homeUrl) {
         $url = $this->homeUrl;
         printf('<do type="access" label="%s"><go href="%s"/></do>%s', $url->text, $url->url, "\n");
     }
     if ($this->upperUrl) {
         $url = $this->upperUrl;
         printf('<do type="vnd.up" label="%s"><go href="%s"/></do>%s', $url->text, $url->url, "\n");
     }
 }
 /**
  * @brief 에디터 컴포넌트가 별도의 고유 코드를 이용한다면 그 코드를 html로 변경하여 주는 method
  *
  * 이미지나 멀티미디어, 설문등 고유 코드가 필요한 에디터 컴포넌트는 고유코드를 내용에 추가하고 나서
  * DocumentModule::transContent() 에서 해당 컴포넌트의 transHtml() method를 호출하여 고유코드를 html로 변경
  **/
 function transHTML($xml_obj)
 {
     // 지정된 옵션을 구함
     $ccl_title = $xml_obj->attrs->ccl_title;
     $ccl_use_mark = $xml_obj->attrs->ccl_use_mark;
     $ccl_allow_commercial = $xml_obj->attrs->ccl_allow_commercial;
     $ccl_allow_modification = $xml_obj->attrs->ccl_allow_modification;
     // 가로/ 세로 크기를 구함
     preg_match_all('/(width|height)([^[:digit:]]+)([^;^"^\']*)/i', $xml_obj->attrs->style, $matches);
     $width = trim($matches[3][0]);
     if (!$width) {
         $width = "90%";
     }
     $height = trim($matches[3][1]);
     if (!$height) {
         $height = "50";
     }
     // 언어파일을 읽음
     Context::loadLang($this->component_path . '/lang');
     $default_title = Context::getLang('ccl_default_title');
     if (!$ccl_title) {
         $ccl_title = $default_title;
     }
     $default_message = Context::getLang('ccl_default_message');
     $option = Context::getLang('ccl_options');
     // 영리 이용 체크
     if ($ccl_allow_commercial == 'N') {
         $opt1 = '-nc';
     } else {
         $opt1 = '';
     }
     // 수정 표시 체크
     if ($ccl_allow_modification == 'N') {
         $opt2 = '-nd';
     } elseif ($ccl_allow_modification == 'SA') {
         $opt2 = '-sa';
     } else {
         $opt2 = '';
     }
     // 버전
     $version = '/3.0';
     // 언어에 따른 설정
     $lang_type = Context::getLangType();
     if ($lang_type != 'en') {
         $lang_file = 'deed.' . strtolower($lang_file);
     }
     // 마크 이용시
     $ccl_image = '';
     if ($ccl_use_mark == "Y") {
         $ccl_image = sprintf('
                     <a rel="license" href="http://creativecommons.org/licenses/by%s%s%s" onclick="window.open(this.href); return false;"><img src="http://i.creativecommons.org/l/by%s%s%s/88x31.png" alt="Creative Commons License" style="margin-bottom:5px;border:0;" /></a><br />', $opt1, $opt2, $version, $opt1, $opt2, $version);
     }
     // 결과물 생성
     $text = $ccl_image . sprintf($default_message, $opt1, $opt2, $version, '', $ccl_title, $option['ccl_allow_commercial'][$ccl_allow_commercial], $option['ccl_allow_modification'][$ccl_allow_modification], $version);
     $style = sprintf('<style type="text/css">.cc_license { clear:both; margin:20px auto 20px auto; padding:8px; width:%s;border:1px solid #c0c0c0; color:#808080; text-align:center; } .cc_license legend { font-weight:bold; } .cc_license a { color:#404040; text-decoration:none; } .cc_license a:hover { text-decoration:underline; </style>', $width);
     $output = sprintf('%s<fieldset class="cc_license"><legend>%s</legend>%s</fieldset>', $style, $ccl_title, $text);
     return $output;
 }
Example #9
0
/**
 * Get or set lang variable.
 *
 * @param string $code Lang variable name
 * @param string $value `$code`s value
 * @return mixed
 */
function lang($code, $value = null)
{
    if (!$GLOBALS['lang'] instanceof Rhymix\Framework\Lang) {
        $GLOBALS['lang'] = Rhymix\Framework\Lang::getInstance(Context::getLangType() ?: config('locale.default_lang') ?: 'ko');
        $GLOBALS['lang']->loadDirectory(RX_BASEDIR . 'common/lang', 'common');
    }
    if ($value === null) {
        return $GLOBALS['lang']->get($code);
    } else {
        $GLOBALS['lang']->set($code, $value);
    }
}
Example #10
0
 /**
  * @brief Initialization
  */
 function init()
 {
     // Get a template path (page in the administrative template tpl putting together)
     $this->setTemplatePath($this->module_path . 'tpl');
     switch ($this->module_info->page_type) {
         case 'WIDGET':
             $this->cache_file = sprintf("%sfiles/cache/page/%d.%s.%s.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType(), Context::getSslStatus());
             $this->interval = (int) $this->module_info->page_caching_interval;
             break;
         case 'OUTSIDE':
             $this->cache_file = sprintf("%sfiles/cache/opage/%d.%s.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getSslStatus());
             $this->interval = (int) $this->module_info->page_caching_interval;
             $this->path = $this->module_info->path;
             break;
     }
 }
Example #11
0
 /**
  * @brief Display license messages
  */
 function dispInstallIntroduce()
 {
     $install_config_file = FileHandler::getRealPath('./config/install.config.php');
     if (file_exists($install_config_file)) {
         /**
         * If './config/install.config.php' file created  and write array shown in the example below, XE installed using config file.
         * ex )
          $install_config = array(
          'db_type' =>'mysqli_innodb',
          'db_port' =>'3306',
          'db_hostname' =>'localhost',
          'db_userid' =>'root',
          'db_password' =>'root',
          'db_database' =>'xe_database',
          'db_table_prefix' =>'xe',
          'user_rewrite' =>'N',
          'time_zone' =>'0000',
          'email_address' =>'*****@*****.**',
          'password' =>'pass',
          'password2' =>'pass',
          'nick_name' =>'admin',
          'user_id' =>'admin',
          'lang_type' =>'ko',	// en, jp, ...
          );
         */
         include $install_config_file;
         if (is_array($install_config)) {
             foreach ($install_config as $k => $v) {
                 $v = $k == 'db_table_prefix' ? $v . '_' : $v;
                 Context::set($k, $v, true);
             }
             unset($GLOBALS['__DB__']);
             Context::set('install_config', true, true);
             $oInstallController = getController('install');
             $output = $oInstallController->procInstall();
             if (!$output->toBool()) {
                 return $output;
             }
             header("location: ./");
             Context::close();
             exit;
         }
     }
     Context::set('l', Context::getLangType());
     $this->setTemplateFile('introduce');
 }
 /**
  * @brief 입력받은 정보로 설치를 함
  **/
 function procInstall()
 {
     // 설치가 되어 있는지에 대한 체크
     if (Context::isInstalled()) {
         return new Object(-1, 'msg_already_installed');
     }
     // 설치시 임시로 최고관리자로 지정
     $logged_info->is_admin = 'Y';
     $_SESSION['logged_info'] = $logged_info;
     Context::set('logged_info', $logged_info);
     // DB와 관련된 변수를 받음
     $db_info = Context::gets('db_type', 'db_port', 'db_hostname', 'db_userid', 'db_password', 'db_database', 'db_table_prefix', 'time_zone', 'use_rewrite');
     if ($db_info->use_rewrite != 'Y') {
         $db_info->use_rewrite = 'N';
     }
     if (!$db_info->default_url) {
         $db_info->default_url = Context::getRequestUri();
     }
     $db_info->lang_type = Context::getLangType();
     // DB의 타입과 정보를 등록
     Context::setDBInfo($db_info);
     // DB Instance 생성
     $oDB =& DB::getInstance();
     // DB접속이 가능한지 체크
     $output = $oDB->getError();
     if (!$oDB->isConnected()) {
         return $oDB->getError();
     }
     // firebird는 설치시에 트랜젝션을 사용하지 않음
     if ($db_info->db_type != "firebird") {
         $oDB->begin();
     }
     // 모든 모듈의 설치
     $this->installDownloadedModule();
     if ($db_info->db_type != "firebird") {
         $oDB->commit();
     }
     // config 파일 생성
     if (!$this->makeConfigFile()) {
         return new Object(-1, 'msg_install_failed');
     }
     // 설치 완료 메세지 출력
     $this->setMessage('msg_install_completed');
 }
Example #13
0
 /**
  * Parse xml data to extract values from it and construct data object
  * @param string $input a data buffer containing xml data
  * @param mixed $arg1 ???
  * @param mixed $arg2 ???
  * @return array Returns a resultant data object or NULL in case of error
  */
 function parse($input = '', $arg1 = NULL, $arg2 = NULL)
 {
     // Save the compile starting time for debugging
     if (__DEBUG__ == 3) {
         $start = getMicroTime();
     }
     $this->lang = Context::getLangType();
     $this->input = $input ? $input : $GLOBALS['HTTP_RAW_POST_DATA'];
     $this->input = str_replace(array('', ''), array('', ''), $this->input);
     // extracts a supported language
     preg_match_all("/xml:lang=\"([^\"].+)\"/i", $this->input, $matches);
     // extracts the supported lanuage when xml:lang is used
     if (count($matches[1]) && ($supported_lang = array_unique($matches[1]))) {
         $tmpLangList = array_flip($supported_lang);
         // if lang of the first log-in user doesn't exist, apply en by default if exists. Otherwise apply the first lang.
         if (!isset($tmpLangList[$this->lang])) {
             if (isset($tmpLangList['en'])) {
                 $this->lang = 'en';
             } else {
                 $this->lang = array_shift($supported_lang);
             }
         }
         // uncheck the language if no specific language is set.
     } else {
         $this->lang = '';
     }
     $this->oParser = xml_parser_create('UTF-8');
     xml_set_object($this->oParser, $this);
     xml_set_element_handler($this->oParser, "_tagOpen", "_tagClosed");
     xml_set_character_data_handler($this->oParser, "_tagBody");
     xml_parse($this->oParser, $this->input);
     xml_parser_free($this->oParser);
     if (!count($this->output)) {
         return;
     }
     $output = array_shift($this->output);
     // Save compile starting time for debugging
     if (__DEBUG__ == 3) {
         $GLOBALS['__xmlparse_elapsed__'] += getMicroTime() - $start;
     }
     return $output;
 }
 function procMagiccontentSetup()
 {
     $req = Context::getRequestVars();
     $widget_sequence = $req->widget_sequence;
     $is_complete = $req->is_complete;
     unset($req->is_complete);
     unset($req->widget_sequence);
     unset($req->act);
     foreach ($req as $key => $value) {
         if ($value == '') {
             unset($req->{$key});
         }
     }
     $serialize_data = serialize($req);
     $args = new stdClass();
     $args->data = $serialize_data;
     $args->widget_sequence = $widget_sequence;
     $args->is_complete = $is_complete;
     if ($is_complete == 1) {
         $dargs = new stdClass();
         $dargs->widget_sequence = $widget_sequence;
         $dargs->is_complete = 0;
         $output = executeQuery('magiccontent.deleteMagicContentData', $dargs);
     }
     $oMagiccontentModel =& getModel('magiccontent');
     if ($oMagiccontentModel->getSetupData($widget_sequence, $is_complete) === false) {
         $args->data_srl = getNextSequence();
         $output = executeQuery('magiccontent.insertMagicContentData', $args);
     } else {
         $output = executeQuery('magiccontent.updateMagicContentData', $args);
     }
     $oCacheHandler = CacheHandler::getInstance('template');
     if ($oCacheHandler->isSupport()) {
         $key = 'widget_cache:' . $widget_sequence;
         $oCacheHandler->delete($key);
     }
     $lang_type = Context::getLangType();
     $cache_file = sprintf('%s%d.%s.cache', $this->cache_path, $widget_sequence, $lang_type);
     FileHandler::removeFile($cache_file);
     return new Object(0, 'success');
 }
Example #15
0
 function getLang($key, $site_srl)
 {
     if (!$this->langs[$site_srl]) {
         $this->langs[$site_srl] = array();
         $args = new stdClass();
         $args->site_srl = $site_srl;
         $args->lang_code = Context::getLangType();
         $output = executeQueryArray("syndication.getLang", $args);
         if (!$output->toBool() || !$output->data) {
             return $key;
         }
         foreach ($output->data as $value) {
             $this->langs[$site_srl][$value->name] = $value->value;
         }
     }
     if ($this->langs[$site_srl][$key]) {
         return $this->langs[$site_srl][$key];
     } else {
         return $key;
     }
 }
Example #16
0
 /**
  * @brief xml 파싱
  **/
 function parse($input = '')
 {
     // 디버그를 위한 컴파일 시작 시간 저장
     if (__DEBUG__ == 3) {
         $start = getMicroTime();
     }
     $this->lang = Context::getLangType();
     $this->input = $input ? $input : $GLOBALS['HTTP_RAW_POST_DATA'];
     // 지원언어 종류를 뽑음
     preg_match_all("/xml:lang=\"([^\"].+)\"/i", $this->input, $matches);
     // xml:lang이 쓰였을 경우 지원하는 언어종류를 뽑음
     if (count($matches[1]) && ($supported_lang = array_unique($matches[1]))) {
         // supported_lang에 현재 접속자의 lang이 없으면 en이 있는지 확인하여 en이 있으면 en을 기본, 아니면 첫번째것을..
         if (!in_array($this->lang, $supported_lang)) {
             if (in_array('en', $supported_lang)) {
                 $this->lang = 'en';
             } else {
                 $this->lang = array_shift($supported_lang);
             }
         }
         // 특별한 언어가 지정되지 않았다면 언어체크를 하지 않음
     } else {
         unset($this->lang);
     }
     $this->oParser = xml_parser_create('UTF-8');
     xml_set_object($this->oParser, $this);
     xml_set_element_handler($this->oParser, "_tagOpen", "_tagClosed");
     xml_set_character_data_handler($this->oParser, "_tagBody");
     xml_parse($this->oParser, $this->input);
     xml_parser_free($this->oParser);
     if (!count($this->output)) {
         return;
     }
     $output = array_shift($this->output);
     // 디버그를 위한 컴파일 시작 시간 저장
     if (__DEBUG__ == 3) {
         $GLOBALS['__xmlparse_elapsed__'] += getMicroTime() - $start;
     }
     return $output;
 }
Example #17
0
<?php

// ko/en/...
$lang = Context::getLangType();
$logged_info = Context::get('logged_info');
$oMenuAdminController = getAdminController('menu');
// sitemap
$sitemap = array('GNB' => array('title' => 'Main menu', 'list' => array(array('menu_name' => 'Welcome Page', 'module_type' => 'WIDGET', 'module_id' => 'index'), array('menu_name' => 'Board', 'module_type' => 'board', 'module_id' => 'board', 'list' => array(array('menu_name' => 'SAMPLE 1', 'is_shortcut' => 'Y', 'shortcut_target' => '#', 'list' => array(array('menu_name' => 'SAMPLE 1-1', 'is_shortcut' => 'Y', 'shortcut_target' => '#'))), array('menu_name' => 'SAMPLE 2', 'is_shortcut' => 'Y', 'shortcut_target' => '#'), array('menu_name' => 'SAMPLE 3', 'is_shortcut' => 'Y', 'shortcut_target' => '#'))), array('menu_name' => 'XEIcon', 'module_type' => 'WIDGET', 'module_id' => 'xeicon'))), 'UNB' => array('title' => 'Utility menu', 'list' => array(array('menu_name' => 'XE Official Site', 'is_shortcut' => 'Y', 'open_window' => 'Y', 'shortcut_target' => 'http://www.xpressengine.com'), array('menu_name' => 'GitHub', 'is_shortcut' => 'Y', 'open_window' => 'Y', 'shortcut_target' => 'https://github.com/xpressengine'))), 'FNB' => array('title' => 'Footer Menu', 'list' => array(array('menu_name' => 'Welcome Page', 'is_shortcut' => 'Y', 'shortcut_target' => 'index', 'list' => array(array('menu_name' => 'SAMPLE 1', 'is_shortcut' => 'Y', 'shortcut_target' => '#'), array('menu_name' => 'SAMPLE 2', 'is_shortcut' => 'Y', 'shortcut_target' => '#'), array('menu_name' => 'SAMPLE 3', 'is_shortcut' => 'Y', 'shortcut_target' => '#'))), array('menu_name' => 'Board', 'is_shortcut' => 'Y', 'shortcut_target' => 'board', 'list' => array(array('menu_name' => 'SAMPLE 1', 'is_shortcut' => 'Y', 'shortcut_target' => '#'), array('menu_name' => 'SAMPLE 2', 'is_shortcut' => 'Y', 'shortcut_target' => '#'))), array('menu_name' => 'XEIcon', 'is_shortcut' => 'Y', 'shortcut_target' => 'xeicon', 'list' => array(array('menu_name' => 'SAMPLE 1', 'is_shortcut' => 'Y', 'shortcut_target' => '#'))))));
function __makeMenu(&$list, $parent_srl)
{
    $oMenuAdminController = getAdminController('menu');
    foreach ($list as $idx => &$item) {
        Context::set('parent_srl', $parent_srl, TRUE);
        Context::set('menu_name', $item['menu_name'], TRUE);
        Context::set('module_type', $item['module_type'], TRUE);
        Context::set('module_id', $item['module_id'], TRUE);
        if ($item['is_shortcut'] === 'Y') {
            Context::set('is_shortcut', $item['is_shortcut'], TRUE);
            Context::set('shortcut_target', $item['shortcut_target'], TRUE);
        } else {
            Context::set('is_shortcut', 'N', TRUE);
            Context::set('shortcut_target', null, TRUE);
        }
        $output = $oMenuAdminController->procMenuAdminInsertItem();
        if ($output instanceof Object && !$output->toBool()) {
            return $output;
        }
        $menu_srl = $oMenuAdminController->get('menu_item_srl');
        $item['menu_srl'] = $menu_srl;
        if ($item['list']) {
            __makeMenu($item['list'], $menu_srl);
Example #18
0
 /**
  * @brief 모듈의 conf/info.xml 을 읽어서 정보를 구함
  * 이것 역시 캐싱을 통해서 xml parsing 시간을 줄인다..
  **/
 function getWidgetStyleInfo($widgetStyle)
 {
     $widgetStyle_path = $this->getWidgetStylePath($widgetStyle);
     if (!$widgetStyle_path) {
         return;
     }
     $xml_file = sprintf("%sskin.xml", $widgetStyle_path);
     if (!file_exists($xml_file)) {
         return;
     }
     // cache 파일을 비교하여 문제 없으면 include하고 $widgetStyle_info 변수를 return
     $cache_file = sprintf('./files/cache/widgetstyles/%s.%s.cache.php', $widgetStyle, Context::getLangType());
     if (file_exists($cache_file) && filemtime($cache_file) > filemtime($xml_file)) {
         @(include $cache_file);
         return $widgetStyle_info;
     }
     // cache 파일이 없으면 xml parsing하고 변수화 한 후에 캐시 파일에 쓰고 변수 바로 return
     $oXmlParser = new XmlParser();
     $tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file);
     $xml_obj = $tmp_xml_obj->widgetstyle;
     if (!$xml_obj) {
         return;
     }
     $buff = '';
     // 위젯의 제목, 버전
     $buff .= sprintf('$widgetStyle_info->widgetStyle = "%s";', $widgetStyle);
     $buff .= sprintf('$widgetStyle_info->path = "%s";', $widgetStyle_path);
     $buff .= sprintf('$widgetStyle_info->title = "%s";', $xml_obj->title->body);
     $buff .= sprintf('$widgetStyle_info->description = "%s";', $xml_obj->description->body);
     $buff .= sprintf('$widgetStyle_info->version = "%s";', $xml_obj->version->body);
     sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d);
     $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d);
     $buff .= sprintf('$widgetStyle_info->date = "%s";', $date);
     $buff .= sprintf('$widgetStyle_info->homepage = "%s";', $xml_obj->link->body);
     $buff .= sprintf('$widgetStyle_info->license = "%s";', $xml_obj->license->body);
     $buff .= sprintf('$widgetStyle_info->license_link = "%s";', $xml_obj->license->attrs->link);
     // preview
     if (!$xml_obj->preview->body) {
         $xml_obj->preview->body = 'preview.jpg';
     }
     $preview_file = sprintf("%s%s", $widgetStyle_path, $xml_obj->preview->body);
     if (file_exists($preview_file)) {
         $buff .= sprintf('$widgetStyle_info->preview = "%s";', $preview_file);
     }
     // 작성자 정보
     if (!is_array($xml_obj->author)) {
         $author_list[] = $xml_obj->author;
     } else {
         $author_list = $xml_obj->author;
     }
     for ($i = 0; $i < count($author_list); $i++) {
         $buff .= sprintf('$widgetStyle_info->author[' . $i . ']->name = "%s";', $author_list[$i]->name->body);
         $buff .= sprintf('$widgetStyle_info->author[' . $i . ']->email_address = "%s";', $author_list[$i]->attrs->email_address);
         $buff .= sprintf('$widgetStyle_info->author[' . $i . ']->homepage = "%s";', $author_list[$i]->attrs->link);
     }
     // history
     if ($xml_obj->history) {
         if (!is_array($xml_obj->history)) {
             $history_list[] = $xml_obj->history;
         } else {
             $history_list = $xml_obj->history;
         }
         for ($i = 0; $i < count($history_list); $i++) {
             sscanf($history_list[$i]->attrs->date, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d);
             $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d);
             $buff .= sprintf('$widgetStyle_info->history[' . $i . ']->description = "%s";', $history_list[$i]->description->body);
             $buff .= sprintf('$widgetStyle_info->history[' . $i . ']->version = "%s";', $history_list[$i]->attrs->version);
             $buff .= sprintf('$widgetStyle_info->history[' . $i . ']->date = "%s";', $date);
             if ($history_list[$i]->author) {
                 !is_array($history_list[$i]->author) ? $obj->author_list[] = $history_list[$i]->author : ($obj->author_list = $history_list[$i]->author);
                 for ($j = 0; $j < count($obj->author_list); $j++) {
                     $buff .= sprintf('$widgetStyle_info->history[' . $i . ']->author[' . $j . ']->name = "%s";', $obj->author_list[$j]->name->body);
                     $buff .= sprintf('$widgetStyle_info->history[' . $i . ']->author[' . $j . ']->email_address = "%s";', $obj->author_list[$j]->attrs->email_address);
                     $buff .= sprintf('$widgetStyle_info->history[' . $i . ']->author[' . $j . ']->homepage = "%s";', $obj->author_list[$j]->attrs->link);
                 }
             }
             if ($history_list[$i]->log) {
                 !is_array($history_list[$i]->log) ? $obj->log_list[] = $history_list[$i]->log : ($obj->log_list = $history_list[$i]->log);
                 for ($j = 0; $j < count($obj->log_list); $j++) {
                     $buff .= sprintf('$widgetStyle_info->history[' . $i . ']->logs[' . $j . ']->text = "%s";', $obj->log_list[$j]->body);
                     $buff .= sprintf('$widgetStyle_info->history[' . $i . ']->logs[' . $j . ']->link = "%s";', $obj->log_list[$j]->attrs->link);
                 }
             }
         }
     }
     // 추가 변수 (템플릿에서 사용할 제작자 정의 변수)
     $extra_var_groups = $xml_obj->extra_vars->group;
     if (!$extra_var_groups) {
         $extra_var_groups = $xml_obj->extra_vars;
     }
     if (!is_array($extra_var_groups)) {
         $extra_var_groups = array($extra_var_groups);
     }
     foreach ($extra_var_groups as $group) {
         $extra_vars = $group->var;
         if (!is_array($group->var)) {
             $extra_vars = array($group->var);
         }
         if ($extra_vars[0]->attrs->id || $extra_vars[0]->attrs->name) {
             $extra_var_count = count($extra_vars);
             $buff .= sprintf('$widgetStyle_info->extra_var_count = "%s";', $extra_var_count);
             for ($i = 0; $i < $extra_var_count; $i++) {
                 unset($var);
                 unset($options);
                 $var = $extra_vars[$i];
                 $id = $var->attrs->id ? $var->attrs->id : $var->attrs->name;
                 $name = $var->name->body ? $var->name->body : $var->title->body;
                 $type = $var->attrs->type ? $var->attrs->type : $var->type->body;
                 $buff .= sprintf('$widgetStyle_info->extra_var->%s->group = "%s";', $id, $group->title->body);
                 $buff .= sprintf('$widgetStyle_info->extra_var->%s->name = "%s";', $id, $name);
                 $buff .= sprintf('$widgetStyle_info->extra_var->%s->type = "%s";', $id, $type);
                 if ($type == 'filebox') {
                     $buff .= sprintf('$widgetStyle_info->extra_var->%s->filter = "%s";', $id, $var->attrs->filter);
                 }
                 $buff .= sprintf('$widgetStyle_info->extra_var->%s->value = $vars->%s;', $id, $id);
                 $buff .= sprintf('$widgetStyle_info->extra_var->%s->description = "%s";', $id, str_replace('"', '\\"', $var->description->body));
                 $options = $var->options;
                 if (!$options) {
                     continue;
                 }
                 if (!is_array($options)) {
                     $options = array($options);
                 }
                 $options_count = count($options);
                 for ($j = 0; $j < $options_count; $j++) {
                     $buff .= sprintf('$widgetStyle_info->extra_var->%s->options["%s"] = "%s";', $id, $options[$j]->value->body, $options[$j]->name->body);
                 }
             }
         }
     }
     $buff = '<?php if(!defined("__ZBXE__")) exit(); ' . $buff . ' ?>';
     FileHandler::writeFile($cache_file, $buff);
     if (file_exists($cache_file)) {
         @(include $cache_file);
     }
     return $widgetStyle_info;
 }
 /**
  * Copy the post
  * @param array $document_srl_list
  * @param int $module_srl
  * @param int $category_srl
  * @return object
  */
 function copyDocumentModule($document_srl_list, $module_srl, $category_srl)
 {
     if (count($document_srl_list) < 1) {
         return;
     }
     $oDocumentModel = getModel('document');
     $oDocumentController = getController('document');
     $oFileModel = getModel('file');
     $oDB =& DB::getInstance();
     $oDB->begin();
     $triggerObj = new stdClass();
     $triggerObj->document_srls = implode(',', $document_srl_list);
     $triggerObj->module_srl = $module_srl;
     $triggerObj->category_srl = $category_srl;
     // Call a trigger (before)
     $output = ModuleHandler::triggerCall('document.copyDocumentModule', 'before', $triggerObj);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     $extraVarsList = $oDocumentModel->getDocumentExtraVarsFromDB($document_srl_list);
     $extraVarsListByDocumentSrl = array();
     if (is_array($extraVarsList->data)) {
         foreach ($extraVarsList->data as $value) {
             if (!isset($extraVarsListByDocumentSrl[$value->document_srl])) {
                 $extraVarsListByDocumentSrl[$value->document_srl] = array();
             }
             $extraVarsListByDocumentSrl[$value->document_srl][] = $value;
         }
     }
     for ($i = count($document_srl_list) - 1; $i >= 0; $i--) {
         $document_srl = $document_srl_list[$i];
         $oDocument = $oDocumentModel->getDocument($document_srl);
         if (!$oDocument->isExists()) {
             continue;
         }
         $obj = $oDocument->getObjectVars();
         $extraVars = $extraVarsListByDocumentSrl[$document_srl];
         if ($module_srl == $obj->module_srl) {
             if (is_array($extraVars)) {
                 foreach ($extraVars as $extraItem) {
                     if ($extraItem->var_idx >= 0) {
                         $obj->{'extra_vars' . $extraItem->var_idx} = $extraItem->value;
                     }
                 }
             }
         }
         $obj->module_srl = $module_srl;
         $obj->document_srl = getNextSequence();
         $obj->category_srl = $category_srl;
         $obj->password_is_hashed = true;
         $obj->comment_count = 0;
         $obj->trackback_count = 0;
         // Pre-register the attachment
         if ($oDocument->hasUploadedFiles()) {
             $files = $oDocument->getUploadedFiles();
             foreach ($files as $val) {
                 $file_info = array();
                 $file_info['tmp_name'] = $val->uploaded_filename;
                 $file_info['name'] = $val->source_filename;
                 $oFileController = getController('file');
                 $inserted_file = $oFileController->insertFile($file_info, $module_srl, $obj->document_srl, 0, true);
                 // if image/video files
                 if ($val->direct_download == 'Y') {
                     $source_filename = substr($val->uploaded_filename, 2);
                     $target_filename = substr($inserted_file->get('uploaded_filename'), 2);
                     $obj->content = str_replace($source_filename, $target_filename, $obj->content);
                     // If binary file
                 } else {
                     $obj->content = str_replace('file_srl=' . $val->file_srl, 'file_srl=' . $inserted_file->get('file_srl'), $obj->content);
                     $obj->content = str_replace('sid=' . $val->sid, 'sid=' . $inserted_file->get('sid'), $obj->content);
                 }
             }
         }
         // Write a post
         $output = $oDocumentController->insertDocument($obj, true, true);
         if (!$output->toBool()) {
             $oDB->rollback();
             return $output;
         }
         // copy multi language contents
         if (is_array($extraVars)) {
             foreach ($extraVars as $value) {
                 if ($value->idx >= 0 && $value->lang_code == Context::getLangType()) {
                     continue;
                 }
                 if ($value->var_idx < 0 || $module_srl == $value->module_srl && $value->var_idx >= 0) {
                     $oDocumentController->insertDocumentExtraVar($value->module_srl, $obj->document_srl, $value->var_idx, $value->value, $value->eid, $value->lang_code);
                 }
             }
         }
         // Move the comments
         if ($oDocument->getCommentCount()) {
             $oCommentModel = getModel('comment');
             $comment_output = $oCommentModel->getCommentList($document_srl, 0, true, 99999999);
             $comments = $comment_output->data;
             if (count($comments) > 0) {
                 $oCommentController = getController('comment');
                 $success_count = 0;
                 $p_comment_srl = array();
                 foreach ($comments as $comment_obj) {
                     $comment_srl = getNextSequence();
                     $p_comment_srl[$comment_obj->comment_srl] = $comment_srl;
                     // Pre-register the attachment
                     if ($comment_obj->uploaded_count) {
                         $files = $oFileModel->getFiles($comment_obj->comment_srl, true);
                         foreach ($files as $val) {
                             $file_info = array();
                             $file_info['tmp_name'] = $val->uploaded_filename;
                             $file_info['name'] = $val->source_filename;
                             $oFileController = getController('file');
                             $inserted_file = $oFileController->insertFile($file_info, $module_srl, $comment_srl, 0, true);
                             // if image/video files
                             if ($val->direct_download == 'Y') {
                                 $source_filename = substr($val->uploaded_filename, 2);
                                 $target_filename = substr($inserted_file->get('uploaded_filename'), 2);
                                 $comment_obj->content = str_replace($source_filename, $target_filename, $comment_obj->content);
                                 // If binary file
                             } else {
                                 $comment_obj->content = str_replace('file_srl=' . $val->file_srl, 'file_srl=' . $inserted_file->get('file_srl'), $comment_obj->content);
                                 $comment_obj->content = str_replace('sid=' . $val->sid, 'sid=' . $inserted_file->get('sid'), $comment_obj->content);
                             }
                         }
                     }
                     $comment_obj->module_srl = $obj->module_srl;
                     $comment_obj->document_srl = $obj->document_srl;
                     $comment_obj->comment_srl = $comment_srl;
                     if ($comment_obj->parent_srl) {
                         $comment_obj->parent_srl = $p_comment_srl[$comment_obj->parent_srl];
                     }
                     $output = $oCommentController->insertComment($comment_obj, true);
                     if ($output->toBool()) {
                         $success_count++;
                     }
                 }
                 $oDocumentController->updateCommentCount($obj->document_srl, $success_count, $comment_obj->nick_name, true);
             }
         }
         // Move the trackbacks
         $oTrackbackModel = getModel('trackback');
         if ($oTrackbackModel && $oDocument->getTrackbackCount()) {
             $trackbacks = $oTrackbackModel->getTrackbackList($oDocument->document_srl);
             if (count($trackbacks)) {
                 $success_count = 0;
                 foreach ($trackbacks as $trackback_obj) {
                     $trackback_obj->trackback_srl = getNextSequence();
                     $trackback_obj->module_srl = $obj->module_srl;
                     $trackback_obj->document_srl = $obj->document_srl;
                     $output = executeQuery('trackback.insertTrackback', $trackback_obj);
                     if ($output->toBool()) {
                         $success_count++;
                     }
                 }
                 // Update the number of trackbacks
                 $oDocumentController->updateTrackbackCount($obj->document_srl, $success_count);
             }
         }
         $copied_srls[$document_srl] = $obj->document_srl;
     }
     // Call a trigger (before)
     $triggerObj->copied_srls = $copied_srls;
     $output = ModuleHandler::triggerCall('document.copyDocumentModule', 'after', $triggerObj);
     if (!$output->toBool()) {
         $oDB->rollback();
         return $output;
     }
     $oDB->commit();
     $output = new Object();
     $output->add('copied_srls', $copied_srls);
     return $output;
 }
Example #20
0
/**
 * Change the time format YYYYMMDDHHIISS to the user defined format
 *
 * @param string|int $str YYYYMMDDHHIISS format time values
 * @param string $format Time format of php date() function
 * @param bool $conversion Means whether to convert automatically according to the language
 * @return string
 */
function zdate($str, $format = 'Y-m-d H:i:s', $conversion = TRUE)
{
    // return null if no target time is specified
    if (!$str) {
        return;
    }
    // convert the date format according to the language
    if ($conversion == TRUE) {
        switch (Context::getLangType()) {
            case 'en':
            case 'es':
                if ($format == 'Y-m-d') {
                    $format = 'M d, Y';
                } elseif ($format == 'Y-m-d H:i:s') {
                    $format = 'M d, Y H:i:s';
                } elseif ($format == 'Y-m-d H:i') {
                    $format = 'M d, Y H:i';
                }
                break;
            case 'vi':
                if ($format == 'Y-m-d') {
                    $format = 'd-m-Y';
                } elseif ($format == 'Y-m-d H:i:s') {
                    $format = 'H:i:s d-m-Y';
                } elseif ($format == 'Y-m-d H:i') {
                    $format = 'H:i d-m-Y';
                }
                break;
        }
    }
    // If year value is less than 1970, handle it separately.
    if ((int) substr($str, 0, 4) < 1970) {
        $hour = (int) substr($str, 8, 2);
        $min = (int) substr($str, 10, 2);
        $sec = (int) substr($str, 12, 2);
        $year = (int) substr($str, 0, 4);
        $month = (int) substr($str, 4, 2);
        $day = (int) substr($str, 6, 2);
        // leading zero?
        $lz = create_function('$n', 'return ($n>9?"":"0").$n;');
        $trans = array('Y' => $year, 'y' => $lz($year % 100), 'm' => $lz($month), 'n' => $month, 'd' => $lz($day), 'j' => $day, 'G' => $hour, 'H' => $lz($hour), 'g' => $hour % 12, 'h' => $lz($hour % 12), 'i' => $lz($min), 's' => $lz($sec), 'M' => getMonthName($month), 'F' => getMonthName($month, FALSE));
        $string = strtr($format, $trans);
    } else {
        // if year value is greater than 1970, get unixtime by using ztime() for date() function's argument.
        $string = date($format, ztime($str));
    }
    // change day and am/pm for each language
    $unit_week = Context::getLang('unit_week');
    $unit_meridiem = Context::getLang('unit_meridiem');
    $string = str_replace(array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'), $unit_week, $string);
    $string = str_replace(array('am', 'pm', 'AM', 'PM'), $unit_meridiem, $string);
    return $string;
}
Example #21
0
 /**
  * Get information by reading conf/info.xml in the module
  * It uses caching to reduce time for xml parsing ..
  * @param string $layout
  * @param object $info
  * @param string $layoutType (P : PC, M : Mobile)
  * @return object info of layout
  */
 function getLayoutInfo($layout, $info = null, $layout_type = "P")
 {
     if ($info) {
         $layout_title = $info->title;
         $layout = $info->layout;
         $layout_srl = $info->layout_srl;
         $site_srl = $info->site_srl;
         $vars = unserialize($info->extra_vars);
         if ($info->module_srl) {
             $layout_path = preg_replace('/([a-zA-Z0-9\\_\\.]+)(\\.html)$/', '', $info->layout_path);
             $xml_file = sprintf('%sskin.xml', $layout_path);
         }
     }
     // Get a path of the requested module. Return if not exists.
     if (!$layout_path) {
         $layout_path = $this->getLayoutPath($layout, $layout_type);
     }
     if (!is_dir($layout_path)) {
         return;
     }
     // Read the xml file for module skin information
     if (!$xml_file) {
         $xml_file = sprintf("%sconf/info.xml", $layout_path);
     }
     if (!file_exists($xml_file)) {
         $layout_info = new stdClass();
         $layout_info->title = $layout;
         $layout_info->layout = $layout;
         $layout_info->path = $layout_path;
         $layout_info->layout_title = $layout_title;
         if (!$layout_info->layout_type) {
             $layout_info->layout_type = $layout_type;
         }
         return $layout_info;
     }
     // Include the cache file if it is valid and then return $layout_info variable
     if (!$layout_srl) {
         $cache_file = $this->getLayoutCache($layout, Context::getLangType(), $layout_type);
     } else {
         $cache_file = $this->getUserLayoutCache($layout_srl, Context::getLangType());
     }
     if (file_exists($cache_file) && filemtime($cache_file) > filemtime($xml_file)) {
         include $cache_file;
         if ($layout_info->extra_var && $vars) {
             foreach ($vars as $key => $value) {
                 if (!$layout_info->extra_var->{$key} && !$layout_info->{$key}) {
                     $layout_info->{$key} = $value;
                 }
             }
         }
         if (!$layout_info->title) {
             $layout_info->title = $layout;
         }
         return $layout_info;
     }
     // If no cache file exists, parse the xml and then return the variable.
     $oXmlParser = new XmlParser();
     $tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file);
     if ($tmp_xml_obj->layout) {
         $xml_obj = $tmp_xml_obj->layout;
     } elseif ($tmp_xml_obj->skin) {
         $xml_obj = $tmp_xml_obj->skin;
     }
     if (!$xml_obj) {
         return;
     }
     $buff = array();
     $buff[] = '$layout_info = new stdClass;';
     $buff[] = sprintf('$layout_info->site_srl = "%s";', $site_srl);
     if ($xml_obj->version && $xml_obj->attrs->version == '0.2') {
         // Layout title, version and other information
         sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d);
         $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d);
         $buff[] = sprintf('$layout_info->layout = "%s";', $layout);
         $buff[] = sprintf('$layout_info->type = "%s";', $xml_obj->attrs->type);
         $buff[] = sprintf('$layout_info->path = "%s";', $layout_path);
         $buff[] = sprintf('$layout_info->title = "%s";', $xml_obj->title->body);
         $buff[] = sprintf('$layout_info->description = "%s";', $xml_obj->description->body);
         $buff[] = sprintf('$layout_info->version = "%s";', $xml_obj->version->body);
         $buff[] = sprintf('$layout_info->date = "%s";', $date);
         $buff[] = sprintf('$layout_info->homepage = "%s";', $xml_obj->link->body);
         $buff[] = sprintf('$layout_info->layout_srl = $layout_srl;');
         $buff[] = sprintf('$layout_info->layout_title = $layout_title;');
         $buff[] = sprintf('$layout_info->license = "%s";', $xml_obj->license->body);
         $buff[] = sprintf('$layout_info->license_link = "%s";', $xml_obj->license->attrs->link);
         $buff[] = sprintf('$layout_info->layout_type = "%s";', $layout_type);
         // Author information
         if (!is_array($xml_obj->author)) {
             $author_list[] = $xml_obj->author;
         } else {
             $author_list = $xml_obj->author;
         }
         $buff[] = '$layout_info->author = array();';
         for ($i = 0, $c = count($author_list); $i < $c; $i++) {
             $buff[] = sprintf('$layout_info->author[%d] = new stdClass;', $i);
             $buff[] = sprintf('$layout_info->author[%d]->name = "%s";', $i, $author_list[$i]->name->body);
             $buff[] = sprintf('$layout_info->author[%d]->email_address = "%s";', $i, $author_list[$i]->attrs->email_address);
             $buff[] = sprintf('$layout_info->author[%d]->homepage = "%s";', $i, $author_list[$i]->attrs->link);
         }
         // Extra vars (user defined variables to use in a template)
         $extra_var_groups = $xml_obj->extra_vars->group;
         if (!$extra_var_groups) {
             $extra_var_groups = $xml_obj->extra_vars;
         }
         if (!is_array($extra_var_groups)) {
             $extra_var_groups = array($extra_var_groups);
         }
         $buff[] = '$layout_info->extra_var = new stdClass;';
         $extra_var_count = 0;
         foreach ($extra_var_groups as $group) {
             $extra_vars = $group->var;
             if ($extra_vars) {
                 if (!is_array($extra_vars)) {
                     $extra_vars = array($extra_vars);
                 }
                 $count = count($extra_vars);
                 $extra_var_count += $count;
                 for ($i = 0; $i < $count; $i++) {
                     unset($var, $options);
                     $var = $extra_vars[$i];
                     $name = $var->attrs->name;
                     $buff[] = sprintf('$layout_info->extra_var->%s = new stdClass;', $name);
                     $buff[] = sprintf('$layout_info->extra_var->%s->group = "%s";', $name, $group->title->body);
                     $buff[] = sprintf('$layout_info->extra_var->%s->title = "%s";', $name, $var->title->body);
                     $buff[] = sprintf('$layout_info->extra_var->%s->type = "%s";', $name, $var->attrs->type);
                     $buff[] = sprintf('$layout_info->extra_var->%s->value = $vars->%s;', $name, $name);
                     $buff[] = sprintf('$layout_info->extra_var->%s->description = "%s";', $name, str_replace('"', '\\"', $var->description->body));
                     $options = $var->options;
                     if (!$options) {
                         continue;
                     }
                     if (!is_array($options)) {
                         $options = array($options);
                     }
                     $buff[] = sprintf('$layout_info->extra_var->%s->options = array();', $var->attrs->name);
                     $options_count = count($options);
                     $thumbnail_exist = false;
                     for ($j = 0; $j < $options_count; $j++) {
                         $buff[] = sprintf('$layout_info->extra_var->%s->options["%s"] = new stdClass;', $var->attrs->name, $options[$j]->attrs->value);
                         $thumbnail = $options[$j]->attrs->src;
                         if ($thumbnail) {
                             $thumbnail = $layout_path . $thumbnail;
                             if (file_exists($thumbnail)) {
                                 $buff[] = sprintf('$layout_info->extra_var->%s->options["%s"]->thumbnail = "%s";', $var->attrs->name, $options[$j]->attrs->value, $thumbnail);
                                 if (!$thumbnail_exist) {
                                     $buff[] = sprintf('$layout_info->extra_var->%s->thumbnail_exist = true;', $var->attrs->name);
                                     $thumbnail_exist = true;
                                 }
                             }
                         }
                         $buff[] = sprintf('$layout_info->extra_var->%s->options["%s"]->val = "%s";', $var->attrs->name, $options[$j]->attrs->value, $options[$j]->title->body);
                     }
                 }
             }
         }
         $buff[] = sprintf('$layout_info->extra_var_count = "%s";', $extra_var_count);
         // Menu
         if ($xml_obj->menus->menu) {
             $menus = $xml_obj->menus->menu;
             if (!is_array($menus)) {
                 $menus = array($menus);
             }
             $menu_count = count($menus);
             $buff[] = sprintf('$layout_info->menu_count = "%s";', $menu_count);
             $buff[] = '$layout_info->menu = new stdClass;';
             for ($i = 0; $i < $menu_count; $i++) {
                 $name = $menus[$i]->attrs->name;
                 if ($menus[$i]->attrs->default == "true") {
                     $buff[] = sprintf('$layout_info->default_menu = "%s";', $name);
                 }
                 $buff[] = sprintf('$layout_info->menu->%s = new stdClass;', $name);
                 $buff[] = sprintf('$layout_info->menu->%s->name = "%s";', $name, $menus[$i]->attrs->name);
                 $buff[] = sprintf('$layout_info->menu->%s->title = "%s";', $name, $menus[$i]->title->body);
                 $buff[] = sprintf('$layout_info->menu->%s->maxdepth = "%s";', $name, $menus[$i]->attrs->maxdepth);
                 $buff[] = sprintf('$layout_info->menu->%s->menu_srl = $vars->%s;', $name, $name);
                 $buff[] = sprintf('$layout_info->menu->%s->xml_file = "./files/cache/menu/".$vars->%s.".xml.php";', $name, $name);
                 $buff[] = sprintf('$layout_info->menu->%s->php_file = "./files/cache/menu/".$vars->%s.".php";', $name, $name);
             }
         }
     } else {
         // Layout title, version and other information
         sscanf($xml_obj->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d);
         $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d);
         $buff[] = sprintf('$layout_info->layout = "%s";', $layout);
         $buff[] = sprintf('$layout_info->path = "%s";', $layout_path);
         $buff[] = sprintf('$layout_info->title = "%s";', $xml_obj->title->body);
         $buff[] = sprintf('$layout_info->description = "%s";', $xml_obj->author->description->body);
         $buff[] = sprintf('$layout_info->version = "%s";', $xml_obj->attrs->version);
         $buff[] = sprintf('$layout_info->date = "%s";', $date);
         $buff[] = sprintf('$layout_info->layout_srl = $layout_srl;');
         $buff[] = sprintf('$layout_info->layout_title = $layout_title;');
         // Author information
         $buff[] = sprintf('$layout_info->author[0]->name = "%s";', $xml_obj->author->name->body);
         $buff[] = sprintf('$layout_info->author[0]->email_address = "%s";', $xml_obj->author->attrs->email_address);
         $buff[] = sprintf('$layout_info->author[0]->homepage = "%s";', $xml_obj->author->attrs->link);
         // Extra vars (user defined variables to use in a template)
         $extra_var_groups = $xml_obj->extra_vars->group;
         if (!$extra_var_groups) {
             $extra_var_groups = $xml_obj->extra_vars;
         }
         if (!is_array($extra_var_groups)) {
             $extra_var_groups = array($extra_var_groups);
         }
         foreach ($extra_var_groups as $group) {
             $extra_vars = $group->var;
             if ($extra_vars) {
                 if (!is_array($extra_vars)) {
                     $extra_vars = array($extra_vars);
                 }
                 $extra_var_count = count($extra_vars);
                 $buff[] = sprintf('$layout_info->extra_var_count = "%s";', $extra_var_count);
                 for ($i = 0; $i < $extra_var_count; $i++) {
                     unset($var, $options);
                     $var = $extra_vars[$i];
                     $name = $var->attrs->name;
                     $buff[] = sprintf('$layout_info->extra_var->%s->group = "%s";', $name, $group->title->body);
                     $buff[] = sprintf('$layout_info->extra_var->%s->title = "%s";', $name, $var->title->body);
                     $buff[] = sprintf('$layout_info->extra_var->%s->type = "%s";', $name, $var->attrs->type);
                     $buff[] = sprintf('$layout_info->extra_var->%s->value = $vars->%s;', $name, $name);
                     $buff[] = sprintf('$layout_info->extra_var->%s->description = "%s";', $name, str_replace('"', '\\"', $var->description->body));
                     $options = $var->options;
                     if (!$options) {
                         continue;
                     }
                     if (!is_array($options)) {
                         $options = array($options);
                     }
                     $options_count = count($options);
                     for ($j = 0; $j < $options_count; $j++) {
                         $buff[] = sprintf('$layout_info->extra_var->%s->options["%s"]->val = "%s";', $var->attrs->name, $options[$j]->value->body, $options[$j]->title->body);
                     }
                 }
             }
         }
         // Menu
         if ($xml_obj->menus->menu) {
             $menus = $xml_obj->menus->menu;
             if (!is_array($menus)) {
                 $menus = array($menus);
             }
             $menu_count = count($menus);
             $buff[] = sprintf('$layout_info->menu_count = "%s";', $menu_count);
             for ($i = 0; $i < $menu_count; $i++) {
                 $name = $menus[$i]->attrs->name;
                 if ($menus[$i]->attrs->default == "true") {
                     $buff[] = sprintf('$layout_info->default_menu = "%s";', $name);
                 }
                 $buff[] = sprintf('$layout_info->menu->%s->name = "%s";', $name, $name);
                 $buff[] = sprintf('$layout_info->menu->%s->title = "%s";', $name, $menus[$i]->title->body);
                 $buff[] = sprintf('$layout_info->menu->%s->maxdepth = "%s";', $name, $menus[$i]->maxdepth->body);
                 $buff[] = sprintf('$layout_info->menu->%s->menu_srl = $vars->%s;', $name, $name);
                 $buff[] = sprintf('$layout_info->menu->%s->xml_file = "./files/cache/menu/".$vars->%s.".xml.php";', $name, $name);
                 $buff[] = sprintf('$layout_info->menu->%s->php_file = "./files/cache/menu/".$vars->%s.".php";', $name, $name);
             }
         }
     }
     // header_script
     $oModuleModel = getModel('module');
     $layout_config = $oModuleModel->getModulePartConfig('layout', $layout_srl);
     $header_script = trim($layout_config->header_script);
     if ($header_script) {
         $buff[] = sprintf(' $layout_info->header_script = "%s"; ', str_replace(array('$', '"'), array('\\$', '\\"'), $header_script));
     }
     FileHandler::writeFile($cache_file, '<?php if(!defined("__XE__")) exit(); ' . join(PHP_EOL, $buff));
     if (FileHandler::exists($cache_file)) {
         include $cache_file;
     }
     if (!$layout_info->title) {
         $layout_info->title = $layout;
     }
     return $layout_info;
 }
Example #22
0
 /**
  * @brief type에 따른 form을 리턴
  **/
 function getFormHTML()
 {
     $type = $this->type;
     $name = $this->name;
     $value = $this->_getTypeValue($this->type, $this->value);
     $default = $this->_getTypeValue($this->type, $this->default);
     $column_name = 'extra_vars' . $this->idx;
     $buff = '';
     switch ($type) {
         // 홈페이지 주소
         case 'homepage':
             $buff .= '<input type="text" name="' . $column_name . '" value="' . $value . '" class="homepage" />';
             break;
             // Email 주소
         // Email 주소
         case 'email_address':
             $buff .= '<input type="text" name="' . $column_name . '" value="' . $value . '" class="email_address" />';
             break;
             // 전화번호
         // 전화번호
         case 'tel':
             $buff .= '<input type="text" name="' . $column_name . '" value="' . $value[0] . '" size="4" class="tel" />' . '<input type="text" name="' . $column_name . '" value="' . $value[1] . '" size="4" class="tel" />' . '<input type="text" name="' . $column_name . '" value="' . $value[2] . '" size="4" class="tel" />';
             break;
             // textarea
         // textarea
         case 'textarea':
             $buff .= '<textarea name="' . $column_name . '" class="textarea">' . $value . '</textarea>';
             break;
             // 다중 선택
         // 다중 선택
         case 'checkbox':
             $buff .= '<ul>';
             foreach ($default as $v) {
                 if ($value && in_array($v, $value)) {
                     $checked = ' checked="checked"';
                 } else {
                     $checked = '';
                 }
                 $buff .= '<li><input type="checkbox" name="' . $column_name . '" value="' . htmlspecialchars($v) . '" ' . $checked . ' />' . $v . '</li>';
             }
             $buff .= '</ul>';
             break;
             // 단일 선택
         // 단일 선택
         case 'select':
             $buff .= '<select name="' . $column_name . '" class="select">';
             foreach ($default as $v) {
                 if ($value && in_array($v, $value)) {
                     $selected = ' selected="selected"';
                 } else {
                     $selected = '';
                 }
                 $buff .= '<option value="' . $v . '" ' . $selected . '>' . $v . '</option>';
             }
             $buff .= '</select>';
             break;
             // radio
         // radio
         case 'radio':
             $buff .= '<ul>';
             foreach ($default as $v) {
                 if ($value && in_array($v, $value)) {
                     $checked = ' checked="checked"';
                 } else {
                     $checked = '';
                 }
                 $buff .= '<li><input type="radio" name="' . $column_name . '" ' . $checked . ' value="' . $v . '"  class="radio" />' . $v . '</li>';
             }
             $buff .= '</ul>';
             break;
             // 날짜 입력
         // 날짜 입력
         case 'date':
             // datepicker javascript plugin load
             Context::loadJavascriptPlugin('ui.datepicker');
             $buff .= '<input type="hidden" name="' . $column_name . '" value="' . $value . '" />' . '<input type="text" id="date_' . $column_name . '" value="' . zdate($value, 'Y-m-d') . '" readonly="readonly" class="date" />' . "\n" . '<script type="text/javascript">' . "\n" . '(function($){' . "\n" . '    $(function(){' . "\n" . '        var option = { gotoCurrent: false,yearRange:\'-100:+10\', onSelect:function(){' . "\n" . '            $(this).prev(\'input[type="hidden"]\').val(this.value.replace(/-/g,""))}' . "\n" . '        };' . "\n" . '        $.extend(option,$.datepicker.regional[\'' . Context::getLangType() . '\']);' . "\n" . '        $("#date_' . $column_name . '").datepicker(option);' . "\n" . '    });' . "\n" . '})(jQuery);' . "\n" . '</script>';
             break;
             // 주소 입력
         // 주소 입력
         case "kr_zip":
             // krzip address javascript plugin load
             Context::loadJavascriptPlugin('ui.krzip');
             $buff .= '<div id="addr_searched_' . $column_name . '" style="display:' . ($value[0] ? 'block' : 'none') . ';">' . '<input type="text" readonly="readonly" name="' . $column_name . '" value="' . $value[0] . '" class="address" />' . '<a href="#" onclick="doShowKrZipSearch(this, \'' . $column_name . '\'); return false;" class="button red"><span>' . Context::getLang('cmd_cancel') . '</span></a>' . '</div>' . '<div id="addr_list_' . $column_name . '" style="display:none;">' . '<select name="addr_list_' . $column_name . '"></select>' . '<a href="#" onclick="doSelectKrZip(this, \'' . $column_name . '\'); return false;" class="button blue"><span>' . Context::getLang('cmd_select') . '</span></a>' . '<a href="#" onclick="doHideKrZipList(this, \'' . $column_name . '\'); return false;" class="button red"><span>' . Context::getLang('cmd_cancel') . '</span></a>' . '</div>' . '<div id="addr_search_' . $column_name . '" style="display:' . ($value[0] ? 'none' : 'block') . '">' . '<input type="text" name="addr_search_' . $column_name . '" class="address" value="" />' . '<a href="#" onclick="doSearchKrZip(this, \'' . $column_name . '\'); return false;" class="button green"><span>' . Context::getLang('cmd_search') . '</span></a>' . '</div>' . '<input type="text" name="' . $column_name . '" value="' . htmlspecialchars($value[1]) . '" class="address" />' . '';
             break;
             // 일반 text
         // 일반 text
         default:
             $buff .= ' <input type="text" name="' . $column_name . '" value="' . $value . '" class="text" />';
             break;
     }
     if ($this->desc) {
         $buff .= '<p>' . $this->desc . '</p>';
     }
     return $buff;
 }
Example #23
0
 /**
  * Insert extra vaiable to the documents table
  * @param int $module_srl
  * @param int $document_srl
  * @param int $var_idx
  * @param mixed $value
  * @param int $eid
  * @param string $lang_code
  * @return Object|void
  */
 function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '')
 {
     if (!$module_srl || !$document_srl || !$var_idx || !isset($value)) {
         return new Object(-1, 'msg_invalid_request');
     }
     if (!$lang_code) {
         $lang_code = Context::getLangType();
     }
     $obj = new stdClass();
     $obj->module_srl = $module_srl;
     $obj->document_srl = $document_srl;
     $obj->var_idx = $var_idx;
     $obj->value = $value;
     $obj->lang_code = $lang_code;
     $obj->eid = $eid;
     executeQuery('document.insertDocumentExtraVar', $obj);
 }
 /**
  * Update layout information into the DB
  * @param object $args
  * @return Object
  */
 function updateLayout($args)
 {
     $output = executeQuery('layout.updateLayout', $args);
     if ($output->toBool()) {
         $oLayoutModel = getModel('layout');
         $cache_file = $oLayoutModel->getUserLayoutCache($args->layout_srl, Context::getLangType());
         FileHandler::removeFile($cache_file);
     }
     return $output;
 }
Example #25
0
 function _replaceLangCode($matches)
 {
     static $lang = null;
     if (is_null($lang)) {
         $site_module_info = Context::get('site_module_info');
         if (!$site_module_info) {
             $oModuleModel =& getModel('module');
             $site_module_info = $oModuleModel->getDefaultMid();
             Context::set('site_module_info', $site_module_info);
         }
         $cache_file = sprintf('%sfiles/cache/lang_defined/%d.%s.php', _XE_PATH_, $site_module_info->site_srl, Context::getLangType());
         if (!file_exists($cache_file)) {
             $oModuleAdminController =& getAdminController('module');
             $oModuleAdminController->makeCacheDefinedLangCode($site_module_info->site_srl);
         }
         if (file_exists($cache_file)) {
             $moduleAdminControllerMtime = filemtime(_XE_PATH_ . 'modules/module/module.admin.controller.php');
             $cacheFileMtime = filemtime($cache_file);
             if ($cacheFileMtime < $moduleAdminControllerMtime) {
                 $oModuleAdminController =& getAdminController('module');
                 $oModuleAdminController->makeCacheDefinedLangCode($site_module_info->site_srl);
             }
             require_once $cache_file;
         }
     }
     if (!Context::get($matches[1]) && $lang[$matches[1]]) {
         return $lang[$matches[1]];
     }
     return str_replace('$user_lang->', '', $matches[0]);
 }
Example #26
0
<?php

define('__XE__', true);
require_once '/var/www/han/config/config.inc.php';
$oContext = Context::getInstance();
$oContext->init();
header("Content-Type: text/xml; charset=UTF-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$lang_type = Context::getLangType();
$is_logged = Context::get('is_logged');
$logged_info = Context::get('logged_info');
$site_srl = 0;
$site_admin = false;
if ($site_srl) {
    $oModuleModel = getModel('module');
    $site_module_info = $oModuleModel->getSiteInfo($site_srl);
    if ($site_module_info) {
        Context::set('site_module_info', $site_module_info);
    } else {
        $site_module_info = Context::get('site_module_info');
    }
    $grant = $oModuleModel->getGrant($site_module_info, $logged_info);
    if ($grant->manager == 1) {
        $site_admin = true;
    }
}
if ($is_logged) {
Example #27
0
 /**
  * import basic .js files for mobile
  */
 private function _loadMobileJSCSS()
 {
     $oContext = Context::getInstance();
     $lang_type = Context::getLangType();
     // add common JS/CSS files
     if (__DEBUG__ || !__XE_VERSION_STABLE__) {
         $oContext->loadFile(array('./common/js/jquery-1.x.js', 'head', 'lt IE 9', -111000), true);
         $oContext->loadFile(array('./common/js/jquery.js', 'head', 'gte IE 9', -110000), true);
         $oContext->loadFile(array('./common/js/x.js', 'head', '', -100000), true);
         $oContext->loadFile(array('./common/js/common.js', 'head', '', -100000), true);
         $oContext->loadFile(array('./common/js/js_app.js', 'head', '', -100000), true);
         $oContext->loadFile(array('./common/js/xml_handler.js', 'head', '', -100000), true);
         $oContext->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000), true);
         $oContext->loadFile(array('./common/css/xe.css', '', '', -1000000), true);
         $oContext->loadFile(array('./common/css/mobile.css', '', '', -1000000), true);
     } else {
         $oContext->loadFile(array('./common/js/jquery-1.x.min.js', 'head', 'lt IE 9', -111000), true);
         $oContext->loadFile(array('./common/js/jquery.min.js', 'head', 'gte IE 9', -110000), true);
         $oContext->loadFile(array('./common/js/x.min.js', 'head', '', -100000), true);
         $oContext->loadFile(array('./common/js/xe.min.js', 'head', '', -100000), true);
         $oContext->loadFile(array('./common/css/xe.min.css', '', '', -1000000), true);
         $oContext->loadFile(array('./common/css/mobile.min.css', '', '', -1000000), true);
     }
 }
 /**
  * @brief Make DB Information by Install Config
  */
 function _makeDbInfoByInstallConfig()
 {
     $db_info = new stdClass();
     $db_info->master_db = array('db_type' => Context::get('db_type'), 'db_port' => Context::get('db_port'), 'db_hostname' => Context::get('db_hostname'), 'db_userid' => Context::get('db_userid'), 'db_password' => Context::get('db_password'), 'db_database' => Context::get('db_database'), 'db_table_prefix' => Context::get('db_table_prefix'));
     $db_info->slave_db = array($db_info->master_db);
     $db_info->default_url = Context::getRequestUri();
     $db_info->lang_type = Context::get('lang_type') ? Context::get('lang_type') : Context::getLangType();
     Context::setLangType($db_info->lang_type);
     $db_info->use_rewrite = Context::get('use_rewrite');
     $db_info->time_zone = Context::get('time_zone');
     return $db_info;
 }
Example #29
0
 /**
  * @brief Modules conf/info.xml wanted to read the information
  * It uses caching to reduce time for xml parsing ..
  */
 function getWidgetStyleInfo($widgetStyle)
 {
     $widgetStyle_path = $this->getWidgetStylePath($widgetStyle);
     if (!$widgetStyle_path) {
         return;
     }
     $xml_file = sprintf("%sskin.xml", $widgetStyle_path);
     if (!file_exists($xml_file)) {
         return;
     }
     // If the problem by comparing the cache file and include the return variable $widgetStyle_info
     $cache_file = sprintf(_XE_PATH_ . 'files/cache/widgetstyles/%s.%s.cache.php', $widgetStyle, Context::getLangType());
     if (file_exists($cache_file) && filemtime($cache_file) > filemtime($xml_file)) {
         @(include $cache_file);
         return $widgetStyle_info;
     }
     // If no cache file exists, parse the xml and then return the variable.
     $oXmlParser = new XmlParser();
     $tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file);
     $xml_obj = $tmp_xml_obj->widgetstyle;
     if (!$xml_obj) {
         return;
     }
     $buff = array();
     $buff[] = '<?php if(!defined("__XE__")) exit();';
     $buff[] = '$widgetStyle_info = new stdClass();';
     // Title of the widget, version
     $buff[] = sprintf('$widgetStyle_info->widgetStyle = "%s";', $widgetStyle);
     $buff[] = sprintf('$widgetStyle_info->path = "%s";', $widgetStyle_path);
     $buff[] = sprintf('$widgetStyle_info->title = "%s";', $xml_obj->title->body);
     $buff[] = sprintf('$widgetStyle_info->description = "%s";', $xml_obj->description->body);
     $buff[] = sprintf('$widgetStyle_info->version = "%s";', $xml_obj->version->body);
     sscanf($xml_obj->date->body, '%d-%d-%d', $date_obj->y, $date_obj->m, $date_obj->d);
     $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d);
     $buff[] = sprintf('$widgetStyle_info->date = "%s";', $date);
     $buff[] = sprintf('$widgetStyle_info->homepage = "%s";', $xml_obj->link->body);
     $buff[] = sprintf('$widgetStyle_info->license = "%s";', $xml_obj->license->body);
     $buff[] = sprintf('$widgetStyle_info->license_link = "%s";', $xml_obj->license->attrs->link);
     // preview
     if (!$xml_obj->preview->body) {
         $xml_obj->preview->body = 'preview.jpg';
     }
     $preview_file = sprintf("%s%s", $widgetStyle_path, $xml_obj->preview->body);
     if (file_exists($preview_file)) {
         $buff[] = sprintf('$widgetStyle_info->preview = "%s";', $preview_file);
     }
     // Author information
     if (!is_array($xml_obj->author)) {
         $author_list[] = $xml_obj->author;
     } else {
         $author_list = $xml_obj->author;
     }
     foreach ($author_list as $idx => $author) {
         $buff[] = sprintf('$widgetStyle_info->author[%d] = new stdClass();', $idx);
         $buff[] = sprintf('$widgetStyle_info->author[%d]->name = "%s";', $idx, $author->name->body);
         $buff[] = sprintf('$widgetStyle_info->author[%d]->email_address = "%s";', $idx, $author->attrs->email_address);
         $buff[] = sprintf('$widgetStyle_info->author[%d]->homepage = "%s";', $idx, $author->attrs->link);
     }
     // Extra vars (user defined variables to use in a template)
     $extra_var_groups = $xml_obj->extra_vars->group;
     if (!$extra_var_groups) {
         $extra_var_groups = $xml_obj->extra_vars;
     }
     if (!is_array($extra_var_groups)) {
         $extra_var_groups = array($extra_var_groups);
     }
     $extra_var_count = 0;
     $buff[] = sprintf('$widgetStyle_info->extra_var = new stdClass();', $extra_var_count);
     foreach ($extra_var_groups as $group) {
         $extra_vars = !is_array($group->var) ? array($group->var) : $group->var;
         if ($extra_vars[0]->attrs->id || $extra_vars[0]->attrs->name) {
             foreach ($extra_vars as $var) {
                 $extra_var_count++;
                 $id = $var->attrs->id ? $var->attrs->id : $var->attrs->name;
                 $name = $var->name->body ? $var->name->body : $var->title->body;
                 $type = $var->attrs->type ? $var->attrs->type : $var->type->body;
                 $buff[] = sprintf('$widgetStyle_info->extra_var->%s = new stdClass();', $id);
                 $buff[] = sprintf('$widgetStyle_info->extra_var->%s->group = "%s";', $id, $group->title->body);
                 $buff[] = sprintf('$widgetStyle_info->extra_var->%s->name = "%s";', $id, $name);
                 $buff[] = sprintf('$widgetStyle_info->extra_var->%s->type = "%s";', $id, $type);
                 if ($type == 'filebox') {
                     $buff[] = sprintf('$widgetStyle_info->extra_var->%s->filter = "%s";', $id, $var->attrs->filter);
                     $buff[] = sprintf('$widgetStyle_info->extra_var->%s->allow_multiple = "%s";', $id, $var->attrs->allow_multiple);
                 }
                 $buff[] = sprintf('$widgetStyle_info->extra_var->%s->value = $vars->%s;', $id, $id);
                 $buff[] = sprintf('$widgetStyle_info->extra_var->%s->description = "%s";', $id, str_replace('"', '\\"', $var->description->body));
                 if ($var->options) {
                     $var_options = !is_array($var->options) ? array($var->options) : $var->options;
                     foreach ($var_options as $option_item) {
                         $buff[] = sprintf('$widgetStyle_info->extra_var->%s->options["%s"] = "%s";', $id, $option_item->value->body, $option_item->name->body);
                     }
                 }
             }
         }
     }
     $buff[] = sprintf('$widgetStyle_info->extra_var_count = %d;', $extra_var_count);
     FileHandler::writeFile($cache_file, implode(PHP_EOL, $buff));
     if (file_exists($cache_file)) {
         @(include $cache_file);
     }
     return $widgetStyle_info;
 }
Example #30
0
 /**
  * Return item information of the menu_srl
  * @return void
  */
 function getMenuAdminItemInfo()
 {
     $menuItemSrl = Context::get('menu_item_srl');
     $menuItem = $this->getMenuItemInfo($menuItemSrl);
     if (!$menuItem->url) {
         $menuItem->moduleType = null;
     } else {
         if (strncasecmp('http', $menuItem->url, 4) !== 0) {
             $oModuleModel = getModel('module');
             $moduleInfo = $oModuleModel->getModuleInfoByMid($menuItem->url, 0);
             if (!$moduleInfo) {
                 $menuItem->moduleType = 'url';
             } else {
                 if ($moduleInfo->mid == $menuItem->url) {
                     $menuItem->moduleType = $moduleInfo->module;
                     $menuItem->pageType = $moduleInfo->page_type;
                     $menuItem->layoutSrl = $moduleInfo->layout_srl;
                 }
             }
         } else {
             $menuItem->moduleType = 'url';
         }
     }
     // grant setting
     if (is_array($menuItem->group_srls) && count($menuItem->group_srls) > 0) {
         if ($menuItem->group_srls[0] == -1) {
             $menuItem->grant = 'member';
         } else {
             if ($menuItem->group_srls[0] == -3) {
                 $menuItem->grant = 'manager';
             } else {
                 $menuItem->grant = 'group';
             }
         }
     }
     // get groups
     $oMemberModel = getModel('member');
     $oModuleAdminModel = getAdminModel('module');
     $output = $oMemberModel->getGroups();
     if (is_array($output)) {
         $groupList = array();
         foreach ($output as $key => $value) {
             $groupList[$value->group_srl] = new stdClass();
             $groupList[$value->group_srl]->group_srl = $value->group_srl;
             if (substr($value->title, 0, 12) == '$user_lang->') {
                 $tmp = $oModuleAdminModel->getLangCode(0, $value->title);
                 $groupList[$value->group_srl]->title = $tmp[Context::getLangType()];
             } else {
                 $groupList[$value->group_srl]->title = $value->title;
             }
             if (in_array($key, $menuItem->group_srls)) {
                 $groupList[$value->group_srl]->isChecked = true;
             } else {
                 $groupList[$value->group_srl]->isChecked = false;
             }
         }
     }
     $menuItem->groupList = $groupList;
     $oModuleController = getController('module');
     $menuItem->name_key = $menuItem->name;
     $oModuleController->replaceDefinedLangCode($menuItem->name);
     $this->add('menu_item', $menuItem);
 }