/** * Adds a new group * * @param string The new group's name * @param string The template's id which must be assigned the new group * * @return int 0 - The save operation failed * 1 - Success */ public function add($groupName, $idTemplate) { $groupName = w3sCommonFunctions::slugify($groupName); if ($groupName != 'n-a') { if ($idTemplate != null) { if (W3sGroupPeer::getFromName($groupName) == null) { if (DbFinder::from('W3sTemplate')->findPK($idTemplate) != null) { $this->group->setTemplateId($idTemplate); $this->group->setGroupName($groupName); $this->group->setEdited(1); $result = $this->group->isModified() && $this->group->save() > 0 ? 1 : 0; } else { // The template doesn't exist $result = 16; } } else { // Group name exists $result = 2; } } else { // The template id is null $result = 8; } } else { // Group name is empty $result = 4; } return $result; }
/** * Renders the images editor * * @return string * */ public function render() { return sprintf($this->editorSkeleton, label_for('page_name', __('Page name:')), input_tag('w3s_page_name', ''), label_for('group_name', __('Group name:')), select_tag('w3s_groups_select', objects_for_select(W3sGroupPeer::getActiveGroups(), 'getId', 'getGroupName')), link_to_function(__('Add Page'), 'W3sPage.add()', 'class="link_button"')); }
/** * Shows the module that allows the user to change the page's group */ public function executeShowChangePageGroupModule() { if ($this->getRequestParameter('idGroup') != '') { $this->idPage = $this->getRequestParameter('idPage'); $this->idGroup = $this->getRequestParameter('idGroup'); $c = new Criteria(); $c->add(W3sGroupPeer::TO_DELETE, 0); $this->options = W3sGroupPeer::doSelect($c); } }
public function renderGroupsSelect() { return select_tag('w3s_groups_select1', objects_for_select(W3sGroupPeer::getActiveGroups(), 'getId', 'getGroupName')); }
/** * Deletes from the database all the deleted languages, pages and contents * during the edit phase * * @return bool The operation result */ private function updateDb() { try { $con = Propel::getConnection(); $con = w3sPropelWorkaround::beginTransaction($con); // Deletes the languages $c = new Criteria(); $c->add(W3sLanguagePeer::TO_DELETE, 1); W3sLanguagePeer::doDelete($c); // Deletes the groups $c = new Criteria(); $c->add(W3sGroupPeer::TO_DELETE, 1); W3sGroupPeer::doDelete($c); // Deletes the pages $c = new Criteria(); $c->add(W3sPagePeer::TO_DELETE, 1); W3sPagePeer::doDelete($c); // Deletes the contents $c = new Criteria(); $c->add(W3sContentPeer::TO_DELETE, 1); W3sContentPeer::doDelete($c); $con->commit(); return true; } catch (Exception $e) { w3sPropelWorkaround::rollBack($con); sfContext::getInstance()->getLogger()->info('W3StudioCMS - ' . $this->setExceptionError($e->getMessage())); return false; } }