当前位置: 首页>>代码示例>>PHP>>正文


PHP ServiceLocator::getInstance方法代码示例

本文整理汇总了PHP中ServiceLocator::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP ServiceLocator::getInstance方法的具体用法?PHP ServiceLocator::getInstance怎么用?PHP ServiceLocator::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ServiceLocator的用法示例。


在下文中一共展示了ServiceLocator::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: display

 function display($tpl = null)
 {
     $layout = $this->getLayout();
     if ($layout == 'multisubscription') {
         $this->newsletters = array();
         if (isset($this->mmsg)) {
             jincimport('utility.servicelocator');
             $servicelocator = ServiceLocator::getInstance();
             $logger = $servicelocator->getLogger();
             jincimport('core.newsletterfactory');
             $ninstance = NewsletterFactory::getInstance();
             foreach ($this->mmsg as $news_id => $text) {
                 if ($newsletter = $ninstance->loadNewsletter($news_id, true)) {
                     $this->newsletters[$news_id] = $newsletter;
                 }
             }
         }
     } else {
         $news_id = JRequest::getInt('id', 0);
         jincimport('core.newsletterfactory');
         $ninstance = NewsletterFactory::getInstance();
         if ($newsletter = $ninstance->loadNewsletter($news_id, true)) {
             $this->newsletter = $newsletter;
         }
     }
     parent::display($tpl);
 }
开发者ID:sulicz,项目名称:JINC_J30,代码行数:27,代码来源:view.html.php

示例2: update

 /**
  * Update method to register message sending events.
  *
  * @access	public
  * @param $args['news_id'] Newsletter identifier refferring to the event.
  * * @param $args['msg_id'] Message identifier refferring to the event.
  * @return  false if something wrong.
  * @since	0.6
  */
 function update(&$args)
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     if (!isset($args['news_id']) || !isset($args['msg_id'])) {
         return false;
     }
     $news_id = (int) $args['news_id'];
     $msg_id = (int) $args['msg_id'];
     $dbo =& JFactory::getDBO();
     $query = 'UPDATE #__jinc_newsletter SET lastsent = now() ' . 'WHERE id = ' . (int) $news_id;
     $dbo->setQuery($query);
     $logger->debug('SentMsgEvent: executing query: ' . $query);
     if (!$dbo->query()) {
         $logger->error('SentMsgEvent: error updating last newsletter dispatch date');
         return false;
     }
     $query = 'UPDATE #__jinc_message SET datasent = now() ' . 'WHERE id = ' . (int) $msg_id;
     $dbo->setQuery($query);
     $logger->debug('SentMsgEvent: executing query: ' . $query);
     if (!$dbo->query()) {
         $logger->error('SentMsgEvent: error updating last message dispatch date');
         return false;
     }
     return true;
 }
开发者ID:madseller,项目名称:coperio,代码行数:36,代码来源:sentmsgevent.php

示例3: ImportFromCSV

 /**
  * The newsletter importer. It imports newsletter subscribers from a CSV file.
  *
  * @access	public
  * @param	integer $newsletter a newsletter object.
  * @param	string  $csvfile_name the CSV file name.
  * @return  array containing import results.
  * @since	0.6
  * @see     Newsletter
  */
 function ImportFromCSV($newsletter, $csvfile_name)
 {
     jincimport('utility.jincjoomlahelper');
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     if (!($handle = @fopen($csvfile_name, "r"))) {
         $logger->finer('NewsletterImporter: unable to open ' . $csvfile_name);
         return false;
     }
     $result = array();
     while (($data = fgetcsv($handle, $this->_LINE_MAX_LENGTH, ",")) !== FALSE) {
         $logger->finer('NewsletterImporter: importing ' . implode(', ', $data));
         $info = $newsletter->getSubscriptionInfo();
         $subscriber_info = array();
         $attributes = array();
         for ($i = 0; $i < count($info); $i++) {
             $prefix = substr($info[$i], 0, 5);
             if ($prefix == 'attr_') {
                 $suffix = substr($info[$i], 5);
                 $attributes[$suffix] = isset($data[$i]) ? $data[$i] : '';
             } else {
                 $subscriber_info[$info[$i]] = $data[$i];
             }
         }
         $sub_result = array();
         $sub_result['data'] = implode(', ', $subscriber_info);
         switch ($newsletter->getType()) {
             case NEWSLETTER_PUBLIC_NEWS:
                 $subscriber_info['noptin'] = true;
                 break;
             case NEWSLETTER_PRIVATE_NEWS:
                 $user_id = $subscriber_info['user_id'];
                 $user_info = JINCJoomlaHelper::getUserInfo($user_id);
                 if (empty($user_info)) {
                     $user_info = JINCJoomlaHelper::getUserInfoByUsername($user_id);
                     if (empty($user_info)) {
                         $user_info = JINCJoomlaHelper::getUserInfoByUsermail($user_id);
                         if (!empty($user_info)) {
                             $subscriber_info['user_id'] = $user_info['id'];
                         }
                     } else {
                         $subscriber_info['user_id'] = $user_info['id'];
                     }
                 }
                 break;
             default:
                 break;
         }
         if ($newsletter->subscribe($subscriber_info, $attributes)) {
             $sub_result['result'] = 'OK';
         } else {
             $sub_result['result'] = $newsletter->getError();
         }
         array_push($result, $sub_result);
     }
     fclose($handle);
     return $result;
 }
开发者ID:sulicz,项目名称:JINC_J30,代码行数:69,代码来源:newsletterimporter.php

示例4: setError

 /**
  * Redefine setError method inherited from Joomla! JObject class
  *
  * @access	public
  * @since	0.6
  */
 function setError($error)
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     $logger->finer(get_class($this) . ': ' . JText::_($error));
     parent::setError($error);
 }
开发者ID:madseller,项目名称:coperio,代码行数:14,代码来源:jincobject.php

示例5: setTemplate

    function setTemplate($id)
    {
        if (empty($id)) {
            return;
        }
        $app = JFactory::getApplication();
        $cssurl = rtrim(JURI::root(), '/') . '/' . 'administrator/index.php?option=com_jinc&task=templatecss.loadcss&format=css&id=' . $id . '&time=' . time();
        $filepath = JPATH_COMPONENT_ADMINISTRATOR . DS . 'assets' . DS . 'templates' . DS . $id . '.css';
        $filepath = str_replace('/', DS, $filepath);
        $name = $this->myEditor->get('_name');
        if ($name == 'tinymce') {
            $this->editorConfig = array('content_css_custom' => $cssurl, 'content_css' => '0');
        } elseif ($name == 'jckeditor' || $name == 'fckeditor') {
            $this->editorConfig = array('content_css_custom' => $filepath, 'content_css' => '0', 'editor_css' => '0');
        } else {
            $fileurl = 'administrator/components/com_jinc/assets/templates/' . $id . '.css';
            $this->editorConfig = array('custom_css_url' => $cssurl, 'custom_css_file' => $fileurl, 'custom_css_path' => $filepath);
            JRequest::setVar('jinc_cssfile', $fileurl);
            if ($name == 'jce') {
                $jcepath = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_jce' . DS . 'models' . DS;
                if (file_exists($jcepath . 'editor.php')) {
                    jimport('joomla.filesystem.file');
                    $content = JFile::read($jcepath . 'editor.php');
                    if (!strpos($content, 'jinc_cssfile')) {
                        $jinccode = '
			if(JRequest::getCmd(\'option\') == \'com_jinc\'){
				$jinc_cssfile = JRequest::getString(\'jinc_cssfile\');
				if(!empty($jinc_cssfile)) $settings[\'content_css\'] = $jinc_cssfile;
			}
			';
                        $content = preg_replace('#(\\$settings\\[\'content_css\'\\][^=]*= *\\$this->getStyleSheets\\(\\);)#', '$1' . $jinccode, $content);
                        jincimport('utility.servicelocator');
                        $servicelocator = ServiceLocator::getInstance();
                        $logger = $servicelocator->getLogger();
                        if (strpos($content, 'jinc_cssfile')) {
                            if (!file_exists($jcepath . 'editor_jbackup.php')) {
                                if (JFile::copy($jcepath . 'editor.php', $jcepath . 'editor_jbackup.php') !== true) {
                                    $logger->info('JINCEditor - Could not copy the file from ' . $jcepath . 'editor.php to ' . $jcepath . 'editor_jbackup.php', 'error');
                                }
                            }
                            if (JFile::write($jcepath . 'editor.php', $content) !== true) {
                                $logger->info('Could not write in ' . $jcepath . 'editor.php <br/> Please make sure this folder is writable', 'error');
                            }
                        }
                    }
                }
            }
        }
    }
开发者ID:madseller,项目名称:coperio,代码行数:49,代码来源:jinceditor.php

示例6: update

 /**
  * Update method to register statistical events.
  *
  * @access	public
  * @param $args['news_id'] Newsletter identifier refferring to the event.
  * @return  false if something wrong.
  * @since	0.6
  */
 function update(&$args)
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     if ($this->_type < 0 || !isset($args['news_id'])) {
         return false;
     }
     $query = 'INSERT INTO `#__jinc_stats_event` ' . '(`type`, `date`, `news_id`) VALUES ' . '(' . (int) $this->_type . ', now(), ' . (int) $args['news_id'] . ')';
     $logger->debug('StatisticalEvent: Executing query: ' . $query);
     $dbo =& JFactory::getDBO();
     $dbo->setQuery($query);
     if (!$dbo->query()) {
         return false;
     }
     return true;
 }
开发者ID:madseller,项目名称:coperio,代码行数:25,代码来源:statisticalevent.php

示例7: getItem

 /**
  * Method to get a single record.
  *
  * @param	integer	The id of the primary key.
  *
  * @return	mixed	Object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     $item = parent::getItem($pk);
     if (strlen($item->cssfile) > 0) {
         $item->cssfile_abs = JPATH_COMPONENT_ADMINISTRATOR . DS . 'assets' . DS . 'templates' . DS . $item->cssfile;
         $logger->debug('JINCModelTemplate - Reading CSS file ' . $item->cssfile_abs);
         $item->cssfile_content = is_readable($item->cssfile_abs) ? file_get_contents($item->cssfile_abs) : false;
         if (!$item->cssfile_content) {
             $logger->debug('JINCModelTemplate - Error reading CSS file ' . $item->cssfile_abs);
         }
     }
     return $item;
 }
开发者ID:madseller,项目名称:coperio,代码行数:25,代码来源:template.php

示例8: getMessages

 function getMessages()
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     $id = JRequest::getInt('id', 0, 'GET');
     $result = array();
     $ninstance = NewsletterFactory::getInstance();
     if ($newsletter = $ninstance->loadNewsletter($id, true)) {
         $max_msg = (int) $newsletter->get('front_max_msg');
         if ($max_msg > 0) {
             $query = 'SELECT id, subject, body, datasent, attachment ' . 'FROM #__jinc_message ' . 'WHERE news_id = ' . (int) $id . ' ' . 'AND UNIX_TIMESTAMP(datasent) > 0 ' . 'ORDER BY datasent DESC';
             $logger->debug('NewslettersModelNewsletter: Executing query: ' . $query);
             $result = $this->_getList($query, 0, $max_msg);
         }
     }
     return $result;
 }
开发者ID:madseller,项目名称:coperio,代码行数:18,代码来源:newsletter.php

示例9: update

 /**
  * Update method to register subscription notify event.
  *
  * @access	public
  * @param $args['news_name'] Newsletter name refferring to the event.
  * @param $args['subs_name'] Name of the subscriber just registered.
  * @return  false if something wrong.
  * @since	0.8
  */
 function update(&$args)
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     if (isset($args['news_notify']) && $args['news_notify']) {
         $logger->finer('SubscriptionNotifyEvent: Notifying subscription for ' . $args['news_name']);
         if (!isset($args['subs_name']) || !isset($args['news_name'])) {
             return false;
         }
         $news_name = $args['news_name'];
         $subs_name = $args['subs_name'];
         $dbo =& JFactory::getDBO();
         //get all super administrator
         $query = 'SELECT name, email, sendEmail FROM `#__users` u INNER JOIN ' . '`#__user_usergroup_map` m on u.id = m.user_id INNER JOIN ' . '`#__usergroups` g on m.group_id = g.id ' . 'WHERE lower(g.title) = "super users"';
         $logger->debug('SubscriptionNotifyEvent: executing query: ' . $query);
         $dbo->setQuery($query);
         if ($rows = $dbo->loadObjectList()) {
             // Sending notification to all administrators
             $subject = sprintf(JText::_('COM_JINC_MAIL_NOTIFY_SUBJECT'), $news_name);
             $subject = html_entity_decode($subject, ENT_QUOTES);
             foreach ($rows as $row) {
                 if ($row->sendEmail) {
                     $body = sprintf(JText::_('COM_JINC_MAIL_NOTIFY_BODY'), $row->name, $news_name, $subs_name);
                     $body = html_entity_decode($body, ENT_QUOTES);
                     $message =& JFactory::getMailer();
                     $message->setSubject($subject);
                     $message->setBody($body);
                     $message->addRecipient($row->email);
                     $logger->finer('SubscriptionNotifyEvent: Sending notification mail to ' . $row->email);
                     $message->send();
                 }
             }
         }
     }
     return true;
 }
开发者ID:madseller,项目名称:coperio,代码行数:46,代码来源:subscriptionnotifyevent.php

示例10: checkMandatoryAttributes

 /**
  * Check if every mandatory attribute are avaivalable for subscription purpose.
  *
  * @access	protected
  * @param   integer $attributes list of attribute values
  * @since	0.7
  * @abstract
  */
 function checkMandatoryAttributes($attributes)
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     $news_attributes = $this->attributes;
     foreach ($news_attributes->toArray() as $attr_name => $attr_cardinality) {
         if ($attr_cardinality == ATTRIBUTE_MANDATORY) {
             if (!in_array($attr_name, array_keys($attributes)) || strlen(trim($attributes[$attr_name])) == 0) {
                 $logger->finer("Newsletter. Mandatory attribute not defined: " . $attr_name);
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:madseller,项目名称:coperio,代码行数:24,代码来源:newsletter.php

示例11: getDb

 /**
  * @param string $dbServiceName
  * @return Medoo
  */
 public function getDb($dbServiceName = 'db')
 {
     return $this->db = ServiceLocator::getInstance()->get($dbServiceName);
 }
开发者ID:loncool,项目名称:yaf-admin,代码行数:8,代码来源:Model.php

示例12: getUserInfoByUsermail

 /**
  * Joomla! user finder. It finds user id by mail address
  *
  * @access	public
  * @param	integer $usermail the user mail.
  * @return  array Containing username, name and email. An empty array is
  *                something wrong.
  * @since	0.8
  */
 function getUserInfoByUsermail($usermail)
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     $dbo =& JFactory::getDBO();
     $query = 'SELECT id, username, name, email FROM #__users WHERE email = ' . $dbo->quote($usermail);
     $dbo->setQuery($query);
     $logger->debug('JINCJoomlaHelper: executing query: ' . $query);
     $infos = array();
     if ($user_info = $dbo->loadObjectList()) {
         if (!empty($user_info)) {
             $user = $user_info[0];
             $infos['id'] = $user->id;
             $infos['username'] = $user->username;
             $infos['name'] = $user->name;
             $infos['email'] = $user->email;
         }
     }
     return $infos;
 }
开发者ID:madseller,项目名称:coperio,代码行数:30,代码来源:jincjoomlahelper.php

示例13: storeAttributeForm

 function storeAttributeForm()
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     jincimport('utility.servicelocator');
     jincimport('utility.jsonresponse');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     $dbo = $this->getDbo();
     $query = $dbo->getQuery(true);
     $query->select('name, description, type, name_i18n');
     $query->from('`#__jinc_attribute`');
     $dbo->setQuery($query);
     $logger->debug('JINCModelAttributes: Executing query: ' . $query->__toString());
     $xmlstring = '<?xml version="1.0" encoding="utf-8"?>';
     $xmlstring .= '<form>';
     $xmlstring .= '   <fields name="attribs">';
     $xmlstring .= '      <fieldset name="addictional" label="COM_JINC_ATTRIBUTES">';
     if ($attributes = $dbo->loadAssocList()) {
         foreach ($attributes as $key => $attribute) {
             $xmlstring .= '         <field name="' . $attribute['name'] . '" type="list" label="' . $attribute['name_i18n'] . '"';
             $xmlstring .= '            description="' . $attribute['description'] . '" Default="">';
             $xmlstring .= '            <option value="">COM_JINC_ATTRIBUTE_NONE</option>';
             $xmlstring .= '            <option value="1">COM_JINC_ATTRIBUTE_MANDATORY</option>';
             $xmlstring .= '            <option value="2">COM_JINC_ATTRIBUTE_OPTIONAL</option>';
             $xmlstring .= '         </field>';
             $xmlstring .= '';
         }
     }
     $xmlstring .= '      </fieldset>';
     $xmlstring .= '   </fields>';
     $xmlstring .= '</form>';
     $filename = JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'forms' . DIRECTORY_SEPARATOR . 'attributes.xml';
     if ($fh = fopen($filename, 'w+')) {
         $logger->debug('Recreating file ' . $filename);
         fwrite($fh, $xmlstring);
         fclose($fh);
     } else {
         $logger->error('Unable to write file ' . $filename);
     }
 }
开发者ID:sulicz,项目名称:JINC_J30,代码行数:41,代码来源:attributes.php

示例14: emogrify

 function emogrify($toemogrify)
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     $body = $toemogrify;
     if ($newsletter = $this->loadNewsletter()) {
         if ($this->tem_id != 0) {
             $template = $this->loadTemplate();
             if (!empty($template)) {
                 $logger->debug(get_class($this) . ': emogrifing message.');
                 jincimport('utility.emogrifier');
                 $emogrifier = new Emogrifier($body, $template->getCSSFileContent());
                 $body = $emogrifier->emogrify();
             }
         }
     }
     return $body;
 }
开发者ID:sulicz,项目名称:JINC_J30,代码行数:19,代码来源:message.php

示例15: deleteReport

 function deleteReport($proc_id)
 {
     jincimport('core.messagefactory');
     jincimport('utility.jsonresponse');
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     $response = new JSONResponse();
     $minstance = MessageFactory::getInstance();
     if ($minstance->deleteReport($proc_id)) {
         $response->set('status', 0);
     } else {
         $response->set('status', -1);
     }
     $logger->debug('JSON: ' . $response->toString());
     return $response->toString();
 }
开发者ID:sulicz,项目名称:JINC_J30,代码行数:17,代码来源:message.php


注:本文中的ServiceLocator::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。