发表新文章
@param  $params 数组
[
'title' => '文章标题',
'description' => '文章内容',
'categories' => '类别，是一个数组'
]
@param  $is_csdn 是不是发到csdn网站
514875
public function newPost( array $params ,$is_csdn = false ){
        $this->method = "metaWeblog.newPost";
        if( $is_csdn ){//csdn要特殊处理下
        	$this->blog_id = 895030;
		}
        $this->buildXML( $params );
        $res_xml = $this->doPost();;
		if( !$res_xml ){
			$this->error = new MetaWeblog_Error(-32700, 'response is empty');
			return false;
		}

        $this->metaweblog_response = new MetaWeblog_Message( $res_xml );
        if( !$this->metaweblog_response->parse() ){
            $this->error = new MetaWeblog_Error(-32700, 'parse error. not well formed');
            return false;
        }

        if ($this->metaweblog_response->messageType == 'fault') {
            $this->error = new MetaWeblog_Error($this->metaweblog_response->faultCode, $this->metaweblog_response->faultString);
            return false;
        }

        $this->setBlogId( $this->metaweblog_response->params[0] );

        return true;
    }
672305
public function update(array $cleanData, $isInit = false)
    {
        if ($isInit) {
            $attrs = $this->getAttrs();
            foreach ($cleanData as $key => $value) {
                if (($value instanceof Model) && isset($attrs[$key]) && isset($attrs[$key]['type'])
                    && ( $attrs[$key]['type'] == self::DATA_TYPE_REFERENCE || $attrs[$key]['type'] == self::DATA_TYPE_REFERENCES )
                ) {
                    $value = $this->setRef($key, $value);
                }
                $this->cleanData[$key] = $value;
            }
        } else {
            foreach ($cleanData as $key => $value) {
                $this->$key = $value;
            }
        }

        return true;
    }
579154
public function importFile( stdClass $params )
	{
		$this->_checkParams( $params, array( 'site', 'items' ) );
		$this->_setLocale( $params->site );

		$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );

		foreach( $items as $path )
		{
			/** controller/extjs/catalog/import/text/default/container/type
			 * Container file type storing all language files of the texts to import
			 *
			 * When exporting texts, one file or content object is created per
			 * language. All those files or content objects are put into one container
			 * file so editors don't have to download one file for each language.
			 *
			 * The container file types that are supported by default are:
			 * * Zip
			 *
			 * Extensions implement other container types like spread sheets, XMLs or
			 * more advanced ways of handling the exported data.
			 *
			 * @param string Container file type
			 * @since 2014.03
			 * @category Developer
			 * @category User
			 * @see controller/extjs/catalog/import/text/default/container/format
			 */

			/** controller/extjs/catalog/import/text/default/container/format
			 * Format of the language files for the texts to import
			 *
			 * The exported texts are stored in one file or content object per
			 * language. The format of that file or content object can be configured
			 * with this option but most formats are bound to a specific container
			 * type.
			 *
			 * The formats that are supported by default are:
			 * * CSV (requires container type "Zip")
			 *
			 * Extensions implement other container types like spread sheets, XMLs or
			 * more advanced ways of handling the exported data.
			 *
			 * @param string Content file type
			 * @since 2014.03
			 * @category Developer
			 * @category User
			 * @see controller/extjs/catalog/import/text/default/container/type
			 * @see controller/extjs/catalog/import/text/default/container/options
			 */

			/** controller/extjs/catalog/import/text/default/container/options
			 * Options changing the expected format for the texts to import
			 *
			 * Each content format may support some configuration options to change
			 * the output for that content type.
			 *
			 * The options for the CSV content format are:
			 * * csv-separator, default ','
			 * * csv-enclosure, default '"'
			 * * csv-escape, default '"'
			 * * csv-lineend, default '\n'
			 *
			 * For format options provided by other container types implemented by
			 * extensions, please have a look into the extension documentation.
			 *
			 * @param array Associative list of options with the name as key and its value
			 * @since 2014.03
			 * @category Developer
			 * @category User
			 * @see controller/extjs/catalog/import/text/default/container/format
			 */
			$container = $this->_createContainer( $path, 'controller/extjs/catalog/import/text/default/container' );

			$textTypeMap = array();
			foreach( $this->_getTextTypes( 'catalog' ) as $item ) {
				$textTypeMap[ $item->getCode() ] = $item->getId();
			}

			foreach( $container as $content ) {
				$this->_importTextsFromContent( $content, $textTypeMap, 'catalog' );
			}

			unlink( $path );
		}

		return array(
			'success' => true,
		);
	}
742014
public function addFile($style, $condition, $isDynamic)
    {
        $config = \OxidEsales\Eshop\Core\Registry::getConfig();
        $suffix = $isDynamic ? '_dynamic' : '';

        if (!preg_match('#^https?://#', $style)) {
            $style = $this->formLocalFileUrl($style);
        }

        if ($style) {
            if (!empty($condition)) {
                $conditionalStylesParameterName = static::CONDITIONAL_STYLES_PARAMETER_NAME . $suffix;
                $conditionalStyles = (array) $config->getGlobalParameter($conditionalStylesParameterName);
                $conditionalStyles[$style] = $condition;
                $config->setGlobalParameter($conditionalStylesParameterName, $conditionalStyles);
            } else {
                $stylesParameterName = static::STYLES_PARAMETER_NAME . $suffix;
                $styles = (array) $config->getGlobalParameter($stylesParameterName);
                $styles[] = $style;
                $styles = array_unique($styles);
                $config->setGlobalParameter($stylesParameterName, $styles);
            }
        }
    }
505360
private function _validateParameters ($params)
    {
        if (! isset($params[1])) {
            throw new \Exception('新しく生成するモデルクラス名を指定してください');
        }

        if (! defined('LIB')) {
            throw new \Exception('LIB 定数(libraryディレクトリパス)が指定されていません');
        }

        if (! defined('APP')) {
            throw new \Exception('APP定数が指定されていません');
        }


        $this->model_name = ucfirst(strtolower($params[1]));
        if (file_exists(LIB.'/'.APP.'/Model/'.$this->model_name.'Model.php')) {
            throw new \Exception('既にモデルクラスが存在します');
        }
    }
805369
public function action_uninstall( $params ) {
		
		$path = $params[0]; 
		
		if ( empty( $path ) ) {
			CCCli::line( 'no ship path given.', 'red' ); return;
		}
		
		/*
		 * direct install if starting with /
		 */
		if ( substr( $path, 0, 1 ) == '/' ) {
			
			// fix path
			if ( substr( $path, -1 ) != '/' ) {
				$path .= '/';
			}
			
			// is directory
			if ( !is_dir( $path ) ) {
				CCCli::line( 'could not find a ship at path: '.$path, 'red' ); return;
			}
			
			// are ya serius..
			if ( !CCCli::confirm( "are you sure you want to uninstall this ship?", true ) ) {
				return;
			}
			
			// run the uninstaller
			try {
				\CCOrbit::uninstall( $path );
			}
			catch ( \Exception $e ) {
				CCCli::line( $e->getMessage(), 'red' ); 
				CCCli::line( 'ship destroying failure.', 'red' ); return;
			}
			
			// also remove the direcoty?
			if ( CCCli::confirm( "do you also wish to remove the ship files?", true ) ) {
				\CCFile::delete( $path );
			}
			
			// we are done
			CCCli::line( 'ship destroyed!', 'green' );
			
			return;
		}
		
		// check if the module is in our orbit path
		if ( is_dir( ORBITPATH.$path ) ) {
			
			// there is a ship yay
			CCCli::line( 'found ship at path: '.ORBITPATH.$path, 'green' );
			
			return static::action_uninstall( array( ORBITPATH.$path ) );
		}
	
		// nothing to do here
		CCCli::line( 'could not find a ship at this path or name.', 'red' ); return;
	}
1293635
function addAdresse($params=array())
    {
        $index = count($this->coordonnees);

        if (isset($params['adresse']) && $params['adresse']!='') {
            $this->coordonnees[$index]['adresse'] = $params['adresse'];
        } else {
            $this->coordonnees[$index]['adresse'] = '';
        }

        if (isset($params['link']) && $params['link']!='') {
            $this->coordonnees[$index]['link'] = $params['link'];
        } else {
            $this->coordonnees[$index]['link']='';
        }

        if (isset($params['imageFlag']) && $params['imageFlag']!='') {
            $this->coordonnees[$index]['imageFlag']=$params['imageFlag'];
        } else {
            $this->coordonnees[$index]['imageFlag']='';
        }

        if (isset($params['longitude']) && $params['longitude']!='' && isset($params['latitude']) && $params['latitude']!='') {
            $this->coordonnees[$index]['longitude'] = $params['longitude'];
            $this->coordonnees[$index]['latitude'] = $params['latitude'];
        }

        if (isset($params['setImageWidth'])) {
            $this->coordonnees[$index]['imageWidth'] = $params['setImageWidth'];
        }

        if (isset($params['setImageHeight'])) {
            $this->coordonnees[$index]['imageHeight'] = $params['setImageHeight'];
        }

        if (isset($params['pathToImageFlag']) && $params['pathToImageFlag']!='') {
            $this->coordonnees[$index]['pathToImageFlag']=$params['pathToImageFlag'];
        } else {
            $this->coordonnees[$index]['pathToImageFlag']='';
        }
    }
516678
public function action_controller( $params ) 
	{	
		$options = \CCDataObject::assign( $params );
		
		$name = $options->get( 0, null );
		$parent = $options->get( 1, null );
		
		// get name if we dont have one
		while( !$name ) 
		{
			$name = $this->read( 'Please enter the controller name: ' );
		}
		
		// fix controller suffix
		if ( substr( $name, ( strlen( 'Controller' ) * -1 ) ) != 'Controller' )
		{
			$name .= 'Controller';
		}
		
		// try to resolve the path
		if ( !$path = \CCPath::controllers( str_replace( '_', '/', $name ), EXT ) )
		{
			$this->error( 'Could not resolve the path. Check if the namespace is registered.' ); return;
		}
		
		// parent
		if ( is_null( $parent ) )
		{
			$parent = '\\CCController';
		} 
		
		// view controller
		if ( $options->get( 'view', false ) )
		{
			$parent = '\\CCViewController';
		}
		
		// create the class
		$class = \CCShipyard::create( 'class', $name, $parent );
		
		// get the actions
		$actions = array( 'index' );
		
		if ( $options->get( 'actions', false ) )
		{
			$actions = array_merge( $actions, explode( ',', $options->get( 'actions' ) ) );
		}
		
		foreach( $actions as $action )
		{
			$action = trim( $action );
			
			$class->add( 'function', 'action_'.$action, 'protected', 'echo "'.$name.' '.$action.' action";', ucfirst($action)." action\n@return void|CCResponse" );
			$class->add( 'line', 2 );
		}
		
		// add static init
		if ( !$options->get( 'no-events', false ) )
		{
			$class->add( 'function', 'wake', 'protected', '//', "Controller wake\n@return void|CCResponse" );
			$class->add( 'line', 2 );
			$class->add( 'function', 'sleep', 'protected', '//', "Controller wake\n@return void" );
		}
						
		// check for overwrite
		if ( file_exists( $path ) )
		{
			if ( !$this->confirm( "The class already exists. Do you wish to overwrite it?", true ) ) 
			{
				return;
			}
		}
		
		// write file
		\CCFile::write( $path, $class->output() );
	}
885782
public function refundTransaction($params)
    {
        if ($params['LogisticsSubType'] === LogisticsSubType::TCAT) {
            // 宅配逆物流訂單產生
            $method = 'CreateHomeReturnOrder';
            $supportedParams = [
                'AllPayLogisticsID' => '',
                'LogisticsSubType' => '',
                'ServerReplyURL' => '',
                'SenderName' => '',
                'SenderPhone' => '',
                'SenderCellPhone' => '',
                'SenderZipCode' => '',
                'SenderAddress' => '',
                'ReceiverName' => '',
                'ReceiverPhone' => '',
                'ReceiverCellPhone' => '',
                'ReceiverZipCode' => '',
                'ReceiverAddress' => '',
                'GoodsAmount' => '',
                'GoodsName' => '',
                'Temperature' => Temperature::ROOM,
                'Distance' => Distance::SAME,
                'Specification' => Specification::CM_60,
                'ScheduledPickupTime' => ScheduledPickupTime::UNLIMITED,
                'ScheduledDeliveryTime' => '',
                'Remark' => '',
                'PlatformID' => '',
            ];
        } elseif (isset($params['LogisticsSubType']) === true) {
            // LogisticsSubType::FAMILY = 'FAMI'; // 全家
            // LogisticsSubType::UNIMART = 'UNIMART'; // 統一超商
            // LogisticsSubType::FAMILY_C2C = 'FAMIC2C'; // 全家店到店
            // LogisticsSubType::UNIMART_C2C = 'UNIMARTC2C'; // 統一超商寄貨便

            // 超商取貨逆物流訂單(全家超商B2C).
            $method = 'CreateFamilyB2CReturnOrder';
            $supportedParams = [
                'AllPayLogisticsID' => '',
                'ServerReplyURL' => '',
                'GoodsName' => '',
                'GoodsAmount' => 0,
                'SenderName' => '',
                'SenderPhone' => '',
                'Remark' => '',
                'Quantity' => '',
                'Cost' => '',
                'PlatformID' => '',
            ];
        } else {
            // 全家逆物流核帳(全家超商B2C).
            $method = 'CheckFamilyB2CLogistics';
            $supportedParams = [
                'RtnMerchantTradeNo' => '',
                'PlatformID' => '',
            ];
        }

        $this->sdk->Send = array_merge($this->sdk->Send, $supportedParams);

        $this->sdk->Send = array_replace(
            $this->sdk->Send,
            array_intersect_key($params, $this->sdk->Send)
        );

        return call_user_func_array([$this->sdk, $method]);
    }
627896
function setExdate( $exdates, $params=FALSE ) {
    $exdate = array();
    $exdate['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ) );
    $parno  = ( isset( $exdate['params']['TZID'] )) ? 6 : null;
    $parno  = $this->_existRem( $exdate['params'], 'VALUE', 'DATE-TIME', 7, $parno );
    if( !isset( $parno )) $parno = $this->_existRem( $exdate['params'], 'VALUE', 'DATE', 3 );
    foreach( $exdates as $eix => $theExdate ) {
      if(  is_array( $theExdate ) &&
         ( in_array( count( $theExdate ), array( 3, 4, 6, 7 )))) {
        if( isset( $exdate['params']['TZID'] ))
          $theExdate['tz'] = $exdate['params']['TZID'];
        if( !isset( $parno )) {
          if( 4 < count( $theExdate ))
            $parno = 7;
          else
            $parno = 3;
        }
        $exdatea   = $this->_date_time_array( $theExdate, $parno );
      }
      elseif( is_array( $theExdate ) && isset( $theExdate['timestamp'] )) {
        if( isset( $exdate['params']['TZID'] ))
          $theExdate['tz'] = $exdate['params']['TZID'];
        $tz        = ( isset( $theExdate['tz'] )) ? ' '.$theExdate['tz'] : null;
        if( !isset( $parno ))
          $parno   = ( !empty( $tz )) ? 7 : 6;
        $exdatea   = $this->_date_time_string( date( 'Y-m-d H:i:s', $theExdate['timestamp'] ).$tz, $parno );
      }
      elseif( 8 <= strlen( trim( $theExdate ))) { // ex. 2006-08-03 10:12:18
        $exdatea   = $this->_date_time_string( $theExdate, $parno );
        if( isset( $exdate['params']['TZID'] ))
          $exdatea['tz'] = $exdate['params']['TZID'];
      }
      if( !isset( $parno )) {
        $parno     = count( $exdatea );
        if( 6 == $parno )
          $parno   = 7;
      }
      if( isset( $exdatea['tz'] ))
        $exdatea['tz'] = (string) $exdatea['tz'];
      $exdate['value'][] = $exdatea;
    }
    if( 0 < count( $exdate['value'] )) {
      if( 3 == $parno ) {
        $exdate['params']['VALUE'] = 'DATE';
        foreach( $exdate['value'] as $eix => $exdatea )
          unset( $exdate['value'][$eix]['tz'] );
        unset( $exdate['params']['TZID'] );
      }
      if( !empty( $exdate['value'][0]['tz'] )   &&
           ( $exdate['value'][0]['tz'] != 'Z' ) &&
        ( !( in_array($exdate['value'][0]['tz']{0}, array( '+', '-' )) &&
             ctype_digit( substr( $exdate['value'][0]['tz'], 1 ))) &&
          !ctype_digit( $exdate['value'][0]['tz'] ) ) ) {
        $exdate['params']['TZID'] = $exdate['value'][0]['tz'];
        foreach( $exdate['value'] as $exix => $exdatea ) {
          if( !empty( $exdate['value'][0]['tz'] )   &&
               ( $exdate['value'][0]['tz'] != 'Z' ) &&
            ( !( in_array($exdate['value'][0]['tz']{0}, array( '+', '-' )) &&
                 ctype_digit( substr( $exdate['value'][0]['tz'], 1 ))) &&
              !ctype_digit( $exdate['value'][0]['tz'] ) ) )
            unset( $exdate['value'][$exix]['tz'] );
        }
      }
      elseif( isset( $exdate['params']['TZID'] ))
        unset( $exdate['params']['TZID'] );
      $this->exdate[] = $exdate;
    }
  }
215551
public function importFile( \stdClass $params )
	{
		$this->checkParams( $params, array( 'site', 'items' ) );
		$this->setLocale( $params->site );

		$fs = $this->getContext()->getFilesystemManager()->get( 'fs-admin' );
		$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );

		foreach( $items as $path )
		{
			$tmpfile = $fs->readf( $path );

			/** controller/extjs/product/import/text/standard/container/type
			 * Container file type storing all language files of the texts to import
			 *
			 * When exporting texts, one file or content object is created per
			 * language. All those files or content objects are put into one container
			 * file so editors don't have to download one file for each language.
			 *
			 * The container file types that are supported by default are:
			 * * Zip
			 *
			 * Extensions implement other container types like spread sheets, XMLs or
			 * more advanced ways of handling the exported data.
			 *
			 * @param string Container file type
			 * @since 2014.03
			 * @category Developer
			 * @category User
			 * @see controller/extjs/product/import/text/standard/container/format
			 */

			/** controller/extjs/product/import/text/standard/container/format
			 * Format of the language files for the texts to import
			 *
			 * The exported texts are stored in one file or content object per
			 * language. The format of that file or content object can be configured
			 * with this option but most formats are bound to a specific container
			 * type.
			 *
			 * The formats that are supported by default are:
			 * * CSV (requires container type "Zip")
			 *
			 * Extensions implement other container types like spread sheets, XMLs or
			 * more advanced ways of handling the exported data.
			 *
			 * @param string Content file type
			 * @since 2014.03
			 * @category Developer
			 * @category User
			 * @see controller/extjs/product/import/text/standard/container/type
			 * @see controller/extjs/product/import/text/standard/container/options
			 */

			/** controller/extjs/product/import/text/standard/container/options
			 * Options changing the expected format for the texts to import
			 *
			 * Each content format may support some configuration options to change
			 * the output for that content type.
			 *
			 * The options for the CSV content format are:
			 * * csv-separator, default ','
			 * * csv-enclosure, default '"'
			 * * csv-escape, default '"'
			 * * csv-lineend, default '\n'
			 *
			 * For format options provided by other container types implemented by
			 * extensions, please have a look into the extension documentation.
			 *
			 * @param array Associative list of options with the name as key and its value
			 * @since 2014.03
			 * @category Developer
			 * @category User
			 * @see controller/extjs/product/import/text/standard/container/format
			 */
			$container = $this->createContainer( $tmpfile, 'controller/extjs/product/import/text/standard/container' );

			$textTypeMap = [];
			foreach( $this->getTextTypes( 'product' ) as $item ) {
				$textTypeMap[$item->getCode()] = $item->getId();
			}

			foreach( $container as $content ) {
				$this->importTextsFromContent( $content, $textTypeMap, 'product' );
			}

			unlink( $tmpfile );
			$fs->rm( $path );
		}

		return array(
			'success' => true,
		);
	}
827150
public function updateByParams( $params = [], $config = [] ) {

		$modelId	= $params[ 'modelId' ];
		$name		= $params[ 'name' ];
		$type		= $params[ 'type' ];

		$model = $this->getByNameType( $modelId, $name, $type );

		if( isset( $model ) ) {

			$model->value = $params[ 'value' ];

			return parent::update( $model, [
				'selective' => false,
				'attributes' => [ 'value' ]
			]);
		}
	}
1309622
public function execute (Array $params)
    {
        try {
            $this->_validateParameters($params);
            
            // スケルトンファイルを取得する
            $skeleton = $this->_getSkeletonFile();

            // スケルトンファイルのコンテンツを置換
            $skeleton = str_replace('${command}', $this->command_name, $skeleton);
            file_put_contents(LIB.'/'.APP.'/Commands/'.$this->command_name.'.php', $skeleton);

            $this->log($this->command_name.' command is created!', 'success');
        
        } catch (\Exception $e) {
            $this->errorLog($e->getMessage());
        }
    }
1373545
public function search($params)
    {
        $query = Product::find();

        $this->load($params);

        $query->andFilterWhere([
            'id' => $this->id,
            'author' => $this->author,
            'quantity' => $this->quantity,
            'promotional_price' => $this->promotional_price,
            'price' => $this->price,
            'product_parent' => $this->product_parent,
            'assign_with' => $this->assign_with,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
            'created_by' => $this->created_by,
            'updated_by' => $this->updated_by,
        ]);

        $query->andFilterWhere(['like', 'title', $this->title])
            ->andFilterWhere(['like', 'slug', $this->slug])
            ->andFilterWhere(['like', 'description', $this->description])
            ->andFilterWhere(['like', 'content', $this->content])
            ->andFilterWhere(['like', 'feature_img', $this->feature_img])
            ->andFilterWhere(['like', 'sku', $this->sku])
            ->andFilterWhere(['like', 'status', $this->status])
            ->andFilterWhere(['like', 'comment_status', $this->comment_status])
            ->andFilterWhere(['like', 'rating_status', $this->rating_status])
            ->andFilterWhere(['like', 'unit', $this->unit])
            ->andFilterWhere(['like', 'gallery', $this->gallery])
            ->andFilterWhere(['like', 'product_type', $this->product_type])
            ->andFilterWhere(['like', 'language', $this->language]);

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        if (!$this->validate()) {
            return $dataProvider;
        }

        return $dataProvider;
    }
861200
public static function write($key, $value, $params = array()) {
		if (empty($key) || empty($value)) {
			return false;
		}
		$params = self::_buildWriteParams($params);

		$key = explode('.', $key);
		$config = self::_getConfigByKey($key[0]);
		$cntKey = count($key);
		if (is_null($config) && $cntKey > 1) {
			$config = array();
		}
		if (!is_null($config) && $cntKey > 1) {
			$afterFirstKey = implode('.', array_slice($key, 1));
			if (is_array($config) && is_array($value) && $params['equalKeysOnly']) {
				$valueDefault = Hash::extract($config, $afterFirstKey);
				$value = Hash::mergeDiff($value, (array)$valueDefault);
			}
			$value = Hash::insert((array)$config, $afterFirstKey, $value);
		}
		self::_getEngine()->add($key[0], $value);

		return true;
	}
168867
public static function buildQueryStr($params) {
        $arrTmp = array();
        foreach ($params as $k => $v){
            //参数为空不参与签名
            if(isset($v) && $v != ''){
                array_push($arrTmp, "$k=$v");
            }
        }
        return implode('&', $arrTmp);
    }
974462
public function action_help( $params ) {
		if ( method_exists( $this, 'help' ) ) 
		{
			 CCCli::line( $this->help_formatter( $this->help() ) ); return;
 		}
		CCCli::line( 'This console controller does not implement an help function or action.' , 'cyan' );
	}