public function setPlanning($startDate, $endDate, $title, $content) { // Parameters for ClientAuth authentication ProjectConfiguration::registerZend(); Zend_Loader::loadClass('Zend_Gdata'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_Calendar'); $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; $user = sfConfig::get('app_gmail_user'); $pass = sfConfig::get('app_gmail_pwd'); // Create an authenticated HTTP client $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); // Create an instance of the Calendar service $service = new Zend_Gdata_Calendar($client); // Create a new entry using the calendar service's magic factory method $event = $service->newEventEntry(); // Populate the event with the desired information // Note that each attribute is crated as an instance of a matching class $event->title = $service->newTitle($title); $event->where = array($service->newWhere("Paris, France")); $event->content = $service->newContent($content); // Set the date using RFC 3339 format. $tzOffset = "+02"; $when = $service->newWhen(); //$when->startTime = "{$start_date}.000{$tzOffset}:00"; //$when->endTime = "{$end_date}.000{$tzOffset}:00"; $when->startTime = "{$startDate}:00.000{$tzOffset}:00"; $when->endTime = "{$endDate}:00.000{$tzOffset}:00"; $event->when = array($when); // Upload the event to the calendar server // A copy of the event as it is recorded on the server is returned $newEvent = $service->insertEvent($event); }
public function gdata_insert_row() { ProjectConfiguration::registerZend(); Zend_Loader::loadClass('Zend_Gdata_AuthSub'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_Spreadsheets'); Zend_Loader::loadClass('Zend_Gdata_Docs'); $username = "******"; $password = "******"; //Chave do arquivo $key = "0Ak_oCZQf3sTidEJnZGQ4MHdhS0R1NUlSeG1ORkpnalE"; //Carregando o serviço do arquivo $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME; $client = Zend_Gdata_ClientLogin::getHttpClient($username, $password, $service); $spreadSheetService = new Zend_Gdata_Spreadsheets($client); //Pegando as planilhas do arquivo $query = new Zend_Gdata_Spreadsheets_DocumentQuery(); $query->setSpreadsheetKey($key); $feed = $spreadSheetService->getWorksheetFeed($query); //Escolhendo a planilha correta foreach ($feed->entries as $entry) { if ($entry->getTitle() == 'Disponiveis') { $worksheetId = basename($entry->getId()); } } //Configura variaveis da nova linha na planilha $assoc = $this->getAssociado(); $matricula = $this->isTitular() ? $assoc->getMatricula() : $assoc->getTitular()->getMatricula(); $dependenteId = $this->isDependente() ? $assoc->getId() : '0'; //Monta array para o serviço do arquivo $rowData = array("data" => $this->getDateTimeObject('created_at')->format('Y-m-d'), "matricula" => $matricula, "nome" => $assoc->getNome(), "dependenteid" => $dependenteId, "encaminhaid" => $this->getId()); //Insere na Planilha $insertedListEntry = $spreadSheetService->insertRow($rowData, $key, $worksheetId); }
public static function getLuceneIndex() { ProjectConfiguration::registerZend(); if (file_exists($index = self::getLuceneIndexFile())) { return Zend_Search_Lucene::open($index); } return Zend_Search_Lucene::create($index); }
/** * YT API KEY: AI39si53nkZgrhA-nJLOurfN5yOdLdQeWHK_M08w1A19kfwa718lRXR8Dilcpnc1D0BVXn8KLAfSyYdYbdrd3X7bgDV0ma59Zg */ public function moveVideo($video) { ProjectConfiguration::registerZend(); $httpClient = Zend_Gdata_ClientLogin::getHttpClient('*****@*****.**', 'watchm3now', 'youtube', null, 'lifeimpact', null, null, 'https://www.google.com/accounts/ClientLogin'); $applicationId = 'lifeimpact'; $clientId = 'lifeimpact'; $yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, YOUTUBE_DEVELOPER_KEY); $yt->setMajorProtocolVersion(2); }
public static function getLuceneIndex() { ProjectConfiguration::registerZend(); Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8()); if (file_exists($index = self::getLuceneIndexFile())) { return Zend_Search_Lucene::open($index); } else { return Zend_Search_Lucene::create($index); } }
protected static function sendUsingZendMailSMTP() { ProjectConfiguration::registerZend(); require_once 'Zend/Mail.php'; $config = array('auth' => 'login', 'username' => ProjectConfiguration::getSMTPUser(), 'password' => ProjectConfiguration::getSMTPPassword()); if (ProjectConfiguration::getSMTPUseTLS()) { $config['ssl'] = 'tls'; } $transport = new Zend_Mail_Transport_Smtp(ProjectConfiguration::getSMTPServer(), $config); return self::sendUsingZendMail($transport); }
public function executeSubmit(sfWebRequest $request) { ProjectConfiguration::registerZend(); $this->video = new Video(); $this->video->url = $request->getParameter('url'); try { $this->video->populateFromUrl(); $this->video->save(); } catch (Exception $e) { $this->error = $e->getMessage(); return sfView::ERROR; } }
function generateFeed() { ProjectConfiguration::registerZend(); $this->feed = new Zend_Feed_Writer_Feed(); foreach ($this->pager->getResults() as $article) { /* @var $entry Zend_Feed_Writer_Entry */ $entry = $this->feed->createEntry(); $entry->setTitle($article->getTitle()); $entry->setLink($this->generateUrl('zs_blog_article', $article, true)); $entry->setDateModified($article->getDateTimeObject('published_at')->format('U')); $entry->setDateCreated($article->getDateTimeObject('published_at')->format('U')); $entry->setContent($this->getPartial('content', array('article' => $article))); $entry->addAuthor((string) $article->getCreatedBy()); $this->feed->addEntry($entry); } }
/** * @see sfPluginConfiguration */ public function initialize() { /** * Zend Autoloader */ ProjectConfiguration::registerZend(); /** * configure amazon s3 */ $uploadDir = sfConfig::get('sf_upload_dir'); if (sfConfig::get('app_amazon_s3_enabled') && ($bucket = sfConfig::get('app_amazon_s3_bucket'))) { $this->registerAmazonS3Stream(); $path = str_replace(sfConfig::get('sf_web_dir'), '', $uploadDir); sfConfig::add(array('sf_upload_read_dir' => 'http://' . $bucket . '.s3.amazonaws.com' . $path, 'sf_upload_write_dir' => 's3://' . $bucket . $path)); } else { sfConfig::add(array('sf_upload_read_dir' => $uploadDir, 'sf_upload_write_dir' => $uploadDir)); } /** * end amazon s3 config */ }
/** * Retourne un tableau formaté des caractéristiques d'un article * * @param string $detailsXml Détails de l'article dans le format XML * @return array() Détail de l'article (ensemble des caractéristiques dans * un tableau formaté */ public static function formatDetails($detailsXml) { // initialisation $details = array(); $keepTrying = true; $i = 1; $detailsXml = '<?xml version="1.0" encoding="ISO-8859-1"?>' . html_entity_decode($detailsXml); // on charge les librairies de Zend Framework ProjectConfiguration::registerZend(); // on format les details de l'article do { try { // on recupere une à une les caractéristiques de l'article $caract = new Zend_Config_Xml($detailsXml, 'caract_' . $i); $details[] = $caract->toArray(); $i++; } catch (Zend_Config_Exception $e) { $keepTrying = false; } } while ($keepTrying); return $details; }
public function executeContactSubmit(sfWebRequest $request) { $this->form = new ContactForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('contact'), $request->getFiles('contact')); if ($this->form->isValid()) { $values = $this->form->getValues(); /* sending email */ ProjectConfiguration::registerZend(); $mail = new Zend_Mail(); $mail->setBodyText($values['message']); $mail->setFrom($values['email']); $mail->addTo(sfConfig::get('app_admin_mail')); $mail->setSubject($values['subject']); $mail->send(); /* sending email */ /* @todo stores the request in admin */ $this->redirect('contact/thankyou?' . http_build_query($this->form->getValues())); } } $this->setTemplate('index'); }
public function getIndex() { $file = sfConfig::get('sf_data_dir') . '/' . sfInflector::underscore($this->name) . '.' . sfConfig::get('sf_environment') . '.index'; ProjectConfiguration::registerZend(); if (file_exists($file)) { return Zend_Search_Lucene::open($file); } return Zend_Search_Lucene::create($file); }
public function __construct() { ProjectConfiguration::registerZend(); $this->document = new Zend_Pdf(); }
public function __construct() { //load zend ProjectConfiguration::registerZend(); $this->_config = sfConfig::get('app_zsUtilPlugin_social'); }
static function getLuceneHits($query, $limit = 20) { ProjectConfiguration::registerZend(); $index = self::getLuceneIndex(); Zend_Search_Lucene::setResultSetLimit($limit); $originalQuery = $query; //if no ORs in query, assume all terms are ANDs if (!strstr($query, ' OR ')) { $query = preg_replace('/\\s{1,}/', ' AND ', $query); } return $index->find($query); }
/** * Конструктор * * @param string $raw * @return void */ public function __construct($raw) { // подключить ZF autoloader ProjectConfiguration::registerZend(); $this->_raw = $raw; }
/** * Статический метод производящий декодировку письма * * @param string $input полный оригинальный текст email с заголовками * @return array|false, в случае неверного формата входящих данных (отсутствует заголовок или часть заголовка) */ public static function getEmailData($input) { // подключить ZF autoloader ProjectConfiguration::registerZend(); $message = new Zend_Mail_Message(array('raw' => $input)); $headers = $message->getHeaders(); if (!count($headers)) { return false; } if (!isset($headers['subject']) || !isset($headers['from']) || !isset($headers['to'])) { return false; } // выдергиваем текстовое тело письма, если можем $body = null; if ($message->isMultipart()) { foreach (new RecursiveIteratorIterator($message) as $part) { try { if (strtok($part->contentType, ';') == 'text/plain') { $body = trim($part); $partHeaders = $part->getHeaders(); break; } } catch (Zend_Mail_Exception $e) { } } // в письме нет текстового варианта // FIXME как-то по человечески обрабатывать if (!$body) { throw new Exception(); } } else { $body = trim($message->getContent()); $partHeaders = $message->getHeaders(); } if (isset($partHeaders['content-transfer-encoding'])) { switch ($partHeaders['content-transfer-encoding']) { // FIXME хз нужно ли нам оно, на локалке не стоит imap_* // м.б. есть альтернативные варианты /* case '7bit': break; case '8bit': $body = quoted_printable_decode(imap_8bit($body)); break; case 'binary': $body = imap_base64(imap_binary($body)); break; case 'base64': $body = imap_base64($body); break; */ case 'quoted-printable': $body = quoted_printable_decode($body); break; case 'base64': $body = base64_decode($body); break; } } if (isset($partHeaders['content-type']) && preg_match("/^(?:.+?);\\scharset=(.+)\$/", $partHeaders['content-type'], $matches)) { $charset = trim($matches['1']); if (!preg_match("/^(utf-8|utf8)\$/i", $charset)) { $body = iconv($charset, "UTF-8//IGNORE", $body); } } $data = array('from' => self::_cleanEmail($headers['from']), 'to' => self::_cleanEmail($headers['to']), 'subject' => $headers['subject'], 'body' => $body); return $data; }