Changeset 9438
- Timestamp:
- Dec 1, 2008, 5:20:13 AM (12 years ago)
- Location:
- OpenPNE3/plugins/opPluginsChannelPlugin/trunk/lib
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE3/plugins/opPluginsChannelPlugin/trunk/lib/form/base/BaseopPluginChannelPackageForm.class.php
r9279 r9438 14 14 { 15 15 $this->setWidgets(array( 16 'id' => new sfWidgetFormInputHidden(),17 'name' => new sfWidgetFormInput(),18 'license' => new sfWidgetFormTextarea(),19 'summary' => new sfWidgetFormTextarea(),20 'descript on' => new sfWidgetFormTextarea(),16 'id' => new sfWidgetFormInputHidden(), 17 'name' => new sfWidgetFormInput(), 18 'license' => new sfWidgetFormTextarea(), 19 'summary' => new sfWidgetFormTextarea(), 20 'description' => new sfWidgetFormTextarea(), 21 21 )); 22 22 23 23 $this->setValidators(array( 24 'id' => new sfValidatorPropelChoice(array('model' => 'opPluginChannelPackage', 'column' => 'id', 'required' => false)),25 'name' => new sfValidatorString(array('max_length' => 64)),26 'license' => new sfValidatorString(array('required' => false)),27 'summary' => new sfValidatorString(array('required' => false)),28 'descript on' => new sfValidatorString(array('required' => false)),24 'id' => new sfValidatorPropelChoice(array('model' => 'opPluginChannelPackage', 'column' => 'id', 'required' => false)), 25 'name' => new sfValidatorString(array('max_length' => 64)), 26 'license' => new sfValidatorString(array('required' => false)), 27 'summary' => new sfValidatorString(array('required' => false)), 28 'description' => new sfValidatorString(array('required' => false)), 29 29 )); 30 30 -
OpenPNE3/plugins/opPluginsChannelPlugin/trunk/lib/form/opPluginChannelPackageForm.class.php
r9279 r9438 4 4 * opPluginChannelPackage form. 5 5 * 6 * @package ##PROJECT_NAME##6 * @package OpenPNE 7 7 * @subpackage form 8 * @author ##AUTHOR_NAME## 9 * @version SVN: $Id: sfPropelFormTemplate.php 10377 2008-07-21 07:10:32Z dwhittle $ 8 * @author Kousuke Ebihara <ebihara@tejimaya.com> 10 9 */ 11 10 class opPluginChannelPackageForm extends BaseopPluginChannelPackageForm -
OpenPNE3/plugins/opPluginsChannelPlugin/trunk/lib/form/opPluginChannelReleaseForm.class.php
r9279 r9438 4 4 * opPluginChannelRelease form. 5 5 * 6 * @package ##PROJECT_NAME##6 * @package OpenPNE 7 7 * @subpackage form 8 * @author ##AUTHOR_NAME## 9 * @version SVN: $Id: sfPropelFormTemplate.php 10377 2008-07-21 07:10:32Z dwhittle $ 8 * @author Kousuke Ebihara <ebihara@tejimaya.com> 10 9 */ 11 10 class opPluginChannelReleaseForm extends BaseopPluginChannelReleaseForm … … 13 12 public function configure() 14 13 { 14 $this->widgetSchema['package_id'] = new sfWidgetFormInputHidden(); 15 $this->widgetSchema['manager_id'] = new sfWidgetFormInputHidden(); 16 $this->widgetSchema['created_at'] = new sfWidgetFormInputHidden(); 17 $this->widgetSchema['updated_at'] = new sfWidgetFormInputHidden(); 18 19 $this->widgetSchema['stability'] = new sfWidgetFormSelect(array('choices' => opPluginChannelRelease::$stabilityList)); 20 21 $this->widgetSchema['file'] = new sfWidgetFormInputFile(); 22 $validatorFileOptions = array(); 23 if (!$this->isNew()) 24 { 25 $validatorFileOptions['required'] = false; 26 } 27 $this->validatorSchema['file'] = new sfValidatorFile($validatorFileOptions); 28 29 unset($this['file_id']); 30 31 $this->setDefaults($this->getOption('defaults')); 32 } 33 34 public function updateObject() 35 { 36 $object = parent::updateObject(); 37 38 $input = $this->getValue('file'); 39 if (!$input) 40 { 41 return $object; 42 } 43 44 $file = new File(); 45 $file->setName(time()); 46 $file->setOriginalFilename($input->getOriginalName()); 47 $file->setBin(file_get_contents($input->getTempName())); 48 $file->setType($input->getType()); 49 50 $object->setFile($file); 51 52 return $object; 15 53 } 16 54 } -
OpenPNE3/plugins/opPluginsChannelPlugin/trunk/lib/model/map/opPluginChannelPackageMapBuilder.php
r9279 r9438 42 42 $tMap->addColumn('SUMMARY', 'Summary', 'LONGVARCHAR', false, null); 43 43 44 $tMap->addColumn('DESCRIPT ON', 'Descripton', 'LONGVARCHAR', false, null);44 $tMap->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null); 45 45 46 46 } -
OpenPNE3/plugins/opPluginsChannelPlugin/trunk/lib/model/om/BaseopPluginChannelPackage.php
r9279 r9438 23 23 24 24 25 protected $descript on;25 protected $description; 26 26 27 27 … … 80 80 81 81 82 public function getDescript on()83 { 84 return $this->descript on;82 public function getDescription() 83 { 84 return $this->description; 85 85 } 86 86 … … 142 142 } 143 143 144 public function setDescript on($v)144 public function setDescription($v) 145 145 { 146 146 if ($v !== null) { … … 148 148 } 149 149 150 if ($this->descript on !== $v) {151 $this->descript on = $v;152 $this->modifiedColumns[] = opPluginChannelPackagePeer::DESCRIPT ON;150 if ($this->description !== $v) { 151 $this->description = $v; 152 $this->modifiedColumns[] = opPluginChannelPackagePeer::DESCRIPTION; 153 153 } 154 154 … … 173 173 $this->license = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; 174 174 $this->summary = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; 175 $this->descript on = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;175 $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; 176 176 $this->resetModified(); 177 177 … … 398 398 break; 399 399 case 4: 400 return $this->getDescript on();400 return $this->getDescription(); 401 401 break; 402 402 default: … … 414 414 $keys[2] => $this->getLicense(), 415 415 $keys[3] => $this->getSummary(), 416 $keys[4] => $this->getDescript on(),416 $keys[4] => $this->getDescription(), 417 417 ); 418 418 return $result; … … 443 443 break; 444 444 case 4: 445 $this->setDescript on($value);445 $this->setDescription($value); 446 446 break; 447 447 } } … … 456 456 if (array_key_exists($keys[2], $arr)) $this->setLicense($arr[$keys[2]]); 457 457 if (array_key_exists($keys[3], $arr)) $this->setSummary($arr[$keys[3]]); 458 if (array_key_exists($keys[4], $arr)) $this->setDescript on($arr[$keys[4]]);458 if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]); 459 459 } 460 460 … … 468 468 if ($this->isColumnModified(opPluginChannelPackagePeer::LICENSE)) $criteria->add(opPluginChannelPackagePeer::LICENSE, $this->license); 469 469 if ($this->isColumnModified(opPluginChannelPackagePeer::SUMMARY)) $criteria->add(opPluginChannelPackagePeer::SUMMARY, $this->summary); 470 if ($this->isColumnModified(opPluginChannelPackagePeer::DESCRIPT ON)) $criteria->add(opPluginChannelPackagePeer::DESCRIPTON, $this->descripton);470 if ($this->isColumnModified(opPluginChannelPackagePeer::DESCRIPTION)) $criteria->add(opPluginChannelPackagePeer::DESCRIPTION, $this->description); 471 471 472 472 return $criteria; … … 505 505 $copyObj->setSummary($this->summary); 506 506 507 $copyObj->setDescript on($this->descripton);507 $copyObj->setDescription($this->description); 508 508 509 509 -
OpenPNE3/plugins/opPluginsChannelPlugin/trunk/lib/model/om/BaseopPluginChannelPackagePeer.php
r9279 r9438 32 32 33 33 34 const DESCRIPT ON = 'op_plugin_channel_package.DESCRIPTON';34 const DESCRIPTION = 'op_plugin_channel_package.DESCRIPTION'; 35 35 36 36 … … 42 42 43 43 private static $fieldNames = array ( 44 BasePeer::TYPE_PHPNAME => array ('Id', 'Name', 'License', 'Summary', 'Descript on', ),45 BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'name', 'license', 'summary', 'descript on', ),46 BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::LICENSE, self::SUMMARY, self::DESCRIPT ON, ),47 BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'license', 'summary', 'descript on', ),44 BasePeer::TYPE_PHPNAME => array ('Id', 'Name', 'License', 'Summary', 'Description', ), 45 BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'name', 'license', 'summary', 'description', ), 46 BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::LICENSE, self::SUMMARY, self::DESCRIPTION, ), 47 BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'license', 'summary', 'description', ), 48 48 BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) 49 49 ); … … 51 51 52 52 private static $fieldKeys = array ( 53 BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'License' => 2, 'Summary' => 3, 'Descript on' => 4, ),54 BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'name' => 1, 'license' => 2, 'summary' => 3, 'descript on' => 4, ),55 BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::LICENSE => 2, self::SUMMARY => 3, self::DESCRIPT ON => 4, ),56 BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'license' => 2, 'summary' => 3, 'descript on' => 4, ),53 BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'License' => 2, 'Summary' => 3, 'Description' => 4, ), 54 BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'name' => 1, 'license' => 2, 'summary' => 3, 'description' => 4, ), 55 BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::LICENSE => 2, self::SUMMARY => 3, self::DESCRIPTION => 4, ), 56 BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'license' => 2, 'summary' => 3, 'description' => 4, ), 57 57 BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) 58 58 ); … … 105 105 $criteria->addSelectColumn(opPluginChannelPackagePeer::SUMMARY); 106 106 107 $criteria->addSelectColumn(opPluginChannelPackagePeer::DESCRIPT ON);107 $criteria->addSelectColumn(opPluginChannelPackagePeer::DESCRIPTION); 108 108 109 109 } -
OpenPNE3/plugins/opPluginsChannelPlugin/trunk/lib/model/opPluginChannelPackage.php
r9279 r9438 3 3 class opPluginChannelPackage extends BaseopPluginChannelPackage 4 4 { 5 public function save(PropelPDO $con = null) 6 { 7 $user = sfContext::getInstance()->getUser(); 8 9 if ($this->isNew()) 10 { 11 $maintainer = new opPluginChannelMaintainer(); 12 $maintainer->setMember($user->getMember()); 13 $maintainer->setIsActive(true); 14 $this->addopPluginChannelMaintainer($maintainer); 15 } 16 17 if (!$this->isBelong()) 18 { 19 throw new opPrivilegeException('You don\'t have permission to access this data.'); 20 } 21 22 return parent::save($con); 23 } 24 25 public function isBelong() 26 { 27 $user = sfContext::getInstance()->getUser(); 28 $c = new Criteria(); 29 $c->add(opPluginChannelMaintainerPeer::MEMBER_ID, $user->getMember()->getId()); 30 return (bool)$this->getopPluginChannelMaintainers($c); 31 } 32 33 public function getReleaseByVersion($version) 34 { 35 $c = new Criteria(); 36 $c->add(opPluginChannelReleasePeer::NAME, $version); 37 $releases = $this->getOpPluginChannelReleases($c); 38 39 return array_shift($releases); 40 } 41 42 public function getVersionByStability($stability) 43 { 44 $c = new Criteria(); 45 46 if ($stability !== 'latest') 47 { 48 $stableIndex = array_search($stability, opPluginChannelRelease::$stabilityList); 49 $c->add(opPluginChannelReleasePeer::STABILITY, $stableIndex); 50 } 51 52 $releases = $this->getOpPluginChannelReleases($c); 53 if (!$releases) 54 { 55 return false; 56 } 57 58 $versions = $this->createVersionList($releases); 59 return array_pop($versions); 60 } 61 62 public function createVersionList($releases) 63 { 64 $versions = array(); 65 66 foreach ($releases as $release) 67 { 68 $versions[] = $release->getName(); 69 } 70 usort($versions, 'version_compare'); 71 72 return $versions; 73 } 5 74 } -
OpenPNE3/plugins/opPluginsChannelPlugin/trunk/lib/model/opPluginChannelPackagePeer.php
r9279 r9438 3 3 class opPluginChannelPackagePeer extends BaseopPluginChannelPackagePeer 4 4 { 5 public static function retrievesAll() 6 { 7 return self::doSelect(new Criteria()); 8 } 9 10 public static function retrieveByName($name) 11 { 12 $c = new Criteria(); 13 $c->add(self::NAME, $name); 14 return self::doSelectOne($c); 15 } 5 16 } -
OpenPNE3/plugins/opPluginsChannelPlugin/trunk/lib/model/opPluginChannelRelease.php
r9279 r9438 3 3 class opPluginChannelRelease extends BaseopPluginChannelRelease 4 4 { 5 public static $stabilityList = array( 6 'stable', 7 'beta', 8 'alpha', 9 'devel', 10 ); 11 12 public function isBelong() 13 { 14 $user = sfContext::getInstance()->getUser(); 15 $c = new Criteria(); 16 $c->add(opPluginChannelMaintainerPeer::MEMBER_ID, $user->getMember()->getId()); 17 return (bool)$this->getOpPluginChannelPackage()->getOpPluginChannelMaintainers($c); 18 } 19 20 public function getStability() 21 { 22 $stabilityIndex = parent::getStability(); 23 if (isset(self::$stabilityList[$stabilityIndex])) 24 { 25 return self::$stabilityList[$stabilityIndex]; 26 } 27 28 return null; 29 } 5 30 }
Note: See TracChangeset
for help on using the changeset viewer.