public function view_child() { $mytable = $this->cpModule('table'); $mychild = $this->child(); // $this->global->js = array($this->url->myStatic.'js/cp/medium-editor.min.js'); $this->data->enum = \lib\sql\getTable::enumValues('posts'); switch ($mytable) { case 'posts': // show list of tags $this->data->tagList = $this->model()->sp_term_list(); // for each type of post switch ($this->cpModule('raw')) { case 'pages': $this->data->parentList = $this->model()->sp_parent_list(); break; case 'polls': $this->data->parentList = $this->model()->sp_parent_list(true, 'poll'); $this->data->catList = $this->model()->sp_cats('cat_poll'); break; case 'attachments': $this->data->maxSize = \lib\utility\upload::max_file_upload_in_bytes(); // $this->include->uploader = true; // array_push($this->global->js, $this->url->myStatic.'js/cp/uploader.js'); $this->data->catList = $this->model()->sp_cats('filecat'); $this->data->catListSelected = $this->model()->sp_cats('filecat', true); break; case 'books': $this->data->catList = $this->model()->sp_cats('bookcat'); $this->data->catListSelected = $this->model()->sp_cats('bookcat', true); $this->data->parentList = $this->model()->sp_parent_list(true, 'book'); break; case 'socialnetwork': $this->data->catList = null; break; default: $this->data->catList = $this->model()->sp_cats(); break; } break; default: switch ($this->cpModule('raw')) { case 'categories': case 'pollcategories': case 'filecategories': case 'bookcategories': $this->data->parentList = $this->model()->sp_category_list($this->cpModule('type')); break; } $this->data->field_list = \lib\sql\getTable::get($mytable); $myform = $this->createform('@' . db_name . '.' . $mytable, $this->data->child); break; } // if module for users then fill permission list if ($this->cpModule('raw') === 'users') { $this->draw_users(); } if ($mychild === 'edit') { $this->data->datarow = $this->model()->datarow($mytable, null, true); // set shortURL $this->data->shortURL = 'sp_' . \lib\utility\shortURL::encode($this->data->datarow['id']); if (isset($this->data->datarow['post_meta'])) { $this->data->datarow['post_meta'] = json_decode($this->data->datarow['post_meta'], true); } if ($this->cpModule('raw') === 'attachments') { if (isset($this->data->datarow['meta']['slug'])) { $this->data->datarow['post_slug'] = $this->data->datarow['meta']['slug']; } } if ($mytable === 'posts') { // $this->data->datarow['post_content'] .= '<img src="/static/images/logo.png" />'; // var_dump($this->data->datarow['post_content']); $url = $this->data->datarow['post_url']; $this->data->datarow['cat_url'] = substr($url, 0, strrpos($url, '/')); // if defaultlang and lang of the post is not the same then add lang to url $defaultLang = substr(\lib\utility\option::get('config', 'meta', 'defaultLang'), 0, 2); if ($defaultLang !== $this->data->datarow['post_language']) { $this->data->datarow['post_url'] = $this->data->datarow['post_language'] . "/" . $this->data->datarow['post_url']; } } } }
/** * gnerate temp password */ public static function temp_password($_num = null) { // alphabet $alphabet = '1234567890abcdefghijklmnopqrstuvwxyz'; if (!$_num) { $_num = time() . rand(0, 9); } $rand = \lib\utility\shortURL::encode($_num, $alphabet); if (!$_num) { return "rand_" . $rand; } return $rand; }