public function setSelectBoxes($scope) { $parents = sfBreadNavPeer::getParentArray($scope); $order = sfBreadNavPeer::getOrderArray($scope); $orderoption = array('above' => 'above', 'below' => 'below'); $this->setWidgetSchema(new sfWidgetFormSchema(array('id' => new sfWidgetFormInputHidden(), 'page' => new sfWidgetFormInput(), 'module' => new sfWidgetFormInput(), 'action' => new sfWidgetFormInput(), 'credential' => new sfWidgetFormInput(), 'catch_all' => new sfWidgetFormInputCheckbox(), 'parent' => new sfWidgetFormSelect(array('choices' => $parents)), 'order' => new sfWidgetFormSelect(array('choices' => $order)), 'order_option' => new sfWidgetFormSelectRadio(array('choices' => $orderoption))))); $this->widgetSchema->setNameFormat('sfbreadnavaddpageform[%s]'); }
public function executeDelete($request) { if (sfBreadNavPeer::scopeowner($request->getParameter('id'))) { $this->forward404Unless($sf_bread_nav_application = sfBreadNavApplicationPeer::retrieveByPk($request->getParameter('id'))); $sf_bread_nav_application->delete(); $this->redirect('sfBreadNavAdmin/list'); } else { $this->setTemplate('breadnav'); $this->message = "You need to be logged in to delete a menu."; return sfView::ERROR; } }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(sfBreadNavPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(sfBreadNavPeer::DATABASE_NAME); $criteria->add(sfBreadNavPeer::ID, $pks, Criteria::IN); $objs = sfBreadNavPeer::doSelect($criteria, $con); } return $objs; }
public static function pageowner($pageid) { //if config set to ownermenu only show users menus if (sfConfig::get('app_sfBreadNav_UserMenus', false)) { $c = new Criteria(); $c->add(sfBreadNavPeer::ID, $pageid); $c->add(sfBreadNavApplicationPeer::USER_ID, sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'sfGuardSecurityUser')); $result = sfBreadNavPeer::doCountJoinsfBreadNavApplication($c); if ($result > 0) { return true; } else { return false; } } else { return true; } }
/** * Returns the number of related sfBreadNav objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related sfBreadNav objects. * @throws PropelException */ public function countsfBreadNavs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(sfBreadNavApplicationPeer::DATABASE_NAME); } else { $criteria = clone $criteria; } if ($distinct) { $criteria->setDistinct(); } $count = null; if ($this->collsfBreadNavs === null) { if ($this->isNew()) { $count = 0; } else { $criteria->add(sfBreadNavPeer::SCOPE, $this->id); $count = sfBreadNavPeer::doCount($criteria, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return count of the collection. $criteria->add(sfBreadNavPeer::SCOPE, $this->id); if (!isset($this->lastsfBreadNavCriteria) || !$this->lastsfBreadNavCriteria->equals($criteria)) { $count = sfBreadNavPeer::doCount($criteria, $con); } else { $count = count($this->collsfBreadNavs); } } else { $count = count($this->collsfBreadNavs); } } return $count; }
/** * Reload all already loaded nodes to sync them with updated db * * @param sfBreadNav $node Propel object for parent node * @param int $delta Value to be shifted by, can be negative * @param PropelPDO $con Connection to use. */ protected static function updateLoadedNode(NodeObject $node, $delta, PropelPDO $con = null) { if (Propel::isInstancePoolingEnabled()) { $keys = array(); foreach (self::$instances as $obj) { $keys[] = $obj->getPrimaryKey(); } if (!empty($keys)) { // We don't need to alter the object instance pool; we're just modifying these ones // already in the pool. $criteria = new Criteria(self::DATABASE_NAME); $criteria->add(sfBreadNavPeer::ID, $keys, Criteria::IN); $stmt = sfBreadNavPeer::doSelectStmt($criteria, $con); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key = sfBreadNavPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($object = sfBreadNavPeer::getInstanceFromPool($key))) { $object->setLeftValue($row[7]); $object->setRightValue($row[8]); } } $stmt->closeCursor(); } } }
<?php $c = navbarfunctions::getCredentialCriteria($credArray, $credRoles); $c->addAscendingOrderByColumn(sfBreadNavPeer::TREE_LEFT); $c->add(sfBreadNavApplicationPeer::NAME, $menu); $c->addJoin(sfBreadNavPeer::SCOPE, sfBreadNavApplicationPeer::ID); $pages = sfBreadNavPeer::doSelect($c); $pages = navbarfunctions::compressNavArray($pages); $outputArray = array(); $root = sfBreadNavPeer::getMenuRoot($menu); //return if no root if (!$root) { return; } $newlevel = true; echo '<ul id="navmenu">'; if (in_array($root->getCredential(), (array) $credArray)) { echo "<li>" . navbardisplayfunctions::link_to_valid($root->getPage(), $root->getModule(), $root->getAction(), array('class' => 'first top')) . "</li>\n"; } $nexttop = 0; for ($i = 0; $i < count($pages); $i++) { if ($i == $nexttop) { $havechildren = navbarfunctions::testforchildren($pages, $i); $nexttop = ($pages[$i]['tree_right'] + 1) / 2 - 1; if ($havechildren) { $open = '<li><a href="' . navbardisplayfunctions::url_for_valid(navbarfunctions::pageroute($pages[$i]['module'], $pages[$i]['action'])) . '">' . $pages[$i]['page'] . '</a><ul>'; $close = '</ul></li>'; } else { $open = '<li><a href="' . navbardisplayfunctions::url_for_valid(navbarfunctions::pageroute($pages[$i]['module'], $pages[$i]['action'])) . '">' . $pages[$i]['page'] . '</a>'; $close = '</li>'; }
{ function __construct($m) { parent::__construct($m, self::SELF_FIRST); } function beginChildren() { echo str_repeat("\t", $this->getDepth()); } function endChildren() { echo str_repeat("\t", $this->getDepth() - 1); } } $root = sfBreadNavPeer::getRoot($scope); $menu = sfBreadNavPeer::retrieveTree($scope); $menu = new myMenuOutput($menu); function bool2string($bool) { if (!is_null($bool)) { return 'On'; } return ' '; } ?> <br/> <table style='border-spacing: 0px 0px; border-style: none; border-collapse: collapse;' id="breadnavtreetable"> <tr class='odd'><strong><td>PAGE NAME</td><td>MODULE</td><td>ACTION</td><td>CREDENTIAL</td><td>CATCH ALL</td></strong></tr> <tr class='even'> <td><a href="<?php
/** * 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 = sfBreadNavPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setPage($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setTitle($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setModule($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setAction($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setCredential($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setCatchall($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setTreeLeft($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setTreeRight($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setTreeParent($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setScope($arr[$keys[10]]); } }
<?php class myMenuOutput extends RecursiveIteratorIterator { function __construct(sfBreadNav $m) { parent::__construct($m, self::SELF_FIRST); } function beginChildren() { echo str_repeat("\t", $this->getDepth()); } function endChildren() { echo str_repeat("\t", $this->getDepth() - 1); } } $menu = sfBreadNavPeer::retrieveTree(1); $it = new myMenuOutput($menu); foreach ($it as $m) { echo $m->getPage(), '[', $m->getLeftValue(), '-', $m->getRightValue(), "]\n", $m->getLevel(), "<br>"; }
/** * Inserts node as parent of given node. * * @param sfBreadNav $node Propel object for destination node * @param PropelPDO $con Connection to use. * @return sfBreadNav The current object (for fluent API support) */ public function insertAsParentOf(NodeObject $node, PropelPDO $con = null) { sfBreadNavPeer::insertAsParentOf($this, $node, $con); return $this; }
/** * This is a method for emulating ON DELETE CASCADE for DBs that don't support this * feature (like MySQL or SQLite). * * This method is not very speedy because it must perform a query first to get * the implicated records and then perform the deletes by calling those Peer classes. * * This method should be used within a transaction if possible. * * @param Criteria $criteria * @param PropelPDO $con * @return int The number of affected rows (if supported by underlying database driver). */ protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con) { // initialize var to track total num of affected rows $affectedRows = 0; // first find the objects that are implicated by the $criteria $objects = sfBreadNavApplicationPeer::doSelect($criteria, $con); foreach ($objects as $obj) { // delete related sfBreadNav objects $c = new Criteria(sfBreadNavPeer::DATABASE_NAME); $c->add(sfBreadNavPeer::SCOPE, $obj->getId()); $affectedRows += sfBreadNavPeer::doDelete($c, $con); } return $affectedRows; }