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


PHP ApiResult::setElement方法代码示例

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


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

示例1: setContent

 /**
  * Adds a content element to an array.
  * Use this function instead of hardcoding the '*' element.
  * @param array $arr To add the content element to
  * @param mixed $value
  * @param string $subElemName When present, content element is created
  *  as a sub item of $arr. Use this parameter to create elements in
  *  format "<elem>text</elem>" without attributes.
  */
 public static function setContent(&$arr, $value, $subElemName = null)
 {
     if (is_array($value)) {
         ApiBase::dieDebug(__METHOD__, 'Bad parameter');
     }
     if (is_null($subElemName)) {
         ApiResult::setElement($arr, '*', $value);
     } else {
         if (!isset($arr[$subElemName])) {
             $arr[$subElemName] = array();
         }
         ApiResult::setElement($arr[$subElemName], '*', $value);
     }
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:23,代码来源:ApiResult.php

示例2: addValue

 /**
  * Add value to the output data at the given path.
  * Path is an indexed array, each element specifing the branch at which to add the new value
  * Setting $path to array('a','b','c') is equivalent to data['a']['b']['c'] = $value
  * If $name is empty, the $value is added as a next list element data[] = $value  
  */
 public function addValue($path, $name, $value)
 {
     $data =& $this->getData();
     if (!is_null($path)) {
         if (is_array($path)) {
             foreach ($path as $p) {
                 if (!isset($data[$p])) {
                     $data[$p] = array();
                 }
                 $data =& $data[$p];
             }
         } else {
             if (!isset($data[$path])) {
                 $data[$path] = array();
             }
             $data =& $data[$path];
         }
     }
     if (empty($name)) {
         $data[] = $value;
     } else {
         ApiResult::setElement($data, $name, $value);
     }
     // Add named element
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:31,代码来源:ApiResult.php

示例3: addValue

 /**
  * Add value to the output data at the given path.
  * Path is an indexed array, each element specifing the branch at which to add the new value
  * Setting $path to array('a','b','c') is equivalent to data['a']['b']['c'] = $value
  * If $name is empty, the $value is added as a next list element data[] = $value
  * @return bool True if $value fits in the result, false if not
  */
 public function addValue($path, $name, $value)
 {
     global $wgAPIMaxResultSize;
     $data =& $this->mData;
     if ($this->mCheckingSize) {
         $newsize = $this->mSize + self::size($value);
         if ($newsize > $wgAPIMaxResultSize) {
             return false;
         }
         $this->mSize = $newsize;
     }
     if (!is_null($path)) {
         if (is_array($path)) {
             foreach ($path as $p) {
                 if (!isset($data[$p])) {
                     $data[$p] = array();
                 }
                 $data =& $data[$p];
             }
         } else {
             if (!isset($data[$path])) {
                 $data[$path] = array();
             }
             $data =& $data[$path];
         }
     }
     if (!$name) {
         $data[] = $value;
     } else {
         ApiResult::setElement($data, $name, $value);
     }
     // Add named element
     return true;
 }
开发者ID:josephdye,项目名称:wikireader,代码行数:41,代码来源:ApiResult.php

示例4: addValue

 /**
  * Add value to the output data at the given path.
  * Path is an indexed array, each element specifing the branch at which to add the new value
  * Setting $path to array('a','b','c') is equivalent to data['a']['b']['c'] = $value  
  */
 public function addValue($path, $name, $value)
 {
     $data =& $this->getData();
     if (isset($path)) {
         if (is_array($path)) {
             foreach ($path as $p) {
                 if (!isset($data[$p])) {
                     $data[$p] = array();
                 }
                 $data =& $data[$p];
             }
         } else {
             if (!isset($data[$path])) {
                 $data[$path] = array();
             }
             $data =& $data[$path];
         }
     }
     ApiResult::setElement($data, $name, $value);
 }
开发者ID:puring0815,项目名称:OpenKore,代码行数:25,代码来源:ApiResult.php


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