本文整理汇总了PHP中Y类的典型用法代码示例。如果您正苦于以下问题:PHP Y类的具体用法?PHP Y怎么用?PHP Y使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Y类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test
function test()
{
$a = X::foo();
$a();
$a = Y::foo();
$a();
$a = X::bar();
$a();
$a = Y::bar();
$a();
$x = new X();
$a = $x->bar();
$a();
$x = new Y();
$a = $x->bar();
$a();
$a = X::bar_nonstatic();
$a();
$a = Y::bar_nonstatic();
$a();
$x = new X();
$a = $x->bar_nonstatic();
$a();
$x = new Y();
$a = $x->bar_nonstatic();
$a();
}
示例2: f
function f()
{
$y = new Y();
$y->foo();
static::g();
$y->foo();
self::g();
Y::foo() && static::g();
}
示例3: test
function test()
{
$x = new X();
$c = $x->f();
var_dump($c(true));
$y = new Y();
$c = $y->f();
var_dump($c("foo"));
}
示例4: test
function test($str)
{
X::bar($str);
(new X())->bar($str);
Y::bar($str);
(new Y())->bar($str);
}
示例5: flushUploadDir
public function flushUploadDir()
{
$session = new CHttpSession();
$session->open();
$folder = $_SERVER['DOCUMENT_ROOT'] . '/upload/tmp/' . $session->SessionID;
Y::recursiveRemDir($folder);
}
示例6: instance
/**
* 连接数据库
*
* @param string $dbFlag 数据库配置命名空间
*/
public static function instance($dbFlag = '')
{
if (empty($dbFlag)) {
throw new DbException('Empty param: dbFlag');
}
if (!isset(Y::$app->db[$dbFlag])) {
throw new InvalidConfigException('Unknow db config: ' . $dbFlag);
}
if (!isset(static::$_links[$dbFlag]) || null === static::$_links[$dbFlag]) {
$config = Y::$app->db[$dbFlag];
$dsn = $config['dsn'];
$driver = static::getDriverName($dsn);
$dbClass = static::$_dbNamespace . '\\' . $driver . '\\Db';
$dbFile = Y::namespaceTranslate($dbClass);
if (!is_file($dbFile)) {
throw new FileNotFoundException('The Classfile: ' . $dbFile . ' not found');
}
try {
static::$_links[$dbFlag] = new $dbClass($dsn, $config['username'], $config['password']);
static::$_links[$dbFlag]->initConnection($config);
} catch (PDOException $e) {
static::$_links[$dbFlag] = null;
throw new DbException('Failed to connect to database');
}
}
return static::$_links[$dbFlag];
}
示例7: __construct
public function __construct(&$config)
{
$this->cachePath = isset($config['cachePath']) ? Y::getPathAlias($config['cachePath']) : Y::getPathAlias($this->cachePath);
if (!is_dir($this->cachePath)) {
FileHelper::createDirectory($this->cachePath);
}
}
示例8: recursiveRemDir
function recursiveRemDir($directory, $empty = FALSE)
{
if (substr($directory, -1) == '/') {
$directory = substr($directory, 0, -1);
}
if (!file_exists($directory) || !is_dir($directory)) {
return FALSE;
} elseif (is_readable($directory)) {
$handle = opendir($directory);
while (FALSE !== ($item = readdir($handle))) {
if ($item != '.' && $item != '..') {
$path = $directory . '/' . $item;
if (is_dir($path)) {
Y::recursiveRemDir($path);
} else {
unlink($path);
}
}
}
closedir($handle);
if ($empty == FALSE) {
if (!rmdir($directory)) {
return FALSE;
}
}
}
return TRUE;
}
示例9: actionUpdate
public function actionUpdate($dir, $fileName)
{
if (isset($_POST['fileContent'])) {
FileSystem::write('./'.$dir.'/'.$fileName, $_POST['fileContent'], 'w');
Y::end();
}
$content = '';
$info = FileSystem::getInfo('./'.$dir.'/'.$fileName, array('name', 'ext'));
if (in_array($info['ext'], array('js', 'css'))) {
if (substr($dir, 0, 2) == 'js' || substr($dir, 0, 3) == 'css') {
$content = FileSystem::read('./'.$dir.'/'.$fileName);
}
}
$output = $this->renderPartial('fileDetails', array(
'fileName' => $fileName,
'content' => $content,
'type' => $info['ext'] == 'css' ? 'css' : 'javascript',
'filePath' => './'.$dir.'/'.$fileName
), true);
Y::tab('Содержимое файла', $output);
$output = Y::getTabs('cssFileForm', true);
Y::clientScript()->render($output);
echo CHtml::tag('div', array(), $output);
}
示例10: actionAdmin
public function actionAdmin($catPk, $opts = array())
{
$cat = Category::model()->findByPk($catPk);
$model = $this->loadModel($catPk, null, 'search');
$this->ajaxSetNextValue('published', $model, 'published', array(BaseDataType::PUBLISHED, BaseDataType::NOT_PUBLISHED));
$model->unsetAttributes(); // clear any default values
$model = $model->current($cat);
if (isset($_GET[get_class($model)]))
$model->attributes=$_GET[get_class($model)];
$opts['model'] = $model;
$opts['cat'] = $cat;
$opts['columns'] = array();
$opts = Y::hooks()->cmsAdminGetGridColumns($this, &$opts);
if (isset($_GET['ajax'])) {
$this->renderPartial('admingrid',$opts);
} else {
$this->render('admin',$opts);
}
}
示例11: actionRecovery
/**
* Recovery password
*/
public function actionRecovery () {
$form = new UserRecoveryForm;
if (Y::userId()) {
$this->redirect(Y::module()->returnUrl);
Y::end();
}
$email = isset($_GET['email']) ? $_GET['email'] : '';
$activkey = isset($_GET['activkey']) ? $_GET['activkey'] : '';
if ($email&&$activkey) { //get new pass
$find = User::model()->notsafe()->findByAttributes(array('email'=>$email));
if(isset($find)&&$find->activkey==$activkey) {
$form2 = new UserChangePassword;
if(isset($_POST['UserChangePassword'])) {
$form2->attributes=$_POST['UserChangePassword'];
if($form2->validate()) {
$find->password = UserModule::encrypting($form2->password);
if ($find->status==0) {
$find->status = 1;
}
$find->save();
Y::flash('recoveryMessage',Users::t("New password is saved."));
$this->redirect(Y::module()->recoveryUrl);
}
}
$this->render('changepassword',array('form'=>$form2));
} else {
Y::flash('recoveryMessage',Users::t("Incorrect recovery link."));
$this->redirect(Y::module()->recoveryUrl);
}
} else { //send email
if(isset($_POST['UserRecoveryForm'])) {
$form->attributes=$_POST['UserRecoveryForm'];
if($form->validate()) {
$user = User::model()->notsafe()->findbyPk($form->user_id);
$user->activkey = Y::module()->encrypting(microtime().$user->password);
$user->save();
$activation_url = 'http://' . $_SERVER['HTTP_HOST'].$this->siteUrl('user/recovery',array("activkey" => $user->activkey, "email" => urldecode($user->email)));
$subject = Users::t("You have requested the password recovery site {site_name}",
array(
'{site_name}'=>Yii::app()->name,
));
$message = Users::t("You have requested the password recovery site {site_name}. To receive a new password, go to {activation_url}.",
array(
'{site_name}'=>Yii::app()->name,
'{activation_url}'=>$activation_url,
));
UserModule::sendMail($user->email,$subject,$message);
Y::flash('recoveryMessage',Users::t("Please check your email. An instructions was sent to your email address."));
$this->refresh();
}
}
$this->render('recovery',array('form'=>$form));
}
}
示例12: authenticate
/**
* Authenticates a user.
* The example implementation makes sure if the username and password
* are both 'demo'.
* In practical applications, this should be changed to authenticate
* against some persistent user identity storage (e.g. database).
* @return boolean whether authentication succeeds.
*/
public function authenticate()
{
if (strpos($this->username,"@")) {
$user=User::model()->notsafe()->findByAttributes(array('email'=>$this->username));
} else {
$user=User::model()->notsafe()->findByAttributes(array('username'=>$this->username));
}
if($user===null)
if (strpos($this->username,"@")) {
$this->errorCode=self::ERROR_EMAIL_INVALID;
} else {
$this->errorCode=self::ERROR_USERNAME_INVALID;
}
else if(Y::module('users')->encrypting($this->password)!==$user->password)
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else if($user->status==0&&Y::module('users')->loginNotActiv==false)
$this->errorCode=self::ERROR_STATUS_NOTACTIV;
else if($user->status==-1)
$this->errorCode=self::ERROR_STATUS_BAN;
else {
$this->_id=$user->id;
$this->username=$user->username;
$this->errorCode=self::ERROR_NONE;
}
return !$this->errorCode;
}
示例13: getListView
public function getListView(&$criteria, $return = false)
{
$dp = new EActiveDataProvider(get_class($this->model), array(
'criteria' => $criteria,
//'pagination' => $this->settings['pagination'],
));
//default params
$params = array(
'dataProvider'=>$dp,
'pager'=>array(
'id'=>$this->widgetModel->pk.'Pager', 'class'=>'LinkPager', 'htmlOptions'=>array('class'=>'pager'),
'cssFile'=>Yii::app()->baseUrl.'/css/pager.css'
),
'ajaxUpdate'=>true,
'template'=>$this->render('listTemplate', array(), true),
'afterAjaxUpdate' => ModelFactory::getAfterAjaxUpdateFunction($this->category->type),
'beforeAjaxUpdate' => ModelFactory::getBeforeAjaxUpdateFunction($this->category->type),
'category' => $this->category,
'contextWidget' => $this
);
try {
$res = Y::controller()->widget('ListView', $params, true);
} catch (CException $e) {
Y::dump($e->__toString());
}
if ($return)
return $res;
else
echo $res;
}
示例14: __construct
public function __construct($config)
{
$this->logPath = isset($config['logPath']) ? Y::getPathAlias($config['logPath']) : Y::getPathAlias($this->logPath);
$this->logFile = $this->generateTimeLogFile();
if (!is_dir($this->logPath)) {
FileHelper::createDirectory($this->logPath);
}
}
示例15: relations
/**
* @return array relational rules.
*/
public function relations()
{
$relations = array(
'profile'=>array(self::HAS_ONE, 'Profile', 'user_id'),
);
if (isset(Y::module('users')->relations)) $relations = array_merge($relations,Y::module('users')->relations);
return $relations;
}