function execute(&$controller, &$request, &$user)
 {
     $id = isset($_REQUEST['cid']) ? intval($_REQUEST['cid']) : 0;
     $handler =& plzXoo::getHandler('category');
     $obj =& $handler->get($id);
     if (!is_object($obj)) {
         $obj =& $handler->create();
     }
     $editform = new CategoryEditForm();
     if ($editform->init($obj) == ACTIONFORM_POST_SUCCESS) {
         $editform->update($obj);
         $request->setAttribute('obj', $obj);
         return $handler->insert($obj) ? VIEW_SUCCESS : VIEW_ERROR;
     }
     // View にカテゴリ一覧を送る
     $categories =& $handler->getObjects();
     $request->setAttribute('editform', $editform);
     $request->setAttribute('obj', $obj);
     $request->setAttribute('categories', $categories);
     return VIEW_INPUT;
 }
Ejemplo n.º 2
0
            $objDatabase = QApplication::$Database[1];
            // Begin a MySQL Transaction to be either committed or rolled back
            $objDatabase->TransactionBegin();
            $objCustomFieldArray = $this->objCategory->objCustomFieldArray;
            $this->objCategory->Delete();
            // Commit the transaction to the database
            $objDatabase->TransactionCommit();
            $this->RedirectToListPage();
        } catch (QDatabaseExceptionBase $objExc) {
            // Rollback the database transaction
            $objDatabase->TransactionRollback();
            if ($objExc->ErrorNumber == 1451) {
                $this->btnCancel->Warning = 'This category cannot be deleted because it is associated with one or more models.';
            } else {
                throw new QDatabaseExceptionBase();
            }
        }
    }
    // Protected Update Methods
    protected function UpdateCategoryFields()
    {
        $this->objCategory->ShortDescription = $this->txtShortDescription->Text;
        $this->objCategory->LongDescription = $this->txtLongDescription->Text;
        $this->objCategory->AssetFlag = $this->chkAssetFlag->Checked;
        $this->objCategory->InventoryFlag = $this->chkInventoryFlag->Checked;
    }
}
// Go ahead and run this form object to render the page and its event handlers, using
// generated/category_edit.php.inc as the included HTML template file
CategoryEditForm::Run('CategoryEditForm', __DOCROOT__ . __SUBDIRECTORY__ . '/admin/category_edit.tpl.php');
Ejemplo n.º 3
0
            $objControl->Blink();
        }
        return $blnToReturn;
    }
    // Button Event Handlers
    protected function btnSave_Click($strFormId, $strControlId, $strParameter)
    {
        // Delegate "Save" processing to the CategoryMetaControl
        $this->mctCategory->SaveCategory();
        $this->RedirectToListPage();
    }
    protected function btnDelete_Click($strFormId, $strControlId, $strParameter)
    {
        // Delegate "Delete" processing to the CategoryMetaControl
        $this->mctCategory->DeleteCategory();
        $this->RedirectToListPage();
    }
    protected function btnCancel_Click($strFormId, $strControlId, $strParameter)
    {
        $this->RedirectToListPage();
    }
    // Other Methods
    protected function RedirectToListPage()
    {
        QApplication::Redirect(__VIRTUAL_DIRECTORY__ . __FORM_DRAFTS__ . '/category_list.php');
    }
}
// Go ahead and run this form object to render the page and its event handlers, implicitly using
// category_edit.tpl.php as the included HTML template file
CategoryEditForm::Run('CategoryEditForm');
Ejemplo n.º 4
0
// Include prepend.inc to load Qcodo
require '../includes/prepend.inc.php';
/* if you DO NOT have "includes/" in your include_path */
// require('prepend.inc.php');				/* if you DO have "includes/" in your include_path */
// Include the classfile for CategoryEditFormBase
require __FORMBASE_CLASSES__ . '/CategoryEditFormBase.class.php';
// Security check for ALLOW_REMOTE_ADMIN
// To allow access REGARDLESS of ALLOW_REMOTE_ADMIN, simply remove the line below
QApplication::CheckRemoteAdmin();
/**
 * This is a quick-and-dirty draft form object to do Create, Edit, and Delete functionality
 * of the Category class.  It extends from the code-generated
 * abstract CategoryEditFormBase class.
 *
 * Any display customizations and presentation-tier logic can be implemented
 * here by overriding existing or implementing new methods, properties and variables.
 *
 * Additional qform control objects can also be defined and used here, as well.
 * 
 * @package My Application
 * @subpackage FormDraftObjects
 * 
 */
class CategoryEditForm extends CategoryEditFormBase
{
}
// Go ahead and run this form object to render the page and its event handlers, using
// generated/category_edit.tpl.php as the included HTML template file
CategoryEditForm::Run('CategoryEditForm', 'generated/category_edit.tpl.php');