本文整理汇总了PHP中Pluf::loadFunction方法的典型用法代码示例。如果您正苦于以下问题:PHP Pluf::loadFunction方法的具体用法?PHP Pluf::loadFunction怎么用?PHP Pluf::loadFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pluf
的用法示例。
在下文中一共展示了Pluf::loadFunction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($request, $vars = array())
{
$vars = array_merge(array('request' => $request), $vars);
foreach (Pluf::f('template_context_processors', array()) as $proc) {
Pluf::loadFunction($proc);
$vars = array_merge($proc($request), $vars);
}
$params = array('request' => $request, 'context' => $vars);
/**
* [signal]
*
* Pluf_Template_Context_Request::construct
*
* [sender]
*
* Pluf_Template_Context_Request
*
* [description]
*
* This signal allows an application to dynamically modify the
* context array.
*
* [parameters]
*
* array('request' => $request,
* 'context' => array());
*
*/
Pluf_Signal::send('Pluf_Template_Context_Request::construct', 'Pluf_Template_Context_Request', $params);
$this->_vars = new Pluf_Template_ContextVars($params['context']);
}
示例2: setUp
protected function setUp()
{
Pluf::start(dirname(__FILE__) . '/../conf/pluf.config.php');
Pluf::loadFunction('Pluf_HTTP_URL_buildReverseUrl');
Pluf::loadFunction('Pluf_HTTP_URL_reverse');
$d = new Pluf_Dispatcher();
$d->loadControllers(Pluf::f('app_views'));
}
示例3: initFields
public function initFields($extra = array())
{
$this->conf = $extra['conf'];
if ($extra['remote_svn']) {
$this->fields['svn_username'] = new Pluf_Form_Field_Varchar(array('required' => false, 'label' => __('Repository username'), 'initial' => $this->conf->getVal('svn_username', ''), 'widget_attrs' => array('size' => '15')));
$this->fields['svn_password'] = new Pluf_Form_Field_Varchar(array('required' => false, 'label' => __('Repository password'), 'initial' => $this->conf->getVal('svn_password', ''), 'widget' => 'Pluf_Form_Widget_PasswordInput'));
}
Pluf::loadFunction('Pluf_HTTP_URL_urlForView');
$url = Pluf_HTTP_URL_urlForView('idf_faq') . '#webhooks';
$this->fields['webhook_url'] = new Pluf_Form_Field_Url(array('required' => false, 'label' => __('Webhook URL'), 'initial' => $this->conf->getVal('webhook_url', ''), 'help_text' => sprintf(__('Learn more about the <a href="%s">post-commit web hooks</a>.'), $url), 'widget_attrs' => array('size' => 35)));
}
示例4: clean
/**
* Validate some possible input for the field.
*
* @param mixed Input
* @return string Path to the file relative to 'upload_path'
*/
function clean($value)
{
parent::clean($value);
if (is_null($value) and !$this->required) {
return '';
// no file
} elseif (is_null($value) and $this->required) {
throw new Pluf_Form_Invalid(__('No files were uploaded. Please try to send the file again.'));
}
$errors = array();
$no_files = false;
switch ($value['error']) {
case UPLOAD_ERR_OK:
break;
case UPLOAD_ERR_INI_SIZE:
throw new Pluf_Form_Invalid(sprintf(__('The uploaded file is too large. Reduce the size of the file to %s and send it again.'), Pluf_Utils::prettySize(ini_get('upload_max_filesize'))));
break;
case UPLOAD_ERR_FORM_SIZE:
throw new Pluf_Form_Invalid(sprintf(__('The uploaded file is too large. Reduce the size of the file to %s and send it again.'), Pluf_Utils::prettySize($_REQUEST['MAX_FILE_SIZE'])));
break;
case UPLOAD_ERR_PARTIAL:
throw new Pluf_Form_Invalid(__('The upload did not complete. Please try to send the file again.'));
break;
case UPLOAD_ERR_NO_FILE:
if ($this->required) {
throw new Pluf_Form_Invalid(__('No files were uploaded. Please try to send the file again.'));
} else {
return '';
// no file
}
break;
case UPLOAD_ERR_NO_TMP_DIR:
case UPLOAD_ERR_CANT_WRITE:
throw new Pluf_Form_Invalid(__('The server has no temporary folder correctly configured to store the uploaded file.'));
break;
case UPLOAD_ERR_EXTENSION:
throw new Pluf_Form_Invalid(__('The uploaded file has been stopped by an extension.'));
break;
default:
throw new Pluf_Form_Invalid(__('An error occured when upload the file. Please try to send the file again.'));
}
if ($value['size'] > $this->max_size) {
throw new Pluf_Form_Invalid(sprintf(__('The uploaded file is to big (%1$s). Reduce the size to less than %2$s and try again.'), Pluf_Utils::prettySize($value['size']), Pluf_Utils::prettySize($this->max_size)));
}
// copy the file to the final destination and updated $value
// with the final path name. 'final_name' is relative to
// Pluf::f('upload_path')
Pluf::loadFunction($this->move_function);
// Should throw a Pluf_Form_Invalid exception if error or the
// value to be stored in the database.
return call_user_func($this->move_function, $value, $this->move_function_params);
}
示例5: __construct
function __construct($user, $pwd, $server, $dbname, $pfx = '', $debug = false)
{
Pluf::loadFunction('Pluf_DB_defaultTypecast');
$this->type_cast = Pluf_DB_defaultTypecast();
$this->debug('* MYSQL CONNECT');
$this->con_id = mysql_connect($server, $user, $pwd);
$this->debug = $debug;
$this->pfx = $pfx;
if (!$this->con_id) {
throw new Exception($this->getError());
}
$this->database($dbname);
$this->execute('SET NAMES \'utf8\'');
}
示例6: __construct
function __construct($user, $pwd, $server, $dbname, $pfx = '', $debug = false)
{
Pluf::loadFunction('Pluf_DB_defaultTypecast');
$this->type_cast = Pluf_DB_defaultTypecast();
$this->debug = $debug;
$this->pfx = $pfx;
$this->debug('* SQLITE OPEN');
$this->type_cast['Pluf_DB_Field_Compressed'] = array('Pluf_DB_CompressedFromDb', 'Pluf_DB_SQLite_CompressedToDb');
// Connect and let the Exception be thrown in case of problem
try {
$this->con_id = new PDO('sqlite:' . $dbname);
} catch (PDOException $e) {
throw $e;
}
}
示例7: __construct
/**
* The $request object is used to know what the post login
* redirect url should be.
*
* If the action url of the login page is not set, it will try to
* get the url from the login view from the 'login_view'
* configuration key.
*
* @param Pluf_HTTP_Request The request object of the current page.
* @param string The full url of the login page (null)
*/
function __construct($request, $loginurl = null)
{
if ($loginurl !== null) {
$murl = new Pluf_HTTP_URL();
$url = $murl->generate($loginurl, array('_redirect_after' => $request->uri), false);
$encoded = $murl->generate($loginurl, array('_redirect_after' => $request->uri));
} else {
Pluf::loadFunction('Pluf_HTTP_URL_urlForView');
$url = Pluf_HTTP_URL_urlForView(Pluf::f('login_view', 'login_view'), array(), array('_redirect_after' => $request->uri), false);
$encoded = Pluf_HTTP_URL_urlForView(Pluf::f('login_view', 'login_view'), array(), array('_redirect_after' => $request->uri));
}
$content = sprintf(__('<a href="%s">Please, click here to be redirected</a>.'), $encoded);
parent::__construct($content);
$this->headers['Location'] = $url;
$this->status_code = 302;
}
示例8: __construct
function __construct($user, $pwd, $server, $dbname, $pfx = '', $debug = false)
{
Pluf::loadFunction('Pluf_DB_defaultTypecast');
$this->type_cast = Pluf_DB_defaultTypecast();
$this->type_cast['Pluf_DB_Field_Boolean'] = array('Pluf_DB_PostgreSQL_BooleanFromDb', 'Pluf_DB_BooleanToDb');
$this->type_cast['Pluf_DB_Field_Compressed'] = array('Pluf_DB_PostgreSQL_CompressedFromDb', 'Pluf_DB_PostgreSQL_CompressedToDb');
$this->debug('* POSTGRESQL CONNECT');
$cstring = '';
if ($server) {
$cstring .= 'host=' . $server . ' ';
}
$cstring .= 'dbname=' . $dbname . ' user=' . $user;
if ($pwd) {
$cstring .= ' password=' . $pwd;
}
$this->debug = $debug;
$this->pfx = $pfx;
$this->cur = null;
$this->con_id = @pg_connect($cstring);
if (!$this->con_id) {
throw new Exception($this->getError());
}
}
示例9: runMigration
/**
* Run the given migration.
*/
public function runMigration($migration, $the_way = 'up')
{
$target_version = $the_way == 'up' ? $migration[0] : $migration[0] - 1;
if ($this->display) {
echo $migration[0] . ' ' . $migration[1] . ' ' . $the_way . "\n";
}
if (!$this->dry_run) {
if ($the_way == 'up') {
$func = $this->app . '_Migrations_' . $migration[1] . '_up';
} else {
$func = $this->app . '_Migrations_' . $migration[1] . '_down';
}
Pluf::loadFunction($func);
$func();
// Real migration run
$this->setAppVersion($this->app, $target_version);
}
}
示例10: testLoadFunction
public function testLoadFunction()
{
Pluf::loadFunction('Pluf_HTTP_handleMagicQuotes');
$this->assertEquals(true, function_exists('Pluf_HTTP_handleMagicQuotes'));
}
示例11:
/**
* Helper to load the default database connection.
*
* This method is just dispatching to the function define in the
* configuration by the 'db_get_connection' key or use the default
* 'Pluf_DB_getConnection'. If you want to use your own function,
* take a look at the Pluf_DB_getConnection function to use the
* same approach for your method.
*
* The extra parameters can be used to selectively connect to a
* given database. When the ORM is getting a connection, it is
* passing the current model as parameter. That way you could get
* different databases for different models.
*
* @param mixed Extra parameters.
* @return resource DB connection.
*/
public static function &db($extra = null)
{
$func = Pluf::f('db_get_connection', 'Pluf_DB_getConnection');
Pluf::loadFunction($func);
$a = $func($extra);
return $a;
}
示例12:
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
Pluf::loadFunction('Pluf_HTTP_URL_urlForView');
Pluf::loadFunction('Pluf_Shortcuts_RenderToResponse');
/**
* User management views.
*
* Edit your account.
* Add emails for the link between a commit and an account.
*/
class IDF_Views_User
{
/**
* Dashboard of a user.
*
* Shows all the open issues assigned to the user.
*
* TODO: This views is a SQL horror. What needs to be done to cut
* by many the number of SQL queries:
示例13: Pluf_Template_timeAgo
/**
* Display the time in a "6 days, 23 hours ago" style.
*/
function Pluf_Template_timeAgo($date, $f = "withal")
{
Pluf::loadFunction('Pluf_Date_Easy');
$date = Pluf_Template_timeFormat($date);
if ($f == 'withal') {
return Pluf_Date_Easy($date, null, 2, __('now'));
} else {
return Pluf_Date_Easy($date, null, 2, __('now'), false);
}
}
示例14: process_request
/**
* Process the request.
*
* When processing the request, if a session is found with
* Pluf_User creditentials the corresponding user is loaded into
* $request->user.
*
* FIXME: We should logout everybody when the session table is emptied.
*
* @param Pluf_HTTP_Request The request
* @return bool false
*/
function process_request(&$request)
{
$session = new Pluf_Session();
$user_model = Pluf::f('pluf_custom_user', 'Pluf_User');
$user = new $user_model();
if (!isset($request->COOKIE[$session->cookie_name])) {
// No session is defined. We set an empty user and empty
// session.
$request->user = $user;
$request->session = $session;
if (isset($request->COOKIE[$request->session->test_cookie_name])) {
$request->session->test_cookie = $request->COOKIE[$request->session->test_cookie_name];
}
return false;
}
try {
$data = self::_decodeData($request->COOKIE[$session->cookie_name]);
} catch (Exception $e) {
$request->user = $user;
$request->session = $session;
if (isset($request->COOKIE[$request->session->test_cookie_name])) {
$request->session->test_cookie = $request->COOKIE[$request->session->test_cookie_name];
}
return false;
}
$set_lang = false;
if (isset($data[$user->session_key])) {
// We can get the corresponding user
$found_user = new $user_model($data[$user->session_key]);
if ($found_user->id == $data[$user->session_key]) {
// User found!
$request->user = $found_user;
// If the last login is from 12h or more, set it to
// now.
Pluf::loadFunction('Pluf_Date_Compare');
if (43200 < Pluf_Date_Compare($request->user->last_login)) {
$request->user->last_login = gmdate('Y-m-d H:i:s');
$request->user->update();
}
$set_lang = $found_user->language;
} else {
$request->user = $user;
}
} else {
$request->user = $user;
}
if (isset($data['Pluf_Session_key'])) {
$sql = new Pluf_SQL('session_key=%s', $data['Pluf_Session_key']);
$found_session = Pluf::factory('Pluf_Session')->getList(array('filter' => $sql->gen()));
if (isset($found_session[0])) {
$request->session = $found_session[0];
} else {
$request->session = $session;
}
} else {
$request->session = $session;
}
if ($set_lang and false == $request->session->getData('pluf_language', false)) {
$request->session->setData('pluf_language', $set_lang);
}
if (isset($request->COOKIE[$request->session->test_cookie_name])) {
$request->session->test_cookie = $request->COOKIE[$request->session->test_cookie_name];
}
return false;
}
示例15: start
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
Pluf::loadFunction('Pluf_HTTP_URL_urlForView');
/**
* Make the links to issues and commits.
*/
class IDF_Template_IssueComment extends Pluf_Template_Tag
{
private $project = null;
private $request = null;
private $scm = null;
function start($text, $request, $echo = true, $wordwrap = true, $esc = true, $autolink = true, $nl2br = false)
{
$this->project = $request->project;
$this->request = $request;
$this->scm = IDF_Scm::get($request->project);
if ($esc) {
$text = Pluf_esc($text);