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


PHP wfObjectToArray函数代码示例

本文整理汇总了PHP中wfObjectToArray函数的典型用法代码示例。如果您正苦于以下问题:PHP wfObjectToArray函数的具体用法?PHP wfObjectToArray怎么用?PHP wfObjectToArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: wfObjectToArray

function wfObjectToArray($object, $recursive = true)
{
    $array = array();
    foreach (get_object_vars($object) as $key => $value) {
        if (is_object($value) && $recursive) {
            $value = wfObjectToArray($value);
        }
        $array[$key] = $value;
    }
    return $array;
}
开发者ID:ErdemA,项目名称:wikihow,代码行数:11,代码来源:Misc.php

示例2: decode

 public static function decode($value, $assoc = false)
 {
     if (!function_exists('json_decode')) {
         $json = new Services_JSON();
         $jsonDec = $json->decode($value);
         if ($assoc) {
             $jsonDec = wfObjectToArray($jsonDec);
         }
         return $jsonDec;
     } else {
         return json_decode($value, $assoc);
     }
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:13,代码来源:FormatJson.php

示例3: wfObjectToArray

/**
 * Recursively converts the parameter (an object) to an array with the same data
 *
 * @param object|array $objOrArray
 * @param bool $recursive
 * @return array
 */
function wfObjectToArray($objOrArray, $recursive = true)
{
    $array = array();
    if (is_object($objOrArray)) {
        $objOrArray = get_object_vars($objOrArray);
    }
    foreach ($objOrArray as $key => $value) {
        if ($recursive && (is_object($value) || is_array($value))) {
            $value = wfObjectToArray($value);
        }
        $array[$key] = $value;
    }
    return $array;
}
开发者ID:D66Ha,项目名称:mediawiki,代码行数:21,代码来源:GlobalFunctions.php

示例4: loadRequest

 function loadRequest($filter, $history_id = null)
 {
     static $row = null;
     static $actions = null;
     $request = $this->getRequest();
     if (!is_null($actions) && !is_null($row)) {
         return array($row, $actions);
     } elseif ($request->wasPosted()) {
         # Nothing, we do it all later
     } elseif ($history_id) {
         return $this->loadHistoryItem($history_id);
     } else {
         return $this->loadFilterData($filter);
     }
     // We need some details like last editor
     list($row, $origActions) = $this->loadFilterData($filter);
     $row->mOriginalRow = clone $row;
     $row->mOriginalActions = $origActions;
     // Check for importing
     $import = $request->getVal('wpImportText');
     if ($import) {
         $data = json_decode($import);
         $importRow = $data->row;
         $actions = wfObjectToArray($data->actions);
         $copy = array('af_public_comments', 'af_pattern', 'af_comments', 'af_deleted', 'af_enabled', 'af_hidden');
         foreach ($copy as $name) {
             $row->{$name} = $importRow->{$name};
         }
     } else {
         $textLoads = array('af_public_comments' => 'wpFilterDescription', 'af_pattern' => 'wpFilterRules', 'af_comments' => 'wpFilterNotes');
         foreach ($textLoads as $col => $field) {
             $row->{$col} = trim($request->getVal($field));
         }
         $row->af_deleted = $request->getBool('wpFilterDeleted');
         $row->af_enabled = $request->getBool('wpFilterEnabled') && !$row->af_deleted;
         $row->af_hidden = $request->getBool('wpFilterHidden');
         global $wgAbuseFilterIsCentral;
         $row->af_global = $request->getBool('wpFilterGlobal') && $wgAbuseFilterIsCentral;
         // Actions
         global $wgAbuseFilterAvailableActions;
         $actions = array();
         foreach ($wgAbuseFilterAvailableActions as $action) {
             // Check if it's set
             $enabled = $request->getBool('wpFilterAction' . ucfirst($action));
             if ($enabled) {
                 $parameters = array();
                 if ($action == 'throttle') {
                     // We need to load the parameters
                     $throttleCount = $request->getIntOrNull('wpFilterThrottleCount');
                     $throttlePeriod = $request->getIntOrNull('wpFilterThrottlePeriod');
                     $throttleGroups = explode("\n", trim($request->getText('wpFilterThrottleGroups')));
                     $parameters[0] = $this->mFilter;
                     // For now, anyway
                     $parameters[1] = "{$throttleCount},{$throttlePeriod}";
                     $parameters = array_merge($parameters, $throttleGroups);
                 } elseif ($action == 'warn') {
                     $specMsg = $request->getVal('wpFilterWarnMessage');
                     if ($specMsg == 'other') {
                         $specMsg = $request->getVal('wpFilterWarnMessageOther');
                     }
                     $parameters[0] = $specMsg;
                 } elseif ($action == 'tag') {
                     $parameters = explode("\n", $request->getText('wpFilterTags'));
                 }
                 $thisAction = array('action' => $action, 'parameters' => $parameters);
                 $actions[$action] = $thisAction;
             }
         }
     }
     $row->af_actions = implode(',', array_keys(array_filter($actions)));
     return array($row, $actions);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:72,代码来源:AbuseFilterViewEdit.php

示例5: naiveResolvePath

 public static function naiveResolvePath($data, $path, $split = true)
 {
     if (is_object($data)) {
         if ($dom instanceof DOMNode) {
             throw new MWException("naiveResolvePath does not like DOMNode objects");
         }
         $data = wfObjectToArray($data);
     }
     if (!is_array($data) || $path === '.') {
         return $data;
     }
     if ($split && is_string($path)) {
         $path = DataTransclusionSource::splitList($path, '/');
     }
     if (is_string($path) || is_int($path)) {
         return @$data[$path];
     }
     if (!$path) {
         return $data;
     }
     $p = array_shift($path);
     if (is_string($p) && preg_match('/^(@)?(\\d+)$/', $p, $m)) {
         //numberic index
         $i = (int) $m[2];
         if ($m[1]) {
             //meta-index
             $k = array_keys($data);
             $p = $k[$i];
         }
     }
     if (!isset($data[$p])) {
         return false;
     }
     $next = $data[$p];
     if ($next && $path) {
         return FlattenRecord::naiveResolvePath($next, $path);
     } else {
         return $next;
     }
     //TODO: named components. separator??
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:41,代码来源:FlattenRecord.php


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