Ejemplo n.º 1
0
 /**
  * Loads the gadget model file in question, makes a instance and
  * stores it globally for later use so we do not have duplicates
  * of the same instance around in our code.
  *
  * @access  public
  * @return  mixed   Model class object on successful, Jaws_Error otherwise
  */
 public function &loadInstaller()
 {
     $classname = $this->gadget->name . '_Installer';
     $file = JAWS_PATH . 'gadgets/' . $this->gadget->name . '/Installer.php';
     if (!file_exists($file)) {
         return Jaws_Error::raiseError("File [{$file}] not exists!", __FUNCTION__);
     }
     include_once $file;
     if (!Jaws::classExists($classname)) {
         return Jaws_Error::raiseError("Class [{$classname}] not exists!", __FUNCTION__);
     }
     $objInstaller = new $classname($this->gadget);
     return $objInstaller;
 }
Ejemplo n.º 2
0
 /**
  * Loads the gadget hook file class in question, makes a instance and
  * stores it globally for later use so we do not have duplicates
  * of the same instance around in our code.
  *
  * @access  public
  * @param   string  $hook  Hook name
  * @return  mixed   Hook class object on successful, Jaws_Error otherwise
  */
 public function &load($hook)
 {
     // filter non validate character
     $hook = preg_replace('/[^[:alnum:]_]/', '', $hook);
     if (!isset($this->objects[$hook])) {
         $classname = $this->gadget->name . '_Hooks_' . $hook;
         $file = JAWS_PATH . 'gadgets/' . $this->gadget->name . "/Hooks/{$hook}.php";
         if (!file_exists($file)) {
             return Jaws_Error::raiseError("File [{$file}] not exists!", __FUNCTION__);
         }
         include_once $file;
         if (!Jaws::classExists($classname)) {
             return Jaws_Error::raiseError("Class [{$classname}] not exists!", __FUNCTION__);
         }
         $this->objects[$hook] = new $classname($this->gadget);
         $GLOBALS['log']->Log(JAWS_LOG_DEBUG, "Loaded gadget hook: [{$classname}]");
     }
     return $this->objects[$hook];
 }
Ejemplo n.º 3
0
 /**
  * Loads the gadget model file in question, makes a instance and
  * stores it globally for later use so we do not have duplicates
  * of the same instance around in our code.
  *
  * @access  public
  * @param   string  $filename   Model class file name
  * @return  mixed   Model class object on successful, Jaws_Error otherwise
  */
 public function &loadAdmin($filename = '')
 {
     // filter non validate character
     $filename = preg_replace('/[^[:alnum:]_]/', '', $filename);
     if (!isset($this->objects['AdminModel'][$filename])) {
         if (empty($filename)) {
             $classname = $this->gadget->name . '_AdminModel';
             $file = JAWS_PATH . 'gadgets/' . $this->gadget->name . '/AdminModel.php';
             if (!file_exists($file)) {
                 return $this;
             }
         } else {
             $classname = $this->gadget->name . "_Model_Admin_{$filename}";
             $file = JAWS_PATH . 'gadgets/' . $this->gadget->name . "/Model/Admin/{$filename}.php";
         }
         if (!file_exists($file)) {
             return Jaws_Error::raiseError("File [{$file}] not exists!", __FUNCTION__);
         }
         include_once $file;
         if (!Jaws::classExists($classname)) {
             return Jaws_Error::raiseError("Class [{$classname}] not exists!", __FUNCTION__);
         }
         $this->objects['AdminModel'][$filename] = new $classname($this->gadget);
         $GLOBALS['log']->Log(JAWS_LOG_DEBUG, "Loaded gadget model: [{$classname}]");
     }
     return $this->objects['AdminModel'][$filename];
 }
Ejemplo n.º 4
0
 /**
  * Parses the input text
  *
  * @access  public
  * @param   string  $text           The Text to parse
  * @param   string  $gadget         The Gadget name
  * @param   string  $plugins_set    Plugins set name(admin or index)
  * @return  string  Returns the parsed text
  */
 function ParseText($text, $gadget = '', $plugins_set = 'admin')
 {
     $res = $text;
     $gadget = empty($gadget) ? $this->name : $gadget;
     $plugins = $GLOBALS['app']->Registry->fetch('plugins_installed_items');
     if (!Jaws_Error::isError($plugins) && !empty($plugins)) {
         $plugins = array_filter(explode(',', $plugins));
         foreach ($plugins as $plugin) {
             $objPlugin = $GLOBALS['app']->LoadPlugin($plugin);
             if (!Jaws_Error::IsError($objPlugin)) {
                 $use_in = '*';
                 if ($plugins_set == 'admin') {
                     $use_in = $GLOBALS['app']->Registry->fetch('backend_gadgets', $plugin);
                 } else {
                     $use_in = $GLOBALS['app']->Registry->fetch('frontend_gadgets', $plugin);
                 }
                 if (!Jaws_Error::isError($use_in) && ($use_in == '*' || in_array($gadget, explode(',', $use_in)))) {
                     $res = $objPlugin->ParseText($res);
                 }
             }
         }
     }
     //So we don't call require_once each time we invoke it
     if (!Jaws::classExists('Jaws_String')) {
         require JAWS_PATH . 'include/Jaws/String.php';
     }
     $res = Jaws_String::AutoParagraph($res);
     return $res;
 }
Ejemplo n.º 5
0
 /**
  * Loads the plugin file in question, makes a instance and
  * stores it globally for later use so we do not have duplicates
  * of the same instance around in our code.
  *
  * @access  public
  * @param   string $plugin Name of the plugin
  * @return  mixed Plugin class object on successful, Jaws_Error otherwise
  */
 function LoadPlugin($plugin)
 {
     // filter non validate character
     $plugin = preg_replace('/[^[:alnum:]_]/', '', $plugin);
     if (!isset($this->_Plugins[$plugin])) {
         if (!is_dir(JAWS_PATH . 'plugins/' . $plugin)) {
             $error = new Jaws_Error(_t('GLOBAL_ERROR_PLUGIN_DOES_NOT_EXIST', $plugin), 'Plugin directory check');
             return $error;
         }
         // is plugin available?
         if (defined('JAWS_AVAILABLE_PLUGINS')) {
             static $available_plugins;
             if (!isset($available_plugins)) {
                 $available_plugins = array_filter(array_map('trim', explode(',', JAWS_AVAILABLE_PLUGINS)));
             }
             if (!in_array($plugin, $available_plugins)) {
                 $error = new Jaws_Error(_t('GLOBAL_ERROR_PLUGIN_NOT_AVAILABLE', $plugin), 'Plugin availability check');
                 return $error;
             }
         }
         $file = JAWS_PATH . 'plugins/' . $plugin . '/Plugin.php';
         if (file_exists($file)) {
             include_once $file;
         }
         $plugin_class = $plugin . '_Plugin';
         if (!Jaws::classExists($plugin_class)) {
             // return a error
             $error = new Jaws_Error(_t('GLOBAL_ERROR_CLASS_DOES_NOT_EXIST', $plugin_class), 'Plugin class check');
             return $error;
         }
         $objPlugin = new $plugin_class($plugin);
         if (Jaws_Error::IsError($objPlugin)) {
             $error = new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_INSTANCE', $file, $plugin_class), 'Plugin file loading');
             return $error;
         }
         $this->_Plugins[$plugin] = $objPlugin;
         $GLOBALS['log']->Log(JAWS_LOG_DEBUG, 'Loaded plugin: ' . $plugin);
     }
     return $this->_Plugins[$plugin];
 }
Ejemplo n.º 6
0
<?php

/**
 * Initiates Piwi Project.
 *
 * @category   Application
 * @package    Core
 * @author     Ali Fazelzadeh <*****@*****.**>
 * @copyright  2007-2014 Jaws Development Group
 * @license    http://www.gnu.org/copyleft/lesser.html
 */
if (!Jaws::classExists('Piwi')) {
    if (!defined('PIWI_URL')) {
        define('PIWI_URL', 'libraries/piwi/');
    }
    if (!defined('PIWI_CREATE_PIWIXML')) {
        define('PIWI_CREATE_PIWIXML', 'no');
    }
    if (!defined('PIWI_LOAD')) {
        define('PIWI_LOAD', 'SMART');
    }
    require JAWS_PATH . 'libraries/piwi/Piwi.php';
    $config = array('LINK_PRIFIX' => '', 'DATAGRID_ACTION_LABEL' => _t('GLOBAL_ACTIONS'), 'DATAGRID_PAGER_PAGEBY' => 10, 'DATAGRID_PAGER_MODE' => 'PIWI_PAGER_NORMAL', 'CLASS_ODD' => 'piwi_option_odd', 'CLASS_EVEN' => 'piwi_option_even', 'DATAGRID_CLASS_CSS' => 'jawsDatagrid', 'DATAGRID_PAGER_LABEL_FIRST' => _t('GLOBAL_FIRST'), 'DATAGRID_PAGER_LABEL_PREV' => _t('GLOBAL_PREVIOUS'), 'DATAGRID_PAGER_LABEL_NEXT' => _t('GLOBAL_NEXT'), 'DATAGRID_PAGER_LABEL_LAST' => _t('GLOBAL_LAST'), 'PIWI_NAME_AS_ID' => true);
    Piwi::exportConf($config);
}