Пример #1
0
 public function test_javascript_tag()
 {
     $javascript = new JavascriptHelper();
     //static call
     $this->AssertEqual(JavascriptHelper::javascript_tag("alert('test akelos');"), "<script type=\"text/javascript\">\n//<![CDATA[\nalert('test akelos');\n//]]>\n</script>");
     //object call
     $this->AssertEqual($javascript->javascript_tag("alert('test akelos');"), "<script type=\"text/javascript\">\n//<![CDATA[\nalert('test akelos');\n//]]>\n</script>");
 }
Пример #2
0
 /**
  * cakeライブラリ仕様 オブジェクトをJSONに変換するメソッド
  *
  * @params $data オブジェクト
  * @return String JSONストリング
  */
 function toJson($data)
 {
     // Helperの呼び出し
     App::import("Helper", "Javascript");
     // インスタンス化
     $javascript = new JavascriptHelper();
     // オブジェクトをJSON形式に変換して、文字列で返す
     return $javascript->object($data);
 }
Пример #3
0
 /**
  * Displays the view.
  *
  * @param  string $tpl the template name
  *
  * @return void
  * @since  1.0
  */
 public function display($tpl = null)
 {
     JHTML::_('behavior.modal');
     JHTML::stylesheet('media/com_newsletter/css/admin.css');
     JHTML::stylesheet('media/com_newsletter/css/sender.css');
     JHTML::script('media/com_newsletter/js/migur/js/core.js');
     JHTML::script('media/com_newsletter/js/migur/js/filterpanel.js');
     JHTML::script('media/com_newsletter/js/migur/js/search.js');
     JHTML::script(JURI::root() . "administrator/components/com_newsletter/views/sender/sender.js");
     $this->setModel(JModel::getInstance('lists', 'NewsletterModel'));
     $this->setModel(JModel::getInstance('newsletters', 'NewsletterModel'));
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $modelLists = $this->getModel('lists');
     JRequest::setVar('limit', 1);
     $limit = $modelLists->setState('limit', 1);
     $modelLists->filtering = array('state' => '1');
     $lists = (object) array('items' => $modelLists->getItems(), 'pagination' => new JPagination(10, 0, 5), 'state' => $modelLists->getState(), 'listOrder' => $modelLists->getState('list.ordering'), 'listDirn' => $modelLists->getState('list.direction'));
     JavascriptHelper::addStringVar('defaultMailbox', MailHelper::getDefaultMailbox('idOnly'));
     $modelLists->setState('limit', $limit);
     $this->assignRef('lists', $lists);
     $this->addToolbar();
     parent::display($tpl);
 }
Пример #4
0
 /**
  * Method to set up the document properties
  *
  * @return void
  * @since  1.0
  */
 protected function setDocument()
 {
     $isNew = !JRequest::getInt('automailing_id', false);
     JToolBarHelper::title($isNew ? JText::_('COM_NEWSLETTER_AUTOMAILING_ADD_TITLE') : JText::_('COM_NEWSLETTER_AUTOMAILING_EDIT_TITLE'), 'article.png');
     JavascriptHelper::addStringVar('isNew', (int) $isNew);
     $document = JFactory::getDocument();
     $document->setTitle(JText::_('COM_NEWSLETTER_MAINTAINANCE'));
     $document->addstylesheet(JURI::root() . '/media/com_newsletter/css/admin.css');
     $document->addstylesheet(JURI::root() . '/media/com_newsletter/css/maintainance.css');
     $document->addScript(JURI::root() . '/media/com_newsletter/js/migur/js/core.js');
     $document->addScript(JURI::root() . '/media/com_newsletter/js/migur/js/widgets.js');
     $document->addScript(JURI::root() . '/media/com_newsletter/js/migur/js/widgets/ajaxchecker.js');
     $document->addScript(JURI::root() . "/administrator/components/com_newsletter/views/maintainance/maintainance.js");
     JText::script('COM_NEWSLETTER_AUTOMAILING_ERROR_UNACCEPTABLE');
 }
Пример #5
0
 /**
  * Display the view
  *
  * @return	void
  */
 public function display($tpl = null)
 {
     JHTML::stylesheet('media/com_newsletter/css/admin.css');
     JHTML::stylesheet('media/com_newsletter/css/smtpprofile.css');
     JHTML::script('media/com_newsletter/js/migur/js/core.js');
     $this->ssForm = $this->get('Form', 'smtpprofile');
     $model = JModel::getInstance('Smtpprofile', 'NewsletterModelEntity');
     $smtpid = JRequest::getInt('smtp_profile_id', null);
     if ($smtpid !== null) {
         $model->load($smtpid);
     }
     JavascriptHelper::addStringVar('migurIsJoomlaProfile', $model->isJoomlaProfile());
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->addToolbar();
     parent::display($tpl);
     // Set the document
     $this->setDocument();
 }
Пример #6
0
 /**
  * Displays the view.
  *
  * @param  string $tpl the template name
  *
  * @return void
  * @since  1.0
  */
 public function display($tpl = null)
 {
     //TODO: Need to move css/js to SetDocument
     JHTML::stylesheet('media/com_newsletter/css/admin.css');
     JHTML::stylesheet('media/com_newsletter/css/queues.css');
     JHTML::script('media/com_newsletter/js/migur/js/core.js');
     JHTML::script('media/com_newsletter/js/migur/js/filterpanel.js');
     JHTML::script('media/com_newsletter/js/migur/js/search.js');
     JHTML::script(JURI::root() . "/administrator/components/com_newsletter/views/queues/queues.js");
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     EnvironmentHelper::showWarnings(array('checkJoomla', 'checkImap', 'checkLogs'));
     // We don't need toolbar in the modal window.
     if ($this->getLayout() !== 'modal') {
         $this->addToolbar();
     }
     //		JHTML::_('behavior.modal');
     // Let's work with model 'queues' !
     $model = $this->getModel('queues');
     $items = $model->getItems();
     $pagination = $model->getPagination();
     $state = $model->getState();
     $listOrder = $model->getState('list.ordering');
     $listDirn = $model->getState('list.direction');
     $saveOrder = $listOrder == 'a.ordering';
     $this->assignRef('items', $items);
     $this->assignRef('pagination', $pagination);
     $this->assignRef('state', $state);
     $this->assignRef('listOrder', $listOrder);
     $this->assignRef('listDirn', $listDirn);
     $this->assignRef('saveOrder', $saveOrder);
     $sess = JFactory::getSession();
     JavascriptHelper::addStringVar('sessname', $sess->getName());
     parent::display($tpl);
 }
Пример #7
0
 function optionsForAjax($options)
 {
     $js_options = JavascriptHelper::buildCallbacks($options);
     $js_options['asynchronous'] = isset($options['type']) && $options['type'] != 'synchronous' ? false : true;
     if (isset($options['method'])) {
         $js_options['method'] = JavascriptHelper::methodOptionToS($options['method']);
     }
     if (isset($options['position'])) {
         $js_options['insertion'] = "Insertion.{$options['position']}";
     }
     if (isset($options['script'])) {
         $js_options['evalScripts'] = $options['script'] ? 'true' : 'false';
     }
     if (isset($options['form'])) {
         $js_options['parameters'] = 'Form.serialize(this)';
     } else {
         if (isset($options['with'])) {
             $js_options['parameters'] = $options['with'];
         }
     }
     return JavascriptHelper::optionsForJavascript($js_options);
 }
Пример #8
0
 /**
  * jsonEncode Helper method for PHP4 compatibility
  *
  * @param mixed $object Something to encode
  * @access protected
  * @static
  * @return string
  **/
 function _jsonEncode($object)
 {
     if (!class_exists('JavascriptHelper')) {
         App::import('Helper', 'Javascript');
     }
     $javascript = new JavascriptHelper();
     $javascript->useNative = false;
     return $javascript->object($object);
 }
 /**
  * Print an ajax response to the browser.
  *
  * @param array $strResponseArray An array keyed with QAjaxResponse items. These items will be read by the qcubed.js
  * ajax success function and operated on. The goals is to eventually have all possible response types represented
  * in the QAjaxResponse so that we can remove the "eval" in qcubed.js.
  */
 public static function SendAjaxResponse(array $strResponseArray)
 {
     header('Content-Type: text/json');
     // not application/json, as IE reportedly blows up on that, but jQuery knows what to do.
     $strJSON = JavascriptHelper::toJSON($strResponseArray);
     if (QApplication::$EncodingType && QApplication::$EncodingType != 'UTF-8') {
         $strJSON = iconv(QApplication::$EncodingType, 'UTF-8', $strJSON);
         // json must be UTF-8 encoded
     }
     print $strJSON;
 }
Пример #10
0
 function setStatisticsData()
 {
     $theHour = 3600;
     $theDay = $theHour * 24;
     $days = 30;
     $previousDay = date('Y-m-d 00:00:00', strtotime("-1 day", time()));
     $fiewDaysBefore = date('Y-m-d 00:00:00', strtotime("-30 Days", time()));
     JavascriptHelper::addObject('opensPerDay', StatisticsHelper::openedNewslettersPerDay($fiewDaysBefore, $previousDay, null));
     JavascriptHelper::addObject('subsPerDay', StatisticsHelper::activeSubscribersPerDay($fiewDaysBefore, $previousDay, null));
 }
Пример #11
0
 /**
  * Get statistics data and set it to JS.
  * 
  * @return void
  * @since  1.0
  */
 protected function setStatisticsData()
 {
     $ids = JRequest::getString('newsletters', '');
     $this->ids = $ids;
     $days = JRequest::getString('days', 30);
     $this->days = $days;
     $ids = !empty($ids) ? explode(',', $ids) : null;
     $data = StatisticsHelper::totalSent($ids);
     JavascriptHelper::addObject('statTotalSent', $data);
     $data = StatisticsHelper::openedActionsCount($ids);
     JavascriptHelper::addObject('statOpenedCount', $data);
     $data = StatisticsHelper::openedNewslettersCount($ids);
     $res = array('newsletters' => empty($data['newsletters']) ? 0 : $data['newsletters'], 'subscribers' => empty($data['subscribers']) ? 0 : $data['subscribers']);
     JavascriptHelper::addObject('statActiveCount', $res);
     $data = StatisticsHelper::totalClicks($ids);
     JavascriptHelper::addObject('statTotalClicks', $data);
     $previousDay = date('Y-m-d 00:00:00', strtotime("-1 day", time()));
     $thisDay = date('Y-m-d 00:00:00');
     $daysIdentifier = $days == 1 ? "-1 day" : "-" . $days . " Days";
     $fiewDaysBefore = date('Y-m-d 00:00:00', strtotime($daysIdentifier, time()));
     $previousHour = date('Y-m-d H:00:00', strtotime("-1 hour", time()));
     $thisHour = date('Y-m-d H:00:00');
     $oneDayBefore = date('Y-m-d H:00:00', strtotime("-1 day", time()));
     JavascriptHelper::addObject('clicksPerDay', StatisticsHelper::activityPerDay($fiewDaysBefore, $thisDay, $ids, NewsletterTableHistory::ACTION_CLICKED));
     JavascriptHelper::addObject('viewsPerDay', StatisticsHelper::activityPerDay($fiewDaysBefore, $thisDay, $ids, NewsletterTableHistory::ACTION_OPENED));
     JavascriptHelper::addObject('clicksPerHour', StatisticsHelper::activityPerHour($oneDayBefore, $thisHour, $ids, NewsletterTableHistory::ACTION_CLICKED));
     JavascriptHelper::addObject('viewsPerHour', StatisticsHelper::activityPerHour($oneDayBefore, $thisHour, $ids, NewsletterTableHistory::ACTION_OPENED));
 }
Пример #12
0
 function display($tpl = null)
 {
     JavascriptHelper::addStringVar('migurFieldId', JRequest::getString('fieldId', 'insertField'));
     JFactory::getDocument()->addScript(JUri::root() . "/administrator/components/com_newsletter/views/media/media.js");
     parent::display($tpl);
 }
Пример #13
0
 /**
  * Gets the statistics data and set it to JS.
  *
  * @return void
  * @since  1.0
  */
 protected function setStatisticsData()
 {
     $data = StatisticsHelper::totalSent();
     JavascriptHelper::addObject('statTotalSent', $data);
     $data = StatisticsHelper::openedActionsCount();
     JavascriptHelper::addObject('statOpenedCount', $data);
     $data = StatisticsHelper::openedNewslettersCount();
     $res = array('newsletters' => empty($data['newsletters']) ? 0 : $data['newsletters'], 'subscribers' => empty($data['subscribers']) ? 0 : $data['subscribers']);
     JavascriptHelper::addObject('statActiveSubscribersCount', $res);
     $now = date('Y-m-d H:i:s');
     $sevenDaysBefore = date('Y-m-d', strtotime('-7 Days', time())) . " 00:00:00";
     $thirtyDaysBefore = date('Y-m-d', strtotime('-30 Days', time())) . " 00:00:00";
     $ninetyDaysBefore = date('Y-m-d', strtotime('-90 Days', time())) . " 00:00:00";
     $this->totalSubs = array(StatisticsHelper::totalSubscribersCount($sevenDaysBefore, $now), StatisticsHelper::totalSubscribersCount($thirtyDaysBefore, $now), StatisticsHelper::totalSubscribersCount($ninetyDaysBefore, $now));
     $this->newSubs = array(StatisticsHelper::newSubscribersCount($sevenDaysBefore, $now), StatisticsHelper::newSubscribersCount($thirtyDaysBefore, $now), StatisticsHelper::newSubscribersCount($ninetyDaysBefore, $now));
     $this->lostSubs = array(StatisticsHelper::lostSubscribersCount($sevenDaysBefore, $now), StatisticsHelper::lostSubscribersCount($thirtyDaysBefore, $now), StatisticsHelper::lostSubscribersCount($ninetyDaysBefore, $now));
     $this->activeSubs = array(StatisticsHelper::activeSubscribersCount($sevenDaysBefore, $now), StatisticsHelper::activeSubscribersCount($thirtyDaysBefore, $now), StatisticsHelper::activeSubscribersCount($ninetyDaysBefore, $now));
 }
Пример #14
0
 /**
  * Method to set up the document properties
  *
  * @return void
  * @since  1.0
  */
 protected function setDocument()
 {
     $isNew = !JRequest::getInt('newsletter_id', false);
     JavascriptHelper::addStringVar('isNew', (int) $isNew);
     $document = JFactory::getDocument();
     $document->setTitle($isNew ? JText::_('COM_NEWSLETTER_NEWSLETTER_CREATING') : JText::_('COM_NEWSLETTER_NEWSLETTER_EDITING'));
     $document->addScript(JURI::root() . $this->script);
     $document->addScript(JURI::root() . "/administrator/components/com_newsletter/views/newsletter/newsletter.js");
     $document->addScript(JURI::root() . "/administrator/components/com_newsletter/views/newsletter/downloads.js");
     $document->addScript(JURI::root() . "/administrator/components/com_newsletter/views/newsletter/submitbutton.js");
     JText::script('COM_NEWSLETTER_NEWSLETTER_ERROR_UNACCEPTABLE');
 }
Пример #15
0
 function makeRemoteForm($options = array())
 {
     if (!$this->form) {
         // TODO: raise error since we can't update a non-existent form. Must call getForm first.
         return;
     }
     include_once 'view/helpers/javascript_helper.php';
     $form =& $this->form;
     if ($validation = $form->getAttribute('onsubmit')) {
         // try { var myValidator = validate_add_person_form_10; } catch(e) { return true; } return myValidator(this);
         $validation = 'var validated=false; try {var myValidator = validate_' . $form->getAttribute('name') . '; } catch(e) { validated=true; } if (myValidator) { validated=myValidator(this); } ';
         $options['condition'] = 'validated';
     }
     if (isset($options['url']) && is_array($options['url']) && isset($options['url']['controller'])) {
         $controller =& NController::singleton($options['url']['controller']);
     } else {
         $controller =& $this->controller;
     }
     $options['form'] = true;
     $function = JavascriptHelper::remoteFunction($controller, $options);
     $function .= '; return false;';
     $form->updateAttributes(array('onsubmit' => $validation . $function));
 }
Пример #16
0
 function _render_jsonp($JsonData, $wrapper = '?')
 {
     if ($wrapper == '?') {
         $wrapper = substr(md5(microtime(1)), -9);
     }
     App::import('Helper', 'Javascript');
     $Javascript = new JavascriptHelper();
     $content = sprintf('%s(%s)', $wrapper, $Javascript->object($JsonData));
     header('Content-Type: application/x-javascript; charset=utf-8');
     print $content;
     die;
 }
Пример #17
0
 /**
  * Calculate the statistics data and add it to the JS
  *
  * @return void
  * @since  1.0
  */
 protected function setStatisticsData()
 {
     $data = StatisticsHelper::totalSent();
     $res = array('no' => empty($data['no']) ? 0 : $data['no'], 'soft' => empty($data['soft']) ? 0 : $data['soft'], 'hard' => empty($data['hard']) ? 0 : $data['hard'], 'total' => empty($data['total']) ? 0 : $data['total']);
     JavascriptHelper::addObject('statTotalSent', $res);
     $data = StatisticsHelper::openedActionsCount();
     $res = array('other' => empty($data['other']) ? 0 : $data['other'], 'opened' => empty($data['opened']) ? 0 : $data['opened'], 'total' => empty($data['total']) ? 0 : $data['total']);
     JavascriptHelper::addObject('statOpenedCount', $res);
     $data = StatisticsHelper::openedNewslettersCount();
     $res = array('newsletters' => empty($data['newsletters']) ? 0 : $data['newsletters'], 'subscribers' => empty($data['subscribers']) ? 0 : $data['subscribers']);
     JavascriptHelper::addObject('statActiveSubscribersCount', $res);
     $theHour = 3600;
     $theDay = $theHour * 24;
     $days = 30;
     $previousDay = date('Y-m-d 00:00:00', time() - $theDay);
     $fiewDaysBefore = date('Y-m-d 00:00:00', time() - $theDay * $days);
     JavascriptHelper::addObject('newSubsPerDay', StatisticsHelper::newSubscribersPerDay($fiewDaysBefore, $previousDay));
 }
Пример #18
0
jimport('joomla.error.log');
// Add the helper
JLoader::import('helpers.javascript', JPATH_COMPONENT_ADMINISTRATOR, '');
JLoader::import('helpers.rssfeed', JPATH_COMPONENT_ADMINISTRATOR, '');
JLoader::import('helpers.log', JPATH_COMPONENT_ADMINISTRATOR, '');
JHtml::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'html');
JFormHelper::addRulePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'rules');
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
JModel::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models');
JModel::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'entities', 'NewsletterModelEntity');
// Get an instance of the controller prefixed by Newsletter
$controller = JController::getInstance('Newsletter');
// ACL
$resource = JRequest::getString('view', '') . '.' . JRequest::getString('layout', 'default');
switch ($resource) {
    case 'subscribe.unsubscribe':
        if (!JFactory::getUser()->id && !JRequest::getString('uid', NULL)) {
            JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_users&view=login&returnurl=' . base64_encode(JRoute::_('index.php?option=com_newsletter&view=subscribe&layout=unsubscribe', false))), JText::_('COM_NEWSLETTER_LOGIN_FIRST'), 'message');
        }
}
// Add translations used in JavaScript
JavascriptHelper::requireTranslations();
// Load 'Migur' group of plugins
JPluginHelper::importPlugin('migur');
$app = JFactory::getApplication();
$app->triggerEvent('onMigurNewsletterStart');
// Perform the Request task
$controller->execute(JRequest::getCmd('task'));
$app->triggerEvent('onMigurNewsletterEnd');
// Redirect if set by the controller
$controller->redirect();
Пример #19
0
 JPluginHelper::importPlugin('migur');
 $app = JFactory::getApplication();
 $app->triggerEvent('onMigurNewsletterStart');
 // Handle the messages from previous requests
 $sess = JFactory::getSession();
 $msg = $sess->get('migur.queue');
 if ($msg) {
     $sess->set('application.queue', $msg);
     $sess->set('migur.queue', null);
 }
 JFormHelper::addRulePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'rules');
 JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
 JModel::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'entities', 'NewsletterModelEntity');
 // Add the site root and user's ACL to JS
 JavascriptHelper::addStringVar('migurSiteRoot', JUri::root());
 JavascriptHelper::addObject('migurUserAcl', AclHelper::toArray());
 // Setup the cache
 $cache = JFactory::getCache('com_newsletter');
 $cache->setCaching(true);
 $cache->setLifeTime(900);
 // cache to 5 min
 // Get an instance of the controller
 // Here we get full task
 $controller = JController::getInstance('Newsletter');
 // Perform the Request task
 // Here we get only tail of a task
 $controller->execute(JRequest::getCmd('task'));
 // Trigger events after exacution
 $app->triggerEvent('onMigurNewsletterEnd');
 // Redirect if set by the controller
 $controller->redirect();
Пример #20
0
 /**
  * Makes the element with the DOM ID specified by +element_id+ receive
  * dropped draggable elements (created by draggable_element).
  * and make an AJAX call  By default, the action called gets the DOM ID 
  * of the element as parameter.
  *
  * Example:
  *   <%= drop_receiving_element("my_cart", :url => 
  *     { :controller => "cart", :action => "add" }) %>
  *
  * You can change the behaviour with various options, see
  * http://script.aculo.us for more documentation.
  */
 function drop_receiving_element($element_id, $options = array())
 {
     $options['with'] = !empty($options['with']) ? $options['with'] : "'id='" . urlencode(element . id);
     $options['onDrop'] = !empty($options['onDrop']) ? $options['onDrop'] : "function(element){" . PrototypeHelper::remote_function($options) . "}";
     foreach ($options as $key => $option) {
         /**
          * @todo: fix this code when implemented PrototypeHelper
          * 
          * if (in_array(PrototypeHelper::AJAX_OPTIONS[$option])) {
          *      unset($options[$option]);
          * }
          */
     }
     if (in_array($options['accept'])) {
         $options['accept'] = JavascriptHelper::_array_or_string_for_javascript($options['accept']);
     }
     if (in_array($options['hoverclass'])) {
         $options['hoverclass'] = "'{$options['hoverclass']}'";
     }
     return JavascriptHelper::javascript_tag("Droppables.add('{$element_id}', " . JavascriptHelper::_options_for_javascript($options) . ")");
 }
Пример #21
0
 function get_site_status()
 {
     if ($this->RequestHandler->isAjax()) {
         Configure::write('debug', 0);
         $this->autoRender = false;
         $this->autoLayout = false;
         App::import('Helper', 'Javascript');
         $javascript = new JavascriptHelper();
         $configuration = Configure::read('Grecocos');
         echo $javascript->object($configuration);
         exit(1);
     }
 }
Пример #22
0
 /**
 * Returns a JavaScript tag with the +content+ inside. Example:
 *   javascript_tag("alert('All is good')") => <script type="text/javascript">alert('All is good')</script>
 */
 function javascript_tag($content)
 {
     return TagHelper::content_tag("script", JavascriptHelper::javascript_cdata_section($content), array('type' => 'text/javascript'));
 }