/** * Show dictionary words by Language code, Area name and key * * @param string $code Language code * @param string $area Area name * @param string $what Dictionary key * @return void */ public function keys($code = '', $area = 'public', $what = '', $str = '') { // load dictionary $this->dict->get_wordarray(array('dictionary')); $area_mod = new Area_model(); list($id_area, $areas) = $area_mod->get_my_areas(2); if ($id_area != 2) { $area = $area_mod->get_var($id_area, 'areas', 'name'); } if (empty($str)) { $code = empty($code) ? X4Route_core::$lang : $code; // get page $page = $this->get_page('dictionary/keys'); // content $view = new X4View_core('container'); $view->content = new X4View_core('languages/words'); $view->content->page = $page; // keys $dict = new Dictionary_model(); $keys = $dict->get_keys($code, $area); $view->content->keys = $keys; // check empty what if (empty($what) && !empty($keys)) { $what = $keys[0]->what; } $view->content->items = $dict->get_words($code, $area, $what); $view->content->what = $what; $view->content->str = ''; // area switcher $view->content->area = $area; $view->content->areas = $areas; // language switcher $view->content->lang = $code; $lang = new Language_model(); $view->content->langs = $lang->get_languages(); header('Content-Type: text/html; charset=utf-8'); $view->render(TRUE); } else { $this->search($code, $area, $what, $str); } }
/** * Rename area (secret method) * If for whatever reason you need to rename an area you can call this script * /admin/areas/reaname_area/ID_AREA/NEW_NAME * * @param integer $id_area Area ID to rename * @param string $new_name New name to set * @return string */ public function rename_area($id_area, $new_name) { // Comment the next row to enable the method die('Operation disabled!'); $mod = new Area_model(); // clean the new name $new = X4Utils_helper::unspace(urldecode($new_name), true); // check if already exists $chk = $mod->exists($new, $id_area); // get the old area name $old = $mod->get_var($id_area, 'areas', 'name'); if (!$chk && $old && $old != $new && strlen($new) > 2) { // replace name $res = $mod->rename_area($id_area, $old, $new); if ($res[1]) { echo '<h1>CONGRATULATIONS!</h1>'; echo '<p>The changes on the database are applied.</p>'; // print instructions for manual changes echo '<p>Follow this instructions to perform manual changes.</p> <ul> <li>Rename the folder /cms/controllers/' . $old . ' to /cms/controllers/' . $new . '</li> <li>Rename the folder /cms/views/' . $old . ' to /cms/views/' . $new . '</li> <li>In the file system/core/X4Route_core.php replace the old area name "' . $old . '" with the new "' . $new . '" in the static vars</li> <li>In the file cms/config/config.php replace the old area name "' . $old . '" with the new "' . $new . '" in the $default array</li> </ul> <p>Done!</p> <p>NOTE: this operation acts on the core system of the CMS, if you use plugins you have to check if they need to be changed.</p>'; } else { echo '<h1>WARNING!</h1>'; echo '<p>Something went wrong, changes are not applied.</p>'; } } else { echo '<h1>WARNING!</h1>'; if (!$old) { echo '<p>Not exists an area with ID ' . $id_area . '.</p>'; } else { if (strlen($new) < 3) { echo '<p>The new name "' . $new . '" is too short (the minimum is 3 chars).</p>'; } if (!$chk) { echo '<p>An area with the same name "' . $new . '" already exists.</p>'; } if ($old == $new) { echo '<p>The old name "' . $old . '" and the new name "' . $new . '" are equal.</p>'; } } } die; }