Esempio n. 1
0
 protected function define_fields()
 {
     $this->name = new TextField(pjango_gettext('Name'), 35, 255, array('validate_required'));
     $this->codename = new TextField(pjango_gettext('Code Name'), 35, 255, array('validate_required'));
     $contentTypeChoices = \ContentType::findAllAsChoice();
     $this->content_type_id = new DropDownField('Content Type', $contentTypeChoices);
 }
Esempio n. 2
0
 function __construct($value)
 {
     echo $value . "HHHHHHHHHHHHH\n";
     if ($value == '' || is_null($value)) {
         throw new ValidationError(pjango_gettext('This field is required'));
     }
 }
Esempio n. 3
0
 protected function define_fields()
 {
     $this->parent_id = new DropDownField(pjango_gettext("Parent Site"), \Site::findAllAsChoice());
     $this->site_type = new DropDownField(__("Site Type"), \Site::getTypeChoices());
     $this->domain = new TextField(__("Site Domain"), 35, 255);
     $this->name = new TextField(__("Site Name"), 35, 255);
     $this->status = new DropDownField(__("Site Status"), \Site::getStatusChoices());
 }
Esempio n. 4
0
 public function __construct()
 {
     $this->list_display = array('username', 'displayname', 'email', 'is_staff', 'is_active', 'last_login', 'date_joined');
     $this->list_display_links = array('username');
     $this->row_actions = array('edit', 'delete');
     $this->search_fields = array('username', 'displayname', 'email');
     $user = User::get_current();
     if ($user->is_active && $user->is_superuser) {
         $this->admin_menu = array('Auth', pjango_gettext('Auth'), '/admin/Auth/User/', array('User', pjango_gettext('Users'), '/admin/Auth/User/'), array('Group', pjango_gettext('Groups'), '/admin/Auth/Group/'), array('Permission', pjango_gettext('Permissions'), '/admin/Auth/Permission/'));
     }
 }
Esempio n. 5
0
 protected function define_fields()
 {
     $this->displayname = new TextField(pjango_gettext('Full name'), 40, 255);
     $this->username = new TextField(pjango_gettext('User name'), 15, 255, array('RequiredValidator'), array("class" => "requiredField"));
     $this->email = new TextField(pjango_gettext('Email'), 40, 255, array('RequiredValidator'), array("class" => "requiredField email"));
     $this->phone = new TextField(pjango_gettext('Phone'), 25, 255, array('RequiredValidator'));
     $this->email = new EmailField(pjango_gettext('Email'), 40, 255, array('RequiredValidator'));
     $this->email_confirm = new EmailField(pjango_gettext('Confirm email'), 35, 255, array('RequiredValidator'));
     $this->password = new PasswordField(pjango_gettext('Password'), 10, 255, 'User::getEncryptedPassword', array('RequiredValidator'));
     $this->password_confirm = new PasswordField(pjango_gettext('Confirm password'), 10, 255, 'User::getEncryptedPassword', array('RequiredValidator'));
     $genderChoices = array('male' => pjango_gettext('Male'), 'female' => pjango_gettext('Female'));
     $this->gender = new DropDownField(pjango_gettext('Gender'), $genderChoices);
 }
Esempio n. 6
0
 public function __construct()
 {
     $this->list_display = array('get_category_names', 'get_title', 'get_slug', 'status', 'created_at', 'updated_at');
     $this->list_filter = array('status');
     $this->search_fields = array('Translation__title', 'Translation__content', 'Translation__excerpt');
     $this->ordering = '-created_at';
     $user = User::get_current();
     if ($user->has_perm('Post.change_Post')) {
         $this->admin_menu = array('Post', pjango_gettext('Post'), '/admin/Post/Post/', array('Post', pjango_gettext('Post'), '/admin/Post/Post/', array('Post', pjango_gettext('Posts'), '/admin/Post/Post/'), array('PostCategory', pjango_gettext('Categories'), '/admin/Post/PostCategory/'), array('Settings', pjango_gettext('Settings'), '/admin/Post/Post/settings/')));
     }
     $this->third_level_navigation = array(array('key' => 'edit', 'url' => 'edit/', 'name' => __('Post Properties')), array('key' => 'files', 'url' => 'files/', 'name' => __('Post Files')));
     $this->row_actions = array('edit', 'delete');
 }
Esempio n. 7
0
 function render($context, $stream)
 {
     $argPrefix = substr($this->args[0], 0, 1);
     if ($argPrefix == ':') {
         $message = $context->resolve($this->args[0]);
     } else {
         $message = $this->text;
         $message = str_replace("'", '', $message);
         $message = str_replace('"', '', $message);
     }
     if ($message) {
         $stream->write(pjango_gettext($message));
     }
 }
Esempio n. 8
0
 protected function define_fields()
 {
     $this->content_type_id = new HiddenField();
     $this->object_id = new HiddenField();
     $fileTypeChoices = array('auto' => __('Auto'), 'image/jpeg' => __('Jpeg Image'), 'video/embed' => __('Embed Video'));
     $this->file_path = new TextField(pjango_gettext("File Path"), 35, 255, array(), array('class' => 'pjangoMedia'));
     $this->file_type = new DropDownField(__('File Type'), $fileTypeChoices);
     $this->file_name = new TextField(pjango_gettext("File Name"), 35, 255);
     $this->description = new LargeTextField(pjango_gettext("Description or Embed Code"), 3, 35);
     $this->is_default = new BooleanField(pjango_gettext("Is Default"));
     //$this->is_active = new BooleanField(pjango_gettext("Is Active"));
     $this->meta_link_title = new TextField(pjango_gettext('Link Title'), 25, 200);
     $this->meta_link_alt = new TextField(pjango_gettext('Link Alt'), 25, 200);
 }
Esempio n. 9
0
 public static function get_status_choices()
 {
     $choices = array(self::STATUS_DRAFT => pjango_gettext("Draft"), self::STATUS_PUBLISHED => pjango_gettext("Published"), self::STATUS_PRIVATE => pjango_gettext("Private"), self::STATUS_ARCHIVE => pjango_gettext("Archive"));
     return $choices;
 }
Esempio n. 10
0
 protected function define_fields()
 {
     $this->username = new TextField(pjango_gettext('User name'), 25, 255);
     $this->password = new PasswordField(pjango_gettext('User password'), 15, 255, 'User::getEncryptedPassword');
 }
Esempio n. 11
0
 public function __construct()
 {
     $this->list_display = array('site_type', 'domain', 'name', 'status');
     $this->row_actions = array('edit', 'delete');
     $this->admin_menu = array('Core', pjango_gettext('Site'), '/admin/Core/Site/', array('Site', __('Site'), '/admin/Core/Site/', array('Site', __('Site List'), '/admin/Core/Site/')));
 }
Esempio n. 12
0
 function render($context, $stream)
 {
     $menuTemplate = '<li class="%s"><a href="%s">%s</a></li>';
     $html = '';
     $adminMenuArr = array(array('home', pjango_gettext('Home'), '/admin/'));
     $currentMenuName = $context->resolve($this->args[0]);
     if (!$currentMenuName) {
         $currentMenuName = 'home';
     }
     $site = AdminSite::getInstance();
     $registry = $site->getRegistry();
     $appsMenuArr = array();
     foreach ($registry as $appName => $modelArr) {
         foreach ($modelArr as $modelName => $modelAdminClass) {
             if (is_string($modelAdminClass)) {
                 $modelAdmin = new $modelAdminClass();
                 if ($modelAdmin instanceof \Pjango\Core\ModelAdmin) {
                     if ($modelAdmin->admin_menu) {
                         $adminMenuArr[] = $modelAdmin->admin_menu;
                     }
                     if ($modelAdmin->apps_menu) {
                         $appsMenuArr[] = $modelAdmin->apps_menu;
                     }
                 }
             }
         }
     }
     foreach ($adminMenuArr as $adminMenuItem) {
         $menuName = $adminMenuItem[0];
         $menuUrl = pjango_ini_get('SITE_URL') . $adminMenuItem[2];
         $menuValue = $adminMenuItem[1];
         $currentMenuClass = '';
         if ($menuName == $currentMenuName) {
             $currentMenuClass = 'active';
             $currentMenuId = $i;
         }
         $html .= sprintf($menuTemplate . "\n", $currentMenuClass, $menuUrl, $menuValue);
     }
     if (count($appsMenuArr) > 0) {
         $appsHtml = '';
         $appsSelected = '';
         foreach ($appsMenuArr as $appsMenuItem) {
             $menuName = $appsMenuItem[0];
             $menuUrl = pjango_ini_get('SITE_URL') . $appsMenuItem[2];
             $menuValue = $appsMenuItem[1];
             $currentMenuClass = '';
             if ($menuName == $currentMenuName) {
                 $currentMenuClass = 'active';
                 $appsSelected .= ': ' . __($currentMenuName);
             }
             $appsHtml .= sprintf($menuTemplate . "\n", $currentMenuClass, $menuUrl, $menuValue);
         }
         $html .= '<li class="dropdown">
 				    	<a href="#" class="dropdown-toggle" data-toggle="dropdown">' . __('Apps') . $appsSelected . '<b class="caret"></b></a>
 				    	<ul class="dropdown-menu">' . $appsHtml . '</ul></li>';
     }
     $stream->write($html);
 }
Esempio n. 13
0
 function admin_group_addchange($request, $id = false)
 {
     $templateArr = array('current_admin_menu' => 'Auth', 'current_admin_submenu' => 'Auth', 'current_admin_submenu2' => 'Group', 'title' => 'Auth Group Add/Change');
     $modelClass = 'Group';
     $formClass = 'Pjango\\Contrib\\Auth\\Forms\\GroupForm';
     $formData = array();
     if (!$request->user->has_perm('Auth.can_change_Group')) {
         Messages::Error(__('Do not have permission to do this.'));
         HttpResponseRedirect($_SERVER['HTTP_REFERER']);
     }
     if ($id) {
         $modelObj = Doctrine::getTable($modelClass)->find($id);
         if ($modelObj) {
             $formData = $modelObj->toArray();
             $templateArr['group_permissions'] = $modelObj->GroupPermissions;
         }
     }
     if ($request->POST) {
         $form = new $formClass($request->POST);
         try {
             if (!$form->is_valid()) {
                 throw new Exception('There are incomplete required fields. Please complete them.');
             }
             $formData = $form->cleaned_data();
             if (!$modelObj) {
                 $modelObj = new $modelClass();
             }
             $modelObj->fromArray($formData);
             $modelObj->save();
             $modelObj->unlink('Permissions');
             $modelObj->link('Permissions', $request->POST['permissions']);
             $modelObj->site_id = SITE_ID;
             $modelObj->save();
             Messages::Info(pjango_gettext('The operation completed successfully'));
             HttpResponseRedirect('/admin/Auth/Group/');
         } catch (Exception $e) {
             Messages::Error($e->getMessage());
         }
     }
     $templateArr['permissions'] = Doctrine_Query::create()->from('Permission')->execute();
     if (!$form) {
         $form = new $formClass($formData);
     }
     $templateArr['addchange_form'] = $form;
     render_to_response('admin/addchange.html', $templateArr);
 }
Esempio n. 14
0
 function admin_category_addchange($request, $taxonomy = 'Post', $id = false)
 {
     $templateArr = array('current_admin_menu' => $taxonomy, 'current_admin_submenu' => $taxonomy, 'current_admin_submenu2' => 'PostCategory', 'title' => __('Post Category Add/Change'));
     if (!$request->user->has_perm($taxonomy . '.can_change_PostCategory')) {
         Messages::Error(__('Do not have permission to do this.'));
         HttpResponseRedirect($_SERVER['HTTP_REFERER']);
     }
     $modelClass = 'PostCategory';
     if ($taxonomy == 'Post') {
         $formClass = 'Pjango\\Contrib\\Post\\Forms\\PostCategoryForm';
     } else {
         $formClass = $taxonomy . '\\Forms\\PostCategoryForm';
     }
     $formData = array();
     $lng = pjango_ini_get('LANGUAGE_CODE');
     //eğer kategori yoksa ekle
     $catTest = Doctrine_Query::create()->from('PostCategory o')->where('o.site_id = ? AND o.taxonomy = ?', array(SITE_ID, $taxonomy))->count();
     if ($catTest <= 0) {
         $category = new PostCategory();
         $category->Translation[$lng]->name = __($taxonomy . ' Main Category');
         $category->Translation[$lng]->slug = __(ucfirst($taxonomy) . '-main-category');
         $category->site_id = SITE_ID;
         $category->taxonomy = $taxonomy;
         $category->save();
         $treeObject = Doctrine_Core::getTable('PostCategory')->getTree();
         $treeObject->createRoot($category);
     }
     if ($id) {
         $addchangeObj = Doctrine_Query::create()->from('PostCategory o')->leftJoin('o.Translation t')->addWhere('o.site_id = ? AND o.id = ?', array(SITE_ID, $id))->fetchOne();
         if ($addchangeObj) {
             $parent = $addchangeObj->getNode()->getParent();
             $formData = $addchangeObj->toArray();
             $templateArr['addchange_obj'] = $addchangeObj;
             $formData['parent_id'] = $parent->id;
             $formData['name'] = $addchangeObj->Translation[$lng]->name;
             $formData['slug'] = $addchangeObj->Translation[$lng]->slug;
         }
     }
     if ($request->POST) {
         $form = new $formClass($taxonomy, $request->POST);
         if ($form->is_valid()) {
             $formData = $form->cleaned_data();
             if (!$addchangeObj) {
                 $addchangeObj = new $modelClass();
             }
             try {
                 $parent = Doctrine::getTable($modelClass)->find($formData['parent_id']);
                 $addchangeObj->taxonomy = $taxonomy;
                 $addchangeObj->site_id = SITE_ID;
                 $addchangeObj->Translation[$lng]->name = $formData['name'];
                 $addchangeObj->Translation[$lng]->slug = $formData['slug'];
                 if ($addchangeObj->state() == Doctrine_Record::STATE_TDIRTY || $addchangeObj->state() == Doctrine_Record::STATE_TCLEAN) {
                     $addchangeObj->getNode()->insertAsLastChildOf($parent);
                 } else {
                     $addchangeObj->save();
                     $curParent = $addchangeObj->getNode()->getParent();
                     if ($curParent->id != $parent->id) {
                         $addchangeObj->getNode()->moveAsLastChildOf($parent);
                     }
                 }
                 Messages::Info(pjango_gettext('The operation completed successfully'));
                 HttpResponseRedirect('/admin/' . $taxonomy . '/' . $modelClass . '/');
             } catch (Exception $e) {
                 Messages::Error($e->getMessage());
             }
         }
     }
     if (!$form) {
         $form = new $formClass($taxonomy, $formData);
     }
     $templateArr['addchange_form'] = $form;
     $templateArr['taxonomy'] = $taxonomy;
     render_to_response('admin/addchange.html', $templateArr);
 }
Esempio n. 15
0
 function app_model_settings($request, $app_label = false, $model = false)
 {
     $templateArr = array('current_admin_menu' => $app_label, 'current_admin_submenu' => $model, 'current_admin_submenu2' => 'Settings', 'title' => __(sprintf('%s %s Settings', $app_label, $model)));
     $coreApps = array('Post');
     $app_label0 = $app_label;
     if (in_array($app_label, $coreApps)) {
         $app_label = sprintf('Pjango\\Contrib\\%s', $app_label);
     }
     $contentType = ContentType::get_for_model($model, $app_label);
     $formClass = sprintf('%s\\Forms\\%sSettingsForm', $app_label, $model);
     $formData = array();
     $ignoredSettings = array('is_active', 'title', 'show_title', 'category_id', 'content');
     $settings = Doctrine_Query::create()->from('Settings o')->where('o.category = ? AND o.site_id = ? ', array($app_label, SITE_ID))->fetchArray();
     foreach ($settings as $settingsValue) {
         $formData[$settingsValue['name']] = $settingsValue['value'];
     }
     if (class_exists('PageLayout')) {
         $pageLayout = Doctrine_Query::create()->from('PageLayout o')->where('o.site_id = ? AND o.content_type_id = ?', array(SITE_ID, $contentType->id))->fetchOne();
         if ($pageLayout) {
             $formData = array_merge($formData, $pageLayout->toArray());
         }
     }
     if ($request->POST) {
         $form = new $formClass($request->POST);
         try {
             if (!$form->is_valid()) {
                 throw new Exception(pjango_gettext('There are some errors, please correct them below.'));
             }
             $formData = $form->cleaned_data();
             if (class_exists('PageLayout')) {
                 if (!$pageLayout) {
                     $pageLayout = new PageLayout();
                 }
                 $pageLayout->fromArray($formData);
                 $pageLayout->content_type_id = $contentType->id;
                 $pageLayout->site_id = SITE_ID;
                 $pageLayout->save();
             }
             foreach ($formData as $key => $value) {
                 if (in_array($key, $ignoredSettings)) {
                     unset($formData[$key]);
                 }
             }
             Settings::saveFromArray($app_label, $formData);
             Messages::Info('The operation completed successfully');
             HttpResponseRedirect(sprintf('/admin/%s/%s/settings/', $app_label0, $model));
         } catch (Exception $e) {
             Messages::Error($e->getMessage());
         }
     }
     if (!$form) {
         $form = new $formClass($formData);
     }
     $templateArr['addchange_form'] = $form;
     render_to_response('admin/addchange.html', $templateArr);
 }