/* Produção dos links ou arquivos compactados.
para Style e Javascript

Em modo 'dev' gera somente os links;
Em modo 'pro' compacta e obfusca os arquivos e insere diretamente no HTML.
192199
private function assets()
    {
        $s = '';
        foreach($this->styles as $id=>$f){
            $s .= '<link id="stylesheet_'.$id.'" rel="stylesheet" href="'.$this->url.'css/'.$f.'.css">'."\n\t";
        }
        $this->val('style', $s);

        $s = '<script id="javascript_base">var URL=\''.$this->url.'\'';

        foreach ($this->jsvalues as $n=>$v) {
            $s .= ','.$n.'='.(is_string($v) ? '\''.str_replace("'", '"', $v).'\'' : $v);
        }
        $s .= ';</script>';
        
        foreach($this->scripts as $id=>$f){
            $s .= "\n\t".'<script id="javascript_'.$id.'" src="'.$this->url.'js/'.$f.'.js"></script>';
        }
        $this->val('script', $s); //e($this);
    }
852682
function(content){

			var html = '';

			html += '<div class="ja_wrap '+backgroundClasses.join(' ')+'">'+
					'<div class="jAlert '+classes.join(' ')+ '" style="' +styles.join(' ')+ '" id="' +alert.id+ '">'+
					'<div>';

			if( alert.closeBtn )
			{
				html += 		"<div class='closejAlert ja_close";
				if( alert.closeBtnAlt )
				{
					html += ' ja_close_alt';
				}
                else if( alert.closeBtnRoundWhite )
                {
                    html += ' ja_close_round_white';
                }
                else if( alert.closeBtnRound )
                {
                    html += ' ja_close_round';
                }
				html += "'>&times;</div>"; //closejAlert has a close handler attached, ja_close is for styling
			}

			if( alert.title )
			{
				html += 		"<div class='ja_title'><div>"+alert.title+"</div></div>";
			}

			html += 			'<div class="ja_body">'+content;


			if( alert.btns )
			{
				html += 			'<div class="ja_btn_wrap ';

				if( alert.btnBackground )
				{
					html += 		'optBack';
				}

				html += 			'">';
			}

			if( typeof alert.btns[0] == 'object' )
			{
				$.each(alert.btns, function(index, btn){
					if( typeof btn == 'object' )
					{
						html += 		getBtnHTML(btn);
					}
				});
			}
			else if( typeof alert.btns == 'object' )
			{
				html += 				getBtnHTML(alert.btns);
			}
			else if( alert.btns )
			{
				console.log('jAlert Config Error: Incorrect value for btns (must be object or array of objects): '+alert.btns);
			}

			if( alert.btns )
			{
				html += 			'</div>';
			}

			html += 			'</div>'+
					'</div>'+
					'</div>'+
					'</div>';

			var alertHTML = $(html);

			if( alert.replaceOtherAlerts )
			{
                var alerts = $('.jAlert:visible');
                alerts.each(function(){
                    $(this).jAlert().closeAlert();
                });
			}

			$('body').append(alertHTML);

            //cache instance
			alert.instance = $('#'+alert.id);

            //attach alert object to dom element
            alert.instance[0]['jAlert'] = alert;

            //doing this now will prevent it from happening mid-animation
            $('html,body').css('overflow', 'hidden');

            //show the new alert
			alert.animateAlert('show');

            //add close button handler
			if( alert.closeBtn ){

				alert.instance.on('click', '.closejAlert', function(e){
					e.preventDefault();
					$(this).parents('.jAlert:first').jAlert().closeAlert();
					return false;
				});

			}

			/* Bind mouseup handler to document if this alert has closeOnClick enabled */
			if( alert.closeOnClick ){

				/* Unbind if already exists */
				$(document).off('mouseup touchstart', $.fn.jAlert.onMouseUp);

				/* Bind mouseup */
				$(document).on('mouseup touchstart', $.fn.jAlert.onMouseUp);

			}

			/* Bind on keydown handler to document and if esc was pressed, find all visible jAlerts with that close option enabled and close them */
			if( alert.closeOnEsc ){

				/* Unbind if already exists */
				$(document).off('keydown', $.fn.jAlert.onEscKeyDown);

				/* Bind keydown */
				$(document).on('keydown', $.fn.jAlert.onEscKeyDown);

			}

			/* If there are onOpen callbacks, run them. */
			if( alert.onOpen )
			{
				$.each(alert.onOpen, function(index, onOpen){
					onOpen(alert.instance);
				});
			}

			/* If the alert has an element that should be focused by default */
			if( alert.autofocus )
			{
				alert.instance.find(alert.autofocus).focus();
			}
			else
			{
				alert.instance.focus();
			}
            /*
            	Set Auto
            	usage $.jAlert({
            		autoClose : 3500,
            	});
             */
            if(alert.autoClose)
            {
                $.fn.closeTimer(function()
				{
                    var currentAlert = $.jAlert('current');
                    if(currentAlert !== false)
                    {
                        currentAlert.closeAlert();
                    }
				}, alert.autoClose);
            }

			return alert.instance;

		}
915250
function remove_stylesheet_tags() {
      // We can remove the style tag with impunity, it is always inlining.
      html = html.replace(/<style.+?<\/style>/g, "");

      // External style resources use the link tag, check again for externals.
      if (options.clean_stylesheets) {
        html = html.replace(/<link[^>]+>/g, function(str){
          if (str.match(/src=/)) {
            grunt.log.warn('Found LINK tag with SRC attribute.');
            return str;
          }
          else if (! str.match(/ rel=['"]?stylesheet/)) { return str; }
          else if (str.match(/href=['"]?https?/)) { return str; }
          else if (str.match(/href=['"]?\/\//)) { return str; }
          else { return ""; }
        });
      }
    }
1308839
function makeLinks (links, item) {
  var retLinks = {}

  _.each(links, function (value, name) {
    if (_.isFunction(value)) {
      retLinks[name] = value(item)
    } else {
      retLinks[name] = _(value).toString()
    }
  })

  return retLinks
}
426660
private function produce($php = false, $brade = false, $sTag = true)
    {
        //With blade ???
        if($brade) $this->setContent($this->blade($this->getContent()));

        //With ©NeosTag ???
        if($sTag) {
            $ponteiro = -1;
            $content = $this->getContent();

            //Loop de varredura para o arquivo HTML
            while($ret = $this->sTag($content, $ponteiro)){
                $ponteiro = 0 + $ret['-final-'];
                $vartemp = '';

                //constant URL
                if($ret['-tipo-'] == 'var' && $ret['var'] == 'url') $vartemp = _URL;
                elseif (method_exists($this, '_' . $ret['-tipo-'])) $vartemp = $this->{'_' . $ret['-tipo-']}($ret);

                //Incluindo o bloco gerado pelas ©NeosTags
                $content = substr_replace($this->getContent(), $vartemp, $ret['-inicio-'], $ret['-tamanho-']);
                $this->setContent($content);

                //RE-setando o ponteiro depois de adicionar os dados acima
                $ponteiro = $ret['-inicio-'];
            }//end while
        }//end ©NeosTag

        //Eval PHP in HTML
        if($php) $this->evalPHP();

        //returns the processed contents
        return $this->getContent();
    }
954904
private static function buildLinksTags() :string {
		// this is where formatted links tags go
		$links = [];
		// pack and minify
		self::packAndMinifyLinks();
		// for each available link
		foreach(self::$_links as $href => $attributes) {
			// sort the attributes (compulse order needs)
			ksort($attributes);
			// build as base stylesheet link and merge its attributes
			$links[] = new \Polyfony\Element('link', $attributes);
		}
		return implode('', $links);
	}
840484
function buildStyles() {
  return Promise.resolve()
    // Create the dist folder if it doesn't exist
    .then(() => {
      if(!FS.existsSync(Path.join(__dirname, 'dist'))) {
        return FS.mkdirAsync(Path.join(__dirname, 'dist'));
      }
    })

    // Generate minified stylesheet
    .then(() => {
      let file = Path.join(__dirname, 'source/css/shoelace.css');
      let css = FS.readFileSync(file, 'utf8');

      return PostCSS([
        AtImport,
        CSSnext({
          features: {
            rem: false
          }
        }),
        CSSnano({
          autoprefixer: false,
          safe: true
        })
      ]).process(css, { from: file });
    })

    // Write stylesheet to dist
    .then((result) => {
      let file = Path.join(__dirname, 'dist/shoelace.css');

      // Update {{version}} in CSS since it's not processed with Handlebars
      result.css = result.css.replace(/\{\{version\}\}/g, __version);

      // Output a message
      console.log(Chalk.green('CSS processed: %s! 🦋'), Path.relative(__dirname, file));

      // Write output file
      return FS.writeFileAsync(file, result.css, 'utf8');
    });
}
1249040
public function generateCSS()
    {
        $result = '';

        $cssRaw       = '';
        $this->styles = array_unique($this->styles, SORT_REGULAR);
        foreach ($this->styles as $style) {
            if ($style[1]) {
                $cssRaw.=$style[0];
            } else {
                $result.='<link href="'.$style[0].'" rel="stylesheet" type="text/css" />';
            }
        }
        $result.=$cssRaw != '' ? '<style>'.$cssRaw.'</style>' : '';

        return $result;
    }
636977
public function buildHtml()
	{
		$list	= array();
		$divs	= array();
		foreach( $this->steps as $nr => $step )
		{
			$id		= $this->id."_link".$nr;
			$list[]	= UI_HTML_Elements::ListItem( $step['label'], 0, array( 'id' => $id ) );
			$id		= $this->id."_".$nr;
			$divs[] = UI_HTML_Tag::create( 'div', $step['content'], array( 'id' => $id ) );
		}
		$list	= UI_HTML_Elements::unorderedList( $list );
		$divs	= implode( "\n", $divs );
		$div	= UI_HTML_Tag::create( 'div', "\n".$list.$divs."\n", array( 'id' => $this->id ) );
		return $div;
	}
1140704
public function LinkForm()
    {
        $this->getLinkObject();

        $action = FormAction::create('doSaveLink', _t('Linkable.SAVE', 'Save'))
            ->setUseButtonTag('true');

        if (!$this->isFrontend) {
            $action
                ->addExtraClass('ss-ui-action-constructive')
                ->setAttribute('data-icon', 'accept');
        }

        $link = null;
        if ($linkID = (int)$this->request->getVar('LinkID')) {
            $link = Link::get()->byID($linkID);
        }

        $link = $link ? $link : singleton(Link::class);
        $link->setAllowedTypes($this->getAllowedTypes());

        /** @var $fields FieldList */
        $fields = $link->getCMSFields();

        $title = $link ? _t('Linkable.EDITLINK', 'Edit Link') : _t('Linkable.ADDLINK', 'Add Link');
        $fields->insertBefore(
            _t('Linkable.TITLE', 'Title'), HeaderField::create('LinkHeader', $title)
        );

        $actions = FieldList::create($action);
        $form = Form::create($this, 'LinkForm', $fields, $actions);

        if ($link) {
            $form->loadDataFrom($link);
            $fields->push(HiddenField::create('LinkID', 'LinkID', $link->ID));
        }

        $this->owner->extend('updateLinkForm', $form);

        return $form;
    }
663540
function inlineStylesheet($, filepath) {
  $('link[rel=stylesheet][href]').each(function() {
    var el      = $(this);
    var href    = el.attr('href');
    if(ABS.test(href)) return;
    var relpath = /^\./.test(href) ? href : './' + href;
    var srcpath = resolve.sync(relpath, {
      basedir    : dirname(filepath),
      extensions : [extname(relpath)]
    })
    var content = read(srcpath);
    var style = whacko('<style>' + content + '</style>');
    style.attr(el.attr());
    style.attr('href', null);
    style.attr('rel', null);
    el.replaceWith(whacko.html(style));
  })
}
690635
function (links) {
            var i, len;
            for (i = 0, len = links.length; i < len; ++i) {
                createLink(links[i]);
            }
        }
580476
function link(scope, element, attrs) {
      scope.showProp = showProp;
      scope.display = ModelDefinitions.display;

      function showProp(propDef) {
        return !scope.narrowMode || propDef.displayPriority !== 'low';
      }
    }
446344
private function obfuscateDirectoryDeep(string $path_plain, string $path_obfuscated) : bool
    {
        // Lista os arquivos do diretório
        $list = scandir($path_plain);
        if (count($list) == 2) { // '.', '..'
            // se não houverem arquivos, ignora o diretório
            return true;
        }

        // Cria o mesmo diretório para os arquivos ofuscados
        if ($this->makeDir($path_obfuscated) == false) {
            return false;
        }

        foreach ($list as $item) {

            if (in_array($item, ['.', '..']) ) {
                continue;
            }

            $iterate_current_item    = $path_plain . DIRECTORY_SEPARATOR . $item;
            $iterate_obfuscated_item = $path_obfuscated . DIRECTORY_SEPARATOR . $item;

            if (is_link($iterate_current_item)) {

                // LINKS
                // TODO: recriar os links
                $link = readlink($iterate_current_item);
                $this->links[$iterate_current_item] = $link;
                continue;

            } elseif (is_file($iterate_current_item) == true) {

                if ($this->isPhpFilename($iterate_current_item) == true
                 && $this->isNotObfuscateFile($iterate_current_item) == false
                ) {

                    // Arquivos PHP são ofuscados
                    if($this->obfuscateFile($iterate_current_item) == false) {
                        $this->addErrorMessage("Ocorreu um erro ao tentar ofuscar o arquivo: {$iterate_current_item}");
                        return false;
                    }

                    // Salva o arquivo sem a opção de 'auto-contido',
                    // ou seja, ele não pode ser revertido sem os outros arquivos do diretório
                    if ($this->save($iterate_obfuscated_item, false) == false) {
                        $this->addErrorMessage("Ocorreu um erro ao tentar salvar o arquivo ofuscado: {$iterate_obfuscated_item}");
                        return false;
                    }

                } else {

                    // Arquivos "não-PHP" ou arquivos marcados para "não-ofuscar"
                    // são simplesmente copiados
                    if (copy($iterate_current_item, $iterate_obfuscated_item) === false) {
                        $this->addErrorMessage("Arquivo " . $iterate_current_item . " não pôde ser copiado");
                        return false;
                    }
                }

            } elseif (is_dir($iterate_current_item) ) {

                if ($this->obfuscateDirectoryDeep($iterate_current_item, $iterate_obfuscated_item) == false) {
                    return false;
                }
            }
        }

        return true;
    }
1077948
function toHtml(){
        $retval = '';
        if ($this->_hiddenLabel){
            $this->_generateId();
            $retval = '<label class="accesshide" for="'.$this->getAttribute('id').'" >'.
                        $this->getLabel().'</label>'.parent::toHtml();
        } else {
             $retval = parent::toHtml();
        }

        if (!empty($this->_link)) {
            if (!empty($this->_linkreturn) && is_array($this->_linkreturn)) {
                $appendchar = '?';
                if (strstr($this->_link, '?')) {
                    $appendchar = '&amp;';
                }

                foreach ($this->_linkreturn as $key => $val) {
                    $this->_link .= $appendchar."$key=$val";
                    $appendchar = '&amp;';
                }
            }

            $retval .= '<a style="margin-left: 5px" href="'.$this->_link.'">'.$this->_linklabel.'</a>';
        }

        return $retval;
    }
1206899
def ler_configuracao
      #@artigo.merge!(YAML.load(ler_arquivo(Formatafacil::Tarefa.arquivo_configuracao)))
      #converte_parametros_para_boolean

      #@modelo = @artigo['modelo']
      if File.exist?(@arquivo_abstract) then
        @artigo['abstract'] = ler_arquivo(@arquivo_abstract)
        @artigo.merge!(ler_metadados_do_arquivo(@arquivo_abstract))
      end
      if File.exist?(@arquivo_resumo) then
        @artigo['resumo'] = ler_arquivo(@arquivo_resumo)
      end
      @artigo['bibliografia'] = ler_arquivo(@arquivo_bibliografia) if File.exist?(@arquivo_bibliografia)

      #unifica_metadados

    end
1263133
function cssFilesToStyleTag(dom) {
    const rootDir = `${__dirname}/`;

    const styles = m('div', {}, cssFiles.map(file => m('link', { rel: 'stylesheet', href: rootDir + file })));

    m.render(dom, styles);
  }