public function indexAction() { $request = $this->getRequest(); $goodies = Model_Pages::getPage(Helper_Config::get('page_goodies')); $pin_text = $this->translate('Pyng images from any website as you browse the web with the %s"Pyng It" button.%s'); if ($goodies) { $this->view->pin_text = sprintf($pin_text, '<a href="' . WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=pages&action=read&page_id=' . Helper_Config::get('page_goodies')) . '">', '</a>'); } $methods = glob(dirname(__FILE__) . '/Addpin/*.php'); $this->view->methods = array(); if ($methods) { $front = $this->getFrontController(); foreach ($methods as $row => $method) { $controller = basename($method, 'Controller.php'); if ($controller) { $name = $front->formatControllerName('addpin_' . strtolower($controller)); if (!class_exists($name, true)) { JO_Loader::loadClass($name); } $instance = new $name(); $this->view->methods[isset($instance->SORT) ? $instance->SORT : 0] = $this->view->callChildren('addpin_' . strtolower($controller)); } } } ksort($this->view->methods); $this->view->popup_main_box = $this->view->render('popup_main', 'addpin'); if ($request->isXmlHttpRequest()) { $this->noViewRenderer(true); echo $this->view->popup_main_box; } else { $this->forward('error', 'error404'); } }
/** * @param string|object $object * @return multitype: */ public static function getControllerResources($controller) { $front = JO_Front::getInstance(); $controller_name = $front->formatControllerName($controller); if ($front->isDispatchable($controller)) { JO_Loader::setIncludePaths(array($front->getDispatchDirectory())); JO_Loader::loadFile($front->classToFilename($controller_name), null, true); if (version_compare(PHP_VERSION, '5.2.6') === -1) { $class = new ReflectionObject(new $controller_name()); $classMethods = $class->getMethods(); $methodNames = array(); foreach ($classMethods as $method) { $methodNames[] = $method->getName(); } } else { $methodNames = get_class_methods(new $controller_name()); } $_classResources = array(); foreach ($methodNames as $method) { if (6 < strlen($method) && 'Action' === substr($method, -6)) { $_classResources[substr($method, 0, -6)] = substr($method, 0, -6); } } return $_classResources; } return array(); }
public function autocompleteAction() { $request = $this->getRequest(); $this->view->items = array(); if (JO_Session::get('user[user_id]') && $request->getPost('value')) { $methods = glob(dirname(__FILE__) . '/Search/*.php'); if ($methods) { foreach ($methods as $file) { $controller = basename($file, '.php'); $class_name = 'Search_' . $controller; if (!class_exists($class_name, false)) { JO_Loader::loadFile($file); } $class = new $class_name(); if (method_exists($class, 'autocomplete')) { $this->view->items = array_merge($this->view->items, $class->autocomplete($request->getPost('value'))); } } } } $this->view->items[] = array('template' => 'global', 'label' => sprintf($this->translate('Search for %s'), $request->getPost('value')), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=search&q=' . $request->getPost('value'))); if ($request->isXmlHttpRequest()) { echo $this->renderScript('json'); } else { $this->forward('error', 'error404'); } }
public static function setClassName($registryClassName = 'JO_Registry') { if (self::$_registry !== null) { throw new Exception('Registry is already initialized'); } if (!is_string($registryClassName)) { throw new Exception("Argument is not a class name"); } if (!class_exists($registryClassName)) { require_once 'JO_Loader.php'; JO_Loader::loadClass($registryClassName); } self::$_registryClassName = $registryClassName; }
public function __construct() { $request = JO_Request::getInstance(); parent::__construct(); if (Model_Allowips::getTotalWords()) { if (!Model_Allowips::getTotalWords(array('filete_ip' => $request->getClientIp()))) { if (!in_array($request->getController(), array('login', 'error'))) { $this->forward('error', 'noPermission'); } } } //set default timezone if is not set if (!ini_get('date.timezone')) { ini_set('date.timezone', 'UTC'); } WM_Users::initSession(JO_Session::get('user[user_id]')); if (!JO_Session::get('user[user_id]')) { JO_Session::set('user', array('user_id' => 0)); } //admin check login $login_page = $request->getController() != 'login'; if (JO_Session::get('user[is_developer]')) { $login_page = false; } else { if (JO_Session::get('user[is_admin]')) { $login_page = false; } } if (in_array($request->getController(), array('login', 'error'))) { $login_page = false; } if ($login_page) { $this->forward('login', 'index'); } //admin top menu Helper_Config::set('adminmenupermisions', WM_Users::initPermision()); //no permisions $controller_name = JO_Front::getInstance()->formatControllerName($request->getController()); if (!class_exists($controller_name, false)) { JO_Loader::loadFile(APPLICATION_PATH . '/modules/' . $request->getModule() . '/controllers/' . JO_Front::getInstance()->classToFilename($controller_name)); } if (method_exists($controller_name, 'config')) { $data = call_user_func(array($controller_name, 'config')); if (isset($data['has_permision']) && $data['has_permision'] && !WM_Users::allow('read', $request->getController())) { $this->forward('error', 'noPermission'); } } WM_Rebuild::getInformation(); WM_Licensecheck::checkIt(); }
public function noPermissionAction() { $request = JO_Request::getInstance(); $forwarded = $request->getParam('forwarded'); if (!$forwarded) { $forwarded = $request->getController(); } $controller_name = JO_Front::getInstance()->formatControllerName($forwarded); if (!class_exists($controller_name, false)) { JO_Loader::loadFile(APPLICATION_PATH . '/modules/' . $request->getModule() . '/controllers/' . JO_Front::getInstance()->classToFilename($controller_name)); } if (method_exists($controller_name, 'config')) { $data = call_user_func(array($controller_name, 'config')); if (isset($data['name']) && $data['name']) { $controller_name = $data['name']; } } $this->view->moduleName = $controller_name; $this->view->fullUrl = $request->getFullUrl(); }
public function __construct($children, $param = '') { $object = $method = ''; if (is_array($children)) { $object = $children[0]; $method = isset($children[1]) ? $children[1] : 'index'; } elseif (preg_match('/^([a-z0-9_]{1,})(->|::|\\/)?([a-z0-9_]{1,})?$/i', $children, $match)) { $object = $match[1]; $method = isset($match[3]) && $match[3] ? $match[3] : false; } if ($object) { $object = $this->_formatName($object); if (!class_exists($object, false)) { JO_Loader::loadClass($object); } $class = new $object($param); if ($method) { parent::__construct($class->{$method}($param)); } else { return $class; } } }
public function dispatch($controller = null, $action = null, $params = array()) { $this->setHelpersPath(); $controller = $controller ? $controller : $this->getRequest()->getController(); $response = JO_Response::getInstance(); if (!$this->isDispatchable($controller) && $this->isDispatchable('error')) { $controller = 'error'; $action = 'error404'; } if ($this->isDispatchable($controller)) { JO_Loader::setIncludePaths(array($this->getDispatchDirectory())); $className = $this->formatControllerName($controller); JO_Loader::loadFile($this->classToFilename($className), null, true); $controller_instance = new $className($this->getRequest()); if (!$controller_instance instanceof JO_Action) { require_once 'JO/Exception.php'; throw new JO_Exception('Controller "' . $className . '" is not an instance of JO_Action'); } $action = $action ? $action : $this->getRequest()->getAction(); // by default, buffer output $disableOb = $this->getParam('disableOutputBuffering'); $obLevel = ob_get_level(); if (empty($disableOb)) { ob_start(); } try { $controller_instance->dispatch($controller, $action, $params); } catch (Exception $e) { // Clean output buffer on error $curObLevel = ob_get_level(); if ($curObLevel > $obLevel) { do { ob_get_clean(); $curObLevel = ob_get_level(); } while ($curObLevel > $obLevel); } throw $e; } if (empty($disableOb)) { $content = ob_get_clean(); $response->appendBody($content); } // Destroy the page controller instance and reflection objects $controller_instance = null; } else { $controller_instance = new JO_Action(); $controller_instance->dispatch($controller, 'error404'); // Destroy the page controller instance and reflection objects $controller_instance = null; // require_once 'JO/Exception.php'; // throw new JO_Exception( // 'Controller "' . $controller . '" is not found' // ); } }
/** * Constructor. * * @param array $config */ public function __construct(array $config) { if (isset($config['table'])) { $this->_table = $config['table']; $this->_tableClass = get_class($this->_table); } if (isset($config['rowClass'])) { $this->_rowClass = $config['rowClass']; } if (!class_exists($this->_rowClass)) { require_once 'JO/Loader.php'; JO_Loader::loadClass($this->_rowClass); } if (isset($config['data'])) { $this->_data = $config['data']; } if (isset($config['readOnly'])) { $this->_readOnly = $config['readOnly']; } if (isset($config['stored'])) { $this->_stored = $config['stored']; } // set the count of rows $this->_count = count($this->_data); $this->init(); }
public function paymentAction() { $request = $this->getRequest(); if (!JO_Session::get('user_id')) { JO_Session::set('msg_error', $this->translate('You must be logged to access that page!')); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login')); } $this->view->title = $this->translate('Deposit pre-paid cash'); if ($request->isPost()) { if ($request->issetPost('amount')) { $amount = $request->getPost('amount'); $image_model = new Helper_Images(); $files = glob(dirname(__FILE__) . '/Payments/*.php'); if ($files) { foreach ($files as $file) { if (preg_match('/^([\\w]{1,})Controller$/i', basename($file, '.php'), $match)) { $key = mb_strtolower($match[1], 'utf-8'); if ($request->issetPost($key)) { $depositID = Model_Deposit::addDeposit($amount); if ($depositID) { JO_Session::set('deposit_id', $depositID); if (JO_Registry::forceGet($key . '_status')) { JO_Loader::loadFile($file); $form = $this->view->callChildren('payments_' . $key . '/depositForm'); if ($form) { $logo = JO_Registry::forceGet($key . '_logo'); if ($logo) { list($width) = getimagesize('uploads/' . $logo); if ($width > 300) { $logo = $image_model->resizeWidth($logo, 300); } else { $logo = 'uploads/' . $logo; } } else { $logo = ''; } $this->view->payment = array('key' => $key, 'edit' => $request->getModule() . '/payments_' . $key, 'name' => $this->translate($match[1]), 'logo' => $logo, 'description' => $this->view->callChildren('payments_' . $key . '/description'), 'form' => $form); break; } } } } } } } } } $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Profile'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username'))), array('name' => $this->translate('Deposit'))); $this->view->total = WM_Currency::format(JO_Session::get('total')); $this->view->children = array(); $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; }
public static function initPermision() { $request = JO_Request::getInstance(); if ($request->getModule() == 'admin' && JO_Session::get('user[is_admin]')) { $files = glob(APPLICATION_PATH . '/modules/' . $request->getModule() . '/controllers/*.php'); $temporary_for_menu = array(); $temporary_for_permision = array(); $sort_order = $sort_order2 = array(); if ($files) { foreach ($files as $d => $file) { $name = basename($file, '.php'); JO_Loader::loadFile($file); if (method_exists($name, 'config')) { $data = call_user_func(array($name, 'config')); if (!isset($data['has_permision']) || !$data['has_permision']) { continue; } if (!$data['in_menu'] || !WM_Users::allow('read', $data['permision_key'])) { continue; } if (isset($sort_order2[$data['menu']])) { $sort_order2[$data['menu']] = min($sort_order[$data['menu']], (int) (isset($data['sort_order']) ? $data['sort_order'] : 0)); } else { $sort_order2[$data['menu']] = (int) (isset($data['sort_order']) ? $data['sort_order'] : 0); } $sort_order[$data['menu']][$d] = (int) (isset($data['sort_order']) ? $data['sort_order'] : 0); $temporary_for_menu[$data['menu']][$d] = array('name' => $data['name'], 'key' => $data['permision_key'], 'has_permision' => $data['has_permision'], 'menu' => $data['menu'], 'href' => $request->getBaseUrl() . $request->getModule() . '/' . (strtolower($name) != 'indexcontroller' ? str_replace('controller', '', strtolower($name)) . '/' : '')); } } } array_multisort($sort_order2, SORT_ASC, $temporary_for_menu); foreach ($temporary_for_menu as $k => $t) { array_multisort($sort_order[$k], SORT_ASC, $temporary_for_menu[$k]); } return $temporary_for_menu; } }
/** * Factory for JO_Db_Adapter_Abstract classes. * * First argument may be a string containing the base of the adapter class * name, e.g. 'Mysqli' corresponds to class JO_Db_Adapter_Mysqli. This * name is currently case-insensitive, but is not ideal to rely on this behavior. * If your class is named 'My_Company_Pdo_Mysql', where 'My_Company' is the namespace * and 'Pdo_Mysql' is the adapter name, it is best to use the name exactly as it * is defined in the class. This will ensure proper use of the factory API. * * First argument may alternatively be an object of type JO_Config. * The adapter class base name is read from the 'adapter' property. * The adapter config parameters are read from the 'params' property. * * Second argument is optional and may be an associative array of key-value * pairs. This is used as the argument to the adapter constructor. * * If the first argument is of type JO_Config, it is assumed to contain * all parameters, and the second argument is ignored. * * @param mixed $adapter String name of base adapter class, or JO_Config object. * @param mixed $config OPTIONAL; an array or JO_Config object with adapter parameters. * @return JO_Db_Adapter_Abstract * @throws JO_Db_Exception */ public static function factory($adapter, $config = array()) { if ($config instanceof JO_Config) { $config = $config->toArray(); } /* * Convert JO_Config argument to plain string * adapter name and separate config object. */ if ($adapter instanceof JO_Config) { if (isset($adapter->params)) { $config = $adapter->params->toArray(); } if (isset($adapter->adapter)) { $adapter = (string) $adapter->adapter; } else { $adapter = null; } } /* * Verify that adapter parameters are in an array. */ if (!is_array($config)) { /** * @see JO_Db_Exception */ require_once 'JO/Db/Exception.php'; throw new JO_Db_Exception('Adapter parameters must be in an array or a JO_Config object'); } /* * Verify that an adapter name has been specified. */ if (!is_string($adapter) || empty($adapter)) { /** * @see JO_Db_Exception */ require_once 'JO/Db/Exception.php'; throw new JO_Db_Exception('Adapter name must be specified in a string'); } /* * Form full adapter class name */ $adapterNamespace = 'JO_Db_Adapter'; if (isset($config['adapterNamespace'])) { if ($config['adapterNamespace'] != '') { $adapterNamespace = $config['adapterNamespace']; } unset($config['adapterNamespace']); } // Adapter no longer normalized- see http://framework.zend.com/issues/browse/ZF-5606 $adapterName = $adapterNamespace . '_'; $adapterName .= str_replace(' ', '_', ucwords(str_replace('_', ' ', strtolower($adapter)))); /* * Load the adapter class. This throws an exception * if the specified class cannot be loaded. */ if (!class_exists($adapterName)) { require_once 'JO/Loader.php'; JO_Loader::loadClass($adapterName); } /* * Create an instance of the adapter class. * Pass the config to the adapter class constructor. */ self::$dbAdapter_name = $adapterName; self::$dbAdapter = new $adapterName($config); /* * Verify that the object created is a descendent of the abstract adapter type. */ if (!self::$dbAdapter instanceof JO_Db_Adapter_Abstract) { /** * @see JO_Db_Exception */ require_once 'JO/Db/Exception.php'; throw new JO_Db_Exception("Adapter class '{$adapterName}' does not extend JO_Db_Adapter_Abstract"); } return self::$dbAdapter; }
public function _initNoPermision() { $request = JO_Request::getInstance(); if ($request->getModule() == 'install') { return ''; } if ($request->getModule() == 'admin') { $controller_name = JO_Front::getInstance()->formatControllerName($request->getController()); if (!class_exists($controller_name, false)) { JO_Loader::loadFile(APPLICATION_PATH . '/modules/' . $request->getModule() . '/controllers/' . JO_Front::getInstance()->classToFilename($controller_name)); } if (method_exists($controller_name, 'config')) { $data = call_user_func(array($controller_name, 'config')); if ($data['has_permision'] && !WM_Users::allow('read', $request->getController())) { JO_Action::getInstance()->forward('error', 'noPermission'); } } } }
public static function initPermision() { $request = JO_Request::getInstance(); $temporary_for_permision = array(); $files = glob(APPLICATION_PATH . '/modules/' . $request->getModule() . '/controllers/*.php'); if ($files) { foreach ($files as $d => $file) { if (preg_match('/(.*)\\/(.*)Controller.php/i', $file, $match)) { $name = basename($file, '.php'); if (!class_exists($name, false)) { JO_Loader::loadFile($file); } if (method_exists($name, 'config')) { $data = call_user_func(array($name, 'config')); if (isset($data['has_permision']) && $data['has_permision'] === true) { $temporary_for_permision[] = array('name' => $data['name'], 'key' => mb_strtolower($match[2])); } } } } } return $temporary_for_permision; }
/** * Returns an SQL statement for preparation. * * @param string $sql The SQL statement with placeholders. * @return JO_Db_Statement_Sqlsrv */ public function prepare($sql) { $this->_connect(); $stmtClass = $this->_defaultStmtClass; if (!class_exists($stmtClass)) { /** * @see JO_Loader */ require_once 'JO/Loader.php'; JO_Loader::loadClass($stmtClass); } $stmt = new $stmtClass($this, $sql); $stmt->setFetchMode($this->_fetchMode); return $stmt; }
/** * Set the adapter's profiler object. * * The argument may be a boolean, an associative array, an instance of * JO_Db_Profiler, or an instance of JO_Config. * * A boolean argument sets the profiler to enabled if true, or disabled if * false. The profiler class is the adapter's default profiler class, * JO_Db_Profiler. * * An instance of JO_Db_Profiler sets the adapter's instance to that * object. The profiler is enabled and disabled separately. * * An associative array argument may contain any of the keys 'enabled', * 'class', and 'instance'. The 'enabled' and 'instance' keys correspond to the * boolean and object types documented above. The 'class' key is used to name a * class to use for a custom profiler. The class must be JO_Db_Profiler or a * subclass. The class is instantiated with no constructor arguments. The 'class' * option is ignored when the 'instance' option is supplied. * * An object of type JO_Config may contain the properties 'enabled', 'class', and * 'instance', just as if an associative array had been passed instead. * * @param JO_Db_Profiler|JO_Config|array|boolean $profiler * @return JO_Db_Adapter_Abstract Provides a fluent interface * @throws JO_Db_Profiler_Exception if the object instance or class specified * is not JO_Db_Profiler or an extension of that class. */ public function setProfiler($profiler) { $enabled = null; $profilerClass = $this->_defaultProfilerClass; $profilerInstance = null; if ($profilerIsObject = is_object($profiler)) { if ($profiler instanceof JO_Db_Profiler) { $profilerInstance = $profiler; } else { if ($profiler instanceof JO_Config) { $profiler = $profiler->toArray(); } else { /** * @see JO_Db_Profiler_Exception */ require_once 'JO/Db/Profiler/Exception.php'; throw new JO_Db_Profiler_Exception('Profiler argument must be an instance of either JO_Db_Profiler' . ' or JO_Config when provided as an object'); } } } if (is_array($profiler)) { if (isset($profiler['enabled'])) { $enabled = (bool) $profiler['enabled']; } if (isset($profiler['class'])) { $profilerClass = $profiler['class']; } if (isset($profiler['instance'])) { $profilerInstance = $profiler['instance']; } } else { if (!$profilerIsObject) { $enabled = (bool) $profiler; } } if ($profilerInstance === null) { if (!class_exists($profilerClass)) { require_once 'JO/Loader.php'; JO_Loader::loadClass($profilerClass); } $profilerInstance = new $profilerClass(); } if (!$profilerInstance instanceof JO_Db_Profiler) { /** @see JO_Db_Profiler_Exception */ require_once 'JO/Db/Profiler/Exception.php'; throw new JO_Db_Profiler_Exception('Class ' . get_class($profilerInstance) . ' does not extend ' . 'JO_Db_Profiler'); } if (null !== $enabled) { $profilerInstance->setEnabled($enabled); } $this->_profiler = $profilerInstance; return $this; }
public function paymentAction() { $request = $this->getRequest(); if (!JO_Session::get('user_id')) { JO_Session::set('msg_error', $this->translate('You must be logged to change your profile')); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login')); } if ($request->isPost() && $request->issetPost('item_id')) { $item = Model_Items::get($request->getPost('item_id')); if ($request->getPost('licence') == 'personal') { $orderID = Model_Orders::add($item); } elseif ($request->getPost('licence') == 'extended') { $orderID = Model_Orders::add($item, 'true'); } JO_Session::set('order_id', $orderID); $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Profile'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username')))), array('name' => $this->translate('Payment'))); $model_images = new Model_Images(); $files = glob(dirname(__FILE__) . '/Payments/*.php'); if ($files) { $payments_data = $sort_order = $order_obj = array(); foreach ($files as $row => $file) { if (preg_match('/^([\\w]{1,})Controller$/i', basename($file, '.php'), $match)) { $key = mb_strtolower($match[1], 'utf-8'); if (JO_Registry::forceGet($key . '_status')) { JO_Loader::loadFile($file); $form = $this->view->callChildren('payments_' . $key . '/itemForm'); if ($form) { $sort_order[$row] = (int) JO_Registry::forceGet($key . '_sort_order'); $logo = JO_Registry::forceGet($key . '_logo'); if ($logo) { list($width) = getimagesize('uploads/' . $logo); if ($width > 300) { $logo = $image_model->resizeWidth($logo, 300); } else { $logo = 'uploads/' . $logo; } } else { $logo = ''; } $payments_data[$row] = array('key' => $key, 'edit' => $request->getModule() . '/payments_' . $key, 'name' => $this->translate($match[1]), 'sort' => (int) JO_Registry::forceGet($key . '_sort_order'), 'logo' => JO_Registry::forceGet($key . '_logo') ? 'uploads/' . JO_Registry::forceGet($key . '_logo') : '', 'form' => $form); } } } } array_multisort($sort_order, SORT_ASC, $payments_data); $this->view->payments = $payments_data; } } else { $this->redirect($request->getServer('HTTP_REFERER')); } $this->view->usertotal = WM_Currency::format(JO_Session::get('total')); $this->view->children = array(); $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; }
/** * _getTableFromString * * @param string $tableName * @return JO_Db_Table_Abstract */ protected function _getTableFromString($tableName) { if ($this->_table instanceof JO_Db_Table_Abstract) { $tableDefinition = $this->_table->getDefinition(); if ($tableDefinition !== null && $tableDefinition->hasTableConfig($tableName)) { return new JO_Db_Table($tableName, $tableDefinition); } } // assume the tableName is the class name if (!class_exists($tableName)) { try { require_once 'JO/Loader.php'; JO_Loader::loadClass($tableName); } catch (JO_Exception $e) { require_once 'JO/Db/Table/Row/Exception.php'; throw new JO_Db_Table_Row_Exception($e->getMessage(), $e->getCode(), $e); } } $options = array(); if ($table = $this->_getTable()) { $options['db'] = $table->getAdapter(); } if (isset($tableDefinition) && $tableDefinition !== null) { $options[JO_Db_Table_Abstract::DEFINITION] = $tableDefinition; } return new $tableName($options); }
public function callChildrenView($children, $param = '') { $controller = $action = ''; if (is_array($children)) { $controller = $children[0]; $action = isset($children[1]) ? $children[1] : 'index'; } elseif (preg_match('/^([a-z0-9_]{1,})(->|::|\\/)?([a-z0-9_]{1,})?$/i', $children, $match)) { $controller = $match[1]; $action = isset($match[3]) && $match[3] ? $match[3] : 'index'; } if ($controller && $action) { $class = $this->formatControllerName($controller); $action = $this->formatActionName($action); if (!class_exists($class, false)) { JO_Loader::loadClass($class); } /** * @var $child JO_Action */ $child = new $class(); $child->initView(); call_user_func(array($child, $action), $param); $result = $child->getView(); return $result; } return null; }
public function uninstallAction() { $request = $this->getRequest(); $extensions = array(); $files = glob(dirname(__FILE__) . '/Extensions/*.php'); if ($files) { foreach ($files as $file) { if (preg_match('/^([\\w]{1,})Controller$/i', basename($file, '.php'), $match)) { $extensions[] = mb_strtolower($match[1], 'utf-8'); } } } $extension = $request->getQuery('extension'); if (in_array($extension, $extensions)) { $res = Model_Extensions::uninstall($extension); if ($res) { $module_name = JO_Front::getInstance()->formatModuleName('model_extensions_' . $extension); $file_model = APPLICATION_PATH . '/modules/' . $request->getModule() . '/' . JO_Front::getInstance()->classToFilename($module_name); if (file_exists($file_model)) { if (!class_exists($module_name, false)) { JO_Loader::loadFile($file_model); } if (method_exists($module_name, 'uninstall')) { call_user_func(array($module_name, 'uninstall')); } } else { $module_name = JO_Front::getInstance()->formatControllerName('extensions_' . $extension); $file_model = APPLICATION_PATH . '/modules/' . $request->getModule() . '/controllers/' . JO_Front::getInstance()->classToFilename($module_name); if (file_exists($file_model)) { if (!class_exists($module_name, false)) { JO_Loader::loadFile($file_model); } if (method_exists($module_name, 'uninstall')) { call_user_func(array($module_name, 'uninstall')); } } } $this->session->set('successfu_edite', true); } } $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/extensions/'); }
/** * Fetches a new blank row (not from the database). * * @param array $data OPTIONAL data to populate in the new row. * @param string $defaultSource OPTIONAL flag to force default values into new row * @return JO_Db_Table_Row_Abstract */ public function createRow(array $data = array(), $defaultSource = null) { $cols = $this->_getCols(); $defaults = array_combine($cols, array_fill(0, count($cols), null)); // nothing provided at call-time, take the class value if ($defaultSource == null) { $defaultSource = $this->_defaultSource; } if (!in_array($defaultSource, array(self::DEFAULT_CLASS, self::DEFAULT_DB, self::DEFAULT_NONE))) { $defaultSource = self::DEFAULT_NONE; } if ($defaultSource == self::DEFAULT_DB) { foreach ($this->_metadata as $metadataName => $metadata) { if ($metadata['DEFAULT'] != null && ($metadata['NULLABLE'] !== true || $metadata['NULLABLE'] === true && isset($this->_defaultValues[$metadataName]) && $this->_defaultValues[$metadataName] === true) && !(isset($this->_defaultValues[$metadataName]) && $this->_defaultValues[$metadataName] === false)) { $defaults[$metadataName] = $metadata['DEFAULT']; } } } elseif ($defaultSource == self::DEFAULT_CLASS && $this->_defaultValues) { foreach ($this->_defaultValues as $defaultName => $defaultValue) { if (array_key_exists($defaultName, $defaults)) { $defaults[$defaultName] = $defaultValue; } } } $config = array('table' => $this, 'data' => $defaults, 'readOnly' => false, 'stored' => false); $rowClass = $this->getRowClass(); if (!class_exists($rowClass)) { require_once 'JO/Loader.php'; JO_Loader::loadClass($rowClass); } $row = new $rowClass($config); $row->setFromArray($data); return $row; }
/** * Returns an SQL statement for preparation. * * @param string $sql The SQL statement with placeholders. * @return JO_Db_Statement_Oracle */ public function prepare($sql) { $this->_connect(); $stmtClass = $this->_defaultStmtClass; if (!class_exists($stmtClass)) { require_once 'JO/Loader.php'; JO_Loader::loadClass($stmtClass); } $stmt = new $stmtClass($this, $sql); if ($stmt instanceof JO_Db_Statement_Oracle) { $stmt->setLobAsString($this->getLobAsString()); } $stmt->setFetchMode($this->_fetchMode); return $stmt; }
/** * Prepare a statement and return a PDOStatement-like object. * * @param string $sql SQL query * @return JO_Db_Statement_Mysqli */ public function prepare($sql) { $this->_connect(); if ($this->_stmt) { $this->_stmt->close(); } $stmtClass = $this->_defaultStmtClass; if (!class_exists($stmtClass)) { require_once 'JO/Loader.php'; JO_Loader::loadClass($stmtClass); } $stmt = new $stmtClass($this, $sql); if ($stmt === false) { return false; } $stmt->setFetchMode($this->_fetchMode); $this->_stmt = $stmt; return $stmt; }
public function callChildren($children, $param = '') { $controller = $action = ''; if (is_array($children)) { $controller = $children[0]; $action = isset($children[1]) ? $children[1] : 'index'; } elseif (preg_match('/^([a-z0-9_]{1,})(->|::|\\/)?([a-z0-9_]{1,})?$/i', $children, $match)) { $controller = $match[1]; $action = isset($match[3]) && $match[3] ? $match[3] : 'index'; } if ($controller && $action) { $class = $this->formatControllerName($controller); if (!class_exists($class, false)) { JO_Loader::loadClass($class); } /* @var $child JO_Action */ $child = new $class(); $child->isChildren(true); $result = $child->dispatch($controller, $action, $param); if (JO_Registry::forceGet('viewSetCallbackChildren')) { $result = call_user_func(JO_Registry::forceGet('viewSetCallbackChildren'), $controller, $action, $result); } return $result; } return null; }