Пример #1
0
function runCron()
{
    $file = '../../vertex' . JSONEXT;
    $jsonData = array();
    $jsonData['vertexFramework'] = array();
    $currentValues = array();
    $check = '';
    $cronned = 0;
    if (file_exists($file)) {
        $check = file_get_contents($file);
        $file_data = json2Array($check);
        foreach ($file_data['vertexFramework'] as $key => $data) {
            $db = JFactory::getDBO();
            $query = "SELECT * FROM #__template_styles WHERE title = '{$key}';";
            $db->setQuery($query);
            $result = $db->loadAssocList();
            foreach ($result as $k => $style) {
                if (isset($style['title'])) {
                    $jsonData['vertexFramework'][$key] = $data;
                } else {
                    unset($file_data['vertexFramework'][$key]);
                    $cronned++;
                }
            }
        }
        $data = array2Json($jsonData);
        $file = fopen($file, 'w');
        fwrite($file, $data);
        fclose($file);
    }
    $msg = array('message' => false);
    if ($cronned) {
        $msg = array('message' => "{$cronned} items have been cleaned up");
    }
    return array2Json($msg);
}
Пример #2
0
function handleJSONFile($file = false, $style = false, $dir = false)
{
    getVersion($dir);
    $config = array();
    if (file_exists($dir . '/' . $file)) {
        $check = file_get_contents($dir . '/' . $file);
        $file_data = json2Array($check);
        if (isset($file_data['vertexFramework'][$style]) && is_array($file_data['vertexFramework'][$style])) {
            $defaults = getJoomlaParams($dir);
            $defaults = array_merge($defaults, getVertexParams($dir));
            foreach ($defaults as $key => $val) {
                $key = str_replace('xml_', '', $key);
                $config[$key] = '';
            }
            foreach ($file_data['vertexFramework'][$style] as $key => $val) {
                $key = str_replace('xml_', '', $key);
                $config[$key] = preg_replace('/\\\\/', '', $val);
            }
        } else {
            $defaults = getJoomlaParams($dir);
            $defaults = array_merge($defaults, getVertexParams($dir));
            foreach ($defaults as $key => $val) {
                $key = str_replace('xml_', '', $key);
                $config[$key] = preg_replace('/\\\\/', '', $val);
            }
        }
    } else {
        $defaults = getJoomlaParams($dir);
        $defaults = array_merge($defaults, getVertexParams($dir));
        foreach ($defaults as $key => $val) {
            $key = str_replace('xml_', '', $key);
            $config[$key] = preg_replace('/\\\\/', '', $val);
        }
    }
    # Parse Multilang Text
    $lang = JFactory::getLanguage();
    $lang_tag = $lang->getTag();
    foreach ($config as $key => $val) {
        if (substr($key, -5) == '_lang') {
            $langvals = explode("\n", $val);
            for ($i = 0; $i < count($langvals); $i++) {
                $sublangval = explode("=", $langvals[$i]);
                if (trim($sublangval[0]) == $lang_tag) {
                    $newkey = str_replace("_lang", "", $key);
                    $config[$newkey] = $sublangval[1];
                }
            }
        }
    }
    # End Parse Multilang Text
    return $config;
}