本文整理汇总了PHP中factory::mergeCfg方法的典型用法代码示例。如果您正苦于以下问题:PHP factory::mergeCfg方法的具体用法?PHP factory::mergeCfg怎么用?PHP factory::mergeCfg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类factory
的用法示例。
在下文中一共展示了factory::mergeCfg方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare
protected function prepare() {
$htVars = http_vars::getInstance();
$this->type = $htVars->post('type', $htVars->get('type'));
$this->config = $htVars->post('config', $htVars->get('config', 'default'));
$this->myCfg = $this->cfg->default;
if ($this->config != 'default' && is_array($this->cfg->get($this->config)))
factory::mergeCfg($this->myCfg, $this->cfg->get($this->config));
$this->dir = $this->myCfg['dir'];
if ($this->myCfg['subdir'])
$this->dir.= DS.$this->myCfg['subdir'];
$this->dir.= DS.$this->type;
$resp = response::getInstance();
/* @var $resp response_http_html */
$resp->setLayout($this->myCfg['layout']);
$resp->setTitle($this->myCfg['title']);
$resp->initIncFiles(false);
foreach($this->myCfg['incFiles'] as $ic)
$resp->add($ic);
$this->uri = request::uriDef(array('module')).'?'.session::getInstance()->getSessIdForce().'='.urlencode(session_id()).'&type='.$this->type.'&config='.$this->config.'&';
}
示例2: overload
/**
* Overload a config from an other class.
* The class could not exists
*
* @param string $className
* @param bool $parent Indicate if the search should load the parent config (if virtual, should be false!)
*/
public function overload($className, $parent = false)
{
factory::mergeCfg($this->vars, factory::loadCfg($className, $parent));
}
示例3: plupload
/**
* Make the field plupload for asynchronous upload.
*
* @param array $opts Plupload options
* @param boolean $hideSubmit Indicate if the submit button should be hide by JavaScript
*/
public function plupload(array $opts = array(), $hideSubmit = true)
{
$resp = response::getInstance();
$resp->addJs('jquery');
$resp->addJs('plupload');
$resp->addJs('nyroPlupload');
$resp->addCss('plupload');
$pluploadOpts = $this->cfg->plupload;
if (count($opts)) {
factory::mergeCfg($pluploadOpts, $opts);
}
$pluploadOpts['file_data_name'] = $this->name;
$resp->blockjQuery('$("#' . $this->id . '").nyroPlupload(' . utils::jsEncode($pluploadOpts) . ');');
if ($hideSubmit) {
$resp->blockjQuery('$("#' . $this->id . '").closest("form").find("fieldset.submit").hide();');
}
}
示例4: execScaffoldList
protected function execScaffoldList($prm = null) {
$iconType = $this->cfg->iconType ? $this->cfg->iconType : $this->cfg->name;
$this->filterTable = null;
$query = null;
if (!empty($this->cfg->filter)) {
$this->filterTable = factory::getHelper('filterTable', array_merge($this->cfg->filterOpts, array(
'table'=>$this->table,
'fields'=>is_array($this->cfg->filter)? $this->cfg->filter : null,
)));
if ($this->cfg->addFilterTableJs)
response::getInstance()->addJs('filterTable');
if ($this->filterTable->hasValues())
$this->filterTable->getForm()->getCfg()->formPlus = str_replace('class="', 'class="filterTableActive ', $this->filterTable->getForm()->getCfg()->formPlus);
$this->hook('listFilter');
$query = array('where'=>$this->updateFilterWhere($this->filterTable->getWhere()));
}
$conf = array(
'table'=>$this->table,
'query'=>$query,
'name'=>$this->cfg->name.'DataTable',
'iconType'=>$iconType,
'cache'=>$this->cfg->cache,
'fields'=>$this->cfg->list,
'actions'=>array(
'show'=>request::uriDef(array('action'=>'show', 'param'=>'[id]')),
'edit'=>request::uriDef(array('action'=>'edit', 'param'=>'[id]')),
'delete'=>request::uriDef(array('action'=>'delete', 'param'=>'[id]')),
),
'actionsAlt'=>array(
'show'=>tr::__('scaffold_show'),
'edit'=>tr::__('scaffold_goEdit'),
'delete'=>tr::__('scaffold_delete'),
),
'multiple'=>$this->cfg->multiple,
'multipleAction'=>$this->cfg->multipleAction,
);
if ($this->cfg->multipleDelete) {
$conf['multiple'] = array_merge($conf['multiple'], array(
'delete'=>array(
'label'=>tr::__('scaffold_delete'),
)
));
}
factory::mergeCfg($conf, $this->cfg->listPrm);
$this->dataTable = factory::getHelper('dataTable', $conf);
$this->hook('list');
$this->setViewVars(array(
'filterTable'=>$this->filterTable,
'dataTable'=>$this->dataTable,
'iconType'=>$iconType,
'allowAdd'=>$this->cfg->allowAdd,
'addPage'=>request::uriDef(array('action'=>'add', 'param'=>''))
));
}
示例5: _initRelatedTables
/**
* Initialize the related tables, if needed
*/
protected function _initRelatedTables()
{
if (is_null($this->relatedTables)) {
$this->relatedTables = array();
$search = $this->rawName . '_';
$tables = $this->getDb()->getTablesWith(array('start' => $search));
foreach ($tables as $t) {
$relatedTable = substr($t, strlen($search));
$table = db::get('table', $t, array('db' => $this->getDb()));
$fields = $table->getField();
$fk1 = $fk2 = null;
foreach ($fields as $k => $v) {
if (is_null($fk1) && strpos($k, $this->rawName) !== false) {
$fk1 = array_merge($v, array('link' => $table->getLinked($k)));
unset($fields[$k]);
} else {
if (strpos($k, $relatedTable) !== false) {
$fk2 = array_merge($v, array('link' => $table->getLinked($k)));
unset($fields[$k]);
}
}
}
$this->relatedTables[$t] = array('tableObj' => $table, 'tableLink' => $t, 'table' => $relatedTable, 'fk1' => $fk1, 'fk2' => $fk2, 'fields' => $fields);
}
}
if ($this->cfg->check('related') && is_array($this->relatedTables) && !empty($this->relatedTables)) {
factory::mergeCfg($this->relatedTables, $this->cfg->related);
}
}
示例6: compress
/**
* Compress the file requested, using MoxieCompressor library
*
* @param string $type File type (css or js)
* @param array $prm Files to compress
*/
protected function compress($type, $prm) {
$resp = response::getInstance();
if ($type == 'js') {
$conf = $this->cfg->all;
factory::mergeCfg($conf, $this->cfg->js);
} else if ($type == 'css') {
$conf = $this->cfg->all;
factory::mergeCfg($conf, $this->cfg->css);
}
$key = $type.'--'.md5(serialize($prm)).'--'.md5(serialize($conf));
$supportsGzip = false;
if ($conf['compress']) {
$encodings = isset($_SERVER['HTTP_ACCEPT_ENCODING']) ? explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING']))) : array();
if ($conf['gzip_compress'] && (in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('gzencode') && !ini_get('zlib.output_compression')) {
$enc = in_array('x-gzip', $encodings) ? 'x-gzip' : 'gzip';
$supportsGzip = true;
$key = 'gzip-'.$key;
}
}
$content = null;
$cache = cache::getInstance($this->cfg->cache);
$cacheDate = $cache->get($content, array('id'=>$key));
if (!$conf['disk_cache'] || !$cacheDate) {
foreach($prm as $file) {
$f = file::nyroExists(array(
'name'=>'module_'.nyro::getCfg()->compressModule.'_'.$type.'_'.$file,
'type'=>'tpl',
'tplExt'=>$type
));
if ($f) {
if ($conf['php'])
$content.= file::fetch($f);
else
$content.= file::read($f);
}
}
if ($conf['compress']) {
if ($type == 'js') {
lib::load('jsMin');
$content = JSMin::minify($content);
} else if ($type == 'css') {
lib::load('cssMin');
$content = CssMin::minify($content, $conf['filters'], $conf['plugins']);
}
if ($supportsGzip)
$content = gzencode($content, 9, FORCE_GZIP);
}
$cache->save();
} else if ($cacheDate) {
$resp->addHeader('Age', time() - $cacheDate);
}
/* @var $resp response_http */
if ($conf['compress']) {
$resp->setCompress(false);
$resp->addHeader('Vary', 'Accept-Encoding'); // Handle proxies
if ($conf['etags'] || preg_match('/MSIE/i', $_SERVER['HTTP_USER_AGENT'])) {
// We need to use etags on IE since it will otherwise always load the contents
$resp->addHeader('ETag', md5($content));
}
$parseTime = $this->_parseTime($conf['expires_offset']);
$resp->addHeader('Expires', gmdate('D, d M Y H:i:s', time() + $parseTime).' GMT');
$resp->addHeader('Cache-Control', 'public, max-age='.$parseTime);
if ($type == 'js') {
// Output explorer workaround or compressed file
if (!isset($_GET['gz']) && $supportsGzip && $conf['patch_ie'] && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
// Build request URL
$url = $_SERVER['REQUEST_URI'];
if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'])
$url.= '?'.$_SERVER['QUERY_STRING'].'&gz=1';
else
$url.= '?gz=1';
// This script will ensure that the gzipped script gets loaded on IE versions with the Gzip request chunk bug
echo 'var gz;try {gz = new XMLHttpRequest();} catch(gz) { try {gz = new ActiveXObject("Microsoft.XMLHTTP");}';
echo 'catch (gz) {gz = new ActiveXObject("Msxml2.XMLHTTP");}}';
echo 'gz.open("GET", "'.$url.'", false);gz.send(null);eval(gz.responseText);';
die();
}
}
if ($supportsGzip)
$resp->addHeader('Content-Encoding', $enc);
}
$resp->sendText($content);
}