コード例 #1
0
 function test_embed_filter_and_lookup()
 {
     // Test filter returns non-empty ID
     $html = 'testing<br />';
     $id = admin_embed_filter($html);
     $this->assertGreaterThan(0, strlen($id));
     // Perform lookup
     $this->assertEquals($html, admin_embed_lookup($id));
     // Filter in reverse, same as lookup
     $this->assertEquals($html, admin_embed_filter($id, true));
 }
コード例 #2
0
ファイル: Functions.php プロジェクト: Selwyn-b/elefant
/**
 * The filter to save dynamic HTML embeds and get an ID value for them.
 * Saves to `cache/html/${md5($html)}.html`.
 *
 * If `$reverse` is set to true, it will call `admin_embed_lookup()`
 * instead to retrieve the original value, as dynamic embed filters
 * are supposed to do.
 */
function admin_embed_filter($html, $reverse = false)
{
    if ($reverse) {
        return admin_embed_lookup($html);
    }
    if (!@file_exists('cache/html')) {
        mkdir('cache/html', 0777);
    }
    $id = md5($html);
    file_put_contents('cache/html/' . $id . '.html', $html);
    return $id;
}
コード例 #3
0
ファイル: html.php プロジェクト: Selwyn-b/elefant
<?php

/**
 * Reverse lookup of HTML code from ID values.
 * Used in dynamic embeds so you can paste arbitrary
 * HTML into a page without alteration by the
 * WYSIWYG editor.
 */
require_once 'apps/admin/lib/Functions.php';
echo admin_embed_lookup($data['id']);