Example #1
0
            $this->enable = false;
        } else {
            throw new H2o_Error("Invalid syntax : autoescape on|off ");
        }
    }
    function render($context, $stream)
    {
        $context->autoescape = $this->enable;
    }
}
class Csrf_token_Tag extends H2o_Node
{
    function render($context, $stream)
    {
        $token = "";
        if (isset($_COOKIE["csrftoken"])) {
            $token = $_COOKIE["csrftoken"];
        } else {
            global $SECRET_KEY;
            if (defined('SECRET_KEY')) {
                $token = md5(mt_rand() . SECRET_KEY);
            } else {
                $token = md5(mt_rand());
            }
        }
        setcookie("csrftoken", $token, time() + 60 * 60 * 24 * 365, "/");
        $stream->write("<div style='display:none'><input type=\"hidden\" value=\"{$token}\" name=\"csrfmiddlewaretoken\" /></div>");
    }
}
H2o::addTag(array('block', 'extends', 'include', 'if', 'ifchanged', 'for', 'with', 'cycle', 'load', 'debug', 'now', 'autoescape', 'csrf_token'));
Example #2
0
        <li style="display: none"></li>
        %s
        </ul>
        </div>
        </div>
        </div>
        </div>
        <div class="switchDown">&nbsp;</div>
        </div>
        </li>';
        $sites = Doctrine_Query::create()->from('Site s')->execute();
        $sitesArr = array();
        $selectedsiteName = '';
        $siteId = SITE_ID;
        foreach ($sites as $value) {
            $sitesArr[] = sprintf('<li><a href="?site=%d">%s</a></li>', $value->id, $value->name);
            if ($siteId == $value->id) {
                $selectedsiteName = $value->name;
            }
        }
        $stream->write(sprintf($html, $selectedsiteName, implode('', $sitesArr)));
    }
}
H2o::addTag(array('result_list'));
H2o::addTag(array('get_admin_menu'));
H2o::addTag(array('get_admin_submenu'));
H2o::addTag(array('admin_list_filter'));
H2o::addTag(array('admin_list_search'));
H2o::addTag(array('admin_actions'));
H2o::addTag(array('account_switcher'));
Example #3
0
        $this->argument = $argstring;
    }
    function render($context, $stream)
    {
        if ($this->argument) {
            $object = $context->resolve(symbol($this->argument));
        } else {
            $object = $context->scopes[0];
        }
        $output = "<pre>" . print_r($object, true) . "</pre>";
        $stream->write($output);
    }
}
class Now_Tag extends H2o_Node
{
    function __construct($argstring, $parser, $pos = 0)
    {
        $this->format = $argstring;
        if (!$this->format) {
            $this->format = "D M j G:i:s T Y";
        }
    }
    function render($contxt, $stream)
    {
        sleep(1);
        $time = date($this->format);
        $stream->write($time);
    }
}
H2o::addTag(array('block', 'extends', 'include', 'if', 'for', 'with', 'cycle', 'load', 'debug', 'now'));
Example #4
0
    {
        $contentType = ContentType::get_for_model('Post', 'Pjango\\Contrib\\Post');
        $slug = false;
        if (isset($this->args[0])) {
            $slug = $this->clearQuotes($this->args[0]);
        }
        $q = Doctrine_Query::create()->from('PostCategory c')->leftJoin('c.Translation t')->where('c.site_id = ? AND c.taxonomy = ?', array(SITE_ID, Post::TYPE_POST));
        if ($slug) {
            $category = PostCategory::findBySlug($slug, Post::TYPE_POST);
            if ($category) {
                $q->andWhere('c.lft >= ? AND c.rgt <= ?', array($category->lft, $category->rgt));
            }
        }
        $results = $q->execute();
        //print_r($results->toArray());
        $htmlContent = '<div class="section post">';
        if ($pageLayout->show_title) {
            $htmlContent .= '<h2>' . __($pageLayout->title) . '</h2>';
        }
        $htmlContent .= '<div class="box-content">';
        //$htmlContent .= '<ul>'.implode('', $htmlItems).'</ul>';
        $htmlContent .= '</div>';
        $htmlContent .= '<div class="buttons"><div class="right"><a href="' . pjango_ini_get('SITE_URL') . '/post/">' . __('All Posts') . ' &raquo;</a></div></div>';
        $htmlContent .= '<div style="clear:both;"></div>';
        $htmlContent .= '</div>';
        //$stream->write($htmlContent);
    }
}
H2o::addTag(array('post'));
H2o::addTag(array('post_category_tree'));