本文整理汇总了PHP中opToolkit类的典型用法代码示例。如果您正苦于以下问题:PHP opToolkit类的具体用法?PHP opToolkit怎么用?PHP opToolkit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了opToolkit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$path = $this->options['dir'] . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR . $this->options['name'] . '.sql';
if (!file_exists($path)) {
throw new RuntimeException('The specified sql doesn\'t exist.');
}
$db = $this->getDatabaseManager()->getDatabase('doctrine');
$this->conn = $db->getDoctrineConnection();
$this->conn->beginTransaction();
$this->conn->execute('SET FOREIGN_KEY_CHECKS = 0');
// for mysql
$sql = opToolkit::unifyEOLCharacter($this->parseSql($path));
$queries = explode("\n", $sql);
try {
$this->executeQueries($queries);
$this->conn->commit();
} catch (Exception $e) {
$this->conn->rollback();
$this->conn->execute('SET FOREIGN_KEY_CHECKS = 0');
// for mysql
throw $e;
}
$this->conn->execute('SET FOREIGN_KEY_CHECKS = 0');
// for mysql
}
示例2: sendMail
public function sendMail()
{
$token = md5(opToolkit::generatePasswordString());
$this->member->setConfig('password_recovery_token', $token);
$params = array('token' => $token, 'id' => $this->member->id, 'subject' => '【' . opConfig::get('sns_name') . '】パスワード再設定用URL発行のお知らせ');
sfOpenPNEMailSend::sendTemplateMail('passwordRecovery', $this->member->getEMailAddress(), opConfig::get('admin_mail_address'), $params);
}
示例3: save
public function save()
{
parent::save();
$emailAddress = $this->member->getEmailAddress();
$params = array('mailAddress' => $emailAddress, 'newPassword' => $this->plainPassword, 'isMobile' => opToolkit::isMobileEmailAddress($emailAddress));
$this->sendConfirmMail($emailAddress, $params);
}
示例4: sendDailyNews
private function sendDailyNews($app)
{
$isAppMobile = 'mobile_frontend' === $app;
$dailyNewsName = $isAppMobile ? 'mobileDailyNews' : 'dailyNews';
$context = sfContext::createInstance($this->createConfiguration($app, 'prod'), $app);
$gadgets = Doctrine::getTable('Gadget')->retrieveGadgetsByTypesName($dailyNewsName);
$gadgets = $gadgets[$dailyNewsName . 'Contents'];
$targetMembers = Doctrine::getTable('Member')->findAll();
foreach ($targetMembers as $member) {
$address = $member->getEmailAddress();
if ($isAppMobile !== opToolkit::isMobileEmailAddress($address)) {
continue;
}
$dailyNewsConfig = $member->getConfig('daily_news');
if (null !== $dailyNewsConfig && 0 === (int) $dailyNewsConfig) {
continue;
}
if (1 === (int) $dailyNewsConfig && !$this->isDailyNewsDay()) {
continue;
}
$filteredGadgets = array();
if ($gadgets) {
foreach ($gadgets as $gadget) {
if ($gadget->isEnabled($member)) {
$filteredGadgets[] = array('component' => array('module' => $gadget->getComponentModule(), 'action' => $gadget->getComponentAction()), 'gadget' => $gadget, 'member' => $member);
}
}
}
$params = array('member' => $member, 'gadgets' => $filteredGadgets, 'subject' => $context->getI18N()->__('デイリーニュース'), 'today' => time());
opMailSend::sendTemplateMail('dailyNews', $address, opConfig::get('admin_mail_address'), $params, $context);
}
}
示例5: execute
protected function execute($arguments = array(), $options = array())
{
parent::execute($arguments, $options);
sfContext::createInstance($this->createConfiguration('pc_frontend', 'prod'), 'pc_frontend');
$pcGadgets = Doctrine::getTable('Gadget')->retrieveGadgetsByTypesName('dailyNews');
$mobileGadgets = Doctrine::getTable('Gadget')->retrieveGadgetsByTypesName('mobileDailyNews');
$targetMembers = Doctrine::getTable('Member')->findAll();
foreach ($targetMembers as $member) {
if (!$member->getConfig('daily_news')) {
continue;
}
if (1 == $member->getConfig('daily_news') && !$this->isDailyNewsDay()) {
continue;
}
$address = $member->getEmailAddress();
$gadgets = $pcGadgets['dailyNewsContents'];
if (opToolkit::isMobileEmailAddress($address)) {
$gadgets = $mobileGadgets['mobileDailyNewsContents'];
}
$filteredGadgets = array();
if ($gadgets) {
foreach ($gadgets as $gadget) {
if ($gadget->isEnabled()) {
$filteredGadgets[] = array('component' => array('module' => $gadget->getComponentModule(), 'action' => $gadget->getComponentAction()), 'gadget' => $gadget, 'member' => $member);
}
}
}
$context = $this->getContextByEmailAddress($address);
$params = array('member' => $member, 'gadgets' => $filteredGadgets, 'subject' => $context->getI18N()->__('デイリーニュース'), 'today' => time());
opMailSend::sendTemplateMail('dailyNews', $address, opConfig::get('admin_mail_address'), $params, $context);
}
}
示例6: execute
protected function execute($arguments = array(), $options = array())
{
if (!isset($options['origin'])) {
$options['origin'] = '2.12';
}
if (!in_array($options['origin'], array('2.12', '2.14', '3.4'))) {
throw new RuntimeException('You must specify "2.12", "2.14" or "3.4" to the --origin option. (--origin オプションには 2.12、 2.14 または 3.4 を指定してください。)');
}
sfConfig::set('op_upgrade2_version', $options['origin']);
$op2config = sfConfig::get('sf_config_dir') . DIRECTORY_SEPARATOR . 'config.OpenPNE2.php';
if (!is_readable($op2config)) {
throw new RuntimeException('You must copy the config.php in your OpenPNE2 as config/config.OpenPNE2.php. (お使いの OpenPNE2 の config.php を config/config.OpenPNE2.php としてコピーしてください。)');
}
if (!defined('OPENPNE_DIR')) {
define('OPENPNE_DIR', sfConfig::get('sf_root_dir'));
}
require_once $op2config;
$this->runTask('configure:database', array(opToolkit::createStringDsnFromArray($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']), $GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['username'], empty($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['password']) ? null : $GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['password']));
$path = sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'upgrade' . DIRECTORY_SEPARATOR . '2';
$upgrader = new opUpgrader($this->dispatcher, $this->formatter, $path, $this->configuration);
if ($options['rules']) {
$upgrader->setOption('targets', $options['rules']);
}
if ('3.4' === $options['origin']) {
$upgrader->setDefinitionName('definition-34to36.yml');
}
$this->logSection('upgrade', 'Begin upgrading from 2.x');
$upgrader->execute();
$task = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter);
$task->run(array(), array());
}
示例7: configure
/**
* @see sfValidatorRegex
*/
protected function configure($options = array(), $messages = array())
{
parent::configure($options, $messages);
$filter = create_function('$value', 'return preg_quote($value, \'/\');');
$str = join('|', array_filter(opToolkit::getMobileMailAddressDomains(), $filter));
$this->setOption('pattern', '/^([^@\\s]+)@(' . $str . ')$/i');
}
示例8: save
public function save()
{
foreach ($this->getValues() as $k => $v) {
opSkinClassicConfig::set($k, $v);
}
opToolkit::clearCache();
}
示例9: sendTemplateMail
public static function sendTemplateMail($template, $to, $from, $params = array(), $context = null)
{
if (!$to) {
return false;
}
if (empty($params['target'])) {
$target = opToolkit::isMobileEmailAddress($to) ? 'mobile' : 'pc';
} else {
$target = $params['target'];
}
if (in_array($target . '_' . $template, Doctrine::getTable('NotificationMail')->getDisabledNotificationNames())) {
return false;
}
if (null === $context) {
$context = sfContext::getInstance();
}
$body = self::getMailTemplate($template, $target, $params, false, $context);
$signature = self::getMailTemplate('signature', $target, array(), true, $context);
if ($signature) {
$signature = "\n" . $signature;
}
$subject = $params['subject'];
$notificationMail = Doctrine::getTable('NotificationMail')->fetchTemplate($target . '_' . $template);
if ($notificationMail instanceof NotificationMail && $notificationMail->getTitle()) {
$subject = $notificationMail->getTitle();
$templateStorage = new sfTemplateStorageString($subject);
$renderer = new opTemplateRendererTwig();
$params['sf_type'] = null;
$parameterHolder = new sfViewParameterHolder($context->getEventDispatcher(), $params);
$subject = $renderer->evaluate($templateStorage, $parameterHolder->toArray());
$notificationMail->free(true);
}
return self::execute($subject, $to, $from, $body . $signature);
}
示例10: doClean
/**
* @see sfValidatorString
*/
protected function doClean($value)
{
$clean = parent::doClean($value);
if (opToolkit::isMobileEmailAddress($clean)) {
throw new sfValidatorError($this, 'invalid', array('value' => $value));
}
return $clean;
}
示例11: getPresetConfig
public function getPresetConfig()
{
$list = opToolkit::getPresetProfileList();
if (!empty($list[$this->getRawPresetName()])) {
return $list[$this->getRawPresetName()];
}
return array();
}
示例12: executeRequestRegisterURL
public function executeRequestRegisterURL($request)
{
$adapter = new opAuthAdapterMailAddress('MailAddress');
if ($adapter->getAuthConfig('invite_mode') < 2) {
$this->forward404();
}
$this->forward404Unless(opToolkit::isEnabledRegistration());
return sfView::INPUT;
}
示例13: getRandom
protected function getRandom($length)
{
if (is_callable(array('opToolkit', 'getRandom'))) {
// for OpenPNE3.6 <=
return opToolkit::getRandom($length);
}
mt_srand();
return substr(md5(mt_rand()), 0, $length);
}
示例14:
public function &getAll($isStripNullbyte = true)
{
if ($isStripNullbyte) {
$value = opToolkit::stripNullByteDeep(parent::getAll());
} else {
$value =& parent::getAll();
}
return $value;
}
示例15: getPackageInfo
protected function getPackageInfo()
{
$xmlPath = sfConfig::get('sf_plugins_dir') . '/' . $this->getName() . '/package.xml';
if (!is_readable($xmlPath)) {
return false;
}
$content = file_get_contents($xmlPath);
return opToolkit::loadXmlString($content, array('return' => 'SimpleXMLElement'));
}