function getUntranslated() { $result = array(); $files = glob(rad_config::getParam('lang.cacheDir') . "*.cachenf"); if (!empty($files)) { foreach ($files as $file) { if ($this->getState('lang', $this->getState('lang_id'))) { $res = json_decode(file_get_contents($file)); foreach ($res as $url => &$d1) { foreach ($d1 as $lngId => &$d2) { if ($this->getState('lang', $this->getState('lang_id')) != $lngId) { unset($res->{$url}->{$lngId}); } } if (empty($res->{$url})) { unset($res->{$url}); } } } else { $result[] = json_decode(file_get_contents($file)); } } } return $result; }
protected function __construct() { include SPHINXPATH . 'sphinxapi.php'; $this->_sphinx = new SphinxClient(); $this->_sphinx->SetServer(rad_config::getParam('sphinx.host'), rad_config::getParam('sphinx.port')); $this->_sphinx->SetMatchMode(SPH_MATCH_EXTENDED); }
public static function setHandlers() { self::setErrorHandler(); self::setExceptionHandler(); if (rad_config::getParam('debug.showErrors', true)) { ini_set('display_errors', 1); error_reporting(rad_config::getParam('debug.reportingLevel', E_ALL)); } else { ini_set('display_errors', 0); } }
function __construct() { if ($this->getParamsObject()) { $params = $this->getParamsObject(); $params->substring_checkbox = rad_config::getParam('sphinx.on') && rad_config::getParam('sphinx.substring_search') == 'allow'; $params->substring_checked = $params->substring_checkbox && $this->get('ss'); $this->setVar('search', $this->request('s', '')); $this->setVar('params', $params); if (rad_config::getParam('sphinx.on')) { $this->setVar('autocomplete_url', $this->makeURL('alias=searchxml&action=autocomplete') . 'term/'); } } }
/** * Return the appropriate configuration parameter from php.ini file * * @param string $paramName Parameter name * @param string $defaultValue Default value * @return string fetched or default value */ public static function getSys($paramName, $defaultValue = '') { switch ($paramName) { case 'max_post': // get the minimal allowed filesize in bytes // from the various configuration options $value = min(rad_config::convertToBytes(ini_get('post_max_size')), rad_config::convertToBytes(ini_get('upload_max_filesize'))); break; default: $value = ini_get($paramName); $value = $value === false ? $defaultValue : $value; } return (string) $value; }
function smarty_function_sendtotpl($params, $template) { if (!isset($params['var'])) { throw new Exception("currency: missing 'var' parameter", E_USER_WARNING); } if (!isset($params['value'])) { throw new Exception("currency: missing 'value' parameter", E_USER_WARNING); } if (!isset($params['template'])) { throw new Exception("currency: missing 'template' parameter", E_USER_WARNING); } call_user_func_array(array(rad_config::getParam('loader_class'), 'sendToTemplate'), array($params['template'], $params['var'], $params['value'])); //rad_ sloader::sendToTemplate($params['template'],$params['var'],$params['value']); return ''; }
function smarty_function_config($params, $smarty) { if (!isset($params['get'])) { throw new rad_exception('Not enouph actual parameters for tag {config', __LINE__); } $params['get'] = $params['get'][0] == '"' ? substr($params['get'], 1, -1) : $params['get']; $params['get'] = $params['get'][0] == '\'' ? substr($params['get'], 1, -1) : $params['get']; if (!empty($params['assign'])) { $params['assign'] = $params['assign'][0] == '"' ? substr($params['assign'], 1, -1) : $params['assign']; $params['assign'] = $params['assign'][0] == '\'' ? substr($params['assign'], 1, -1) : $params['assign']; $smarty->assign(trim($params['assign']), rad_config::getParam($params['get'])); return ''; } else { return rad_config::getParam($params['get']); } }
/** * Init and gets all the params and make the html strings! * @return Boolean - if all is good */ public static function initandmake(struct_core_alias $alias) { $o = rad_rsmarty::getSmartyObject(); $o->assign('lang', call_user_func(array(rad_config::getParam('loader_class'), 'getLangContainer'))); foreach (self::$_varvals as $classname => $vrnn) { foreach ($vrnn as $varname => $varvalue) { $o->assign('<%' . $classname . '.' . $varname . '%>', $varvalue); } $o->assign($classname, $vrnn); } $srcPrefix = SMARTYBCCACHE . 'alias_' . $alias->id . '_'; self::$_title = self::_fetchSrc($o, $srcPrefix . 'title.tpl', $alias->title_script); self::$_breadcrumbs = self::_fetchSrc($o, $srcPrefix . 'bc.tpl', $alias->navi_script); self::$_tags = self::_fetchSrc($o, $srcPrefix . 'meta.tpl', $alias->metatitle_script); self::$_description = self::_fetchSrc($o, $srcPrefix . 'descr.tpl', $alias->metadescription_script); $o->clearAllAssign(); return true; }
/** * parse templates from alias and assing variables from Controller To Templates * Also I think I can do that in function show() */ public static function parseTemplates() { $o = rad_rsmarty::getSmartyObject(); if (rad_config::getParam('lang.caching')) { $templates = array(); foreach (self::$_alias->includes as $id) { $templates[] = self::$_includes[$id->inc_name]; } self::loadLangCache($templates); } //No needed - fix to {lang code= in older modules rad_instances::setCurrentTemplate('BREADCRUMBS'); self::$_langContainer->setTemplate('BREADCRUMBS'); define(rad_config::getParam('bc.title'), rad_breadcrumbs::getTitle()); define(rad_config::getParam('bc.meta_description'), rad_breadcrumbs::getMetaDescription()); define(rad_config::getParam('bc.meta_tags'), rad_breadcrumbs::getMetaTags()); define(rad_config::getParam('bc.breadcrumbs'), rad_breadcrumbs::getBreadcrumbs()); foreach (self::$_alias->includes as $id) { if (isset(self::$_controllerResults[$id->incinal_id]) and self::$_controllerResults[$id->incinal_id]) { if (isset(self::$sendedParams[$id->inc_filename]) and count(self::$sendedParams[$id->inc_filename])) { foreach (self::$sendedParams[$id->inc_filename] as $pkey => $pval) { $o->assign($pkey, $pval); } } $data = self::$_controllerResults[$id->incinal_id]->getVars(); if ($data !== null) { foreach ($data as $key => $value) { $o->assign($key, $value); } } } if (!isset(self::$_html[$id->rp_name])) { self::$_html[$id->rp_name] = ''; } rad_instances::setCurrentTemplate(self::$_includes[$id->inc_name]); self::$_langContainer->setTemplate(self::$_includes[$id->inc_name]); $o->assign('_CURRENT_LOAD_PATH', dirname(self::$_includes[$id->inc_name])); $o->assign('_CURR_LANG_OBJ', rad_lang::getCurrentLanguage()); self::$_html[$id->rp_name] .= $o->fetch(self::$_includes[$id->inc_name]); $o->clearAllAssign(); } //foreach }
function smarty_function_lang($params, $smarty) { if (!isset($params['code'])) { throw new rad_exception("lang: missing 'code' parameter", E_USER_WARNING); } $params['code'] = trim($params['code'], " \t\"'"); if (isset($params['lang'])) { $val = call_user_func_array(array(rad_config::getParam('loader_class'), 'lang'), array($params['code'], $params['lang'])); } else { $val = call_user_func_array(array(rad_config::getParam('loader_class'), 'lang'), array($params['code'])); } if (isset($params['find']) && isset($params['replace'])) { if (!is_array($params['find'])) { $params['find'] = array($params['find']); } if (!is_array($params['replace'])) { $params['replace'] = array($params['replace']); } if (count($params['find']) != count($params['replace'])) { throw new rad_exception('lang: find/replace params should either be both scalar or be arrays of the same size'); } $find = reset($params['find']); $replace = reset($params['replace']); while ($find) { $val = mb_str_replace($val, $find, $replace); $find = next($params['find']); $replace = next($params['replace']); } } if (!empty($params['htmlchars'])) { $val = mb_str_replace($val, '"', '"'); } if (!empty($params['ucf'])) { $val = mb_ucfirst($val); } if (isset($params['assign'])) { $smarty->assign($params['assign'], $val); } else { return $val; } }
function save() { if ($this->request('hash') == $this->hash()) { $newParams = array(); foreach ($this->_allowedConfigFields as $acf) { $getacf = $this->request(str_replace('.', '__', $acf)); //beacuse we can't get form params with "." in name if ($getacf !== NULL) { $newParams[$acf] = $getacf; } } if ($this->validateParams($newParams)) { $modelSettings = rad_instances::get('model_core_settings'); $modelSettings->updateItemsByfldName($newParams); rad_config::setParam('lang.location_show', $newParams['lang.location_show']); header('Location: ' . $this->makeUrl('alias=' . SITE_ALIAS)); } } else { $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName()); } }
/** * Returns Smarty Object or null * @var Smarty * @return Smarty */ public static function getSmartyObject() { if (!self::$object) { if (!class_exists('Smarty', false)) { if (!file_exists(SMARTYPATH . 'Smarty.class.php')) { die(SMARTYPATH . 'Smarty.class.php does not exists!'); } include_once SMARTYPATH . 'Smarty.class.php'; } self::$object = new Smarty(); self::$object->compile_check = rad_config::getParam('smarty.compile_check', true); self::$object->debugging = rad_config::getParam('smarty.debugging;', false); self::$object->template_dir = rad_config::getParam('rootPath'); //NB: Looks like this parameter is never used since we use absolute adressing. self::$object->compile_dir = SMARTYCOMPILEPATH; self::$object->caching = rad_config::getParam('smarty.caching', false); self::$object->cache_dir = SMARTYCACHEPATH; self::$object->muteExpectedErrors(); self::$object->loadPlugin('smarty_compiler_switch'); } return self::$object; }
protected function makeUrl($page) { if ($page == 1 and SITE_ALIAS == rad_config::getParam('defaultAlias', 'index.html')) { return SITE_URL; } $current = $this->currentPage == $this->rightNeighbour ? true : false; $gp = strlen($this->getParams) ? '&' . $this->getParams : ''; $site_alias = SITE_ALIAS; if ($this->addAliasXML and substr($site_alias, -3) != 'XML') { $site_alias .= 'XML'; } return rad_input::makeURL('alias=' . $site_alias . $gp . ($page > 1 ? '&' . $this->getParam . '=' . $page : '')); }
/** * The function wrapper for the rad_config::getSys(). * Returns the appropriate configuration parameter from php.ini file * * @param string $paramName Parameter name * @param string $defaultValue Default value * @return string fetched or default value */ function configSys($paramName, $defaultValue = '') { return rad_config::getSys($paramName); }
/** * Formats cost depending on the amount of entered in the admin settings * @param number $cost * @return float format */ public static function formatCost($cost, $curId = null) { self::init(); $currency = $curId ? self::$_currs[$curId] : self::$_curcours; $decimal_separator = $currency->cur_decimal_separator ?: rad_config::getParam('currency.decimal_separator', '.'); $group_separator = $currency->cur_group_separator ?: rad_config::getParam('currency.group_separator', ' '); return number_format($cost, (int) rad_config::getParam('currency.precision'), $decimal_separator, $group_separator); }
function smarty_function_paginator($params, $smarty) { /** * Default params */ $step = 1; $maxshow = 30; $showsteps = false; $showfirst = false; $showlast = false; $show_long_listing = false; $first_title_text = call_user_func_array(array(rad_config::getParam('loader_class'), 'lang'), array('-first')); $last_title_text = call_user_func_array(array(rad_config::getParam('loader_class'), 'lang'), array('-last')); $next_title_text = call_user_func_array(array(rad_config::getParam('loader_class'), 'lang'), array('-next')); $prev_title_text = call_user_func_array(array(rad_config::getParam('loader_class'), 'lang'), array('-prev')); $long_listing_text = '..'; $num_delimiter = ' '; $alias = SITE_ALIAS; $page_varname = 'p'; if (!isset($params['from'])) { throw new rad_exception("paginator: missing 'from' parameter", E_USER_ERROR); } $from = (int) $params['from']; if (!isset($params['to'])) { throw new rad_exception("paginator: missing 'to' parameter", E_USER_ERROR); } $to = (int) $params['to']; if (!isset($params['curpage'])) { throw new rad_exception("paginator: missing 'curpage' parameter", E_USER_ERROR); } $curpage = (int) $params['curpage']; if (isset($params['step'])) { $step = (int) $params['step']; } if (!$step or $step <= 0) { throw new rad_exception("paginator: default parameter 'step' can't be < or = 0 ", E_USER_ERROR); } if (isset($params['maxshow'])) { $maxshow = (int) $params['maxshow'] - 1; } if (!$maxshow or $maxshow <= 1) { throw new rad_exception("paginator: default parameter 'maxshow' can't be < or = 1 ", E_USER_ERROR); } if (isset($params['long_listing_text'])) { $long_listing_text = $params['long_listing_text']; } $showsteps = isset($params['showsteps']) ? (bool) $params['showsteps'] : $showsteps; $showfirst = isset($params['showfirst']) ? (bool) $params['showfirst'] : $showfirst; $showlast = isset($params['showlast']) ? (bool) $params['showlast'] : $showlast; $show_long_listing = isset($params['show_long_listing']) ? (bool) $params['show_long_listing'] : $show_long_listing; $first_title_text = isset($params['first_title_text']) ? (string) rad_sloader::lang($params['first_title_text']) : $first_title_text; $last_title_text = isset($params['last_title_text']) ? (string) rad_sloader::lang($params['last_title_text']) : $last_title_text; $next_title_text = isset($params['next_title_text']) ? (string) rad_sloader::lang($params['next_title_text']) : $next_title_text; $prev_title_text = isset($params['prev_title_text']) ? (string) rad_sloader::lang($params['prev_title_text']) : $prev_title_text; $num_delimiter = isset($params['num_delimiter']) ? (string) $params['num_delimiter'] : $num_delimiter; $alias = isset($params['alias']) ? (string) $params['alias'] : $alias; $page_varname = isset($params['page_varname']) ? (string) $params['page_varname'] : $page_varname; $bothldelimiter = isset($params['bothldelimiter']) ? (string) $params['bothldelimiter'] : ''; $bothrdelimiter = isset($params['bothrdelimiter']) ? (string) $params['bothrdelimiter'] : ''; /**** Calculate and return values ******/ $return = ''; /*** Parse GET params ******/ $get_params = array(); if (isset($params['GET']) and strlen($params['GET'])) { if ($params['GET'][0] == '&') { substr($params['GET'], 1); } $pt = explode('&', $params['GET']); if (count($pt)) { foreach ($pt as $ptID => $ptVL) { $pv = explode('=', $ptVL); if (count($pv) > 1) { $get_params[trim($pv[0])] = trim($pv[1]); } } } } $get_params['alias'] = $alias; //TODO Сделать чтобы при переходе на первую страницу или назад(если таже самая страница будет при клике назад) - небыло ссылки if ($showfirst) { $get_params[$page_varname] = $from; if ($get_params[$page_varname] == $from) { unset($get_params[$page_varname]); } $return .= $bothldelimiter . '<a href="' . smarty_function_url(array('href' => smarty_function_paginator_make_get($get_params)), $smarty) . '">' . $first_title_text . '</a> ' . $bothrdelimiter; if (isset($get_params[$page_varname])) { unset($get_params[$page_varname]); } } if ($showsteps) { $get_params[$page_varname] = $curpage == $from ? $curpage : $curpage; if ($get_params[$page_varname] == $from) { unset($get_params[$page_varname]); } else { $get_params[$page_varname]--; $return .= $bothldelimiter . '<a href="' . smarty_function_url(array('href' => smarty_function_paginator_make_get($get_params)), $smarty) . '">' . $prev_title_text . '</a> ' . $bothrdelimiter; } if (isset($get_params[$page_varname])) { unset($get_params[$page_varname]); } } if ($show_long_listing) { $get_params[$page_varname] = $curpage - $maxshow - 1 <= $from ? $from : $curpage - $maxshow - 1; if ($from + $maxshow >= $curpage) { unset($get_params[$page_varname]); } else { $return .= $bothldelimiter . '<a href="' . smarty_function_url(array('href' => smarty_function_paginator_make_get($get_params)), $smarty) . '">' . $long_listing_text . '</a> ' . $bothrdelimiter; } if (isset($get_params[$page_varname])) { unset($get_params[$page_varname]); } } $return_pag = array(); //$maxshow if ($from == $to - 1) { $return_pag[] = $bothldelimiter . '<font class="pages_active last">1</font>' . $bothrdelimiter; } else { for ($i = $from; $i < $to - 1; $i = $i + $step) { if ($i >= $curpage - $maxshow and $i <= $curpage + $maxshow) { if ($curpage == $i) { $return_pag[] = $bothldelimiter . '<font class="pages_active' . ($i == $to - 2 ? ' last' : '') . '">' . (string) ($i + 1) . '</font>' . $bothrdelimiter; } else { $get_params[$page_varname] = $i; $return_pag[] = $bothldelimiter . '<font class="pages_active' . ($i == $to - 2 ? ' last' : '') . '"><a href="' . smarty_function_url(array('href' => smarty_function_paginator_make_get($get_params)), $smarty) . '">[' . ($i + 1) . ']</a></font>' . $bothrdelimiter; } } } } $return .= implode($num_delimiter, $return_pag); if ($show_long_listing) { $get_params[$page_varname] = $curpage + $maxshow + 1 >= $to - 2 ? $curpage : $curpage + $maxshow + 1; $get_params[$page_varname] = $get_params[$page_varname] == 0 ? $curpage + $maxshow + 1 : $get_params[$page_varname]; if ($curpage + $maxshow < $to - 2) { $return .= $bothldelimiter . ' <a href="' . smarty_function_url(array('href' => smarty_function_paginator_make_get($get_params)), $smarty) . '">' . $long_listing_text . '</a> ' . $bothrdelimiter; } unset($get_params[$page_varname]); } if ($showsteps) { if ($curpage != $to - 2) { $get_params[$page_varname] = $curpage == $to - 2 ? $curpage : $curpage + 1; $return .= $bothldelimiter . ' <a href="' . smarty_function_url(array('href' => smarty_function_paginator_make_get($get_params)), $smarty) . '">' . $next_title_text . '</a> ' . $bothrdelimiter; unset($get_params[$page_varname]); } } if ($showlast) { $get_params[$page_varname] = $to - 2; if ($get_params[$page_varname] != $to) { $return .= $bothldelimiter . '<a href="' . smarty_function_url(array('href' => smarty_function_paginator_make_get($get_params)), $smarty) . '">' . $last_title_text . '</a>' . $bothrdelimiter; } unset($get_params[$page_varname]); } if ($to > 2) { return $return; } return ''; }
/** * Makes the url from standart params * @param string $context * @param bool $url_aliases_enabled * @return string * @example makeURL('alias=index.html&page=2&itemsperpage=10&category=754') */ public static function makeURL($context, $url_aliases_enabled = false) { static $alias_plugins = null; static $search = null; static $replace = null; if (!$alias_plugins) { $alias_plugins = rad_loader::getAliasInputClasses(); } if (!$search) { $search = array('SITE_URL'); $replace = array(SITE_URL); if (defined('SITE_ALIAS')) { $search[] = 'SITE_ALIAS'; $replace[] = SITE_ALIAS; } } $c = str_replace($search, $replace, $context); if (is_link_external($c)) { return $c; } $r = strstr($c, '?'); if ($r) { $c = substr($r, 1); } $r = explode('&', $c); $get = array(); foreach ($r as $id) { $r1 = explode('=', $id); if (count($r1) >= 2) { $get[$r1[0]] = $r1[1]; } else { $get[$r1[0]] = ''; } } if (!isset($get['alias'])) { $get['alias'] = SITE_ALIAS; } if ($url_aliases_enabled && rad_config::getParam('cleanurl.on')) { if ($alias = rad_cleanurl::getAliasByParams($get)) { return SITE_URL . $alias; } } if (isset($alias_plugins[$get['alias']])) { $model = rad_instances::get($alias_plugins[$get['alias']]); $string = $model->makeurl($get); } else { if ((!count($get) or count($get) == 1 and isset($get['alias'])) and trim($get['alias']) == rad_config::getParam('defaultAlias')) { $string = SITE_URL; } else { if (rad_config::getParam('lang.location_show')) { $string = SITE_URL . rad_lang::getCurrentLanguage() . '/' . $get['alias'] . '/'; } else { $string = SITE_URL . $get['alias'] . '/'; } if (strlen($context)) { foreach ($get as $prmname => $prmvalue) { if ($prmname != 'alias') { $string .= $prmname . '/' . $prmvalue . '/'; } } if (strpos($prmvalue, '.')) { if ($string[strlen($string) - 1] == '/') { $string = substr($string, 0, -1); } } } } } return $string; }
public static function getAliasByName(&$aliasname = '') { $result = self::getAliasRecord($aliasname); if (!$result->id || !$result->active) { rad_session::setVar('message', $aliasname); $aliasname = rad_config::getParam('alias.404'); $result = self::getAliasRecord(self::$alias); header(rad_config::getParam('header.404')); } if ($result->ali_admin && !rad_session::adminAccess()) { rad_session::setVar('message', $aliasname); rad_session::logout(); $aliasname = rad_config::getParam('alias.loginform'); $result = self::getAliasRecord(self::$alias); } if ($result->id) { $result->includes = array(); $themeId = $result->themeid ? $result->themeid : 0; $sqlParams = array('alias_1_id' => $result->id, 'theme_1_id' => $themeId); if ($result->group_id) { $sqlParams['alias_2_id'] = $result->group_id; $theme2Id = rad_dbpdo::query('SELECT theme_id FROM ' . RAD . 'themes WHERE theme_aliasid=? AND theme_folder=?', array($result->group_id, rad_themer::getCurrentTheme())); $theme2Id = !empty($theme2Id['theme_id']) ? (int) $theme2Id['theme_id'] : $themeId; $sqlParams['theme_2_id'] = $theme2Id; } $sql = 'SELECT inc_id,inc_name,inc_filename,controller,order_sort,rp_name,id_module,m_name,params_hash,ina.id as incinal_id,ina.params_presonal as params_presonal, ip.ip_params as original_params ' . 'FROM ' . RAD . 'includes_in_aliases ina ' . 'INNER JOIN ' . RAD . 'includes on include_id=inc_id ' . 'INNER JOIN ' . RAD . 'modules m on m.m_id=id_module ' . 'INNER JOIN ' . RAD . 'positions p on position_id=p.rp_id ' . 'LEFT JOIN ' . RAD . 'includes_params ip on ip.ip_incid=ina.include_id ' . 'WHERE alias_id=:alias_1_id' . ' AND ina.theme_id=:theme_1_id' . ($result->group_id ? ' UNION (SELECT inc_id,inc_name,inc_filename,controller,order_sort,rp_name,id_module,m_name,params_hash,ina.id as incinal_id,ina.params_presonal as params_presonal, ip.ip_params as original_params ' . 'FROM ' . RAD . 'includes_in_aliases ina ' . 'INNER JOIN ' . RAD . 'includes on include_id=inc_id ' . 'INNER JOIN ' . RAD . 'modules m on m.m_id=id_module ' . 'INNER JOIN ' . RAD . 'positions p on position_id=p.rp_id ' . 'LEFT JOIN ' . RAD . 'includes_params ip on ip.ip_incid=ina.include_id ' . 'WHERE alias_id=:alias_2_id' . ' AND ina.theme_id=:theme_2_id' . ')' : '') . ' ORDER BY order_sort, rp_name'; foreach (rad_dbpdo::queryAll($sql, $sqlParams) as $id) { $result->includes[] = new struct_core_include($id); } } else { $result = NULL; } return $result; }
final function config($paramname, $defaultValue = NULL) { return rad_config::getParam($paramname, $defaultValue); }
/** * Assign theme folders * */ function assignThemes() { $this->setVar('theme_default', rad_config::getParam('theme.default')); $this->setVar('themes', rad_themer::getThemes()); $this->setVar('curr_theme', call_user_func(array(rad_config::getParam('loader_class'), 'getCurrentTheme'))); }
private static function _renewCache($module, $file, $type) { $filename = fixPath($file); $cacheFile = CACHEPATH . $type . DS . self::$themeName . DS . $module . DS . $filename; $cachePath = dirname($cacheFile); if (!file_exists($cachePath)) { recursive_mkdir($cachePath); } if (file_exists($cacheFile) && time() - filemtime($cacheFile) < rad_config::getParam('cache.power.time')) { return true; } if ($fname = rad_themer::getFilePath(self::$themeName, 'jscss', $module, $filename)) { return self::copyToCache($fname, $cacheFile); } return false; }
/** * Makes the correct url from string to work with the access * It is not recommended overriding the function. Override protected _makeUrl*() instead. * @param array $get Parsed $GET array * @return string Full URI generated */ public final function makeurl($get = array()) { $string = SITE_URL; if (rad_config::getParam('lang.location_show')) { $string .= rad_lang::getCurrentLanguage() . '/'; } $string .= $get['alias'] . '/'; unset($get['alias']); $string .= $this->_makeUrlMiddle($get); $string .= $this->_makeUrlEnd($get); if (substr($string, -1) == '/') { $string .= 'index' . $this->_ending; } else { $string .= $this->_ending; } return $string; }
/** * Install the file * @param string $filename - specified filename with @CONSTANT@ without root start path to RADCMS * @param float $version */ public function installFile($filename, $version) { $fileContent = $this->_getURL($this->_url, array('action' => 'getfile', 'version' => $version, 'filename' => $filename)); if (strlen($fileContent)) { $search = array('@LIBPATH@', '@COMPONENTSPATH@', '@THEMESPATH@', '@SMARTYPATH@', '@ROOTPATH@'); $replace = array(LIBPATH, COMPONENTSPATH, THEMESPATH, SMARTYPATH, rad_config::getParam('rootPath')); $fullFileName = str_replace($search, $replace, $filename); $this->mkFile($fullFileName, $fileContent, 0777); } else { throw new rad_exception('File "' . $filename . '" with version "' . $version . '" is empty'); } }
public static function prepareImages(array $files) { $theme = rad_themer::getCurrentTheme(); foreach ($files as $file) { $fileOriginal = rad_themer::getFilePath($theme, 'img', $file['module'], $file['file']); $fileCached = CACHEPATH . 'img' . DS . $theme . DS . $file['module'] . DS . 'original' . DS . fixPath($file['file']); if (file_exists($fileCached)) { if (time() - filemtime($fileCached) < rad_config::getParam('cache.power.time')) { continue; //File is already cached } } else { $cachePath = dirname($fileCached); if (!is_dir($cachePath) && !recursive_mkdir($cachePath)) { throw new RuntimeException('Could not create cache folder for image'); } } copy($fileOriginal, $fileCached); } }
public static function redirectUrl($params) { $string = 'alias='; switch ($params['type']) { case self::TYPE_INDEX: $string .= rad_config::getParam('defaultAlias'); break; case self::TYPE_ARTICLE: $string .= 'articles&a=' . (int) $params['item_id']; break; case self::TYPE_CATALOG: $string .= 'catalog&cat=' . (int) $params['item_id']; break; case self::TYPE_NEWS: $string .= 'news&nid=' . (int) $params['item_id']; break; case self::TYPE_PAGE: $string .= 'page&pgid=' . (int) $params['item_id']; break; case self::TYPE_PRODUCT: $string .= 'product&p=' . (int) $params['item_id']; break; } rad_input::redirect(rad_input::makeURL($string)); }
private function substringSearchChecked() { return rad_config::getParam('sphinx.on') && rad_config::getParam('sphinx.substring_search') == 'allow' && $this->request('ss'); }
public static function getCurrentTheme() { static $theme; if (isset($theme)) { return $theme; } if (($theme = @$_SESSION['theme']) && ($theme == 'default' || self::themeExists($theme))) { return $theme; } if (!empty($_SERVER['HTTP_REFERER']) && preg_match('~^' . preg_quote($GLOBALS['config']['url']) . 'cache/(?:js|css)/([a-z0-9]+)/~i', $_SERVER['HTTP_REFERER'], $matches)) { $theme = $matches[1]; if ($theme == 'default' || self::themeExists($theme)) { return $theme; } } if (!empty($_GET['th'])) { $theme = urldecode($_GET['th']); if ($theme == 'default' || self::themeExists($theme)) { return $theme; } } $theme = rad_config::getParam('theme.default'); if ($theme == 'default' || self::themeExists($theme)) { return $theme; } $theme = $GLOBALS['config']['theme.default']; if ($theme == 'default' || self::themeExists($theme)) { return $theme; } $theme = 'default'; return $theme; }
protected function getValValuesCache() { $file = self::getCacheFileName($this->_catIds, $this->_cat->tre_id); $result = NULL; if (is_file($file)) { $data = unserialize(file_get_contents($file)); if ($data['date'] >= time() - rad_config::getParam('cache.power.time')) { $result = $data['rows']; } } if (!$result) { $result = $this->getValValues(); $data = array('date' => time(), 'rows' => $result); safe_put_contents($file, serialize($data)); } return $result; }
/** * Gets the main javascript for the page */ function getJS() { $this->setVar('ROOT_PID', addslashes(str_replace(rad_config::getParam('rootPath'), '', TEMPLATESPATH))); $this->setVar('lang', $this->getCurrentLang()); $this->header('Content-type: text/javascript'); }
/** * Edit the product - shows the edit form * * @return html Full page edit form */ function editForm() { $cat_id = (int) $this->request('cat_id'); if ($cat_id) { $this->setVar('cat_id', $cat_id); $model = rad_instances::get('model_coremenus_tree'); $model->setState('pid', $this->request('pid', $this->_pid))->setState('lang', $this->getContentLangID()); $this->setVar('trees', $model->getItems(true)); $model->setState('pid', $this->_pid_types); $producttypes = $model->getItems(true); $firest_el = new struct_coremenus_tree(); $firest_el->tre_name = $this->lang('-pleaseselect'); array_unshift($producttypes, $firest_el); $this->setVar('producttypes', $producttypes); $this->setVar('currencys', rad_instances::get('model_corecatalog_currency')->getItems()); /** FOR MEASUREMENT IN RIGHT PANEL WHITCH NAMED "MAGAZINE" $model = new model_core_table('measurement','corecatalog'); $model->setState('order by','ms_position,ms_value'); $measurements = $model->getItems(); $this->setVar( 'measurements', $measurements ); */ $model_product = rad_instances::get('model_corecatalog_catalog'); if ($this->_have_downloads) { $model_product->setState('with_download_files', true); } if ($this->_have_tags) { $model_product->setState('with_tags', true); } $product = $model_product->getItem($cat_id); $this->addBC('product', $product->cat_name); $model->clearState(); $tree_link = $this->product ? $this->product->tree_link : $product->tree_catin_link; if (count($tree_link)) { $curr_cat = $model->getItem($tree_link[0]->cit_tre_id); $this->addBC('curr_cat', $curr_cat); $cat_path = $model->getCategoryPath($curr_cat, $this->_pid, 0); unset($cat_path[0]); $this->addBC('parents', $cat_path); $mas = array(); foreach ($tree_link as $id) { $mas[] = $id->cit_tre_id; } $this->setVar('selected_tree', $mas); } //if count catin_link $model = rad_instances::get('model_corecatalog_brands'); $this->setVar('brands', $model->getListBrands()); $this->setVar('product', $product); $this->setVar('cleanurl_enabled', rad_config::getParam('cleanurl.on')); if ($cat_id && rad_config::getParam('cleanurl.on')) { $this->setVar('url_alias', rad_cleanurl::getAlias('product', $cat_id)); } include_once 'helpers' . DS . 'fileuploader.php'; $uploader = new fileuploader($this); $imageWidgets = array($uploader->initWidget('images', array(), '', CORECATALOG_IMG_PATH, 'catalog', true)); $this->setVar('widgets', $imageWidgets); $this->get3DBinItems($cat_id); } else { //if $cat_id $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName()); } }