本文整理汇总了PHP中Parse::template方法的典型用法代码示例。如果您正苦于以下问题:PHP Parse::template方法的具体用法?PHP Parse::template怎么用?PHP Parse::template使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parse
的用法示例。
在下文中一共展示了Parse::template方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render()
{
$options = $this->getConfig();
$field_options = array_get($this->field_config, 'options', array());
$options = array_merge($options, $field_options);
// File options
if ($file_dir = array_get($this->field_config, 'file_dir', false)) {
$file_dir = trim(array_get($this->field_config, 'file_dir'), '/') . '/';
$options['fileUpload'] = Config::getSiteRoot() . 'TRIGGER/redactor/upload?path=' . $file_dir;
$options['fileManagerJson'] = Config::getSiteRoot() . 'TRIGGER/redactor/fetch_files?path=' . $file_dir;
$options['plugins'][] = 'filemanager';
}
// Image options
if ($image_dir = array_get($this->field_config, 'image_dir', false)) {
$image_dir = trim(array_get($this->field_config, 'image_dir'), '/') . '/';
$options['imageUpload'] = Config::getSiteRoot() . 'TRIGGER/redactor/upload?path=' . $image_dir;
$options['imageManagerJson'] = Config::getSiteRoot() . 'TRIGGER/redactor/fetch_images?path=' . $image_dir;
$options['plugins'][] = 'imagemanager';
if ($resize = array_get($this->field_config, 'resize')) {
$options['imageUpload'] .= '&resize=1&' . http_build_query($resize);
}
}
// Enable plugins
$supported_plugins = array('table', 'video', 'fullscreen', 'fontcolor', 'fontsize', 'fontfamily');
foreach ($options['buttons'] as $button) {
if (in_array($button, $supported_plugins)) {
$options['plugins'][] = $button;
}
}
$vars = array('field_id' => $this->field_id, 'field_name' => $this->fieldname, 'tabindex' => $this->tabindex, 'field_data' => $this->field_data, 'field_config' => $this->field_config, 'options' => $options);
$template = File::get($this->getAddonLocation() . 'views/fieldtype.html');
return Parse::template($template, $vars);
}
示例2: __call
public function __call($method, $arguments)
{
$extensions = array(".html", ".md", ".markdown", ".textile");
$html = null;
foreach ($extensions as $extension) {
$full_src = Path::assemble(BASE_PATH, Config::getCurrentThemePath(), 'partials', ltrim($method . $extension, '/'));
if (File::exists($full_src)) {
// Merge additional variables passed as parameters
Statamic_View::$_dataStore = $arguments + Statamic_View::$_dataStore;
if ($this->fetchParam('use_context', false, false, true, false)) {
$html = Parse::contextualTemplate(File::get($full_src), Statamic_View::$_dataStore, $this->context, 'Statamic_View::callback');
} else {
$html = Parse::template(File::get($full_src), Statamic_View::$_dataStore, 'Statamic_View::callback');
}
// parse contents if needed
if ($extension == ".md" || $extension == ".markdown") {
$html = Parse::markdown($html);
} elseif ($extension == ".textile") {
$html = Parse::textile($html);
}
}
}
if (Config::get('enable_smartypants', TRUE)) {
$html = Parse::smartypants($html);
}
return $html;
}
示例3: render
public function render()
{
$data = $this->field_data ? $this->field_data : array(array('cells' => array('')));
$vars = array('field_id' => $this->field_id, 'field_name' => $this->fieldname, 'height' => array_get($this->field_config, 'height'), 'rows' => json_encode($data));
$template = File::get($this->getAddonLocation() . 'views/fieldtype.html');
return Parse::template($template, $vars);
}
示例4: getContent
/**
* Lists entries based on passed parameters
*
* @return array|string
*/
public function getContent($variable)
{
$urls = array_get($this->context, $variable);
if (!$urls) {
return null;
}
// grab common parameters
$settings = $this->parseCommonParameters();
// grab content set based on the common parameters
// $content_set = $this->getContentSet($settings);
$content_set = ContentService::getContentByURL($urls);
$content_set->filter(array('show_hidden' => $this->fetchParam('show_hidden', false, null, true, false), 'show_drafts' => $this->fetchParam('show_drafts', false, null, true, false), 'show_past' => $this->fetchParam('show_past', true, null, true), 'show_future' => $this->fetchParam('show_future', false, null, true), 'type' => 'all', 'conditions' => trim($this->fetchParam('conditions', null, false, false, false))));
// limit
$limit = $this->fetchParam('limit', null, 'is_numeric');
$offset = $this->fetchParam('offset', 0, 'is_numeric');
if ($limit || $offset) {
$content_set->limit($limit, $offset);
}
// sort
$sort_by = $this->fetchParam('sort_by');
$sort_dir = $this->fetchParam('sort_dir');
if ($sort_by || $sort_dir) {
$content_set->sort($sort_by, $sort_dir);
}
// check for results
if (!$content_set->count()) {
return Parse::template($this->content, array('no_results' => true));
}
return Parse::tagLoop($this->content, $content_set->get(), false, $this->context);
}
示例5: profile
public function profile()
{
$current_user = Statamic_Auth::get_current_user() ? Statamic_Auth::get_current_user()->get_name() : false;
$member = $this->fetchParam('member', $current_user);
$profile_data = Statamic_user::get_profile($member);
if ($profile_data) {
return Parse::template($this->content, $profile_data);
}
}
示例6: setTemplates
/**
* Generate the set templates
*
* @return string JSON encoded string of templates
*/
private function setTemplates()
{
$template = File::get($this->getAddonLocation() . 'views/templates.html');
foreach ($this->set_types as $set) {
$set['buttons'] = $this->buttons;
$templates[] = array('type' => $set['name'], 'html' => Parse::template($template, $set));
}
return json_encode($templates);
}
示例7: file__thumbnail
public function file__thumbnail()
{
if ( ! $path = Request::get('path')) {
exit('No path specified');
}
$template = "{{ transform src='{ path }' width='125' height='125' action='smart' }}";
exit(Parse::template($template, compact('path')));
}
示例8: control_panel__add_to_head
public function control_panel__add_to_head()
{
if (URL::getCurrent(false) != '/publish' && URL::getCurrent(false) != '/member') {
return;
}
$config = array('max_files' => 1, 'allowed' => array(), 'destination' => 'UPLOAD_PATH', 'browse' => false);
$fieldtype = Fieldtype::render_fieldtype('file', 'markituploader', $config, null, null, 'markituploader', 'markituploader');
$template = File::get($this->getAddonLocation() . 'views/modal.html');
return $this->js->inline('Statamic.markituploader = ' . json_encode(Parse::template($template, compact('fieldtype'))) . ';');
}
示例9: generateModal
public function generateModal($config, $destination)
{
$vars = array(
'server_files' => $this->getServerFiles($config, $destination),
'destination' => $destination
);
$template = File::get($this->getAddonLocation() . 'views/modal.html');
return Parse::template($template, $vars);
}
示例10: map_url
public function map_url()
{
// parse settings
$settings = $this->parseParameters();
// we need to set auto_center to false, here's why:
// this tag will only ever place one marker on the map, and because of
// the situation, we'll always know its latitude and longitude; by not
// setting auto_center to false, starting_zoom no longer works (as the
// auto_center function will try to determine the best zoom within the
// allowed min_zoom and max_zoom); setting this to false allows users
// to start using starting_zoom again without having to worry about any
// automagic stuff taking over and wrestling away control
$settings['auto_center'] = 'false';
$content_set = ContentService::getContentAsContentSet($settings['url']);
// supplement
$content_set->supplement(array(
'locate_with' => $settings['locate_with'],
'center_point' => $settings['center_point'],
'pop_up_template' => $this->content
));
// re-filter, we only want entries that have been found
$content_set->filter(array('located' => true));
$content = $content_set->get();
// no results? no results.
if (!count($content)) {
return Parse::template($this->content, array('no_results' => true));
}
// check for valid center point
if (!preg_match(Pattern::COORDINATES, $settings['center_point'], $matches)) {
if (
$settings['locate_with'] &&
isset($content[0][$settings['locate_with']]) &&
is_array($content[0][$settings['locate_with']]) &&
isset($content[0][$settings['locate_with']]['latitude']) &&
isset($content[0][$settings['locate_with']]['longitude'])
) {
$settings['starting_latitude'] = $content[0][$settings['locate_with']]['latitude'];
$settings['starting_longitude'] = $content[0][$settings['locate_with']]['longitude'];
}
} else {
$settings['starting_latitude'] = $matches[1];
$settings['starting_longitude'] = $matches[2];
}
// other overrides
$settings['clusters'] = 'false';
return $this->buildScript($content, $settings);
}
示例11: render
public function render()
{
// Let's make sure they set an upload destination
if (array_get($this->field_config, 'destination', false) === false) {
throw new Exception("You need to set a destination for your File field.");
}
// Normalize the destination
$this->destination = trim(array_get($this->field_config, 'destination'), '/') . '/';
// Allow a string or an array, but we want an array
$has_data = ($this->field_data != '');
$this->field_data = Helper::ensureArray($this->field_data);
// Clean up {{ _site_root }} and lack of leading slash existence
foreach ($this->field_data as $i => $file) {
$this->field_data[$i] = URL::tidy('/' . str_replace('{{ _site_root }}', '', $file));
}
// Whether or not to allow the browse existing files functionality
$allow_browse = array_get($this->field_config, 'browse', true);
// Resizing config
if ($resize = array_get($this->field_config, 'resize')) {
$resize['resize'] = true;
$resize = http_build_query($resize);
}
// If we're in a subdirectory, prepend it to all the filenames
if (($site_root = Config::getSiteRoot()) != '/') {
foreach ($this->field_data as $i => $file) {
$this->field_data[$i] = URL::assemble($site_root, $file);
}
}
// Send data to the view
$vars = array(
'field_id' => $this->field_id,
'field_name' => $this->fieldname,
'tabindex' => $this->tabindex,
'has_data' => $has_data,
'field_data' => $this->field_data,
'field_config' => $this->field_config,
'destination' => $this->destination,
'allow_browse' => $allow_browse,
'server_files' => ($allow_browse) ? json_encode($this->tasks->generateModal($this->field_config, $this->destination)) : null,
'file_thumb' => URL::assemble(Config::getSiteRoot(), Config::get('admin_path'), 'themes', Config::get('admin_theme'), '/img/file.png'),
'resize' => $resize
);
$template = File::get($this->getAddonLocation() . 'views/fieldtype.html');
return Parse::template($template, $vars);
}
示例12: words
public function words()
{
$limit = $this->fetchParam('limit', NULL);
$ending = $this->fetchParam('ending', '...');
$this->content = Parse::template($this->content, Statamic_View::$_dataStore, 'Statamic_View::callback');
$words = preg_split("/[\n\r\t ]+/", $this->content, $limit + 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE);
if (count($words) > $limit) {
end($words);
$last_word = prev($words);
$this->content = substr($this->content, 0, $last_word[1] + strlen($last_word[0])) . $ending;
}
return $this->content;
}
示例13: partial
public function partial()
{
$src = $this->fetchParam('src', null, null, false, false);
if ($src) {
$src .= ".html";
$partial_path = $this->theme_root . 'partials/' . ltrim($src, '/');
if (File::exists($partial_path)) {
Statamic_View::$_dataStore = array_merge(Statamic_View::$_dataStore, $this->attributes);
return Parse::template(file_get_contents($partial_path), Statamic_View::$_dataStore, 'Statamic_View::callback');
}
}
return null;
}
示例14: render
public function render()
{
// Generate a hash unique to this field's config and data
$hash = Helper::makeHash($this->field_config, $this->field_data);
// If we've already saved the output, grab it from blink's cache
// and avoid further processing.
if ($this->blink->exists($hash)) {
$html = $this->blink->get($hash);
return $this->renderFieldReplacements($html);
}
// Let's make sure they set an upload destination
if (array_get($this->field_config, 'destination', false) === false) {
throw new Exception("You need to set a destination for your File field.");
}
// Normalize the destination
$this->destination = trim(array_get($this->field_config, 'destination'), '/') . '/';
// Allow a string or an array, but we want an array
$has_data = $this->field_data != '';
$this->field_data = Helper::ensureArray($this->field_data);
// Clean up {{ _site_root }} and lack of leading slash existence
foreach ($this->field_data as $i => $file) {
$this->field_data[$i] = URL::tidy('/' . str_replace('{{ _site_root }}', '', $file));
}
// Whether or not to allow the browse existing files functionality
$allow_browse = array_get($this->field_config, 'browse', true);
// Resizing config
if ($resize = array_get($this->field_config, 'resize')) {
$resize['resize'] = true;
$resize = http_build_query($resize);
}
// If we're in a subdirectory, prepend it to all the filenames
if (($site_root = Config::getSiteRoot()) != '/') {
foreach ($this->field_data as $i => $file) {
$this->field_data[$i] = URL::assemble($site_root, $file);
}
}
// Send data to the view
$vars = array('field_id' => $this->field_id, 'field_name' => $this->fieldname, 'tabindex' => $this->tabindex, 'has_data' => $has_data, 'field_data' => $this->field_data, 'field_config' => $this->field_config, 'destination' => $this->destination, 'allow_browse' => $allow_browse, 'browse_url' => URL::assemble(Config::getSiteRoot(), Config::get('admin_path') . '.php/files?config=' . rawurlencode(Helper::encrypt(serialize($this->field_config)))), 'file_thumb' => $this->tasks->defaultFileThumbnail(), 'resize' => $resize);
// Get the view template from the file
$template = File::get($this->getAddonLocation() . 'views/fieldtype.html');
// Parse it
$html = Parse::template($template, $vars);
// Save it to cache for other similar fields
$this->blink->set($hash, $html);
// Output!
return $this->renderFieldReplacements($html);
}
示例15: render
public function render()
{
$vars = array(
'field_id' => $this->field_id,
'field_name' => $this->fieldname,
'tabindex' => $this->tabindex,
'field_data' => $this->field_data,
'field_config' => $this->field_config,
'file_dir' => trim(array_get($this->field_config, 'file_dir'), '/') . '/',
'image_dir' => trim(array_get($this->field_config, 'image_dir'), '/') . '/',
'buttons' => array_get($this->field_config, 'buttons', $this->config['buttons']),
'resize' => array_get($this->field_config, 'resize')
);
$template = File::get($this->getAddonLocation() . 'views/fieldtype.html');
return Parse::template($template, $vars);
}