Implemented from \Altamira\JsWriter\Ability\Legendable
@see \Altamira\JsWriter\Ability\Legendable::setLegend()
@param array $opts
@return \Altamira\JsWriter\Flot
424081
public function setLegend(array $opts = array('on' => 'true', 
                                                  'location' => 'ne', 
                                                  'x' => 0, 
                                                  'y' => 0))
    {
        $opts['on']       = isset($opts['on']) ? $opts['on'] : true;
        $opts['location'] = isset($opts['location']) ? $opts['location'] : 'ne';

        $legendMapper = array('on'       => 'show',
                              'location' => 'position');

        foreach ($opts as $key=>$val) {
            if ( array_key_exists($key, $this->nativeOpts['legend']) ) {
                $this->setNestedOptVal( $this->options, 'legend', $key, $val );
            } else if ( in_array($key, array_keys($legendMapper)) ) {
                $this->setNestedOptVal( $this->options, 'legend', $legendMapper[$key], $val );
            }
        }

        $margin = array(
                    isset($opts['x']) ? $opts['x'] : 0, 
                    isset($opts['y']) ? $opts['y'] : 0
                );

        return $this->setNestedOptVal( $this->options, 'legend', 'margin', $margin );
    }
1300798
public function setOpt($opt)
    {
        if ($this->currentStep > 0) {
            throw new \Exception("setOpt method must be called before exec method.", 1);
        }
        foreach ($opt as $key => $value) {
            $this->userOpt[$key] = $value;
        }
    }
1072299
public function build($array, $opts = array())
	{
		$this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
		$opts = array_merge(array(
			'xml_tag'		=> false,
			'xml_version'	=> '1.0',
			'xml_encoding'	=> 'utf-8',
			'empty_tags'	=> false,
			'empty_attribs' => false,
			'indent'		=> "\t",
			'wrap_tag'		=> null,
			'wrap_attribs'	=> array(),
			'debug_group'	=> false,
		), $opts);
		$w = new \XMLWriter();
		$w->openMemory();
		if ($opts['indent']) {
			$w->setIndent(true);
			$w->setIndentString("\t");
		}
		if ($opts['xml_tag']) {
			$w->startDocument($opts['xml_version'], $opts['xml_encoding']);
		}
		if ($opts['wrap_tag']) {
			$w->startElement($opts['wrap_tag']);
			foreach ($opts['wrap_attribs'] as $k => $v) {
				$w->writeAttribute($k, $v);
			}
		}
		$path = array();
		$levels = array(
			array(
				'startElement'		=> false,
				'keys'				=> array_keys($array),
				'pointer_source'	=> &$array,
			),
		);
		while (!empty($levels)) {
			$level =& $levels[count($levels)-1];
			if (empty($level['prepped'])) {
				#$this->debug->log('prepping');
				$level['prepped'] = true;
				#$this->debug->log('path', implode('/', $path));
				// make sure attribs is first in keys
				$key = array_search('attribs', $level['keys']);
				if ($key > 0) {
					unset($level['keys'][$key]);
					array_unshift($level['keys'], 'attribs');
				}
			}
			if (!empty($level['keys'])) {
				$key = array_shift($level['keys']);
				$val = &$level['pointer_source'][$key];
				$name = $key;
				if (is_int($key)) {
					$name = is_array($val) && isset($val['tag'])
						? $val['tag']
						: $path[count($path)-1];
				}
				#$this->debug->log('name a',$name);
				$collapsed = true;
				if (is_array($val)) {
					foreach ($val as $k => $v) {
						if (substr($k, 0, 1) == '_' && $k != '_text') {
							$k2 = substr($k, 1);
							$level['pointer_source'][$key]['attribs'][$k2] = $v;
							unset($level['pointer_source'][$key][$k]);
						}
					}
					if (isset($val['tag']) || isset($val['nodes']) || isset($val['text'])) {
						$collapsed = false;
						if (isset($val['tag'])) {
							$name = $val['tag'];
						}
						if (isset($val['prefix'])) {
							$name = $val['prefix'].':'.$name;
						}
					}
				}
				#$this->debug->log('name b',$name);
				if ($val === null || $val === array() || $val === '') {
					if ($opts['empty_tags']) {
						$w->writeElement($name, $val);
					}
					// else
					//	$this->debug->log('skip '.$key);
				} elseif (is_string($val) && $key === 'text') {
					$val = Str::toUtf8($val);
					$w->text($val);
				} elseif (is_array($val) && $key === 'attribs') {
					foreach ($val as $k => $v) {
						if (is_null($v)) {
							continue;
						}
						$w->writeAttribute($k, $v);
					}
				} elseif (is_array($val)) {
					if ($opts['debug_group']) {
						$this->debug->groupCollapsed($key);
					}
					#$this->debug->log('collapsed', $collapsed);
					if ($collapsed) {
						$level_new = array(
							'startElement'		=> ArrayUtil::isHash($val),
							'keys'				=> array_keys($val),
							'pointer_source'	=> &$level['pointer_source'][$key],
						);
					} else {
						$level_new = array(
							'startElement'		=> true,
							'keys'				=> !empty($val['nodes'])
														? array_keys($val['nodes'])
														: array(),
							'pointer_source'	=> isset($val['text'])
														? $val['text']
														: null,
						);
						if (!empty($val['nodes'])) {
							$level_new['pointer_source'] =& $level['pointer_source'][$key]['nodes'];
						}
					}
					#$this->debug->log('level_new', $level_new);
					$levels[] = $level_new;
					$path[] = $key;
					if ($level_new['startElement']) {
						$w->startElement($name);
						if (!$collapsed && !empty($val['attribs'])) {
							foreach ($val['attribs'] as $k => $v) {
								$w->writeAttribute($k, $v);
							}
						}
						if (empty($level_new['keys']) && isset($level_new['pointer_source']) && $level_new['pointer_source'] !== '') {
							$w->text($level_new['pointer_source']);
						}
					}
				} else {
					if ($name == '_text') {
						$name = 'text';
					}
					$val = Str::toUtf8($val);
					$w->writeElement($name, $val);
				}
			} else {
				array_pop($levels);
				$p = array_pop($path);
				if ($level['startElement']) {
					$w->endElement();
				}
				if ($opts['debug_group'] && $p !== null) {
					$this->debug->groupEnd();
				}
			}
		}
		if ($opts['wrap_tag']) {
			$w->endElement();
		}
		if ($opts['xml_tag']) {
			$w->endDocument();
		}
		$xml = $w->flush();
		if (!$opts['empty_tags']) {
			$xml = preg_replace('#'.$opts['indent'].'*<[\w:]+/>\n#', '', $xml);
		}
		$this->debug->groupEnd();
		return $xml;
	}
568924
public function mount(array $opts) {
		if (!isset($opts['path']) || $opts['path'] === '') {
			return $this->setError('Path undefined.');;
		}
		
		$this->options = array_merge($this->options, $opts);
		$this->id = $this->driverId.(!empty($this->options['id']) ? $this->options['id'] : elFinder::$volumesCnt++).'_';
		$this->root = $this->normpathCE($this->options['path']);
		$this->separator = isset($this->options['separator']) ? $this->options['separator'] : DIRECTORY_SEPARATOR;
		
		// set server encoding
		if (!empty($this->options['encoding']) && strtoupper($this->options['encoding']) !== 'UTF-8') {
			$this->encoding = $this->options['encoding'];
		} else {
			$this->encoding = null;
		}
		
		$argInit = ($_SERVER['REQUEST_METHOD'] === 'POST')? !empty($_POST['init']) : !empty($_GET['init']);
		
		// session cache
		if ($argInit || ! isset($_SESSION[elFinder::$sessionCacheKey][$this->id])) {
			$_SESSION[elFinder::$sessionCacheKey][$this->id] = array();
		}
		$this->sessionCache = &$_SESSION[elFinder::$sessionCacheKey][$this->id];
		
		// default file attribute
		$this->defaults = array(
			'read'    => isset($this->options['defaults']['read'])  ? !!$this->options['defaults']['read']  : true,
			'write'   => isset($this->options['defaults']['write']) ? !!$this->options['defaults']['write'] : true,
			'locked'  => isset($this->options['defaults']['locked']) ? !!$this->options['defaults']['locked'] : false,
			'hidden'  => isset($this->options['defaults']['hidden']) ? !!$this->options['defaults']['hidden'] : false
		);

		// root attributes
		$this->attributes[] = array(
			'pattern' => '~^'.preg_quote(DIRECTORY_SEPARATOR).'$~',
			'locked'  => true,
			'hidden'  => false
		);
		// set files attributes
		if (!empty($this->options['attributes']) && is_array($this->options['attributes'])) {
			
			foreach ($this->options['attributes'] as $a) {
				// attributes must contain pattern and at least one rule
				if (!empty($a['pattern']) || count($a) > 1) {
					$this->attributes[] = $a;
				}
			}
		}

		if (!empty($this->options['accessControl']) && is_callable($this->options['accessControl'])) {
			$this->access = $this->options['accessControl'];
		}
		
		$this->today     = mktime(0,0,0, date('m'), date('d'), date('Y'));
		$this->yesterday = $this->today-86400;
		
		// debug($this->attributes);
		if (!$this->init()) {
			return false;
		}
		
		// check some options is arrays
		$this->uploadAllow = isset($this->options['uploadAllow']) && is_array($this->options['uploadAllow'])
			? $this->options['uploadAllow']
			: array();
			
		$this->uploadDeny = isset($this->options['uploadDeny']) && is_array($this->options['uploadDeny'])
			? $this->options['uploadDeny']
			: array();

		if (is_string($this->options['uploadOrder'])) { // telephat_mode on, compatibility with 1.x
			$parts = explode(',', isset($this->options['uploadOrder']) ? $this->options['uploadOrder'] : 'deny,allow');
			$this->uploadOrder = array(trim($parts[0]), trim($parts[1]));
		} else { // telephat_mode off
			$this->uploadOrder = $this->options['uploadOrder'];
		}
			
		if (!empty($this->options['uploadMaxSize'])) {
			$size = ''.$this->options['uploadMaxSize'];
			$unit = strtolower(substr($size, strlen($size) - 1));
			$n = 1;
			switch ($unit) {
				case 'k':
					$n = 1024;
					break;
				case 'm':
					$n = 1048576;
					break;
				case 'g':
					$n = 1073741824;
			}
			$this->uploadMaxSize = intval($size)*$n;
		}
			
		$this->disabled = isset($this->options['disabled']) && is_array($this->options['disabled'])
			? $this->options['disabled']
			: array();
		
		$this->cryptLib   = $this->options['cryptLib'];
		$this->mimeDetect = $this->options['mimeDetect'];

		// find available mimetype detect method
		$type = strtolower($this->options['mimeDetect']);
		$type = preg_match('/^(finfo|mime_content_type|internal|auto)$/i', $type) ? $type : 'auto';
		$regexp = '/text\/x\-(php|c\+\+)/';
	
		if (($type == 'finfo' || $type == 'auto') 
		&& class_exists('finfo')) {
			$tmpFileInfo = @explode(';', @finfo_file(finfo_open(FILEINFO_MIME), __FILE__));
		} else {
			$tmpFileInfo = false;
		}
	
		if ($tmpFileInfo && preg_match($regexp, array_shift($tmpFileInfo))) {
			$type = 'finfo';
			$this->finfo = finfo_open(FILEINFO_MIME);
		} elseif (($type == 'mime_content_type' || $type == 'auto') 
		&& function_exists('mime_content_type')
		&& preg_match($regexp, array_shift(explode(';', mime_content_type(__FILE__))))) {
			$type = 'mime_content_type';
		} else {
			$type = 'internal';
		}
		$this->mimeDetect = $type;

		// load mimes from external file for mimeDetect == 'internal'
		// based on Alexey Sukhotin idea and patch: http://elrte.org/redmine/issues/163
		// file must be in file directory or in parent one 
		if ($this->mimeDetect == 'internal' && !self::$mimetypesLoaded) {
			self::$mimetypesLoaded = true;
			$this->mimeDetect = 'internal';
			$file = false;
			if (!empty($this->options['mimefile']) && file_exists($this->options['mimefile'])) {
				$file = $this->options['mimefile'];
			} elseif (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'mime.types')) {
				$file = dirname(__FILE__).DIRECTORY_SEPARATOR.'mime.types';
			} elseif (file_exists(dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'mime.types')) {
				$file = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'mime.types';
			}

			if ($file && file_exists($file)) {
				$mimecf = file($file);

				foreach ($mimecf as $line_num => $line) {
					if (!preg_match('/^\s*#/', $line)) {
						$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
						for ($i = 1, $size = count($mime); $i < $size ; $i++) {
							if (!isset(self::$mimetypes[$mime[$i]])) {
								self::$mimetypes[$mime[$i]] = $mime[0];
							}
						}
					}
				}
			}
		}

		$this->rootName = empty($this->options['alias']) ? $this->basenameCE($this->root) : $this->options['alias'];

		// This get's triggered if $this->root == '/' and alias is empty.
		// Maybe modify _basename instead?
		if ($this->rootName === '') $this->rootName = $this->separator;

		$root = $this->stat($this->root);
		
		if (!$root) {
			return $this->setError('Root folder does not exists.');
		}
		if (!$root['read'] && !$root['write']) {
			return $this->setError('Root folder has not read and write permissions.');
		}
		
		// debug($root);
		
		if ($root['read']) {
			// check startPath - path to open by default instead of root
			if ($this->options['startPath']) {
				$start = $this->stat($this->options['startPath']);
				if (!empty($start)
				&& $start['mime'] == 'directory'
				&& $start['read']
				&& empty($start['hidden'])
				&& $this->inpathCE($this->options['startPath'], $this->root)) {
					$this->startPath = $this->options['startPath'];
					if (substr($this->startPath, -1, 1) == $this->options['separator']) {
						$this->startPath = substr($this->startPath, 0, -1);
					}
				}
			}
		} else {
			$this->options['URL']     = '';
			$this->options['tmbURL']  = '';
			$this->options['tmbPath'] = '';
			// read only volume
			array_unshift($this->attributes, array(
				'pattern' => '/.*/',
				'read'    => false
			));
		}
		$this->treeDeep = $this->options['treeDeep'] > 0 ? (int)$this->options['treeDeep'] : 1;
		$this->tmbSize  = $this->options['tmbSize'] > 0 ? (int)$this->options['tmbSize'] : 48;
		$this->URL      = $this->options['URL'];
		if ($this->URL && preg_match("|[^/?&=]$|", $this->URL)) {
			$this->URL .= '/';
		}

		$this->tmbURL   = !empty($this->options['tmbURL']) ? $this->options['tmbURL'] : '';
		if ($this->tmbURL && preg_match("|[^/?&=]$|", $this->tmbURL)) {
			$this->tmbURL .= '/';
		}
		
		$this->nameValidator = !empty($this->options['acceptedName']) && (is_string($this->options['acceptedName']) || is_callable($this->options['acceptedName']))
			? $this->options['acceptedName']
			: '';

		$this->_checkArchivers();
		// manual control archive types to create
		if (!empty($this->options['archiveMimes']) && is_array($this->options['archiveMimes'])) {
			foreach ($this->archivers['create'] as $mime => $v) {
				if (!in_array($mime, $this->options['archiveMimes'])) {
					unset($this->archivers['create'][$mime]);
				}
			}
		}
		
		// manualy add archivers
		if (!empty($this->options['archivers']['create']) && is_array($this->options['archivers']['create'])) {
			foreach ($this->options['archivers']['create'] as $mime => $conf) {
				if (strpos($mime, 'application/') === 0 
				&& !empty($conf['cmd']) 
				&& isset($conf['argc']) 
				&& !empty($conf['ext'])
				&& !isset($this->archivers['create'][$mime])) {
					$this->archivers['create'][$mime] = $conf;
				}
			}
		}
		
		if (!empty($this->options['archivers']['extract']) && is_array($this->options['archivers']['extract'])) {
			foreach ($this->options['archivers']['extract'] as $mime => $conf) {
				if (strpos($mime, 'application/') === 0
				&& !empty($conf['cmd']) 
				&& isset($conf['argc']) 
				&& !empty($conf['ext'])
				&& !isset($this->archivers['extract'][$mime])) {
					$this->archivers['extract'][$mime] = $conf;
				}
			}
		}

		$this->configure();
		// echo $this->uploadMaxSize;
		// echo $this->options['uploadMaxSize'];
		return $this->mounted = true;
	}
908431
public function setOptions(array $options)
    {
        foreach ($options as $index=>$val) {
            if (property_exists($this, $index)) {
                $this->{$index} = $val;
            }
        }
        return $this;
    }
201547
public function setShadow($series, $opts = array('use'    => true,
                                                     'angle'  => 45,
                                                     'offset' => 1.25,
                                                     'depth'  => 3,
                                                     'alpha'  => 0.1) )
    {
        
        if (! empty( $opts['use'] ) ) {
            $depth = ! empty( $opts['depth'] ) ? $opts['depth'] : 3;
            $this->setNestedOptVal( $this->options, 'seriesStorage', $this->getSeriesTitle( $series ), 'shadowSize', $depth );
        }

        return $this;
    }
844099
public function set($options = [
        'icon' => null,
        'title' => null,
        'message' => '',
        'url' => null,
        'target' => null
    ], $settings = []){
        $settings = Arr::merge($this->settings, $settings);
        $this->session->flash('notify.options', $options);
        $this->session->flash('notify.settings', $settings);
        $this->hook->put('__app.notify.options', $options);
        $this->hook->put('__app.notify.settings', $settings);
        return $this;
    }
482336
public function setOptions(array $options)
    {
        foreach ($options as $option => $value) {
            if (property_exists($this, $option)) {
                $this->{$option} = $value;
            }
        }

        return $this;
    }
1348720
public function reconfigure(array $options = []): AntiCSRF
    {
        /** @var string $opt */
        /** @var \DateInterval $val */
        foreach ($options as $opt => $val) {
            switch ($opt) {
                case 'tokenLifetime':
                    if ($val instanceof \DateInterval) {
                        $this->tokenLifetime = $val;
                    }
                    break;
            }
        }
        return parent::reconfigure($options);
    }
466410
protected function curlOptionsNormalize($opts)
    {
        $this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
        $optionTrans = array(
            'follow'        => 'CURLOPT_FOLLOWLOCATION',
            'proxy_userpwd' => 'CURLOPT_PROXYUSERPWD',
            // 'timeout'    => array('CURLOPT_CONNECTTIMEOUT','CURLOPT_TIMEOUT'),
            'timeout'       => 'CURLOPT_CONNECTTIMEOUT',
        );
        if (!empty($opts['cookies'])) {
            $cookieString = '';
            foreach ($opts['cookies'] as $key => $value) {
                $cookieString .= $key.'='.$value.'; ';
            }
            $opts['CURLOPT_COOKIE'] = \substr($cookieString, 0, -2);    // take off trailing ';'.
            unset($opts['cookies']);
        }
        if (!empty($opts['post'])) {
            $opts['CURLOPT_POST'] = true;
            $opts['CURLOPT_POSTFIELDS'] = $opts['post'];    // array sets content-type multi-part
            unset($opts['post']);
        }
        $haveInt = false;
        foreach ($optionTrans as $k => $kna) {
            if (\array_key_exists($k, $opts)) {
                if (!\is_array($kna)) {
                    $kna = array($kna);
                }
                foreach ($kna as $kn) {
                    if (!\array_key_exists($kn, $opts)) {
                        $opts[$kn] = $opts[$k];
                    }
                }
                unset($opts[$k]);
            }
        }
        foreach ($opts as $k => $v) {
            if ($k == 'verbose') {
                continue;
            }
            if (\is_string($k) && \defined('CURLOPT_'.\strtoupper($k))) {
                ArrayUtil::keyRename($opts, $k, 'CURLOPT_'.\strtoupper($k));
            } elseif (\is_int($k)) {
                $haveInt = true;
            }
        }
        if ($haveInt) {
            // convert any integer consts to string so that may be merged with defaults
            $consts_all = \get_defined_constants(true);
            $consts_all = $consts_all['curl'];
            $consts = array();
            foreach ($consts_all as $k => $v) {
                unset($consts_all[$k]);
                if (\preg_match('/^CURLOPT_/', $k)) {
                    if (!isset($consts[$v])) {
                        $consts[$v] = $k;
                    } else {
                        if (!\is_array($consts[$v])) {
                            $consts[$v] = array( $consts[$v] );
                        }
                        $consts[$v][] = $k;
                    }
                }
            }
            #$this->debug->log('consts', $consts);
            foreach ($opts as $k => $v) {
                if (\is_int($k)) {
                    if (isset($consts[$k])) {
                        $k_new = \is_array($consts[$k])
                            ? $consts[$k][0]
                            : $consts[$k];
                        unset($opts[$k]);
                        $opts[$k_new] = $v;
                    } else {
                        $this->debug->warn('no such curl opt!', $k);
                    }
                }
            }
        }
        if (!empty($opts['CURLOPT_COOKIEFILE'])) {
            // can't use curlopt_cookie if using curlopt_cookiefile
            unset($opts['CURLOPT_COOKIE']);
        }
        $this->debug->log('post normalize opts', $opts);
        $this->debug->groupEnd();
        return $opts;
    }
804986
function addTableOpt( $opt ) {
		if(isset($this->currentPlatform)) {
			$this->opts[$this->parent->db->databaseType] = $opt;
		}
		return $this->opts;
	}
88637
public function set_options(array $options)
	{
		foreach ($options as $key => $val)
		{
			if (is_string($key) && ! is_numeric($key))
			{
				$key = constant('CURLOPT_' . strtoupper($key));
			}

			$this->options[$key] = $val;
		}

		return $this;
	}
670511
public function setOptions(array $options = [], $reset = false)
    {
        return $this->setLength(current($options) ? (int) current($options) : 80)
                ->setEnding(next($options) !== false ? current($options) : '...')
                ->setBoundary(next($options) !== false ? true : false);
    }
738663
public function setShadow( $opts = array( 'use'    =>    true, 
                                              'angle'  =>    45, 
                                              'offset' =>    1.25, 
                                              'depth'  =>    3, 
                                              'alpha'  =>    0.1 ) )
	{
	    if ( $this->jsWriter instanceOf \Altamira\JsWriter\Ability\Shadowable ) {
	        $this->jsWriter->setShadow( $this->getTitle(), $opts );
	    }
	    
		return $this;
	}
301877
public function refreshFrom($values, $opts, $partial = false)
    {
        $this->_opts = Util\RequestOptions::parse($opts);

        $this->_originalValues = self::deepCopy($values);

        if ($values instanceof StripeObject) {
            $values = $values->__toArray(true);
        }

        // Wipe old state before setting new.  This is useful for e.g. updating a
        // customer, where there is no persistent card parameter.  Mark those values
        // which don't persist as transient
        if ($partial) {
            $removed = new Util\Set();
        } else {
            $removed = new Util\Set(array_diff(array_keys($this->_values), array_keys($values)));
        }

        foreach ($removed->toArray() as $k) {
            unset($this->$k);
        }

        $this->updateAttributes($values, $opts, false);
        foreach ($values as $k => $v) {
            $this->_transientValues->discard($k);
            $this->_unsavedValues->discard($k);
        }
    }
882044
public function setOptional($fields)
    {

        if (empty($fields) === false) {

            if (is_array($fields) === true) {
                $this->optionalFields = implode(',', $fields);
            } else {
                $this->optionalFields = $fields;

            }
        }

        return $this;

    }
1261107
public function curlOptSet($opt)
    {
        return isset($this->curlOpts[$opt]) || array_key_exists($opt, $this->curlOpts);
    }