Esempio n. 1
0
 /**
  * HTML属性削除処理の実行
  *
  * Pickles2の状態を参照し、自動的に処理を振り分けます。
  *
  * - パブリッシュする場合、DECコメントを削除します。
  * - プレビューの場合、DECライブラリを埋め込み、URIパラメータからDECの表示・非表示を切り替えられるようにします。
  *
  * @param object $px Picklesオブジェクト
  * @param object $options オプション
  * @return boolean true
  */
 public static function exec($px, $options = null)
 {
     require_once __DIR__ . '/simple_html_dom.php';
     if (!$px->is_publish_tool()) {
         // パブリッシュ時にのみ働きます。
         return true;
     }
     if (!@is_array($options->attrs)) {
         @($options->attrs = array());
     }
     // var_dump($options);
     foreach ($px->bowl()->get_keys() as $key) {
         $src = $px->bowl()->pull($key);
         // HTML属性を削除
         $html = str_get_html($src, true, true, DEFAULT_TARGET_CHARSET, false, DEFAULT_BR_TEXT, DEFAULT_SPAN_TEXT);
         foreach ($options->attrs as $attr) {
             $ret = $html->find('*[' . $attr . ']');
             foreach ($ret as $retRow) {
                 // var_dump($retRow->$attr);
                 $retRow->{$attr} = null;
             }
         }
         $src = $html->outertext;
         $px->bowl()->replace($src, $key);
     }
     return true;
 }
Esempio n. 2
0
 /**
  * 変換処理の実行
  * @param object $px Picklesオブジェクト
  */
 public static function exec($px)
 {
     foreach ($px->bowl()->get_keys() as $key) {
         $src = $px->bowl()->pull($key);
         if ($key != 'head' && $key != 'foot') {
             $src = \Michelf\MarkdownExtra::defaultTransform($src);
         }
         $px->bowl()->replace($src, $key);
     }
     return true;
 }
Esempio n. 3
0
 /**
  * 変換処理の実行
  * @param object $px Picklesオブジェクト
  */
 public static function exec($px)
 {
     foreach ($px->bowl()->get_keys() as $key) {
         $src = $px->bowl()->pull($key);
         $tmp_current_dir = realpath('./');
         chdir(dirname($_SERVER['SCRIPT_FILENAME']));
         $scss = new \Leafo\ScssPhp\Compiler();
         $src = $scss->compile($src);
         chdir($tmp_current_dir);
         $px->bowl()->replace($src, $key);
     }
     return true;
 }
Esempio n. 4
0
 /**
  * 変換処理の実行
  * @param object $px Picklesオブジェクト
  */
 public static function exec_ext($px)
 {
     $data = $px->site()->get_current_page_info();
     foreach ($px->bowl()->get_keys() as $key) {
         $src = $px->bowl()->pull($key);
         // Using Library "ronan-gloo/jade-php" ==> see https://github.com/ronan-gloo/jade-php
         $jade = new \Jade\Jade(['prettyprint' => true]);
         ob_start();
         $results = $jade->render($src, $data);
         $src = ob_get_clean();
         $src = $px->bowl()->replace($src, $key);
     }
     return true;
 }
Esempio n. 5
0
 /**
  * extensions function
  * @param object $px Picklesオブジェクト
  */
 public static function exec($px)
 {
     $autoindex = new self($px);
     //  autoindex
     if (strlen($autoindex->func_data_memos)) {
         $px->bowl()->each(array($autoindex, 'apply_autoindex'));
     }
     return true;
 }
Esempio n. 6
0
 /**
  * 自動DEC表示機能を追加する
  *
  * URIパラメータ `showDEC` をつけてアクセスすると、自動的にDECが表示されるようになります。
  *
  *   例: http://yourdomain.com/abc/def.html?showDEC
  *
  * @param object $px Picklesオブジェクト
  * @param object $options オプション
  * @return boolean true
  */
 public static function add_auto_dec($px, $options = null)
 {
     $jscode = file_get_contents(__DIR__ . '/res/dec.js');
     $jscode = '<script>' . $jscode . '</script>';
     foreach ($px->bowl()->get_keys() as $key) {
         $src = $px->bowl()->pull($key);
         // body要素の最後にスクリプトを追加
         if (preg_match('/<\\/body>/is', $src)) {
             // body要素の閉じタグが見つかる場合、
             // その手前に挿入
             $src = preg_replace('/<\\/body>/is', $jscode . '</body>', $src);
         } else {
             // body要素の閉じタグが見つからない場合、
             // コードの最後に追記
             $src .= $jscode;
         }
         $px->bowl()->replace($src, $key);
     }
     return true;
 }
Esempio n. 7
0
 /**
  * execute content
  * @param object $px picklesオブジェクト
  * @return bool true
  */
 private static function exec_content($px)
 {
     if (!$px->fs()->is_file('./' . $px->get_path_content())) {
         @header('Content-type: text/html;');
         $px->set_status(404);
         // 404 NotFound
         $px->bowl()->send('<p>404 - File not found.</p>');
         return true;
     }
     if ($px->proc_type === 'direct') {
         $src = $px->fs()->read_file('./' . $px->get_path_content());
     } else {
         ob_start();
         include './' . $px->get_path_content();
         $src = ob_get_clean();
     }
     $px->bowl()->send($src);
     return true;
 }
Esempio n. 8
0
 /**
  * Starting function
  * @param object $px Picklesオブジェクト
  * @param object $options オプション
  * <dl>
  * <dt>$options->output_encoding</dt>
  * 	<dd>出力エンコーディング。<code>mb_convert_encoding()</code> が取り扱えるエンコード名で指定します。</dd>
  * <dt>$options->output_eol_coding</dt>
  * 	<dd>出力改行コード。文字列で、<code>crlf</code>、<code>cr</code>、または <code>lf</code> のいずれかで指定します。</dd>
  * </dl>
  * 
  * 省略時は、`$px->conf()` から、同名の値を参照します。
  * 
  * どちらにも設定がない場合、encodingconverter は変換を実行しません。
  */
 public static function exec($px, $options = null)
 {
     $me = new self($px, $options);
     $px->bowl()->each(array($me, 'apply'));
 }