当前位置: 首页>>代码示例>>PHP>>正文


PHP Util::jsonToArray方法代码示例

本文整理汇总了PHP中Util::jsonToArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::jsonToArray方法的具体用法?PHP Util::jsonToArray怎么用?PHP Util::jsonToArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Util的用法示例。


在下文中一共展示了Util::jsonToArray方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * run
  *
  * @param string $name
  * @return array
  */
 public function run($name)
 {
     if ($this->name != 'script') {
         return array('state' => 'error', 'message' => '잘못된 객체로 접근했습니다.');
     }
     // set run path
     $path = $this->runPath . $name . '/';
     // check run file
     if (!file_exists(__GOOSE_PWD__ . $path . 'run.php')) {
         return array('state' => 'error', 'message' => '실행코드 파일이 없습니다.');
     }
     // get meta data
     $meta = Util::jsonToArray(Util::openFile(__GOOSE_PWD__ . $path . 'meta.json'), null, true);
     return require_once __GOOSE_PWD__ . $path . 'run.php';
 }
开发者ID:qeist,项目名称:goose,代码行数:21,代码来源:script.class.php

示例2: view_index

 /**
  * view - index
  */
 private function view_index()
 {
     // set repo
     $repo = array('run');
     // get data
     $repo['run'] = Util::getDir(__GOOSE_PWD__ . $this->runPath, 'name');
     // set data
     foreach ($repo['run'] as $k => $v) {
         $meta = Util::jsonToArray(Util::openFile(__GOOSE_PWD__ . $this->runPath . $v['name'] . '/meta.json'), null, true);
         $repo['run'][$k]['meta'] = $meta;
     }
     // set pwd_container
     $this->pwd_container = __GOOSE_PWD__ . $this->skinPath . 'view_index.html';
     require_once $this->layout->getUrl();
 }
开发者ID:qeist,项目名称:goose,代码行数:18,代码来源:view.class.php

示例3: view_read

 /**
  * view - read
  */
 private function view_read($module)
 {
     $this->moduleName = $module;
     $this->page = $this->param['params'][0] ? $this->param['params'][0] : 'index';
     // check doc file
     $pwd_page = __GOOSE_PWD__ . 'module/' . $this->moduleName . '/help/' . $this->page;
     $this->pwd_page = Util::isFile(array($pwd_page . '.md', $pwd_page . '.html'));
     if (file_exists($this->pwd_page)) {
         // get module setting
         $this->page_modSet = Util::jsonToArray(Util::openFile(__GOOSE_PWD__ . 'module/' . $this->moduleName . '/setting.json'));
         // set pwd_container
         $this->pwd_container = __GOOSE_PWD__ . $this->skinPath . 'view_page.html';
         require_once $this->layout->getUrl();
     } else {
         Goose::error(404);
         Goose::end();
     }
 }
开发者ID:qeist,项目名称:goose,代码行数:21,代码来源:help.class.php

示例4: index

 /**
  * index method
  */
 public function index()
 {
     if ($this->param['method'] == 'POST') {
         $post = Util::getMethod();
         switch ($this->param['action']) {
             case 'upload':
                 $result = $this->actUploadFiles($_FILES['file'], $post['upload_loc'], $post['table'] ? $post['table'] : $this->name);
                 echo Util::arrayToJson($result);
                 break;
             case 'remove':
                 $data = Util::jsonToArray($post['data'], true);
                 $fileSrls = $fileTmpSrls = array();
                 foreach ($data as $k => $v) {
                     if ($v['table'] == 'file_tmp') {
                         $fileTmpSrls[] = $v['srl'];
                     } else {
                         if ($v['table'] == 'file') {
                             $fileSrls[] = $v['srl'];
                         }
                     }
                 }
                 if (count($fileSrls)) {
                     $this->actRemoveFile($fileSrls, 'file');
                 }
                 if (count($fileTmpSrls)) {
                     $this->actRemoveFile($fileTmpSrls, 'file_tmp');
                 }
                 echo json_encode(array('state' => 'success'));
                 break;
         }
         Goose::end(false);
     } else {
         require_once __GOOSE_PWD__ . $this->path . 'view.class.php';
         $view = new View($this);
         $view->render();
     }
 }
开发者ID:qeist,项目名称:goose,代码行数:40,代码来源:file.class.php

示例5: array

require_once __GOOSE_PWD__ . 'data/config.php';
// create and connect database
$this->goose->createSpawn();
$this->goose->spawn->connect($dbConfig);
$this->goose->spawn->prefix = $table_prefix;
// set admin
$this->goose->isAdmin = true;
// install modules
$arr = array('user', 'nest', 'app', 'json', 'file', 'article', 'category');
foreach ($arr as $k => $v) {
    $result = $this->installModule($v);
    echo "<p>Create table - " . $result['message'] . "</p>";
}
// add admin user
$result = Spawn::insert(array('table' => Spawn::getTableName('user'), 'data' => array('srl' => null, 'email' => $_POST['email'], 'name' => $_POST['name'], 'pw' => md5($_POST['password']), 'level' => $_POST['adminLevel'], 'regdate' => date("YmdHis"))));
echo "<p>Add admin user - " . ($result == 'success' ? 'Complete' : "ERROR : {$result}") . "</p>";
// add basic navigation on json table
$cnt = Spawn::count(array('table' => Spawn::getTableName('json'), 'where' => "name='Goose Navigation'"));
if (!$cnt) {
    $data = Util::checkUserFile(__GOOSE_PWD__ . 'core/misc/navigationTree.json');
    $data = Util::openFile($data);
    $data = Util::jsonToArray($data, true, true);
    $data = Util::arrayToJson($data, true);
    $result = Spawn::insert(array('table' => __dbPrefix__ . 'json', 'data' => array('srl' => null, 'name' => 'Goose Navigation', 'json' => $data, 'regdate' => date("YmdHis"))));
} else {
    $result = '"Goose Navigation" Data already exists.';
}
echo "<p>Add json data - " . ($result == 'success' ? 'Complete' : "ERROR : {$result}") . "</p>";
echo "<hr/>";
echo "<h1>END INSTALL</h1>";
echo "<nav><a href=\"" . __GOOSE_ROOT__ . "\">Go to intro page</a></nav>";
开发者ID:qeist,项目名称:goose,代码行数:31,代码来源:transaction_install.php

示例6: getSetting

 /**
  * get setting
  *
  * @param string $modName
  * @return array
  */
 private function getSetting($modName = null)
 {
     $loc = Module::existModule($modName);
     $file = Util::checkUserFile($loc['pwd'] . 'setting.json');
     return Util::jsonToArray(Util::openFile($file), true);
 }
开发者ID:qeist,项目名称:goose,代码行数:12,代码来源:modules.class.php

示例7: Exception

// load program files
require_once __GOOSE_LIB__;
require_once 'lib/func.php';
// get preferences
try {
    $tmp = Spawn::item(['table' => Spawn::getTableName('json'), 'field' => 'json', 'where' => 'srl=' . (int) $srl_json_pref])['json'];
    if (!$tmp) {
        throw new Exception('not found preference data');
    }
    $pref = new Object(['string' => $tmp, 'json' => Util::jsonToArray($tmp, true, true)]);
    // get gnb
    $tmp = Spawn::item(['table' => Spawn::getTableName('json'), 'field' => 'json', 'where' => 'srl=' . (int) $pref->json['srl']['json_gnb']])['json'];
    if (!$tmp) {
        throw new Exception('not found global navigation data');
    }
    $gnb = new Object(['string' => $tmp, 'json' => Util::jsonToArray($tmp, true, true)]);
} catch (Exception $e) {
    echo $e->getMessage();
    Goose::end();
}
// init router
$router = Module::load('router');
$router->route->setBasePath(__ROOT__);
require_once 'lib/map.php';
$router->match = $router->route->match();
// route action
if ($router->match) {
    $_target = $router->match['target'];
    $_params = $router->match['params'];
    $_name = $router->match['name'];
    $_method = $_SERVER['REQUEST_METHOD'];
开发者ID:hellojintae,项目名称:app-first-gallery,代码行数:31,代码来源:index.php

示例8: transaction

 /**
  * api - transaction
  *
  * @param string $method
  * @param array $post
  * @return array
  */
 public function transaction($method, $post = array())
 {
     if (!$method) {
         return array('state' => 'error', 'action' => 'back', 'message' => 'method값이 없습니다.');
     }
     if ($this->name != 'nest') {
         return array('state' => 'error', 'action' => 'back', 'message' => '잘못된 객체로 접근했습니다.');
     }
     if (!$this->isAdmin) {
         return array('state' => 'error', 'action' => 'back', 'message' => '권한이 없습니다.');
     }
     $json = Util::jsonToArray($post['json'], null, true);
     $loc = Util::isFile(array(__GOOSE_PWD__ . $this->path . 'skin/' . $post['nestSkin'] . '/transaction_' . $method . '.php', __GOOSE_PWD__ . $this->path . 'skin/' . $this->set['skin'] . '/transaction_' . $method . '.php'));
     if ($loc) {
         return require_once $loc;
     } else {
         return array('state' => 'error', 'action' => 'back', 'message' => '처리파일이 없습니다.');
     }
 }
开发者ID:qeist,项目名称:goose,代码行数:26,代码来源:nest.class.php

示例9: array

    $file = Module::load('file');
    // get articles
    $articles = Spawn::items(array('table' => Spawn::getTableName('article'), 'field' => 'srl,json', 'where' => 'nest_srl=' . (int) $post['nest_srl']));
    $file_srls = array();
    foreach ($articles as $k => $v) {
        // remove attach files
        $data = $file->getItems(array('field' => 'srl', 'where' => 'article_srl=' . (int) $v['srl']));
        if ($data['state'] == 'success') {
            foreach ($data['data'] as $k2 => $v2) {
                if ($v2['srl']) {
                    $file_srls[] = (int) $v2['srl'];
                }
            }
        }
        // remove thumnail files
        $json = Util::jsonToArray($v['json']);
        if (__GOOSE_PWD__ . $json['thumnail']['url'] && file_exists(__GOOSE_PWD__ . $json['thumnail']['url'])) {
            unlink(__GOOSE_PWD__ . $json['thumnail']['url']);
        }
    }
    $file->actRemoveFile($file_srls, 'file');
    $result = Spawn::delete(array('table' => Spawn::getTableName('article'), 'where' => 'nest_srl=' . (int) $post['nest_srl'], 'debug' => false));
}
// remove category data
if ($post['delete_category']) {
    $result = Spawn::delete(array('table' => Spawn::getTableName('category'), 'where' => 'nest_srl=' . (int) $post['nest_srl'], 'debug' => false));
}
// remove nest data
$result = Spawn::delete(array('table' => Spawn::getTableName($this->name), 'where' => 'srl=' . (int) $post['nest_srl'], 'debug' => false));
if ($result != 'success') {
    return array('state' => 'error', 'action' => 'back', 'message' => 'Fail execution database');
开发者ID:qeist,项目名称:goose,代码行数:31,代码来源:transaction_remove.php

示例10: getArticleJSON

/**
 * get article json
 * article의 json필드의 내용을 가져온다.
 *
 * @param int $srl
 * @return array
 */
function getArticleJSON($srl)
{
    $data = Spawn::items(array('table' => Spawn::getTableName('article'), 'field' => 'json', 'where' => 'srl=' . (int) $srl));
    return count($data) ? Util::jsonToArray($data[0]['json'], null, true) : null;
}
开发者ID:qeist,项目名称:goose,代码行数:12,代码来源:func.php

示例11: upLike

 /**
  * Up like
  *
  * @param array $options : [
  *   article_srl
  *   header_key
  * ]
  * @return array
  */
 public function upLike($options)
 {
     if (!$this->checkAuthHeader($options['header_key'])) {
         return ['state' => 'error', 'message' => 'Path not allowed'];
     }
     if (!$options['article_srl']) {
         return ['state' => 'error', 'message' => 'not found article_srl'];
     }
     $article = Spawn::item(['table' => Spawn::getTableName('article'), 'where' => 'srl=' . $options['article_srl'], 'field' => 'srl,json']);
     if (!isset($article['json'])) {
         return ['state' => 'error', 'message' => 'not found article data'];
     }
     $article['json'] = Util::jsonToArray($article['json'], null, true);
     $like = isset($article['json']['like']) ? (int) $article['json']['like'] : 0;
     $article['json']['like'] = $like + 1;
     $json = Util::arrayToJson($article['json'], true);
     $result = Spawn::update(['table' => Spawn::getTableName('article'), 'data' => ['json=\'' . $json . '\''], 'where' => 'srl=' . (int) $options['article_srl']]);
     return $result == 'success' ? ['state' => 'success', 'message' => 'update complete'] : ['state' => 'error', 'message' => 'fail update complete'];
 }
开发者ID:hellojintae,项目名称:app-first-gallery,代码行数:28,代码来源:ClientAPI.class.php

示例12: getItem

 /**
  * api - get item
  *
  * @param array $getParam
  * @return array|null
  */
 public function getItem($getParam = array())
 {
     if ($this->name != 'article') {
         return array('state' => 'error', 'message' => '잘못된 객체로 접근했습니다.');
     }
     // set original parameter
     $originalParam = array('table' => Spawn::getTableName($this->name));
     // get data
     $data = Spawn::item(Util::extendArray($originalParam, $getParam));
     // check data
     if (!$data) {
         return array('state' => 'error', 'message' => '데이터가 없습니다.');
     }
     // convert json data
     if ($data['json']) {
         $data['json'] = Util::jsonToArray($data['json'], null, true);
     }
     // return data
     return array('state' => 'success', 'data' => $data);
 }
开发者ID:qeist,项目名称:goose,代码行数:26,代码来源:article.class.php

示例13: getInstallModule

 /**
  * get install module
  *
  * @return array()
  */
 public static function getInstallModule()
 {
     return Util::jsonToArray(Util::openFile(__GOOSE_PWD__ . 'data/modules.json'));
 }
开发者ID:qeist,项目名称:goose,代码行数:9,代码来源:Module.class.php


注:本文中的Util::jsonToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。