当前位置: 首页>>代码示例>>PHP>>正文


PHP Template::factory方法代码示例

本文整理汇总了PHP中Template::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Template::factory方法的具体用法?PHP Template::factory怎么用?PHP Template::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Template的用法示例。


在下文中一共展示了Template::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: historyAction

 public function historyAction()
 {
     $historylimit = $this->config['history'];
     $historykey = "phpredmin:terminal:history";
     $historylen = $this->db->lLen($historykey);
     $command = '';
     $reset = false;
     if ($historylimit > 0 && $historylen > 0) {
         $navigation = $this->inputs->get('navigation', self::NAVIGATION_UP);
         $start = $this->inputs->get('start');
         $pointer = $this->db->get("phpredmin:terminal:history:pointer");
         if ($historylen > $historylimit) {
             $this->db->lTrim($historykey, $historylimit * -1, -1);
             $historylen = $historylimit;
         }
         if ($navigation == self::NAVIGATION_UP) {
             if ($historylen <= $pointer * -1) {
                 $pointer = $historylen * -1;
             } elseif (!isset($start)) {
                 $pointer--;
             }
         } elseif ($pointer != -1) {
             $pointer++;
         } else {
             $reset = true;
         }
         $command = $this->db->lRange($historykey, $pointer, $pointer);
         $this->db->set("phpredmin:terminal:history:pointer", $pointer);
     }
     Template::factory('json')->render(array('command' => $command, 'reset' => $reset));
 }
开发者ID:BlackIkeEagle,项目名称:phpredmin,代码行数:31,代码来源:terminal.php

示例2: email

 public function email($email)
 {
     if (is_array($this->emails)) {
         foreach ($this->emails as $settings) {
             $send = TRUE;
             if ($settings['to_element'] !== 'manual') {
                 // replace to_email with value from form
                 $settings['to_email'] = $this->_form->value($settings['to_element']);
             }
             // replace text in body
             $settings['body'] = Template::factory($settings['body'], $this->_form->values())->render();
             // check if email is ok
             if (filter_var($settings['to_email'], FILTER_VALIDATE_EMAIL) === FALSE) {
                 $send = FALSE;
             }
             //if it's ok to send: do it
             if ($send) {
                 // feed the settings to the mailer
                 $email->settings($settings);
                 // send it out
                 try {
                     $email->send();
                 } catch (Exception $e) {
                     Kohana::$log->add(Log::ERROR, 'Failed sending email: ' . var_export($settings, TRUE) . ' with exception: ' . var_export($e, TRUE));
                 }
             }
         }
     }
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:29,代码来源:Form.php

示例3: viewAction

 public function viewAction($key, $page = 0)
 {
     $count = $this->db->lSize(urldecode($key));
     $start = $page * 30;
     $values = $this->db->lRange(urldecode($key), $start, $start + 29);
     Template::factory()->render('lists/view', array('count' => $count, 'values' => $values, 'key' => urldecode($key), 'page' => $page));
 }
开发者ID:BlackIkeEagle,项目名称:phpredmin,代码行数:7,代码来源:lists.php

示例4: Poll

function Poll($id, $question, $answer1 = 'Yes', $answer2 = 'No')
{
    // values
    $id = isset($id) ? $id : '';
    $question = isset($question) ? $question : '';
    $answer1 = isset($answer1) ? $answer1 : '';
    $answer2 = isset($answer2) ? $answer2 : '';
    // json dir
    $dir = PLUGINS_PATH . '/poll/db/db.json';
    // clear vars init
    $db = '';
    $data = '';
    // check if exists file if not make one
    if (File::exists($dir)) {
        $db = File::getContent($dir);
        $data = json_decode($db, true);
        if (!$data[$id]) {
            // array of data
            $data[$id] = array('question' => '', 'yes' => '', 'no' => '');
            File::setContent($dir, json_encode($data));
            // redirect
            Request::redirect(Url::getCurrent());
        }
    } else {
        File::setContent($dir, '[]');
    }
    // check session if exists show answer only
    if (Session::get('user_poll' . $id)) {
        $template = Template::factory(PLUGINS_PATH . '/poll/template/');
        return $template->fetch('answer.tpl', ['id' => trim($id), 'question' => trim($question), 'answer1' => trim($answer1), 'answer2' => trim($answer2), 'yes' => $data[$id]['yes'], 'no' => $data[$id]['no']]);
    } else {
        // form post
        if (Request::post('sendData_' . $id)) {
            // check token
            if (Request::post('token')) {
                if (Request::post('answer') == 1) {
                    $good = $data[$id]['yes'] + 1;
                    $bad = $data[$id]['no'];
                } elseif (Request::post('answer') == 0) {
                    $bad = $data[$id]['no'] + 1;
                    $good = $data[$id]['yes'];
                }
                // array of data
                $data[$id] = array('question' => $question, 'yes' => $good, 'no' => $bad);
                // set content
                File::setContent($dir, json_encode($data));
                // set session cookie
                Session::set('user_poll' . $id, uniqid($id));
                // redirect
                Request::redirect(Url::getCurrent());
            } else {
                die('crsf detect !');
            }
        }
        // show template form
        $template = Template::factory(PLUGINS_PATH . '/poll/template/');
        return $template->fetch('poll.tpl', ['id' => trim($id), 'question' => trim($question), 'answer1' => trim($answer1), 'answer2' => trim($answer2), 'yes' => $data[$id]['yes'], 'no' => $data[$id]['no']]);
    }
}
开发者ID:nakome,项目名称:Fansoro-poll-plugin,代码行数:59,代码来源:poll.php

示例5: short

/**
 * Description: add Shortcode.
 */
function short($attributes)
{
    extract($attributes);
    $text = isset($text) ? $text : 'Start Collab';
    $end = isset($end) ? $end : 'End Collab';
    $class = isset($class) ? $class : 'btn btn-default';
    $icon = isset($icon) ? '<i class="' . $icon . '"></i> ' : '';
    $template = Template::factory(PLUGINS_PATH . '/togetherjs/template/');
    return $template->fetch('btn.tpl', ['text' => $text, 'end' => $end, 'class' => $class, 'icon' => $icon]);
}
开发者ID:nakome,项目名称:Fansoro-togetherjs-plugin,代码行数:13,代码来源:togetherjs.php

示例6: addAction

 public function addAction()
 {
     $added = false;
     if ($this->router->method == Router::POST) {
         $value = $this->inputs->post('value', null);
         $key = $this->inputs->post('key', null);
         if (isset($value) && trim($value) != '' && isset($key) && trim($key) != '') {
             $added = $this->db->set($key, $value);
         }
     }
     Template::factory('json')->render($added);
 }
开发者ID:BlackIkeEagle,项目名称:phpredmin,代码行数:12,代码来源:strings.php

示例7: delallAction

 public function delallAction()
 {
     if ($this->router->method == Router::POST) {
         $results = array();
         $values = $this->inputs->post('values', array());
         $keyinfo = $this->inputs->post('keyinfo', null);
         foreach ($values as $key => $value) {
             $results[$value] = $this->db->zDelete($keyinfo, $value);
         }
         Template::factory('json')->render($results);
     }
 }
开发者ID:BlackIkeEagle,项目名称:phpredmin,代码行数:12,代码来源:zsets.php

示例8: moveallAction

 public function moveallAction()
 {
     if ($this->router->method == Router::POST) {
         $results = array();
         $values = $this->inputs->post('values', array());
         $destination = $this->inputs->post('destination');
         $keyinfo = $this->inputs->post('keyinfo');
         foreach ($values as $key => $value) {
             $results[$value] = $this->db->sMove($value, $keyinfo, $destination);
         }
         Template::factory('json')->render($results);
     }
 }
开发者ID:xxoxx,项目名称:phpredmin,代码行数:13,代码来源:sets.php

示例9: slowlogAction

 public function slowlogAction()
 {
     $support = false;
     $slowlogs = array();
     $serverInfo = $this->db->info('server');
     $count = $this->inputs->post('count', null);
     $count = isset($count) ? $count : 10;
     if (!preg_match('/^(0|1)/', $serverInfo['redis_version']) && !preg_match('/^2\\.[0-5]/', $serverInfo['redis_version'])) {
         $slowlogs = $this->db->eval("return redis.call('slowlog', 'get', {$count})");
         $support = true;
     }
     Template::factory()->render('welcome/slowlog', array('slowlogs' => $slowlogs, 'support' => $support, 'version' => $serverInfo['redis_version'], 'count' => $count));
 }
开发者ID:BlackIkeEagle,项目名称:phpredmin,代码行数:13,代码来源:welcome.php

示例10: __construct

 /**
  * Constructor.
  *
  * @access  protected
  */
 protected function __construct()
 {
     // Get Theme Templates
     static::$current_template = Template::factory(THEMES_PATH . '/' . Config::get('system.theme'));
     // Get Current Page
     static::$current_page = static::getPage(Url::getUriString());
     // Send default header
     header('Content-Type: text/html; charset=' . Config::get('system.charset'));
     // Run actions before page rendered
     Action::run('before_page_rendered');
     // Display page for current requested url
     static::display(static::$current_page);
     // Run actions after page rendered
     Action::run('after_page_rendered');
 }
开发者ID:cv0,项目名称:fansoro,代码行数:20,代码来源:Pages.php

示例11: editAction

 public function editAction($key, $member)
 {
     $edited = null;
     if ($this->router->method == Router::POST) {
         $newvalue = $this->inputs->post('newvalue', null);
         $member = $this->inputs->post('member', null);
         $key = $this->inputs->post('key', null);
         if (!isset($newvalue) || trim($newvalue) == '' || !isset($key) || trim($key) == '' || !isset($member) || trim($member) == '') {
             $edited = false;
         } elseif ($this->db->hDel($key, $member)) {
             $edited = $this->db->hSet($key, $member, $newvalue);
         }
     }
     $value = $this->db->hGet(urldecode($key), urldecode($member));
     Template::factory()->render('hashes/edit', array('member' => urldecode($member), 'key' => urldecode($key), 'value' => $value, 'edited' => $edited));
 }
开发者ID:BlackIkeEagle,项目名称:phpredmin,代码行数:16,代码来源:hashes.php

示例12: function

<?php

/**
 * Youtube for Fansoro CMS
 * Based on https://togetherjs.com/#tryitout-section.
 *
 * @author     Moncho Varela
 *
 * @version    1.0.0
 *
 * @license    MIT
 */
Action::add('theme_footer', function () {
    echo '<script type="text/javascript" src="' . Url::getBase() . '/plugins/channel/assets/channel-dist.js"></script>';
});
ShortCode::add('Channel', function ($attr) {
    extract($attr);
    //{Channel name="nakome" limit="50"}
    $name = isset($name) ? $name : Config::get('plugins.channel.username');
    $limit = isset($limit) ? $limit : 1;
    $quality = isset($quality) ? $quality : 'false';
    $quantity = isset($quantity) ? $quantity : 8;
    // template factory
    $template = Template::factory(PLUGINS_PATH . '/' . Config::get('plugins.channel.name') . '/templates/');
    $template->setOptions(['strip' => false]);
    return $template->fetch('gallery.tpl', ['name' => $name, 'limit' => $limit, 'quality' => $quality, 'quantity' => $quantity, 'apikey' => Config::get('plugins.channel.apikey')]);
});
开发者ID:nakome,项目名称:Fansoro-channel-plugin,代码行数:27,代码来源:channel.php

示例13: function

<?php

/**
 * Breadcrumb Plugin
 * Based on idea from https://github.com/tovic/breadcrumb-plugin-for-fansoro-cms
 *
 * @package    Fansoro
 * @subpackage Plugins
 * @author     Pavel Belousov / pafnuty
 * @version    1.1.0
 * @license    https://github.com/pafnuty-fansoro-plugins/fansoro-plugin-breadcrumb/blob/master/LICENSE MIT
 */
Action::add('breadcrumb', function () {
    // Configuration data
    $config = Config::get('plugins.breadcrumb');
    // Get current URI segments
    $paths = Url::getUriSegments();
    // Count total paths
    $total_paths = count($paths);
    // Path lifter
    $lift = '';
    // Breadcrumb's data
    $data = [];
    for ($i = 0; $i < $total_paths; $i++) {
        $lift .= '/' . $paths[$i];
        $page = Pages::getPage(file_exists(STORAGE_PATH . '/pages/' . $lift . '/index.md') || file_exists(STORAGE_PATH . '/pages/' . $lift . '.md') ? $lift : '404');
        $data[Url::getBase() . $lift] = ['title' => $page['title'], 'current' => rtrim(Url::getCurrent(), '/') === rtrim(Url::getBase() . $lift, '/')];
    }
    $template = Template::factory(THEMES_PATH . '/' . Config::get('system.theme'));
    $template->display('/plugins/breadcrumb/breadcrumb.tpl', ['home' => rtrim(Url::getCurrent(), '/') === rtrim(Url::getBase(), '/') ? true : Url::getBase(), 'config' => $config, 'branch' => $data]);
});
开发者ID:pafnuty-fansoro-plugins,项目名称:fansoro-plugin-breadcrumb,代码行数:31,代码来源:breadcrumb.php

示例14: deleteAction

 public function deleteAction($key)
 {
     Template::factory('json')->render($this->db->del(urldecode($key)));
 }
开发者ID:BlackIkeEagle,项目名称:phpredmin,代码行数:4,代码来源:keys.php

示例15: route

 public function route()
 {
     $class = $this->controller . '_Controller';
     $method = $this->action . 'Action';
     if (class_exists($class)) {
         $controller = new $class(array('serverId' => $this->serverId, 'dbId' => $this->dbId));
         if (method_exists($controller, $method)) {
             call_user_func_array(array($controller, $method), $this->_params);
         }
         return;
     }
     header("HTTP/1.0 404 Not Found");
     Template::factory()->render('404');
 }
开发者ID:xxoxx,项目名称:phpredmin,代码行数:14,代码来源:router.php


注:本文中的Template::factory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。