/** {@inheritdoc} */ public function showMain() { if (!is_writable($this->app['configPath'])) { $this->addMessage("Configuration file doesn't seem to be writable.", self::MSG_ERROR); } $config = $this->app->openConfiguration(); $pages = PagePeer::getSelect(); $form = new Curry_Form(array('action' => url('', array("module", "view")), 'method' => 'post', 'elements' => array('enabled' => array('checkbox', array('label' => 'Enable domain mapping', 'value' => $config->domainMapping->enabled)), 'default_base_page' => array('select', array('label' => 'Default base page', 'description' => 'The default base page will only be used if there are no other domains matching and domain mapping is enabled', 'value' => $config->domainMapping->default, 'multiOptions' => array('' => '[ None ]') + $pages))))); $domainForm = new Curry_Form_Dynamic(array('legend' => 'Domain', 'elements' => array('domain' => array('text', array('label' => 'Domain', 'description' => 'You can use default as a wildcard to fetch unmatched domains.', 'required' => true)), 'base_page' => array('select', array('label' => 'Base page', 'multiOptions' => array('' => '[ None ]') + $pages, 'required' => true)), 'include_www' => array('checkbox', array('label' => 'Include www'))))); $form->addSubForm(new Curry_Form_MultiForm(array('legend' => '', 'cloneTarget' => $domainForm, 'defaults' => $config->domainMapping->domains ? $config->domainMapping->domains->toArray() : array())), 'domainMapping'); $form->addElement('submit', 'save', array('label' => 'Save')); if (isPost() && $form->isValid($_POST)) { $values = $form->getValues(); if (!$config->domainMapping) { $config->domainMapping = array(); } $config->domainMapping->enabled = count($values['domainMapping']) ? (bool) $values['enabled'] : false; $config->domainMapping->default = $values['default_base_page']; $config->domainMapping->domains = $values['domainMapping']; try { $this->app->writeConfiguration($config); $this->addMessage("Settings saved.", self::MSG_SUCCESS); } catch (Exception $e) { $this->addMessage($e->getMessage(), self::MSG_ERROR); } } $this->addMainContent($form); }
public function postSave(PropelPDO $oConnection = null) { PagePeer::ignoreRights(true); //Mark page as updated to flush full page caches $this->getPage()->save(); PagePeer::ignoreRights(false); }
public function __construct() { try { $this->oRootPage = PagePeer::getRootPage(); } catch (Exception $e) { $this->oRootPage = self::initializeRootPage(); } $this->oTreeWidget = new TreeWidgetModule(); $this->oTreeWidget->setDelegate($this); $this->oTreeWidget->setSetting('init_dnd', true); $oInitialPage = null; if (Manager::hasNextPathItem()) { $oInitialPage = PageQuery::create()->findPk(Manager::usePath()); if ($oInitialPage !== null) { Session::getSession()->setAttribute('persistent_page_id', $oInitialPage->getId()); } } else { if (Session::getSession()->hasAttribute('persistent_page_id')) { $oInitialPage = PageQuery::create()->findPk(Session::getSession()->getAttribute('persistent_page_id')); } } if ($oInitialPage === null) { $oInitialPage = $this->oRootPage; } $this->addResourceParameter(ResourceIncluder::RESOURCE_TYPE_JS, 'tree_session', $this->oTreeWidget->getSessionKey()); $this->addResourceParameter(ResourceIncluder::RESOURCE_TYPE_JS, 'initial_page_id', $oInitialPage->getId()); $this->addResourceParameter(ResourceIncluder::RESOURCE_TYPE_JS, 'initial_page_tree_left', $oInitialPage->getTreeLeft()); $oResourceIncluder = ResourceIncluder::defaultIncluder(); $oResourceIncluder->addResource('admin/template.css', null, null, array(), ResourceIncluder::PRIORITY_NORMAL, null, true); }
public function __construct($sSessionId) { parent::__construct($sSessionId); $oRichtext = WidgetModule::getWidget('rich_text', null, null, 'documentation'); $oRichtext->setTemplate(PagePeer::getRootPage()->getTemplate()); $this->setSetting('richtext_session', $oRichtext->getSessionKey()); $this->setSetting('international_option', LanguageInputWidgetModule::isMonolingual()); }
public function executePublish(sfWebRequest $request, $set = true) { $id = $request->getParameter('id'); $c = new Criteria(); $page = PagePeer::retrieveByPK($id); $page->setIsPublished($set); $page->save(); $this->getUser()->setFlash('notice', 'The selected page has been ' . ($set ? 'published' : 'drafted') . ' successfully.'); $this->redirect('page'); }
/** * @return Page The root page */ public static function getRootPage() { if (self::$ROOT_PAGE === null) { self::$ROOT_PAGE = self::retrieveRoot(); if (self::$ROOT_PAGE === null) { throw new Exception('Error in PagePeer::getRootPage(): there is no root page'); } } return self::$ROOT_PAGE; }
/** {@inheritdoc} */ public function showMain() { $this->addMainMenu(); $configFile = Curry_Core::$config->curry->configPath; if (!$configFile) { $this->addMessage("Configuration file not set.", self::MSG_ERROR); } else { if (!is_writable($configFile)) { $this->addMessage("Configuration file doesn't seem to be writable.", self::MSG_ERROR); } } $config = new Zend_Config($configFile ? require $configFile : array(), true); $defaultConfig = Curry_Core::getDefaultConfiguration(); $form = new Curry_Form(array('action' => url('', array("module", "view")), 'method' => 'post')); $themes = array(); $backendPath = Curry_Util::path(true, Curry_Core::$config->curry->wwwPath, 'shared', 'backend'); if ($backendPath) { foreach (new DirectoryIterator($backendPath) as $entry) { $name = $entry->getFilename(); if (!$entry->isDot() && $entry->isDir() && $name !== 'common') { $themes[$name] = $name; } } } $activeTheme = isset($config->curry->backend->theme) ? $config->curry->backend->theme : false; if ($activeTheme && !array_key_exists($activeTheme, $themes)) { $themes[$activeTheme] = $activeTheme; } $pages = PagePeer::getSelect(); // General $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'General', 'elements' => array('name' => array('text', array('label' => 'Name', 'required' => true, 'value' => isset($config->curry->name) ? $config->curry->name : '', 'description' => 'Name of site, shown in backend header and page title by default.', 'placeholder' => $defaultConfig->curry->name)), 'baseUrl' => array('text', array('label' => 'Base URL', 'value' => isset($config->curry->baseUrl) ? $config->curry->baseUrl : '', 'description' => 'The URL to use when creating absolute URLs. This should end with a slash, and may include a path.', 'placeholder' => $defaultConfig->curry->baseUrl)), 'adminEmail' => array('text', array('label' => 'Admin email', 'value' => isset($config->curry->adminEmail) ? $config->curry->adminEmail : '')), 'divertOutMailToAdmin' => array('checkbox', array('label' => 'Divert outgoing email to adminEmail', 'value' => isset($config->curry->divertOutMailToAdmin) ? $config->curry->divertOutMailToAdmin : '', 'description' => 'All outgoing Curry_Mail will be diverted to adminEmail.')), 'developmentMode' => array('checkbox', array('label' => 'Development mode', 'value' => isset($config->curry->developmentMode) ? $config->curry->developmentMode : '')), 'forceDomain' => array('checkbox', array('label' => 'Force domain', 'value' => isset($config->curry->forceDomain) ? $config->curry->forceDomain : '', 'description' => 'If the domain of the requested URL doesn\'t match the domain set by Base URL, the user will be redirected to the correct domain.')), 'fallbackLanguage' => array('select', array('label' => 'Fallback Language', 'multiOptions' => array('' => '[ None ]') + LanguageQuery::create()->find()->toKeyValue('PrimaryKey', 'Name'), 'value' => isset($config->curry->fallbackLanguage) ? $config->curry->fallbackLanguage : '', 'description' => 'The language used when no language has been specified for the rendered page. Also the language used in backend context.'))))), 'general'); // Backend $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Backend', 'class' => 'advanced', 'elements' => array('theme' => array('select', array('label' => 'Theme', 'multiOptions' => array('' => '[ Default ]') + $themes, 'value' => isset($config->curry->backend->theme) ? $config->curry->backend->theme : '', 'description' => 'Theme for the administrative back-end.')), 'logotype' => array('filebrowser', array('label' => 'Backend Logotype', 'value' => isset($config->curry->backend->logotype) ? $config->curry->backend->logotype : '', 'description' => 'Path to the backend logotype. The height of this image should be 100px.')), 'templatePage' => array('select', array('label' => 'Template page', 'multiOptions' => array('' => '[ None ]') + $pages, 'value' => isset($config->curry->backend->templatePage) ? $config->curry->backend->templatePage : '', 'description' => 'The page containing page templates (i.e. pages to be used as base pages). When creating new pages or editing a page using the Content tab, only this page and pages below will be shown as base pages.')), 'defaultEditor' => array('text', array('label' => 'Default HTML editor', 'value' => isset($config->curry->defaultEditor) ? $config->curry->defaultEditor : '', 'description' => 'The default WYSIWYG editor to use with the article module.', 'placeholder' => $defaultConfig->curry->defaultEditor)), 'autoBackup' => array('text', array('label' => 'Automatic database backup', 'value' => isset($config->curry->autoBackup) ? $config->curry->autoBackup : '', 'placeholder' => $defaultConfig->curry->autoBackup, 'description' => 'Specifies the number of seconds since last backup to create automatic database backups when logged in to the backend.')), 'revisioning' => array('checkbox', array('label' => 'Revisioning', 'value' => isset($config->curry->revisioning) ? $config->curry->revisioning : '', 'description' => 'When enabled, a new working revision will automatically be created when you create a page. You will also be warned when editing a published page revision')), 'autoPublish' => array('checkbox', array('label' => 'Auto Publish', 'value' => isset($config->curry->autoPublish) ? $config->curry->autoPublish : '', 'description' => 'When enabled, a check will be made on every request to check if there are any pages that should be published (using publish date).')), 'noauth' => array('checkbox', array('label' => 'Disable Backend Authorization', 'value' => isset($config->curry->backend->noauth) ? $config->curry->backend->noauth : '', 'description' => 'This will completely disable authorization for the backend.')), 'autoUpdateIndex' => array('checkbox', array('label' => 'Auto Update Search Index', 'value' => isset($config->curry->autoUpdateIndex) ? $config->curry->autoUpdateIndex : '', 'description' => 'Automatically update (rebuild) search index when changing page content.'))))), 'backend'); // Live edit $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Live edit', 'class' => 'advanced', 'elements' => array('liveEdit' => array('checkbox', array('label' => 'Enable Live Edit', 'value' => isset($config->curry->liveEdit) ? $config->curry->liveEdit : $defaultConfig->curry->liveEdit, 'description' => 'Enables editing of content directly in the front-end.')), 'placeholderExclude' => array('textarea', array('label' => 'Excluded placeholders', 'value' => isset($config->curry->backend->placeholderExclude) ? join(PHP_EOL, $config->curry->backend->placeholderExclude->toArray()) : '', 'description' => 'Prevent placeholders from showing up in live edit mode. Use newlines to separate placeholders.', 'rows' => 5))))), 'liveEdit'); // Error pages $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Error pages', 'class' => 'advanced', 'elements' => array('notFound' => array('select', array('label' => 'Page not found (404)', 'multiOptions' => array('' => '[ None ]') + $pages, 'value' => isset($config->curry->errorPage->notFound) ? $config->curry->errorPage->notFound : '')), 'unauthorized' => array('select', array('label' => 'Unauthorized (401)', 'multiOptions' => array('' => '[ None ]') + $pages, 'value' => isset($config->curry->errorPage->unauthorized) ? $config->curry->errorPage->unauthorized : '')), 'error' => array('select', array('label' => 'Internal server error (500)', 'multiOptions' => array('' => '[ None ]') + $pages, 'value' => isset($config->curry->errorPage->error) ? $config->curry->errorPage->error : ''))))), 'errorPage'); // Maintenance $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Maintenance', 'class' => 'advanced', 'elements' => array('enabled' => array('checkbox', array('label' => 'Enabled', 'required' => true, 'value' => isset($config->curry->maintenance->enabled) ? $config->curry->maintenance->enabled : '', 'description' => 'When maintenance is enabled, users will not be able to access the pages. Only a page (specified below) will be shown. If no page is specified, the message will be shown.')), 'page' => array('select', array('label' => 'Page to show', 'multiOptions' => array('' => '[ None ]') + $pages, 'value' => isset($config->curry->maintenance->page) ? $config->curry->maintenance->page : '')), 'message' => array('textarea', array('label' => 'Message', 'value' => isset($config->curry->maintenance->message) ? $config->curry->maintenance->message : '', 'rows' => 6, 'cols' => 40))))), 'maintenance'); // Mail $testEmailUrl = url('', array('module', 'view' => 'TestEmail')); $dlgOpts = array('width' => 600, 'minHeight' => 150); $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Mail', 'class' => 'advanced', 'elements' => array('method' => array('select', array('label' => 'Transport', 'multiOptions' => array('' => '[ Default ]', 'smtp' => 'SMTP', 'sendmail' => 'PHP mail() function, ie sendmail.'), 'value' => isset($config->curry->mail->method) ? $config->curry->mail->method : '')), 'host' => array('text', array('label' => 'Host', 'value' => isset($config->curry->mail->host) ? $config->curry->mail->host : '')), 'port' => array('text', array('label' => 'Port', 'value' => isset($config->curry->mail->options->port) ? $config->curry->mail->options->port : '')), 'auth' => array('select', array('label' => 'Auth', 'multiOptions' => array('' => '[ Default ]', 'plain' => 'plain', 'login' => 'login', 'cram-md5' => 'cram-md5'), 'value' => isset($config->curry->mail->options->auth) ? $config->curry->mail->options->auth : '')), 'username' => array('text', array('label' => 'Username', 'value' => isset($config->curry->mail->options->username) ? $config->curry->mail->options->username : '')), 'password' => array('password', array('label' => 'Password')), 'ssl' => array('select', array('label' => 'SSL', 'multiOptions' => array('' => 'Disabled', 'ssl' => 'SSL', 'tls' => 'TLS'), 'value' => isset($config->curry->mail->options->ssl) ? $config->curry->mail->options->ssl : '')), 'mailTest' => array('rawHtml', array('value' => '<a href="' . $testEmailUrl . '" class="btn dialog" data-dialog="' . htmlspecialchars(json_encode($dlgOpts)) . '">Test email</a>'))))), 'mail'); // Paths $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Paths', 'class' => 'advanced', 'elements' => array('basePath' => array('text', array('label' => 'Base path', 'value' => isset($config->curry->basePath) ? $config->curry->basePath : '', 'placeholder' => $defaultConfig->curry->basePath)), 'projectPath' => array('text', array('label' => 'Project Path', 'value' => isset($config->curry->projectPath) ? $config->curry->projectPath : '', 'placeholder' => $defaultConfig->curry->projectPath)), 'wwwPath' => array('text', array('label' => 'WWW path', 'value' => isset($config->curry->wwwPath) ? $config->curry->wwwPath : '', 'placeholder' => $defaultConfig->curry->wwwPath)), 'vendorPath' => array('text', array('label' => 'Vendor path', 'value' => isset($config->curry->vendorPath) ? $config->curry->vendorPath : '', 'placeholder' => $defaultConfig->curry->vendorPath))))), 'paths'); // Encoding $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Encoding', 'class' => 'advanced', 'elements' => array('internal' => array('text', array('label' => 'Internal Encoding', 'value' => isset($config->curry->internalEncoding) ? $config->curry->internalEncoding : '', 'description' => 'The internal encoding for PHP.', 'placeholder' => $defaultConfig->curry->internalEncoding)), 'output' => array('text', array('label' => 'Output Encoding', 'value' => isset($config->curry->outputEncoding) ? $config->curry->outputEncoding : '', 'description' => 'The default output encoding for pages.', 'placeholder' => $defaultConfig->curry->outputEncoding))))), 'encoding'); // Misc $form->addSubForm(new Curry_Form_SubForm(array('legend' => 'Misc', 'class' => 'advanced', 'elements' => array('error_notification' => array('checkbox', array('label' => 'Error notification', 'value' => isset($config->curry->errorNotification) ? $config->curry->errorNotification : '', 'description' => 'If enabled, an attempt to send error-logs to the admin email will be performed when an error occur.')), 'log_propel' => array('checkbox', array('label' => 'Propel Logging', 'value' => isset($config->curry->propel->logging) ? $config->curry->propel->logging : '', 'description' => 'Database queries and other debug information will be logged to the selected logging facility.')), 'debug_propel' => array('checkbox', array('label' => 'Debug Propel', 'value' => isset($config->curry->propel->debug) ? $config->curry->propel->debug : '', 'description' => 'Enables query counting but doesn\'t log queries.')), 'log' => array('select', array('label' => 'Logging', 'multiOptions' => array('' => '[ Other ]', 'none' => 'Disable logging', 'firebug' => 'Firebug'), 'value' => isset($config->curry->log->method) ? $config->curry->log->method : '')), 'update_translations' => array('checkbox', array('label' => 'Update Language strings', 'value' => isset($config->curry->updateTranslationStrings) ? $config->curry->updateTranslationStrings : '', 'description' => 'Add strings as they are used and record last used timestamp'))))), 'misc'); $form->addElement('submit', 'save', array('label' => 'Save', 'disabled' => $configFile ? null : 'disabled')); if (isPost() && $form->isValid($_POST)) { $this->saveSettings($config, $form->getValues()); } $this->addMainContent($form); }
public function loadPages() { $allPages = array('' => '----- select a page -----'); $c = new Criteria(); $c->addAscendingOrderByColumn(PagePeer::LABEL); $pages = PagePeer::doSelect($c); foreach ($pages as $p) { $allPages[$p->getId()] = $p->getLabel(); } $this->allPages = $allPages; }
/** * Adds a new Page row with specified parent Id. * * @param int $parentId */ protected function addNewChildPage($parentId) { $db = Propel::getConnection(PagePeer::DATABASE_NAME); //$db->beginTransaction(); $parent = PagePeer::retrieveByPK($parentId); $page = new Page(); $page->setTitle('new page ' . time()); $page->insertAsLastChildOf($parent); $page->save(); //$db->commit(); }
public static function getPost($iJournalEntryId, $sUserName, $sPassword) { if (!self::checkLogin($sUserName, $sPassword)) { return self::loginError(); } $oJournalEntry = JournalEntryQuery::create()->findPk($iJournalEntryId); if ($oJournalEntry === null) { return self::error("No Entry with id {$iJournalEntryId}", 2); } return $oJournalEntry->getRssAttributes(PagePeer::getRootPage()->getPageOfType('journal'), true); }
public function __construct($sSessionId) { parent::__construct($sSessionId); $iDocumentationPartCategory = 2; if (DocumentCategoryQuery::create()->filterById($iDocumentationPartCategory)->count() === 0) { throw new Exception(__METHOD__ . ': Please setup the exernally managed document category for this module'); } $this->setSetting('documentation_image_category_id', $iDocumentationPartCategory); $oRichtext = WidgetModule::getWidget('rich_text', null, null, 'documentation_part'); $oRichtext->setTemplate(PagePeer::getRootPage()->getTemplate()); $this->setSetting('richtext_session', $oRichtext->getSessionKey()); }
public function renderFile() { $this->oXmlDocument = new DOMDocument(); $this->oUrl = $this->oXmlDocument->createElement('urlset'); $this->oUrl->setAttribute('xmlns', $this->sXmlNamespace); $this->oXmlDocument->appendChild($this->oUrl); $oRootPage = PagePeer::getRootPage(); $oRootNavigationItem = PageNavigationItem::navigationItemForPage($oRootPage); $this->renderNavigationItem($oRootNavigationItem); header('Content-Type: application/xml;charset=utf-8'); print $this->oXmlDocument->saveXML(); }
public static function website_search(&$c, &$pager) { self::getSearchParams($context, $user, $request, $keys, $stype); $pager = "Page"; $c->add(PagePeer::LABEL, $keys, Criteria::LIKE); $res = PagePeer::doSelect($c); $c = new Criteria(); $c->add(PageI18nPeer::LABEL, $keys, Criteria::LIKE); $res2 = PageI18nPeer::doSelect($c); $c = new Criteria(); $c->add(TopicPeer::LABEL, $keys, Criteria::LIKE); $res3 = TopicPeer::doSelect($c); $c = new Criteria(); $c->add(TopicI18nPeer::LABEL, $keys, Criteria::LIKE); $res4 = TopicI18nPeer::doSelect($c); $c = array_merge($res, array_merge($res2, array_merge($res3, $res4))); }
public function __construct($aRequestPath, Page $oJournalPage = null, $aJournalIds = null) { if ($aRequestPath === false) { $this->oJournalPage = $oJournalPage; $this->aJournalIds = $aJournalIds; } else { parent::__construct($aRequestPath); Manager::usePath(); //the “journal” bit $this->oJournalPage = PagePeer::getRootPage()->getPageOfType('journal'); $sLanguageId = Manager::usePath(); if (LanguagePeer::languageIsActive($sLanguageId)) { Session::getSession()->setLanguage($sLanguageId); } } header("Content-Type: application/rss+xml;charset=" . Settings::getSetting('encoding', 'db', 'utf-8')); RichtextUtil::$USE_ABSOLUTE_LINKS = LinkUtil::isSSL(); }
public function pages($bIncludeVirtual = false) { $aResult = array(); $cGather = function ($aNavigationItems, $iLevel) use(&$aResult, &$cGather, $bIncludeVirtual) { foreach ($aNavigationItems as $oNavigationItem) { if (!$bIncludeVirtual && !$oNavigationItem instanceof PageNavigationItem) { continue; } $oResult = new StdClass(); $oResult->level = $iLevel; $oResult->page_id = $oNavigationItem->getId(); $oResult->name = $oNavigationItem->getName(); $aResult[] = $oResult; if ($oNavigationItem->hasChildren(null, false, true)) { $cGather($oNavigationItem->getChildren(null, false, true), $iLevel + 1); } } }; $cGather(array(PageNavigationItem::navigationItemForPage(PagePeer::getRootPage())), 0); return $aResult; }
public function renderFile() { //Prerequisites Session::getSession()->setLanguage($this->sLanguageId); //Clear index SearchIndexQuery::create()->filterByLanguageId($this->sLanguageId)->delete(); //Spider index $oRootPage = PagePeer::getRootPage(); $this->oRootNavigationItem = PageNavigationItem::navigationItemForPage($oRootPage); $this->spider($this->oRootNavigationItem); //GC gc_enable(); //Update index PreviewManager::setTemporaryManager('FrontendManager'); foreach ($this->aIndexPaths as $aPath) { $bIsIndexed = $this->index($aPath); set_time_limit(30); $this->gc(); $sMessage = $bIsIndexed ? 'Indexed' : 'Skipped'; print "{$sMessage} <code>/" . htmlentities(implode('/', $aPath)) . "</code><br>\n"; } PreviewManager::revertTemporaryManager(); }
/** {@inheritdoc} */ public function showBack() { $form = new Curry_Form_SubForm(array('elements' => array('direction' => array('select', array('label' => 'Direction', 'multiOptions' => array(self::TO_ROOT => "From page to root", self::FROM_ROOT => "From root to page"), 'value' => $this->direction)), 'root' => array('select', array('label' => 'RootPage', 'multiOptions' => PagePeer::getSelect(), 'value' => $this->rootPageId))))); return $form; }
/** * Test xxxNestedSet::makeRoot() exception * @expectedException PropelException */ public function testObjectMakeRootException() { $c = new Criteria(); $c->add(PagePeer::TITLE, 'home', Criteria::EQUAL); $home = PagePeer::doSelectOne($c); $home->makeRoot(); }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = PagePeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setName($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setHeader($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setContent($arr[$keys[3]]); } }
/** * Test xxxNestedSetPeer::createRoot() exception * @expectedException PropelException */ public function testPeerCreateRootException() { $c = new Criteria(); $c->add(PagePeer::TITLE, 'home', Criteria::EQUAL); $home = PagePeer::doSelectOne($c); PagePeer::createRoot($home); }
public function executeView(sfWebRequest $request) { $this->page = PagePeer::retrieveByName($request->getParameter('name')); $this->forward404Unless($this->page); }
/** * Deletes all descendants for the given node * Instance pooling is wiped out by this command, * so existing Page instances are probably invalid (except for the current one) * * @param PropelPDO $con Connection to use. * * @return int number of deleted nodes */ public function deleteDescendants(PropelPDO $con = null) { if ($this->isLeaf()) { // save one query return; } if ($con === null) { $con = Propel::getConnection(PagePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $left = $this->getLeftValue(); $right = $this->getRightValue(); $con->beginTransaction(); try { // delete descendant nodes (will empty the instance pool) $ret = PageQuery::create()->descendantsOf($this)->delete($con); // fill up the room that was used by descendants PagePeer::shiftRLValues($left - $right + 1, $right, null, $con); // fix the right value for the current node, which is now a leaf $this->setRightValue($left + 1); $con->commit(); } catch (Exception $e) { $con->rollback(); throw $e; } return $ret; }
/** * Method to invalidate the instance pool of all tables related to users * by a foreign key with ON DELETE CASCADE */ public static function clearRelatedInstancePool() { // Invalidate objects in UserGroupPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. UserGroupPeer::clearInstancePool(); // Invalidate objects in UserRolePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. UserRolePeer::clearInstancePool(); // Invalidate objects in PagePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. PagePeer::clearInstancePool(); // Invalidate objects in PagePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. PagePeer::clearInstancePool(); // Invalidate objects in PagePropertyPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. PagePropertyPeer::clearInstancePool(); // Invalidate objects in PagePropertyPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. PagePropertyPeer::clearInstancePool(); // Invalidate objects in PageStringPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. PageStringPeer::clearInstancePool(); // Invalidate objects in PageStringPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. PageStringPeer::clearInstancePool(); // Invalidate objects in ContentObjectPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ContentObjectPeer::clearInstancePool(); // Invalidate objects in ContentObjectPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ContentObjectPeer::clearInstancePool(); // Invalidate objects in LanguageObjectPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LanguageObjectPeer::clearInstancePool(); // Invalidate objects in LanguageObjectPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LanguageObjectPeer::clearInstancePool(); // Invalidate objects in LanguageObjectHistoryPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LanguageObjectHistoryPeer::clearInstancePool(); // Invalidate objects in LanguageObjectHistoryPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LanguageObjectHistoryPeer::clearInstancePool(); // Invalidate objects in LanguagePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LanguagePeer::clearInstancePool(); // Invalidate objects in LanguagePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LanguagePeer::clearInstancePool(); // Invalidate objects in TranslationPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. TranslationPeer::clearInstancePool(); // Invalidate objects in TranslationPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. TranslationPeer::clearInstancePool(); // Invalidate objects in UserGroupPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. UserGroupPeer::clearInstancePool(); // Invalidate objects in UserGroupPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. UserGroupPeer::clearInstancePool(); // Invalidate objects in GroupPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. GroupPeer::clearInstancePool(); // Invalidate objects in GroupPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. GroupPeer::clearInstancePool(); // Invalidate objects in GroupRolePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. GroupRolePeer::clearInstancePool(); // Invalidate objects in GroupRolePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. GroupRolePeer::clearInstancePool(); // Invalidate objects in RolePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. RolePeer::clearInstancePool(); // Invalidate objects in RolePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. RolePeer::clearInstancePool(); // Invalidate objects in UserRolePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. UserRolePeer::clearInstancePool(); // Invalidate objects in UserRolePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. UserRolePeer::clearInstancePool(); // Invalidate objects in RightPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. RightPeer::clearInstancePool(); // Invalidate objects in RightPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. RightPeer::clearInstancePool(); // Invalidate objects in DocumentPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. DocumentPeer::clearInstancePool(); // Invalidate objects in DocumentPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. DocumentPeer::clearInstancePool(); // Invalidate objects in DocumentDataPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. DocumentDataPeer::clearInstancePool(); // Invalidate objects in DocumentDataPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. DocumentDataPeer::clearInstancePool(); // Invalidate objects in DocumentTypePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. DocumentTypePeer::clearInstancePool(); // Invalidate objects in DocumentTypePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. DocumentTypePeer::clearInstancePool(); // Invalidate objects in DocumentCategoryPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. DocumentCategoryPeer::clearInstancePool(); // Invalidate objects in DocumentCategoryPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. DocumentCategoryPeer::clearInstancePool(); // Invalidate objects in TagPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. TagPeer::clearInstancePool(); // Invalidate objects in TagPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. TagPeer::clearInstancePool(); // Invalidate objects in TagInstancePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. TagInstancePeer::clearInstancePool(); // Invalidate objects in TagInstancePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. TagInstancePeer::clearInstancePool(); // Invalidate objects in LinkPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LinkPeer::clearInstancePool(); // Invalidate objects in LinkPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LinkPeer::clearInstancePool(); // Invalidate objects in LinkCategoryPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LinkCategoryPeer::clearInstancePool(); // Invalidate objects in LinkCategoryPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LinkCategoryPeer::clearInstancePool(); // Invalidate objects in ReferencePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ReferencePeer::clearInstancePool(); // Invalidate objects in ReferencePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ReferencePeer::clearInstancePool(); }
/** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. * * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * * @return Page A model object, or null if the key is not found * @throws PropelException */ protected function findPkSimple($key, $con) { $sql = 'SELECT `id`, `name`, `identifier`, `page_type`, `template_name`, `is_inactive`, `is_folder`, `is_hidden`, `is_protected`, `canonical_id`, `tree_left`, `tree_right`, `tree_level`, `created_at`, `updated_at`, `created_by`, `updated_by` FROM `pages` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); } $obj = null; if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $obj = new Page(); $obj->hydrate($row); PagePeer::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); return $obj; }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = PagePeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setLabel($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setPageType($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setNavigationTitle($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setMetaDescription($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setMetaKeywords($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setImage($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setTemplate($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setContent($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setPageId($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setUrl($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setDescription($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setIsSecure($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setCreatedAt($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { $this->setUpdatedAt($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { $this->setPublicationStatus($arr[$keys[15]]); } }
/** * Selects a collection of ContentObject objects pre-filled with all related objects except UserRelatedByUpdatedBy. * * @param Criteria $criteria * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of ContentObject objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptUserRelatedByUpdatedBy(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden // $criteria->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(ContentObjectPeer::DATABASE_NAME); } ContentObjectPeer::addSelectColumns($criteria); $startcol2 = ContentObjectPeer::NUM_HYDRATE_COLUMNS; PagePeer::addSelectColumns($criteria); $startcol3 = $startcol2 + PagePeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(ContentObjectPeer::PAGE_ID, PagePeer::ID, $join_behavior); $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = ContentObjectPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = ContentObjectPeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $cls = ContentObjectPeer::getOMClass(); $obj1 = new $cls(); $obj1->hydrate($row); ContentObjectPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Page rows $key2 = PagePeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = PagePeer::getInstanceFromPool($key2); if (!$obj2) { $cls = PagePeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); PagePeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (ContentObject) to the collection in $obj2 (Page) $obj2->addContentObject($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Initializes multiOptions. */ public function init() { $this->setMultiOptions(array('' => '[ None ]') + PagePeer::getSelect()); }
public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(PagePeer::ID, $pks, Criteria::IN); $objs = PagePeer::doSelect($criteria, $con); } return $objs; }
function getChildren() { $c = new Criteria(); return PagePeer::doSelect($c->add(PagePeer::PARENT_ID, $this->id)); }
/** * Show metadata form. */ public function showPageMetadata() { $ses = new \Zend\Session\Container(__CLASS__); $ses->pageView = 'PageMetadata'; $page = self::getPage(PageAccessPeer::PERM_META); $pageRevision = $page->getPageRevision(); $form = Curry_Backend_PageHelper::getMetadataForm($pageRevision); if (isPost('pid_metadata') && $form->isValid($_POST)) { Curry_Backend_PageHelper::savePageMetadata($pageRevision, $form->getValues()); $form = Curry_Backend_PageHelper::getMetadataForm($pageRevision); PagePeer::changePage(); $this->addMessage('Page metadata was saved.', self::MSG_SUCCESS); } $this->addPageMenu($page); $this->addMainContent($form); if (self::getPagePermission(PageQuery::create()->findRoot(), PageAccessPeer::PERM_META)) { $url = url('', array('module', 'view' => 'NewMetadata')); $this->addDialogCommand('Add new field', $url, 'icon-plus'); } $url = url('', array('module' => 'Curry_Backend_Database', 'view' => 'Table', 'table' => 'Metadata')); $this->addCommand('Edit fields', $url, 'icon-table'); }