/**
  * delete check terms from language_text and update according record in table "checks" to empty
  * @access  private
  * @param   $checkID
  *          $term       : term to delete from 'language_text' table
  *          $fieldName  : field name in table 'checks' to update
  * @return  true    if update successfully
  *          false   if update unsuccessful
  * @author  Cindy Qi Li
  */
 private function deleteLang($checkID, $term, $fieldName)
 {
     require_once AC_INCLUDE_PATH . 'classes/DAO/LanguageTextDAO.class.php';
     $langTextDAO = new LanguageTextDAO();
     $langTextDAO->DeleteByVarAndTerm('_check', $term);
     $sql = "UPDATE " . TABLE_PREFIX . "checks SET " . $fieldName . "='' WHERE check_id=" . intval($checkID);
     $this->execute($sql);
     return true;
 }
 /**
  * Update an existing guideline
  * @access  public
  * @param   $guidelineID
  *          $userID : user id
  *          $title
  *          $abbr
  *          $long_name
  *          $published_date
  *          $earlid
  *          $preamble
  *          $status
  *          $open_to_public
  * @return  true : if successful
  *          false : if not successful
  * @author  Cindy Qi Li
  */
 public function update($guidelineID, $userID, $title, $abbr, $long_name, $published_date, $earlid, $preamble, $status, $open_to_public)
 {
     global $addslashes;
     $guidelineID = intval($guidelineID);
     $userID = intval($userID);
     $title = $addslashes(trim($title));
     $abbr = $addslashes(trim($abbr));
     $long_name = trim($long_name);
     // $addslashes is not necessary as it's called in LanguageTextDAO->setText()
     $earlid = $addslashes(trim($earlid));
     $preamble = $addslashes(trim($preamble));
     if (!$this->isFieldsValid($title, $abbr, false, $guidelineID)) {
         return false;
     }
     $sql = "UPDATE " . TABLE_PREFIX . "guidelines\n\t\t\t\t   SET `user_id`=" . $userID . ", \n\t\t\t\t       `title` = '" . $title . "', \n\t\t\t\t       `abbr` = '" . $abbr . "', \n\t\t\t\t       `published_date` = '" . $published_date . "',  \n\t\t\t\t       `earlid` = '" . $earlid . "', \n\t\t\t\t       `preamble` = '" . $preamble . "', \n\t\t\t\t       `status` = " . $status . ", \n\t\t\t\t       `open_to_public` = " . $open_to_public . " \n\t\t\t\t WHERE guideline_id = " . $guidelineID;
     if (!$this->execute($sql)) {
         $msg->addError('DB_NOT_UPDATED');
         return false;
     } else {
         // find language term to update
         $rows = $this->getGuidelineByIDs($guidelineID);
         $term = $rows[0]['long_name'];
         require_once AC_INCLUDE_PATH . 'classes/DAO/LanguageTextDAO.class.php';
         $langTextDAO = new LanguageTextDAO();
         if ($langTextDAO->setText($_SESSION['lang'], '_guideline', $term, $long_name)) {
             return true;
         } else {
             return false;
         }
     }
 }
Beispiel #3
0
/* Copyright (c) 2010                                                   */
/* Inclusive Design Institute                                           */
/*                                                                      */
/* This program 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.                        */
/************************************************************************/
define('TR_INCLUDE_PATH', '../include/');
include_once TR_INCLUDE_PATH . 'vitals.inc.php';
include_once TR_INCLUDE_PATH . 'classes/DAO/DAO.class.php';
include_once TR_INCLUDE_PATH . 'classes/DAO/LanguagesDAO.class.php';
include_once TR_INCLUDE_PATH . 'classes/DAO/LanguageTextDAO.class.php';
global $msg, $addslashes;
$dao = new DAO();
$languagesDAO = new LanguagesDAO();
$languageTextDAO = new LanguageTextDAO();
//debug($_REQUEST);exit;
if (isset($_REQUEST['reset_filter'])) {
    unset($_REQUEST);
}
if (isset($_REQUEST['submit']) || isset($_REQUEST['search'])) {
    if (isset($_REQUEST['submit'])) {
        if (isset($_REQUEST['term_type']) && $_REQUEST['term_type'] != '') {
            $term_type = $_REQUEST['term_type'];
        }
        $sql = "SELECT * FROM " . TABLE_PREFIX . "language_text \n\t\t\t\t\t\tWHERE language_code='" . DEFAULT_LANGUAGE_CODE . "'";
        if ($term_type != '') {
            $sql .= " AND variable = '" . $term_type . "'";
        }
        if (isset($_REQUEST['new_or_translated']) && ($_REQUEST['new_or_translated'] == 1 || $_REQUEST['new_or_translated'] == 2)) {
            $subquery = "(SELECT term FROM " . TABLE_PREFIX . "language_text\n\t\t\t\t\t\t\t\t\t\tWHERE language_code='" . $_REQUEST['lang_code'] . "'\n\t\t\t\t\t\t\t\t\t\t  AND text <> '')";
Beispiel #4
0
a:hover { color: #66AECC; }
</style>
</head>
<body>
<?php 
echo '<a href="frame_toc.php" target="_self">';
echo _AT('back_to_contents');
echo '</a>';
if ($_GET['query']) {
    $_GET['query'] = str_replace(',', ' ', $_GET['query']);
    $_GET['query'] = str_replace('"', '', $_GET['query']);
    if (strlen($_GET['query']) > 3) {
        $_GET['query'] = strtolower($_GET['query']);
        $search_terms = explode(' ', $_GET['query']);
        $results = array();
        $languageTextDAO = new LanguageTextDAO();
        $final_match_rows = array();
        foreach ($search_terms as $term) {
            $match_rows = $languageTextDAO->getHelpByMatchingText($addslashes($term), $_SESSION['lang']);
            if (is_array($match_rows)) {
                $final_match_rows = array_merge($final_match_rows, $match_rows);
            }
        }
        if (is_array($final_match_rows)) {
            foreach ($final_match_rows as $match) {
                if (is_array($result)) {
                    $all_match_terms = array_keys($result);
                } else {
                    $all_match_terms = array();
                }
                if (!in_array($match['term'], $all_match_terms)) {
Beispiel #5
0
/**
* Converts language code to actual language message, caches them according to page url
* @access	public
* @param	args				unlimited number of arguments allowed but first arg MUST be name of the language variable/term
*								i.e		$args[0] = the term to the format string $_template[term]
*										$args[1..x] = optional arguments to the formatting string 
* @return	string|array		full resulting message
* @see		$db			        in include/vitals.inc.php
* @see		cache()				in include/phpCache/phpCache.inc.php
* @see		cache_variable()	in include/phpCache/phpCache.inc.php
* @author	Joel Kronenberg
*/
function _AC()
{
    global $_cache_template, $lang_et, $_rel_url, $stripslashes;
    static $_template;
    $args = func_get_args();
    if ($args[0] == "") {
        return "";
    }
    $languageTextDAO = new LanguageTextDAO();
    // a feedback msg
    if (!is_array($args[0])) {
        /**
         * Added functionality for translating language code String (AC_ERROR|AC_INFOS|AC_WARNING|AC_FEEDBACK).*
         * to its text and returning the result. No caching needed.
         * @author Jacek Materna
         */
        // Check for specific language prefix, extendible as needed
        // 0002767:  a substring+in_array test should be faster than a preg_match test.
        // replaced the preg_match with a test of the substring.
        $sub_arg = substr($args[0], 0, 7);
        // 7 is the shortest type of msg (AC_INFO)
        if (in_array($sub_arg, array('AC_ERRO', 'AC_INFO', 'AC_WARN', 'AC_FEED', 'AC_CONF'))) {
            global $_base_path, $addslashes;
            $args[0] = $addslashes($args[0]);
            /* get $_msgs_new from the DB */
            $rows = $languageTextDAO->getMsgByTermAndLang($args[0], $_SESSION['lang']);
            $msgs = '';
            if (is_array($rows)) {
                $row = $rows[0];
                // do not cache key as a digit (no contstant(), use string)
                $msgs = str_replace('SITE_URL/', $_base_path, $row['text']);
                if (defined('AC_DEVEL') && AC_DEVEL) {
                    $msgs .= ' <small><small>(' . $args[0] . ')</small></small>';
                }
            }
            return $msgs;
        }
    }
    // a template variable
    if (!isset($_template)) {
        $url_parts = parse_url(AC_BASE_HREF);
        $name = substr($_SERVER['PHP_SELF'], strlen($url_parts['path']) - 1);
        if (!($lang_et = cache(120, 'lang', $_SESSION['lang'] . '_' . $name))) {
            /* get $_template from the DB */
            $rows = $languageTextDAO->getAllTemplateByLang($_SESSION['lang']);
            if (is_array($rows)) {
                foreach ($rows as $id => $row) {
                    //Do not overwrite the variable that existed in the cache_template already.
                    //The edited terms (_c_template) will always be at the top of the resultset
                    //0003279
                    if (isset($_cache_template[$row['term']])) {
                        continue;
                    }
                    // saves us from doing an ORDER BY
                    if ($row['language_code'] == $_SESSION['lang']) {
                        $_cache_template[$row['term']] = $stripslashes($row['text']);
                    } else {
                        if (!isset($_cache_template[$row['term']])) {
                            $_cache_template[$row['term']] = $stripslashes($row['text']);
                        }
                    }
                }
            }
            cache_variable('_cache_template');
            endcache(true, false);
        }
        $_template = $_cache_template;
    }
    $num_args = func_num_args();
    if (is_array($args[0])) {
        $args = $args[0];
        $num_args = count($args);
    }
    $format = array_shift($args);
    if (isset($_template[$format]) && count($args) > 0) {
        $outString = vsprintf($_template[$format], $args);
        $str = ob_get_contents();
    } else {
        $outString = '';
    }
    if ($outString === false) {
        return '[Error parsing language. Variable: <code>' . $format . '</code>. Language: <code>' . $_SESSION['lang'] . '</code> ]';
    }
    if (empty($outString)) {
        $rows = $languageTextDAO->getByTermAndLang($format, $_SESSION['lang']);
        if (is_array($rows) && isset($rows[0])) {
            $row = $rows[0];
            $_template[$row['term']] = $stripslashes($row['text']);
            $outString = $_template[$row['term']];
        }
        if (empty($outString)) {
            return '[ ' . $format . ' ]';
        }
    }
    return $outString;
}
 /**
  * insert/update guideline group term into language_text and update according record in table "guideline_groups"
  * @access  private
  * @param   $groupID
  *          $term      : term to create/update into 'language_text' table
  *          $text      : text to create/update into 'language_text' table
  *          $fieldName : field name in table 'guideline_groups' to update
  * @return  true    if update successfully
  *          false   if update unsuccessful
  * @author  Cindy Qi Li
  */
 private function updateLang($groupID, $term, $text, $fieldName)
 {
     global $addslashes;
     require_once AC_INCLUDE_PATH . 'classes/DAO/LanguageTextDAO.class.php';
     $langTextDAO = new LanguageTextDAO();
     $langs = $langTextDAO->getByTermAndLang($term, $_SESSION['lang']);
     if (is_array($langs)) {
         // term already exists. Only need to update modified text
         if ($langs[0]['text'] != $addslashes($text)) {
             $langTextDAO->setText($_SESSION['lang'], '_guideline', $term, $text);
         }
     } else {
         $langTextDAO->Create($_SESSION['lang'], '_guideline', $term, $text, '');
         $sql = "UPDATE " . TABLE_PREFIX . "guideline_groups SET " . $fieldName . "='" . $term . "' WHERE group_id=" . $groupID;
         $this->execute($sql);
     }
     return true;
 }
Beispiel #7
0
a:hover { color: #66AECC; }
</style>
</head>
<body>
<?php 
echo '<a href="frame_toc.php" target="_self">';
echo _AC('back_to_contents');
echo '</a>';
if ($_GET['query']) {
    $_GET['query'] = str_replace(',', ' ', $_GET['query']);
    $_GET['query'] = str_replace('"', '', $_GET['query']);
    if (strlen($_GET['query']) > 3) {
        $_GET['query'] = strtolower($_GET['query']);
        $search_terms = explode(' ', $_GET['query']);
        $results = array();
        $languageTextDAO = new LanguageTextDAO();
        $final_match_rows = array();
        foreach ($search_terms as $term) {
            $match_rows = $languageTextDAO->getHelpByMatchingText($term, $_SESSION['lang']);
            if (is_array($match_rows)) {
                $final_match_rows = array_merge($final_match_rows, $match_rows);
            }
        }
        if (is_array($final_match_rows)) {
            foreach ($final_match_rows as $match) {
                if (is_array($result)) {
                    $all_match_terms = array_keys($result);
                } else {
                    $all_match_terms = array();
                }
                if (!in_array($match['term'], $all_match_terms)) {
 function export($filename = '')
 {
     //		$search  = array('"', "'", "\x00", "\x0a", "\x0d", "\x1a"); //\x08\\x09, not required
     //		$replace = array('\"', "\'", '\0', '\n', '\r', '\Z');
     // use a function to generate the ini file
     // use a diff fn to generate the sql dump
     // use the zipfile class to package the ini file and the sql dump
     global $addslashes;
     $sql_dump = "INSERT INTO `languages` VALUES ('{$this->code}', '{$this->characterSet}', '{$this->regularExpression}', '{$this->nativeName}', '{$this->englishName}', {$this->status});\r\n\r\n";
     $sql_dump .= "INSERT INTO `language_text` VALUES ";
     $languageTextDAO = new LanguageTextDAO();
     $rows = $languageTextDAO->getAllByLang($this->code);
     if (is_array($rows)) {
         foreach ($rows as $row) {
             //				$row['text']    = str_replace($search, $replace, $row['text']);
             //				$row['context'] = str_replace($search, $replace, $row['context']);
             $row['text'] = $addslashes($row['text']);
             $row['context'] = $addslashes($row['context']);
             $sql_dump .= "('{$this->code}', '{$row['variable']}', '{$row['term']}', '{$row['text']}', '{$row['revised_date']}', '{$row['context']}'),\r\n";
         }
     } else {
         $this->msg->addError('LANG_EMPTY');
         return;
     }
     $sql_dump = substr($sql_dump, 0, -3) . ";";
     $readme = 'This is an AChecker language pack. Use the administrator Language section to import this language pack or manually import the contents of the SQL file into your [table_prefix]language_text table, where `table_prefix` should be replaced with your correct AChecker table prefix as defined in ./include/config.inc.php .';
     require AC_INCLUDE_PATH . 'classes/zipfile.class.php';
     $zipfile = new zipfile();
     $zipfile->add_file($sql_dump, 'language_text.sql');
     $zipfile->add_file($readme, 'readme.txt');
     $zipfile->add_file($this->getXML(), 'language.xml');
     if ($filename) {
         $fp = fopen($filename, 'wb+');
         fwrite($fp, $zipfile->get_file(), $zipfile->get_size());
     } else {
         $version = str_replace('.', '_', VERSION);
         $zipfile->send_file('achecker_' . $version . '_' . $this->code);
     }
 }