Esempio n. 1
0
 /**
  * function to rewrite the path of the file if the file doesn't exist
  * @param type $mofile
  * @param type $domain
  * @return type
  */
 public static function load_textdomain_mofile($mofile, $domain)
 {
     $extensionloaded = WYSIJA::load_lang('get_all');
     if (isset($extensionloaded[$domain]) && !file_exists($mofile)) {
         return WYSIJA_PLG_DIR . $domain . DS . 'languages' . DS . $extensionloaded[$domain] . '-' . get_locale() . '.mo';
     }
     return $mofile;
 }
Esempio n. 2
0
 /**
  * function to generate objects of different types, managing file requiring in order to be the most efficient
  * @staticvar array $arrayOfObjects
  * @param type $name
  * @param type $type
  * @return type
  */
 public static function get($name, $type, $forceside = false, $extendedplugin = 'wysija-newsletters')
 {
     static $arrayOfObjects;
     WYSIJA::load_lang($extendedplugin);
     /*store all the objects made so that we can reuse them accross the application*/
     if (isset($arrayOfObjects[$extendedplugin][$type . $name])) {
         return $arrayOfObjects[$extendedplugin][$type . $name];
     }
     if ($forceside) {
         $side = $forceside;
     } else {
         $side = WYSIJA_SIDE;
     }
     if ($extendedplugin == 'wysija-newsletters') {
         $extendeconstant = strtoupper("wysija");
         if (!defined($extendeconstant)) {
             define($extendeconstant, $extendeconstant);
         }
         $extendedpluginname = 'wysija';
     } else {
         $extendeconstant = strtoupper($extendedplugin);
         if (!defined($extendeconstant)) {
             define($extendeconstant, $extendeconstant);
         }
         $extendedpluginname = $extendedplugin;
     }
     //security to protect against ./../ includes
     $name = preg_replace('#[^a-z0-9_]#i', '', $name);
     switch ($type) {
         case 'controller':
             $ctrdir = WYSIJA_PLG_DIR . $extendedplugin . DS . 'controllers' . DS;
             /*require the parent class necessary*/
             require_once WYSIJA_CORE . 'controller.php';
             /*require the common controller file*/
             if (defined('DOING_AJAX')) {
                 $classpath = $ctrdir . 'ajax' . DS . $name . '.php';
             } else {
                 $classpath = $ctrdir . $side . DS . $name . '.php';
                 require_once WYSIJA_CTRL . $side . '.php';
                 /*require the side specific controller file*/
             }
             $classname = strtoupper($extendedpluginname) . '_control_' . $side . '_' . $name;
             break;
         case 'view':
             $viewdir = WYSIJA_PLG_DIR . $extendedplugin . DS . 'views' . DS;
             $classpath = $viewdir . $side . DS . $name . ".php";
             $classname = strtoupper($extendedpluginname) . '_view_' . $side . '_' . $name;
             require_once WYSIJA_CORE . 'view.php';
             /*require the common view file*/
             require_once WYSIJA_VIEWS . $side . '.php';
             /*require the side specific view file*/
             break;
         case 'helper':
             $helpdir = WYSIJA_PLG_DIR . $extendedplugin . DS . 'helpers' . DS;
             $classpath = $helpdir . $name . '.php';
             $classname = strtoupper($extendedpluginname) . '_help_' . $name;
             break;
         case 'model':
             $modeldir = WYSIJA_PLG_DIR . $extendedplugin . DS . 'models' . DS;
             $classpath = $modeldir . $name . '.php';
             $classname = strtoupper($extendedpluginname) . '_model_' . $name;
             /*require the parent class necessary*/
             require_once WYSIJA_CORE . 'model.php';
             break;
         default:
             WYSIJA::setInfo('error', 'WYSIJA::get does not accept this type of file "' . $type . '" .');
             return false;
     }
     if (!file_exists($classpath)) {
         WYSIJA::setInfo('error', 'file has not been recognised ' . $classpath);
         return;
     }
     require_once $classpath;
     return $arrayOfObjects[$extendedplugin][$type . $name] = new $classname($extendedpluginname);
 }