/** * main action */ public function mainAction() { /** * input - selected blog */ $blog_node_id = $this->GET['blog_node_id']; /** * create objects */ $Conf = new common_configuration(); $Node = new common_node(); /** * list all id_map-blog* configuration options */ $conf = $Conf->listing("object = 'common_node' AND property LIKE 'id_map-blog%'"); if (is_array($conf) && count($conf) > 0) { foreach ($conf as $item) { $id = (int) $item['value']; $list[$id] = $id; } } else { $node_conf = $Node::initConfiguration(); $default_blog_node_id = (int) $node_conf['id_map-blog']; $list = array($default_blog_node_id => $default_blog_node_id); } /** * parse dropdown */ if (count($list) > 0) { foreach ($list as $id) { $node = $Node->getDetail($id); $this->tpl->assign('NODE', $node); $this->tpl->assign('SELECTED', $id == $blog_node_id ? 'selected="selected"' : ''); $this->tpl->parse('content.select.item'); } $this->tpl->parse('content.select'); } return true; }
/** * Initialise configuration from database */ function initConfiguration() { $conf = array(); require_once 'models/common/common_configuration.php'; $Configuration = new common_configuration(); $conf = $Configuration->getConfiguration(); return $conf; }
/** * save configuration * * @param string $object * name of object * * @param string $property * name of property * * @param string $value * value of saved object.property * * @param integer $node_id * ID of node * * TODO: keep id up to 1000 as reserved for system */ function saveConfig($object, $property, $value, $node_id = 0) { //check if (!is_numeric($node_id)) { msg('common_configuration->saveConfig(): node_id is not numeric', 'error'); return false; } //trim $object = trim($object); $property = trim($property); $value = trim($value); //try to find current value $cs = $this->listing("node_id = {$node_id} AND object = '{$object}' AND property = '{$property}'"); if (count($cs) > 0) { $conf_old = $cs[0]; } else { $conf_old = array(); } $conf_new = $conf_old; //set values $conf_new['node_id'] = $node_id; $conf_new['object'] = $object; $conf_new['property'] = $property; $conf_new['value'] = $value; $conf_new['description'] = ''; //compare and save only if values changed if ($this->checkIfValuesChanged($conf_old, $conf_new)) { // invalidate cache self::$localCache = false; // save (update or insert) if ($id = $this->save($conf_new)) { // insertRevision $this->insertRevision($conf_new); // return ID return $id; } else { return false; } } else { msg("Nothing has changed"); return false; } }
/** * Initialise configuration overwrites from database */ function initGlobalNodeConfigurationOverwrites($node_id) { if (!is_numeric($node_id)) { return false; } $conf = array(); require_once 'models/common/common_configuration.php'; $Configuration = new common_configuration(); $conf = $Configuration->getConfiguration($node_id); return $conf; }
/** * main action */ public function mainAction() { set_time_limit(0); require_once 'models/common/common_file.php'; $File = new common_file(); $tool = $this->GET['tool']; switch ($tool) { case 'uri': require_once 'models/common/common_uri_mapping.php'; $CommonURIMapping = new common_uri_mapping(); $CommonURIMapping->generateAndSaveURITable(); msg("Nice URLs has been completely generated"); break; case 'flush_thumb': if ($File->rm(ONXSHOP_PROJECT_DIR . "var/thumbnails/*")) { msg("All image thumbnails have been deleted"); } else { "Flushing thumbnails failed"; } break; case 'flush_tmp': if ($File->rm(ONXSHOP_PROJECT_DIR . "var/tmp/*")) { msg("Temp directory has been cleaned"); } else { "Flushing temp dir failed"; } break; case 'flush_cache': if (onxshop_flush_cache()) { msg("Cache has been refreshed"); } else { msg("Flushing cache failed"); } break; case 'flush_api_cache': if (is_numeric($GLOBALS['onxshop_conf']['common_configuration']['api_data_version'])) { $current_api_data_version = $GLOBALS['onxshop_conf']['common_configuration']['api_data_version']; } else { $current_api_data_version = 1; } $api_data_version = $current_api_data_version + 1; $Configuration = new common_configuration(); if ($Configuration->saveConfig('common_configuration', 'api_data_version', $api_data_version)) { msg("Data version of API has increased to {$api_data_version}"); if (onxshop_flush_cache()) { msg("Cache has been refreshed"); } else { msg("Flushing cache failed"); } } break; case 'find_hard_links': require_once 'models/common/common_node.php'; $Node = new common_node(); $hard_links = $Node->findHardLinks(); foreach ($hard_links as $hard_link) { $this->tpl->assign('ITEM', $hard_link); $this->tpl->parse('content.hard_links.item'); } $this->tpl->parse('content.hard_links'); break; case 'delete_orphaned_baskets': require_once 'models/ecommerce/ecommerce_basket.php'; $Basket = new ecommerce_basket(); if ($Basket->deleteOrphanedAnonymouseBaskets()) { msg('Deleted orphaned baskets older than two weeks'); } break; case 'backup': $_Onxshop = new Onxshop_Request("bo/component/backup"); $this->tpl->assign('SUB_CONTENT', $_Onxshop->getContent()); break; default: $this->tpl->parse('content.menu'); break; } return true; }