/** * Loads a list of document-types for the specicifies parameters, returns an array of Document_DocType elements * * @return array */ public function load() { $docTypesData = $this->db->fetchAll("SELECT id FROM documents_doctypes" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables()); $docTypes = array(); foreach ($docTypesData as $docTypeData) { $docTypes[] = Document_DocType::getById($docTypeData["id"]); } $this->model->setDocTypes($docTypes); return $docTypes; }
/** * @return string $statusMessage */ public static function install() { $queries = array('questions' => 'CREATE TABLE IF NOT EXISTS `plugin_poll_questions` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , `title` VARCHAR(255) NOT NULL , `creationDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `startDate` DATETIME NULL DEFAULT NULL , `endDate` DATETIME NULL DEFAULT NULL , `isActive` TINYINT(1) NOT NULL DEFAULT 0 , `viewsCount` INT NOT NULL DEFAULT 0 , `multiple` TINYINT(1) NOT NULL DEFAULT 0 , PRIMARY KEY (`id`) ) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8 COLLATE = utf8_general_ci;', 'answers' => 'CREATE TABLE IF NOT EXISTS `plugin_poll_answers` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , `questionId` INT UNSIGNED NOT NULL , `title` VARCHAR(255) NOT NULL , `responses` INT NOT NULL DEFAULT 0 , `index` INT UNSIGNED NOT NULL DEFAULT 999999 , PRIMARY KEY (`id`) , INDEX `fk_plugin_poll_answers_plugin_poll_questions` (`questionId` ASC) , CONSTRAINT `fk_plugin_poll_answers_plugin_poll_questions` FOREIGN KEY (`questionId` ) REFERENCES `plugin_poll_questions` (`id` ) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8 COLLATE = utf8_general_ci;'); // add snippet document type $docType = Document_DocType::create(); $docType->setName('Poll'); $docType->setType('snippet'); $docType->setModule('Poll'); $docType->setController('frontend'); $docType->setAction('snippet'); $docType->save(); if (self::_executeQueries($queries)) { return "Poll Plugin successfully installed."; } else { return "Poll Plugin could not be installed. See debug log for more details."; } }
public function docTypesAction() { if ($this->_getParam("data")) { if ($this->getUser()->isAllowed("document_types")) { if ($this->_getParam("xaction") == "destroy") { $id = Zend_Json::decode($this->_getParam("data")); $type = Document_DocType::getById($id); $type->delete(); $this->_helper->json(array("success" => true, "data" => array())); } else { if ($this->_getParam("xaction") == "update") { $data = Zend_Json::decode($this->_getParam("data")); // save type $type = Document_DocType::getById($data["id"]); $type->setValues($data); $type->save(); $this->_helper->json(array("data" => $type, "success" => true)); } else { if ($this->_getParam("xaction") == "create") { $data = Zend_Json::decode($this->_getParam("data")); unset($data["id"]); // save type $type = Document_DocType::create(); $type->setValues($data); $type->save(); $this->_helper->json(array("data" => $type, "success" => true)); } } } } } else { // get list of types $list = new Document_DocType_List(); if ($this->_getParam("sort")) { $list->setOrderKey($this->_getParam("sort")); $list->setOrder($this->_getParam("dir")); } $list->load(); $docTypes = array(); foreach ($list->getDocTypes() as $type) { $docTypes[] = $type; } $this->_helper->json(array("data" => $docTypes, "success" => true, "total" => count($docTypes))); } $this->_helper->json(false); }
public function createDocTypes() { $conf = new Zend_Config_Xml(PIMCORE_PLUGINS_PATH . '/Blog/install/doctypes.xml'); foreach ($conf->doctypes->doctype as $def) { $docType = Document_DocType::create(); $docType->setName($def->name); $docType->setType($def->type); $docType->setModule($def->module); $docType->setController($def->controller); $docType->setAction($def->action); $docType->save(); } }