[Joomla-commits] r18749 - in development/branches/jcamp: administrator/components/com_projects/tables components/com_projects/controllers components/com_projects/helpers components/com_projects/models components/com_projects/models/forms components/com_projects/views/document/tmpl language/en-GB

0 views
Skip to first unread message

3den...@jcode001.directrouter.com

unread,
Sep 1, 2010, 4:09:41 PM9/1/10
to joomla-...@joomlacode.org
Author: 3dentech
Date: 2010-09-01 15:09:41 -0500 (Wed, 01 Sep 2010)
New Revision: 18749

Modified:
development/branches/jcamp/administrator/components/com_projects/tables/content.php
development/branches/jcamp/components/com_projects/controllers/document.php
development/branches/jcamp/components/com_projects/helpers/projects.php
development/branches/jcamp/components/com_projects/models/document.php
development/branches/jcamp/components/com_projects/models/forms/document.xml
development/branches/jcamp/components/com_projects/models/forms/project.xml
development/branches/jcamp/components/com_projects/models/forms/task.xml
development/branches/jcamp/components/com_projects/views/document/tmpl/edit.php
development/branches/jcamp/language/en-GB/en-GB.com_projects.ini
Log:


Modified: development/branches/jcamp/administrator/components/com_projects/tables/content.php
===================================================================
--- development/branches/jcamp/administrator/components/com_projects/tables/content.php 2010-09-01 06:57:26 UTC (rev 18748)
+++ development/branches/jcamp/administrator/components/com_projects/tables/content.php 2010-09-01 20:09:41 UTC (rev 18749)
@@ -18,6 +18,5 @@
*/
class ProjectsTableContent extends JTableContent
{
-
-
+
}
\ No newline at end of file

Modified: development/branches/jcamp/components/com_projects/controllers/document.php
===================================================================
--- development/branches/jcamp/components/com_projects/controllers/document.php 2010-09-01 06:57:26 UTC (rev 18748)
+++ development/branches/jcamp/components/com_projects/controllers/document.php 2010-09-01 20:09:41 UTC (rev 18749)
@@ -8,30 +8,21 @@
// no direct access
defined('_JEXEC') or die;

-jimport('joomla.application.component.controllerform');
+//jimport('joomla.application.component.controllerform');
+require_once 'components'.DS.'com_content'.DS.'controllers'.DS.'article.php';

/**
* @package Joomla.Site
* @subpackage com_project
*/
-class ProjectsControllerDocument extends JControllerForm
+class ProjectsControllerDocument extends ContentControllerArticle
{
+
protected $_context = 'com_projects.edit.document';
-
+ protected $view_item = 'document';
+ protected $view_list = 'documents';

- /**
- * Constructor
- */
- public function __construct($config = array())
- {
- parent::__construct($config);
-
- $this->registerTask('apply', 'save');
- $this->registerTask('save2new', 'save');
- $this->registerTask('save2copy', 'save');
- }

-
/**
* Method to get a model object, loading it if required.
*
@@ -46,105 +37,53 @@
$model = parent::getModel($name, $prefix, $config);
return $model;
}
+
+ public function add(){
+ parent::add();
+
+ $model = $this->getModel();
+ $this->setRedirect(ProjectsHelper::getLink('document.form'), false);
+ }
+
+ public function edit(){
+ parent::edit();
+
+ $model = $this->getModel();
+ $this->setRedirect(ProjectsHelper::getLink('document.form', $model->getState('article.id')), false);
+ }

-
+ public function cancel(){
+ parent::cancel();
+
+ $model = $this->getModel();
+ $this->setRedirect(ProjectsHelper::getLink('documents', $model->getState('project.id')), false);
+ }
/**
* Save the record
*/
public function save()
{
- // Check for request forgeries.
- JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
-
- // Initialise variables.
- $app = JFactory::getApplication();
- $context = $this->_context.'.';
- $model = $this->getModel();
- $task = $this->getTask();
- $id = (int)$model->getState('document.id', 0);
- $menu = $app->getMenu();

- // Get posted form variables.
- $data = JRequest::getVar('jform', array(), 'post', 'array');
-
- // Populate the row id from the session.
- $data['id'] = $id;
- $isNew = !$id;
-
- // Split introtext and fulltext
- $pattern = '#<hr\s+id=(["\'])system-readmore\1\s*/?>#i';
- $text = $data['text'];
- $tagPos = preg_match($pattern, $text);
-
- if ($tagPos == 0) {
- $data['introtext'] = $text;
- }
- else {
- list($data['introtext'], $data['fulltext']) = preg_split($pattern, $text, 2);
- }
-
- // Validate the posted data.
- $form = $model->getForm();
- if (!$form) {
- JError::raiseError(500, $model->getError());
- return false;
- }
- $data = $model->validate($form, $data);
-
- // Check for validation errors.
- if ($data === false)
- {
- // Get the validation messages.
- $errors = $model->getErrors();
-
- // Push up to three validation messages out to the user.
- for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++)
- {
- if (JError::isError($errors[$i])) {
- $app->enqueueMessage($errors[$i]->getMessage(), 'notice');
- }
- else {
- $app->enqueueMessage($errors[$i], 'notice');
- }
- }
-
- // Save the data in the session.
- $app->setUserState($context.'data', $data);
-
- // Redirect back to the edit screen.
- $this->setRedirect(ProjectsHelper::getLink('document', $data['id'].'&layout=edit'));
- return false;
- }
-
- // Attempt to save the data.
- $append= '&Itemid='.$menu->getActive()->id;
- if (!$model->save($data))
- {
- // Save the data in the session.
- $app->setUserState($context.'data', $data);
-
- // Redirect back to the edit screen.
- $this->setMessage(JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError()), 'notice');
- $this->setRedirect(JRoute::_('index.php?option=com_projects&view=document&layout=edit'.$append));
- return false;
- }
+ parent::save();

- // Save succeeded, check-in the row.
- if (!$model->checkin())
- {
- // Check-in failed, go back to the row and display a notice.
- $message = JText::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError());
- $this->setRedirect('index.php?option=com_projects&view=document&layout=edit'.$append, $message, 'error');
+ // Set the row data in the session.
+ $app = JFactory::getApplication();
+ $model = $this->getModel();
+ $id = $model->getState('article.id');
+ // Redirect back to the edit screen.
+ if(!$id){
+ $app->setUserState($this->_context.'.id', null);
+ $app->setUserState($this->_context.'.data', null);
+ $msg = JText::_('COM_PROJECTS_DOCUMENT_SAVE_ERROR');
+ //$this->setMessage($msg, 'error');
+ $this->setRedirect(ProjectsHelper::getLink('documents', $model->getState('project.id')));
return false;
}
-
- // Set the row data in the session.
- $app->setUserState($context.'id', $model->getState('document.id'));
- $app->setUserState($context.'data', null);

- // Redirect back to the edit screen.
+ $app->setUserState($this->_context.'.id', $id);
+ $app->setUserState($this->_context.'.data', null);
$this->setMessage(JText::_('COM_PROJECTS_DOCUMENT_SAVE_SUCCESS'));
- $this->setRedirect(ProjectsHelper::getLink('document', $model->getState('document.id')), false);
+ $this->setRedirect(ProjectsHelper::getLink('document', $id));
return true;
}
}
\ No newline at end of file

Modified: development/branches/jcamp/components/com_projects/helpers/projects.php
===================================================================
--- development/branches/jcamp/components/com_projects/helpers/projects.php 2010-09-01 06:57:26 UTC (rev 18748)
+++ development/branches/jcamp/components/com_projects/helpers/projects.php 2010-09-01 20:09:41 UTC (rev 18749)
@@ -301,6 +301,7 @@

'documents' => 'index.php?option=com_projects&view=documents&id=',
'document' => 'index.php?option=com_projects&view=document&id=',
+ 'document.form' => 'index.php?option=com_projects&view=document&layout=edit&id=',
);
}
return JRoute::_($links[strtolower($key)].$append);

Modified: development/branches/jcamp/components/com_projects/models/document.php
===================================================================
--- development/branches/jcamp/components/com_projects/models/document.php 2010-09-01 06:57:26 UTC (rev 18748)
+++ development/branches/jcamp/components/com_projects/models/document.php 2010-09-01 20:09:41 UTC (rev 18749)
@@ -10,25 +10,31 @@
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die;

-jimport('joomla.application.component.modeladmin');
-//require_once 'components'.DS.'com_content'.DS .'models'.DS.'form.php';
+//jimport('joomla.application.component.modeladmin');
+require_once 'components'.DS.'com_content'.DS.'models'.DS.'form.php';

/**
* Model to display editing form for a document
* @author elf
*
*/
-class ProjectsModelDocument extends JModelAdmin
+class ProjectsModelDocument extends ContentModelForm
{
/**
* Model context string.
*
* @var string
*/
- protected $context = 'com_projects.edit.document';
+ protected $_context = 'com_projects.edit.document';
protected $project;
protected $item;

+
+ public function __construct($config){
+ parent::__construct($config);
+
+ $this->addTablePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_content'.DS.'tables');
+ }
/**
* Method to test whether a record can be deleted.
*
@@ -85,9 +91,10 @@
// project
$this->setState('project.id',
$app->getUserState('project.id'));
-
- $app->setUserState($this->context.'id', null);
- $app->setUserState($this->context.'data', null);
+
+ //$this->setState('article.id',
+ // $app->setUserState($this->_context.'id', null);
+ //$app->setUserState($this->_context.'data', null);
}


@@ -136,7 +143,7 @@
protected function loadFormData()
{
// Check the session for previously entered form data.
- $data = JFactory::getApplication()->getUserState($this->context.'.data', array());
+ $data = JFactory::getApplication()->getUserState($this->_context.'.data', array());

if (empty($data)) {
$data = $this->getItem();
@@ -156,6 +163,7 @@
{
if(!is_object($this->item)){
$this->item = parent::getItem($pk);
+
if(!empty($this->item)){
$app = JFactory::getApplication();
if($this->item->id){
@@ -170,11 +178,6 @@
$app->setUserState('project.id', $this->item->project_id);
}

- $this->item->text = $this->item->introtext;
- if (!empty($this->item->fulltext)) {
- $this->item->text .= '<hr id="system-readmore" />'.$this->item->fulltext;
- }
-
// Convert parameter fields to objects.
$registry = new JRegistry;
$registry->loadJSON($this->item->attribs);
@@ -182,6 +185,7 @@
$this->item->params->merge($registry);
}
}
+
return $this->item;
}

@@ -204,13 +208,14 @@
}

public function save($data){
+ $isNew = !$data['id'];
if(!parent::save($data)){
return false;
}
-
- if($this->getState('document.new')){
+
+ if($isNew){
$db = $this->getDbo();
- $id = $this->getState('document.id', $db->insertid());
+ $id = $this->getState('article.id', $db->insertid());
$app= JFactory::getApplication();
$q = 'INSERT INTO `#__project_contents`'.
'(`project_id`,`content_id`)'.

Modified: development/branches/jcamp/components/com_projects/models/forms/document.xml
===================================================================
--- development/branches/jcamp/components/com_projects/models/forms/document.xml 2010-09-01 06:57:26 UTC (rev 18748)
+++ development/branches/jcamp/components/com_projects/models/forms/document.xml 2010-09-01 20:09:41 UTC (rev 18749)
@@ -42,7 +42,7 @@
description="COM_PROJECT_FIELD_DOCUMENT_CATEGORY_DESC"
class="inputbox"
default="0">
- <option value="0">JNONE</option>
+ <option value="0">JOPTION_SELECT_CATEGORY</option>
</field>
<!-- this is for rendering -->
<field
@@ -154,6 +154,19 @@
<option value="*">JALL</option>
</field>

+ <field
+ id="featured"
+ name="featured"
+ type="list"
+ label="JGLOBAL_FIELD_FEATURED_LABEL"
+ description="JGLOBAL_FIELD_FEATURED_DESC"
+ class="inputbox"
+ default="0"
+ >
+ <option value="0">JNO</option>
+ <option value="1">JYES</option>
+ </field>
+
<field
id="access"
name="access"
@@ -161,6 +174,8 @@
label="JFIELD_ACCESS_LABEL"
description="JFIELD_ACCESS_DESC"
class="inputbox"
- size="1" />
+ size="1">
+ <option value="">JOPTION_SELECT_ACCESS</option>
+ </field>
</fieldset>
</form>
\ No newline at end of file

Modified: development/branches/jcamp/components/com_projects/models/forms/project.xml
===================================================================
--- development/branches/jcamp/components/com_projects/models/forms/project.xml 2010-09-01 06:57:26 UTC (rev 18748)
+++ development/branches/jcamp/components/com_projects/models/forms/project.xml 2010-09-01 20:09:41 UTC (rev 18749)
@@ -18,7 +18,7 @@
extension="com_projects"
label="COM_PROJECTS_FIELD_PORTFOLIO_LABEL"
required="true">
- <option value="">JOPTION_NO_CATEGORY</option>
+ <option value="">COM_PROJECTS_SELECT_PORTFOLIO</option>
</field>

<field id="title"

Modified: development/branches/jcamp/components/com_projects/models/forms/task.xml
===================================================================
--- development/branches/jcamp/components/com_projects/models/forms/task.xml 2010-09-01 06:57:26 UTC (rev 18748)
+++ development/branches/jcamp/components/com_projects/models/forms/task.xml 2010-09-01 20:09:41 UTC (rev 18749)
@@ -31,7 +31,7 @@
description="JFIELD_CATEGORY_DESC"
extension="com_projects.task"
label="JCATEGORY" >
- <option value="">JNONE</option>
+ <option value="">JOPTION_SELECT_CATEGORY</option>
</field>

<field id="title"

Modified: development/branches/jcamp/components/com_projects/views/document/tmpl/edit.php
===================================================================
--- development/branches/jcamp/components/com_projects/views/document/tmpl/edit.php 2010-09-01 06:57:26 UTC (rev 18748)
+++ development/branches/jcamp/components/com_projects/views/document/tmpl/edit.php 2010-09-01 20:09:41 UTC (rev 18749)
@@ -27,12 +27,13 @@
<legend><?php echo JText::_('JEDITOR'); ?></legend>

<div class="formelm">
+ <?php echo $this->form->getLabel('featured'); ?>
+ <?php echo $this->form->getInput('featured'); ?>
+ </div>
+
+ <div class="formelm">
<?php echo $this->form->getLabel('title'); ?>
<?php echo $this->form->getInput('title'); ?>
- </div>
-
- <div class="formelm">
- <?php echo $this->form->getLabel('catid'); ?>
<?php echo $this->form->getInput('catid'); ?>
</div>

Modified: development/branches/jcamp/language/en-GB/en-GB.com_projects.ini
===================================================================
--- development/branches/jcamp/language/en-GB/en-GB.com_projects.ini 2010-09-01 06:57:26 UTC (rev 18748)
+++ development/branches/jcamp/language/en-GB/en-GB.com_projects.ini 2010-09-01 20:09:41 UTC (rev 18749)
@@ -76,6 +76,7 @@
;
COM_PROJECTS_FIELD_PORTFOLIO_LABEL="Portfolio"
COM_PROJECTS_FIELD_PORTFOLIO_DESC="Select the portfolio that contains the project."
+COM_PROJECTS_SELECT_PORTFOLIO="- Select Portfolio -"

;
; Fields - Document

_______________________________________________
Joomla-commits mailing list
Joomla-...@joomlacode.org
http://joomlacode.org/mailman/listinfo/joomla-commits

Reply all
Reply to author
Forward
0 new messages