本文整理汇总了PHP中Variable类的典型用法代码示例。如果您正苦于以下问题:PHP Variable类的具体用法?PHP Variable怎么用?PHP Variable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Variable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: RestoreByNameForClass
public static function RestoreByNameForClass($strName, $intClassId, $strVersion, $objFile)
{
$objConstant = QcodoConstant::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::QcodoConstant()->QcodoClassId, $intClassId), QQ::Equal(QQN::QcodoConstant()->Variable->Name, $strName)));
if (!$objConstant) {
$objVariable = new Variable();
$objVariable->Name = $strName;
$objVariable->VariableTypeId = VariableType::String;
$objVariable->FirstVersion = $strVersion;
$objVariable->Save();
$objConstant = new QcodoConstant();
$objConstant->Variable = $objVariable;
$objConstant->File = $objFile;
$objConstant->QcodoClassId = $intClassId;
$objConstant->Save();
} else {
if ($objConstant->Variable->LastVersion) {
$objConstant->Variable->LastVersion = null;
$objConstant->Variable->Save();
}
if ($objFile->Id != $objConstant->intFileId) {
$objConstant->File = $objFile;
$objConstant->Save();
}
}
return $objConstant;
}
示例2: render
public function render($context)
{
try {
$expire_time = $this->expire_time_var->resolve($context);
} catch (VariableDoesNotExist $e) {
throw new TemplateSyntaxError('"cache" tag got an unknown variable: ' . $this->expire_time_var->var);
}
if (!is_numeric($expire_time)) {
throw new TemplateSyntaxError('"cache" tag got a non-integer timeout value: ' . print_r($expire_time, true));
}
$expire_time = (int) $expire_time;
// Build a unicode key for this fragment and all vary-on's.
$vs_ = array();
foreach ($this->vary_on as $var) {
$v_ = new Variable($var);
$vs_[] = urlencode($v_->resolve($context));
}
$args = join(':', $vs_);
unset($vs_);
$cache_key = 'template.cache.' . $this->fragment_name . '.' . md5($args);
$manager = Dja::getCacheManager();
$value = $manager->get($cache_key);
if ($value === null) {
$value = $this->nodelist->render($context);
$manager->set($cache_key, $value, $expire_time);
}
return $value;
}
示例3: testCreateInstanceFromLocal
public function testCreateInstanceFromLocal()
{
$local = new Variable('$var');
$instance = $local->convertToInstance();
$this->assertTrue($instance->isInstance());
$this->assertFalse($local->isInstance());
}
示例4: testVariableParsing
public function testVariableParsing()
{
$c = array('article' => array('section' => 'News'));
$v = new Variable('article.section');
$this->assertEquals('News', $v->resolve($c));
$v = new Variable('"News"');
$this->assertEquals('News', $v->resolve($c));
$v = new Variable("'News'");
$this->assertEquals('News', $v->resolve($c));
// Translated strings are handled correctly.
$v = new Variable('_(article.section)');
$this->assertEquals('News', $v->resolve($c));
$v = new Variable('_("Good News")');
$this->assertEquals('Good News', $v->resolve($c));
$v = new Variable("_('Better News')");
$this->assertEquals('Better News', $v->resolve($c));
// Escaped quotes work correctly as well.
$v = new Variable('"Some \\"Good\\" News"');
$this->assertEquals('Some "Good" News', $v->resolve($c));
$v = new Variable("'Some 'Better' News'");
$this->assertEquals("Some 'Better' News", $v->resolve($c));
// Variables should reject access of attributes beginning with underscores.
$this->setExpectedException('TemplateSyntaxError');
new Variable('article._hidden');
}
示例5: CreateNewForName
public static function CreateNewForName($strName, $strVersion)
{
$objVariable = new Variable();
$objVariable->Name = $strName;
$objVariable->VariableTypeId = VariableType::Unknown;
switch (substr($strName, 0, 3)) {
case 'str':
$objVariable->VariableTypeId = VariableType::String;
break;
case 'obj':
$objVariable->VariableTypeId = VariableType::Object;
break;
case 'int':
$objVariable->VariableTypeId = VariableType::Integer;
break;
case 'bln':
$objVariable->VariableTypeId = VariableType::Boolean;
break;
case 'mix':
$objVariable->VariableTypeId = VariableType::Mixed;
break;
case 'dtt':
$objVariable->VariableTypeId = VariableType::QDateTime;
break;
case 'flt':
$objVariable->VariableTypeId = VariableType::Float;
break;
}
$objVariable->FirstVersion = $strVersion;
if (strpos(strtolower($strName), 'array') !== false) {
$objVariable->ArrayFlag = true;
}
$objVariable->Save();
return $objVariable;
}
示例6: parse
/**
* Parse a variable line
*
* @param string $varLine
* @return Variable
*/
public static function parse($varLine)
{
$parts = explode('=', $varLine, 2);
if (!$parts || count($parts) !== 2) {
throw new \InvalidArgumentException("Line does not appear to contain a variable");
}
$variable = new Variable();
$variable->setName(trim(array_shift($parts)))->setValue(trim(array_shift($parts)));
return $variable;
}
示例7: pre_config
/**
* Appeler dans les fichiers: ./tinymce4_admin_title.php ; ./filemanager/config.php
* @return array
* @see extract()
*/
public static function pre_config()
{
if (!isset($_SESSION['util'], $_SESSION[self::MODULE])) {
die('ERROR 403');
}
$urlsite = new Variable();
$urlsite->charger('urlsite');
$baseurl = rtrim('/' . preg_replace('/https?:\\/\\/[^\\/]+\\/?/', '', $urlsite->valeur), '/') . '/';
$style_chem = new Variable();
$style_chem->charger('style_chem');
return array('thelia_path' => '../client/plugins/' . self::MODULE . '/', 'thelia_urlsite' => $urlsite->valeur, 'thelia_baseurl' => $baseurl, 'thelia_utilisateur' => 'client/gfx/utilisateur/', 'thelia_styles' => $urlsite->valeur && $style_chem->valeur ? $urlsite->valeur . $style_chem->valeur : '');
}
示例8: ecrire
public static function ecrire($nom, $valeur, $creer_si_inexistante = false, $protege = 1, $cache = 1)
{
$var = new Variable($nom);
if ($creer_si_inexistante && !$var->charger($nom)) {
$var->nom = $nom;
$var->valeur = $valeur;
$var->protege = $protege;
$var->cache = $cache;
$var->add();
} else {
$var->valeur = $valeur;
$var->maj();
}
}
示例9: showPage
public function showPage($name)
{
$this->cache_control('private', 300);
$this->page_title = Variable::getString("page-title-{$name}");
$this->page_content = Variable::getString("page-content-{$name}");
$this->render('home/show_page');
}
示例10: uninstall
public function uninstall()
{
$ret = true;
if ($ret) {
$ret = Variable::delete('mail_from_addr');
}
if ($ret) {
$ret = Variable::delete('mail_from_name');
}
if ($ret) {
$ret = Variable::delete('mail_use_replyto');
}
if ($ret) {
$ret = Variable::delete('mail_method');
}
if ($ret) {
$ret = Variable::delete('mail_user');
}
if ($ret) {
$ret = Variable::delete('mail_password');
}
if ($ret) {
$ret = Variable::delete('mail_host');
}
if ($ret) {
$ret = Variable::delete('mail_security');
}
if ($ret) {
$ret = Variable::delete('mail_auth');
}
Base_ThemeCommon::uninstall_default_theme($this->get_type());
return $ret;
}
示例11: parseBaseUrl
public static function parseBaseUrl()
{
switch (Config::get("URL_MODEL")) {
case 'NORMAL':
$groupName = ucfirst(Variable::get(Config::get("GROUP_PARAM")));
$controllerName = ucfirst(Variable::get(Config::get("CONTROLLER_PARAM")));
$actionName = ucfirst(Variable::get(Config::get("ACTION_PARAM")));
break;
case 'PATH_INFO':
$pathInfo = Variable::server("PATH_INFO");
if (isset($pathInfo)) {
$pathInfo = ltrim($pathInfo, "/");
$urlInfo = explode("/", $pathInfo);
if (count($urlInfo) >= 3) {
foreach ($urlInfo as &$value) {
$value = ucfirst($value);
}
unset($value);
list($groupName, $controllerName, $actionName) = $urlInfo;
} else {
$groupName = isset($urlInfo[0]) ? ucfirst($urlInfo[0]) : "";
$controllerName = isset($urlInfo[1]) ? ucfirst($urlInfo[1]) : "";
$actionName = isset($urlInfo[2]) ? ucfirst($urlInfo[2]) : "";
}
break;
} else {
break;
}
default:
}
define("GROUP_NAME", !empty($groupName) ? $groupName : Config::get("DEFAULT_GROUP"));
define("CONTROLLER_NAME", !empty($controllerName) ? $controllerName : Config::get("DEFAULT_CONTROLLER"));
define("ACTION_NAME", !empty($actionName) ? $actionName : Config::get("DEFAULT_ACTION"));
}
示例12: __construct
/**
* This hook is called once any activated plugins have been loaded.
*/
protected function __construct()
{
$this->settings = Variable::settings();
add_action('admin_init', array(&$this, 'admin_init'));
add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
add_action('admin_enqueue_scripts', array(&$this, 'add_pointer_script'));
}
示例13: auth
private function auth($user, $pass)
{
$error = '';
$t = Variable::get('host_ban_time');
if ($t > 0) {
$fails = DB::GetOne('SELECT count(*) FROM user_login_ban WHERE failed_on>%d AND from_addr=%s', array(time() - $t, $_SERVER['REMOTE_ADDR']));
if ($fails >= 3) {
$error = 'Host banned.';
}
}
if ($error === '') {
$ret = Base_User_LoginCommon::check_login($user, $pass);
if (!$ret) {
$error = 'Login failed.';
if ($t > 0) {
DB::Execute('DELETE FROM user_login_ban WHERE failed_on<=%d', array(time() - $t));
DB::Execute('INSERT INTO user_login_ban(failed_on,from_addr) VALUES(%d,%s)', array(time(), $_SERVER['REMOTE_ADDR']));
$fails = DB::GetOne('SELECT count(*) FROM user_login_ban WHERE failed_on>%d AND from_addr=%s', array(time() - $t, $_SERVER['REMOTE_ADDR']));
if ($fails >= 3) {
$error .= ' Host banned.';
}
}
} else {
$uid = Base_UserCommon::get_user_id($user);
Acl::set_user($uid, true);
}
}
return $error;
}
示例14: fetch
private static function fetch($name, $default)
{
global $cache;
$cache_key = static::buildCacheKey($name);
$cache_value = $cache->get($cache_key);
if ($cache_value === NULL) {
try {
$var = new Variable($name);
$cache_value = $var->getValue();
} catch (fNotFoundException $e) {
$cache_value = $default;
}
$cache->set($cache_key, $cache_value);
}
return $cache_value;
}
示例15: RestoreByNameForClass
public static function RestoreByNameForClass($strName, $intClassId, $strVersion)
{
$objClassProperty = ClassProperty::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::ClassProperty()->QcodoClassId, $intClassId), QQ::Equal(QQN::ClassProperty()->Variable->Name, $strName)));
if (!$objClassProperty) {
$objConnectedClassVariable = ClassVariable::LoadByPartialNameForClass($strName, $intClassId);
$objVariable = Variable::CreateNewForName($strName, $strVersion);
$objClassProperty = new ClassProperty();
$objClassProperty->QcodoClassId = $intClassId;
$objClassProperty->VariableGroupId = 1;
$objClassProperty->Variable = $objVariable;
if ($objConnectedClassVariable) {
$objClassProperty->ClassVariable = $objConnectedClassVariable;
$objClassProperty->VariableGroupId = $objConnectedClassVariable->VariableGroupId;
}
$objClassProperty->Save();
} else {
if ($objClassProperty->Variable->LastVersion) {
$objClassProperty->Variable->LastVersion = null;
$objClassProperty->Variable->Save();
}
if ($objClassProperty->ClassVariable) {
$objClassProperty->VariableGroupId = $objClassProperty->ClassVariable->VariableGroupId;
$objClassProperty->Save();
}
}
return $objClassProperty;
}