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;
 }
Beispiel #2
0
 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;
 }
 public function testCreateInstanceFromLocal()
 {
     $local = new Variable('$var');
     $instance = $local->convertToInstance();
     $this->assertTrue($instance->isInstance());
     $this->assertFalse($local->isInstance());
 }
Beispiel #4
0
 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');
 }
Beispiel #5
0
 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;
 }
Beispiel #6
0
 /**
  * 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;
 }
 /**
  * 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 : '');
 }
 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();
     }
 }
Beispiel #9
0
 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');
 }
Beispiel #10
0
 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;
 }
Beispiel #11
0
 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"));
 }
 /**
  * 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'));
 }
Beispiel #13
0
 public function __construct($name, $byRef, $scope = self::SCOPE_GLOBAL, $extra = null)
 {
     parent::__construct($name);
     $this->byRef = (bool) $byRef;
     $this->scope = $scope;
     $this->extra = $extra;
 }
Beispiel #14
0
 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;
 }
Beispiel #15
0
 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;
 }
 /**
  * This hook is called once any activated plugins have been loaded.
  */
 protected function __construct()
 {
     $this->settings = Variable::settings();
     add_action('admin_notices', array(&$this, 'admin_notices'));
     add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
     add_action("wp_ajax_{$this->ajax_action}", array(&$this, 'dismiss_admin_notice'));
 }
Beispiel #17
0
 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;
 }
Beispiel #18
0
 public function show($id)
 {
     $this->cache_control('private', Variable::getInteger('status-refresh', 30));
     try {
         $this->report = new Report($id);
         if (!$this->report->isReadable()) {
             throw new fAuthorizationException('You are not allowed to view this report.');
         }
         global $cache;
         $this->board = $cache->get($this->report->getBoardCacheKey());
         if ($this->board === NULL) {
             $p = $this->report->getProblems();
             $un = $this->report->getUsernames();
             $up = $this->report->getUserPairs();
             $un[] = '';
             $up[] = array('id' => '', 'name' => '平均');
             $st = $this->report->getStartDatetime();
             $et = $this->report->getEndDatetime();
             $this->board = new BoardTable(ReportGenerator::headers($p), $up, ReportGenerator::scores($p, $un, $st, $et));
             $cache->set($this->report->getBoardCacheKey(), $this->board, 10);
         }
         if ($this->report->isHomework()) {
             $this->nav_class = 'homework';
         } else {
             $this->nav_class = 'reports';
         }
         $this->render('report/show');
     } catch (fExpectedException $e) {
         fMessaging::create('warning', $e->getMessage());
         fURL::redirect(Util::getReferer());
     } catch (fUnexpectedException $e) {
         fMessaging::create('error', $e->getMessage());
         fURL::redirect(Util::getReferer());
     }
 }
Beispiel #19
0
function get_img_quality($nomvar, $min, $max, $defaut)
{
    $quality = intval(Variable::lire($nomvar, $defaut));
    if ($quality < $min || $quality > $max) {
        $quality = $defaut;
    }
    return $quality;
}
Beispiel #20
0
 public function uninstall()
 {
     Base_ThemeCommon::uninstall_default_theme(Base_User_LoginInstall::module_name());
     Variable::delete('host_ban_time');
     Variable::delete('host_ban_nr_of_tries');
     Variable::delete('host_ban_by_login');
     return DB::DropTable('user_password') && DB::DropTable('user_login_ban') && DB::DropTable('user_autologin') && DB::DropTable('user_reset_pass');
 }
Beispiel #21
0
 public function submit_admin($data)
 {
     Variable::set('default_theme', $data['theme']);
     Base_ThemeCommon::create_cache();
     Base_StatusBarCommon::message('Theme changed - reloading page');
     eval_js('setTimeout(\'document.location=\\\'index.php\\\'\',\'3000\')');
     return true;
 }
Beispiel #22
0
 public function uninstall()
 {
     recursive_rmdir(DATA_DIR . '/Base_Theme/templates/default/images');
     Variable::delete('default_theme');
     Variable::delete('preload_image_cache_default');
     Variable::delete('preload_image_cache_selected');
     return true;
 }
Beispiel #23
0
 public function __construct($node, $parent)
 {
     parent::__construct($node, $parent);
     self::$possible_attributes = array_merge(parent::$possible_attributes, self::$possible_attributes);
     self::$required_attributes = array_merge(parent::$required_attributes, self::$required_attributes);
     self::$possible_children = array_merge(parent::$possible_children, self::$possible_children);
     self::$required_children = array_merge(parent::$required_children, self::$required_children);
 }
Beispiel #24
0
 public static function store($key, $value)
 {
     if (Variable::data()->where('data_key', '=', $key)->first()) {
         Variable::data()->where('data_key', '=', $key)->update(array('data_value' => $value));
     } else {
         Variable::data()->insert(array('data_key' => $key, 'data_value' => $value));
     }
 }
 function beforeDelete($db)
 {
     $event = $db->get(new Event($this->event));
     if (!Variable::istype('Event', $event) || !$event->isActive($db)) {
         return false;
     }
     return true;
 }
Beispiel #26
0
function epesi_requires_update()
{
    $ret = null;
    if (class_exists('Variable', false)) {
        $system_version = Variable::get('version');
        $ret = version_compare($system_version, EPESI_VERSION, '<');
    }
    return $ret;
}
Beispiel #27
0
 public function uninstall()
 {
     Base_ThemeCommon::uninstall_default_theme($this->get_type());
     Variable::delete('printers_registered', false);
     Variable::delete('print_document_types', false);
     Variable::delete('print_href_callback', false);
     Variable::delete('print_disabled_templates', false);
     return true;
 }
Beispiel #28
0
 function add($entry)
 {
     $this->method = 'add';
     if (Variable::istype('ClippAtomEntry10', $entry)) {
         $this->browser->setRequestHeader(array('type' => 'application/atom+xml;type=entry;charset=utf-8', 'rawdata' => '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL . $entry->get()));
         return $this->post();
     }
     return false;
 }
Beispiel #29
0
 public function add_signature($b)
 {
     $footer = Variable::get('crm_roundcube_global_signature', false);
     if ($b['type'] == 'plain') {
         $b['body'] .= "\r\n" . strip_tags(preg_replace('/<[bh]r\\s*\\/?>/i', "\r\n", $footer));
     } else {
         $b['body'] .= '<br />' . $footer;
     }
     return $b;
 }
 public function uninstall()
 {
     Variable::delete('logo_file');
     Variable::delete('login_logo_file');
     Variable::delete('base_page_title');
     Variable::delete('show_caption_in_title');
     Variable::delete('show_module_indicator');
     Base_ThemeCommon::uninstall_default_theme(Base_MainModuleIndicatorInstall::module_name());
     return true;
 }