/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Theme(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Theme'])) { $model->attributes = $_POST['Theme']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function installTheme($name) { $is_installed = Theme::where('name', '=', $name)->get() == NULL; if ($is_installed) { return Redirect::back()->with(['notice' => 'Theme is already installed']); } $theme = new Theme(); $theme->name = $name; $theme->path = "assets/themes/{$name}"; $theme->active = false; $theme->save(); return Redirect::back()->with(['notice' => 'Bootstrap Theme Updated']); }
public function find_icons() { $time_since_last_scan = time() - $this->theme->last_scan_time; $icons = array(); $page_count = $this->page_count(); $i = $this->theme->processed_pages; if ($i <= 0) { $i = 1; } else { if ($i < $page_count) { $i += 1; } } if ($i >= $page_count) { $i = $page_count; } $this->current_page = $i; $this->total_pages = $page_count; if ($time_since_last_scan < 4 || $i == $page_count && $time_since_last_scan < CACHE_EXPIRE) { return $this->theme->icons(); } if ($this->theme->processed_pages < $i) { $this->theme->processed_pages = $i; } $this->theme->save(); #for ($i = $start; $i <= $page_count; $i++) { $doc = $this->get_page($i); $posts = $doc['#punviewtopic .blockpost:not(.firstpost)']; /* if ($i === 1) { $this->theme->title = strip_tag_prefix($doc['head title']->text()); $this->theme->artist = $doc['#punviewtopic .firstpost .postleft dt a']->text(); } */ foreach ($posts as $full_post) { $full_post = pq($full_post); $artist = $full_post['.postleft dt'][0]->text(); $post = $full_post['.postmsg'][0]; $post_imgs = $post['img.postimg']; $post_icons = $this->icons_in_post($full_post); $icons = array_merge($icons, $post_icons); } #} $this->theme->last_scan_time = time(); $this->theme->save(); return $this->theme->icons(); }
/** * Add a new theme */ public function actionCreate() { // Check Access checkAccessThrowException('op_theme_create'); $model = new Theme(); if (isset($_POST['Theme'])) { $model->attributes = $_POST['Theme']; if ($model->save()) { fok(at('Theme Created.')); alog(at("Created Theme '{name}'.", array('{name}' => $model->name))); $this->redirect(array('themes/index')); } } // Add Breadcrumb $this->addBreadCrumb(at('Creating New Theme')); $this->title[] = at('Creating New Theme'); // Display form $this->render('theme_form', array('model' => $model)); }
public function actionCreate() { $model = new Theme(); $suc = Yii::t('info', 'The record was successfully created'); $err = Yii::t('info', 'The record could not be created'); $zip = new XUploadForm(); $userZips = array(); if (!isset($_POST[$this->modelName])) { Yii::app()->user->setState('images', NULL); } if (isset($_POST['Theme'])) { $model->attributes = $_POST['Theme']; $userZips = Yii::app()->user->getState('images'); if ($model->validate()) { //$path = Yii::app()->runtimePath.'/dir/'.$model->zip; //$img->saveAs('dir/'.$model->name); $model->save(); $path = $userZips[0]["path"]; $this->unzipTheme($path, $model->name, UtilityHelper::yiiparam('frontPath') . "/www/themes"); Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, $suc); if (Yii::app()->getRequest()->getIsAjaxRequest()) { $this->renderPartial('_view', array('model' => $model), false, true); Yii::app()->end(); } else { $this->redirect(array('view', 'id' => $model->id)); } } else { Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, $err); } UtilityHelper::sendToLog($userZips); } if (Yii::app()->getRequest()->getIsAjaxRequest()) { $this->renderPartial('_form', array('model' => $model, 'zip' => $zip, 'userZips' => $userZips), false, true); Yii::app()->end(); } $this->render('create', array('model' => $model, 'zip' => $zip, 'userZips' => $userZips)); }
public function theme() { $th = Theme::all()->count(); if ($th == 1) { $theme = Theme::first(); } else { $theme = new Theme(); } $theme->theme_color = '#' . Input::get('color1'); $theme->secondary_color = '#' . Input::get('color3'); $theme->primary_color = '#' . Input::get('color2'); $theme->hover_color = '#' . Input::get('color4'); $theme->active_color = '#' . Input::get('color5'); $css_msg = ".btn-default {\n color: #ffffff;\n background-color: {$theme->theme_color};\n}\n.navbar-nav > li {\n float: left;\n}\n.btn-info{\n color: #000;\n background: #fff;\n border-radius: 0px;\n border:1px solid {$theme->theme_color};\n}\n.nav-admin .dropdown :hover, .nav-admin .dropdown :hover {\n background: {$theme->hover_color};\n color: #000;\n}\n.navbar-nav > li > a {\n border-radius: 0px;\n}\n.navbar-nav > li + li {\n margin-left: 2px;\n}\n.navbar-nav > li.active > a,\n.navbar-nav> li.active > a:hover,\n.navbar-nav > li.active > a:focus {\n color: #ffffff;\n background-color: {$theme->active_color}!important;\n}\n.logo_img_login{\nborder-radius: 30px;border: 4px solid {$theme->theme_color};\n}\n.btn-success {\n color: #ffffff;\n background-color: {$theme->theme_color};\n border-color: {$theme->theme_color};\n}\n.btn-success:hover,\n.btn-success:focus,\n.btn-success:active,\n.btn-success.active,\n.open .dropdown-toggle.btn-success {\n color: #ffffff;\n background-color: {$theme->theme_color};\n border-color: {$theme->theme_color};\n\n}\n\n\n.btn-success.disabled,\n.btn-success[disabled],\nfieldset[disabled] .btn-success,\n.btn-success.disabled:hover,\n.btn-success[disabled]:hover,\nfieldset[disabled] .btn-success:hover,\n.btn-success.disabled:focus,\n.btn-success[disabled]:focus,\nfieldset[disabled] .btn-success:focus,\n.btn-success.disabled:active,\n.btn-success[disabled]:active,\nfieldset[disabled] .btn-success:active,\n.btn-success.disabled.active,\n.btn-success[disabled].active,\nfieldset[disabled] .btn-success.active {\n\n background-color: {$theme->theme_color};\n border-color: {$theme->theme_color};\n}\n.btn-success .badge {\n color: {$theme->theme_color};\n background-color: #ffffff;\n}\n.btn-info {\n color: #ffffff;\n background-color: {$theme->theme_color};\n border-color: {$theme->theme_color};\n}\n.btn-info:hover,\n.btn-info:focus,\n.btn-info:active,\n.btn-info.active,\n.open .dropdown-toggle.btn-info {\n color: #000;\n background-color: #FFFF;\n border-color: {$theme->theme_color};\n}\n.btn-info:active,\n.btn-info.active,\n.open .dropdown-toggle.btn-info {\n background-image: none;\n}\n.btn-info.disabled,\n.btn-info[disabled],\nfieldset[disabled] .btn-info,\n.btn-info.disabled:hover,\n.btn-info[disabled]:hover,\nfieldset[disabled] .btn-info:hover,\n.btn-info.disabled:focus,\n.btn-info[disabled]:focus,\nfieldset[disabled] .btn-info:focus,\n.btn-info.disabled:active,\n.btn-info[disabled]:active,\nfieldset[disabled] .btn-info:active,\n.btn-info.disabled.active,\n.btn-info[disabled].active,\nfieldset[disabled] .btn-info.active {\n background-color: {$theme->theme_color};\n border-color: {$theme->theme_color};\n}\n.btn-info .badge {\n color: {$theme->theme_color};\n background-color: #029acf;\n border-color: #029acf;\n}\n.btn-success,\n.btn-success:hover {\n background-image: -webkit-linear-gradient({$theme->theme_color} {$theme->theme_color} 6%, {$theme->theme_color});\n background-image: linear-gradient({$theme->theme_color}, {$theme->theme_color} 6%, {$theme->theme_color});\n background-repeat: no-repeat;\n filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='{$theme->theme_color}', endColorstr='{$theme->theme_color}', GradientType=0);\n filter: none;\n border: 1px solid {$theme->theme_color};\n}\n.btn-info,\n.btn-info:hover {\n background-image: -webkit-linear-gradient({$theme->theme_color}, {$theme->theme_color} 6%, {$theme->theme_color});\n background-image: linear-gradient({$theme->theme_color}, {$theme->theme_color} 6%, {$theme->theme_color});\n background-repeat: no-repeat;\n filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='{$theme->theme_color}', endColorstr='{$theme->theme_color}', GradientType=0);\n filter: none;\n border: 1px solid {$theme->theme_color};\n}\n.logo h3{\n margin: 0px;\n color: {$theme->theme_color};\n}\n\n.second-nav{\n background: {$theme->theme_color};\n}\n.login_back{background-color: {$theme->theme_color};}\n.no_radious:hover{background-image: -webkit-linear-gradient({$theme->theme_color}, {$theme->theme_color} 6%, {$theme->theme_color});background-image: linear-gradient(#5d4dd1, #5d4dd1 6%, #5d4dd1);background-repeat: no-repeat;filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#5d4dd1', endColorstr='#5d4dd1', GradientType=0);filter: none;border: 1px solid #5d4dd1;}\n.navbar-nav li:nth-child(1) a{\n background: {$theme->primary_color};\n}\n\n.navbar-nav li:nth-child(2) a{\n background: {$theme->secondary_color};\n}\n\n.navbar-nav li:nth-child(3) a{\n background: {$theme->primary_color};\n}\n\n.navbar-nav li:nth-child(4) a{\n background: {$theme->secondary_color};\n}\n\n.navbar-nav li:nth-child(5) a{\n background: {$theme->primary_color};\n}\n\n.navbar-nav li:nth-child(6) a{\n background: {$theme->secondary_color};\n}\n\n.navbar-nav li:nth-child(7) a{\n background: {$theme->primary_color};\n}\n\n.navbar-nav li:nth-child(8) a{\n background: {$theme->secondary_color};\n}\n\n.navbar-nav li:nth-child(9) a{\n background: {$theme->primary_color};\n}\n\n.navbar-nav li:nth-child(10) a{\n background: {$theme->secondary_color};\n}\n\n.navbar-nav li a:hover{\n background: {$theme->hover_color};\n}\n.btn-green{\n\n background: {$theme->theme_color};\n color: #fff;\n}\n.btn-green:hover{\n background: {$theme->hover_color};\n color: #fff;\n}\n"; $t = file_put_contents(public_path() . '/stylesheet/theme_cus.css', $css_msg); /* chmod(public_path() . '/stylesheet/theme_cus.css', 0777); */ if (Input::hasFile('logo')) { // Upload File $file_name = time(); $file_name .= rand(); $ext = Input::file('logo')->getClientOriginalExtension(); Input::file('logo')->move(public_path() . "/uploads", $file_name . "." . $ext); $local_url = $file_name . "." . $ext; /* $new = Image::make(public_path() . "/uploads/" . $local_url)->resize(70, 70)->save(); */ // Upload to S3 if (Config::get('app.s3_bucket') != "") { $s3 = App::make('aws')->get('s3'); $pic = $s3->putObject(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'SourceFile' => public_path() . "/uploads/" . $local_url)); $s3->putObjectAcl(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'ACL' => 'public-read')); $s3_url = $s3->getObjectUrl(Config::get('app.s3_bucket'), $file_name); } else { $s3_url = asset_url() . '/uploads/' . $local_url; } if (isset($theme->logo)) { $icon = asset_url() . '/uploads/' . $theme->logo; unlink_image($icon); } $theme->logo = $local_url; } if (Input::hasFile('icon')) { // Upload File $file_name1 = time(); $file_name1 .= rand(); $file_name1 .= 'icon'; $ext1 = Input::file('icon')->getClientOriginalExtension(); Input::file('icon')->move(public_path() . "/uploads", $file_name1 . "." . $ext1); $local_url1 = $file_name1 . "." . $ext1; // Upload to S3 if (Config::get('app.s3_bucket') != "") { $s3 = App::make('aws')->get('s3'); $pic = $s3->putObject(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name1, 'SourceFile' => public_path() . "/uploads/" . $local_url1)); $s3->putObjectAcl(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name1, 'ACL' => 'public-read')); $s3_url1 = $s3->getObjectUrl(Config::get('app.s3_bucket'), $file_name1); } else { $s3_url1 = asset_url() . '/uploads/' . $local_url1; } if (isset($theme->favicon)) { $icon = asset_url() . '/uploads/' . $theme->favicon; unlink_image($icon); } $theme->favicon = $local_url1; } $theme->save(); return Redirect::to("/admin/settings"); }
public static function update($values, $user) { $id = $values['id']; if ($id) { $q = new Doctrine_Query(); $q = $q->select('t.*')->from('Theme t'); $q = $q->addWhere('id = ?', array($id)); if (!$user->getRole() == User::ADMIN) { $q = $q->addWhere('user_id = ?', array($user->getId())); } $theme = $q->fetchOne(); } else { $theme = new Theme(); } if ($theme) { $theme->setName($values['name']); $theme->setDescription($values['description']); if (!$theme->getUserId()) { $theme->setUserId($user->getId()); } $file = $values['file']; if ($file) { $filename = $file->getOriginalName(); $theme->setFileName($filename); } $theme->setApproved(false); $theme->save(); $folderpath = $theme->getFolderPath(); if (!is_dir($folderpath)) { mkdir($folderpath); } if ($file) { $filepath = $folderpath . $theme->getFileName(); $file->save($filepath); } $screenshot = $values['screenshot']; if ($screenshot) { $screenshotpath = $folderpath . $theme->getId() . $screenshot->getOriginalName(); $screenshot->save($screenshotpath); $smallThumb = new Thumbnail($screenshotpath); if ($smallThumb->getCurrentWidth() > 150 || $smallThumb->getCurrentHeight() > 150) { $smallThumb->resize(150, 150); } $smallThumb->show(100, $folderpath . 'smallthumb.png'); $bigThumb = new Thumbnail($screenshotpath); if ($bigThumb->getCurrentWidth() > 500 || $bigThumb->getCurrentHeight() > 500) { $bigThumb->resize(500, 500); } $bigThumb->show(100, $folderpath . 'bigthumb.png'); $screenshot = new Thumbnail($screenshotpath); $screenshot->show(100, $folderpath . 'screenshot.png'); unlink($screenshotpath); } $outputs = array(); if ($file) { exec(Tools::get('edje_list_path') . ' ' . $filepath, $outputs); $groups = array_splice($outputs, 4); $groups = array_keys(array_flip($groups)); $name = substr($outputs[0], 6); if ($name) { $theme->setName($name); } $author = substr($outputs[1], 8); if ($author) { $theme->setAuthor($author); } $license = substr($outputs[2], 9); $theme->setLicense($license); $version = substr($outputs[3], 9); $theme->setVersion($version); $theme->save(); $theme->clearThemeGroups(); foreach ($groups as $group) { $theme->addThemeGroup($group); } } return $theme; } return null; }
/** * theme selector * @return [view] */ public function action_license() { $theme = $this->request->param('id', Theme::$theme); // save only changed values if (core::request('license')) { if (Theme::license(core::request('license'), $theme) == TRUE) { //activating a mobile theme if (in_array($theme, array_keys(Theme::get_installed_themes(TRUE)))) { Theme::set_mobile_theme($theme); } else { Theme::set_theme($theme); } Theme::$options = Theme::get_options($theme); Theme::load($theme); Theme::$data['license'] = core::request('license'); Theme::$data['license_date'] = time() + 7 * 24 * 60 * 60; Theme::save($theme); Alert::set(Alert::SUCCESS, __('Theme activated, thanks.')); $this->redirect(Route::url('oc-panel', array('controller' => 'theme', 'action' => 'options'))); } else { Alert::set(Alert::INFO, __('There was an error activating your license.')); } } Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Theme License'))); $this->template->title = __('Theme License'); $this->template->scripts['footer'][] = 'js/oc-panel/license.js'; $this->template->content = View::factory('oc-panel/pages/themes/license', array('theme' => Theme::$theme)); }
$theme->status = $_POST['status']; $theme->visible = $_POST['visible']; $target_path = SITE_ROOT . DS . "images" . DS . $filename . $extention; move_uploaded_file($_FILES['logo_name']['tmp_name'], $target_path); $theme->logo_name = $filename . $extention; if (isset($_POST['theme_id']) && !empty($_POST['theme_id'])) { $theme->theme_id = $_POST['theme_id']; } else { $theme_exist_query = "SELECT * from themes WHERE institution_name = '" . $_POST['institution_name'] . "' OR logo_name = '" . $target_path . "'"; $theme_exist = theme::find_by_sql($theme_exist_query); $theme_exist = array_shift($theme_exist); if ($theme_exist) { $theme->theme_id = $theme_exist->theme_id; } } if ($theme->save()) { sleep(2); echo '<h4 class="alert alert-success">Success</h4>'; echo '<hr>'; echo 'The Theme Settings have being save successfully.'; echo '<hr>'; } else { sleep(2); echo '<h4 class="alert alert-error">Error</h4>'; echo '<hr>'; echo 'An error occured while saving theme information.'; echo '<hr>'; } } else { sleep(2); echo '<h4 class="alert alert-error">Error</h4>';