Пример #1
0
function register_menu_courses()
{
    $ED =& instance();
    $ED->load_class(array('class' => 'courses', 'name' => 'courses'));
    add_menu_page('Cursos', 'Cursos', 'manage_options', 'edupress-courses', array('ED_Courses', 'courses'), plugins_url('\\edupress/admin/images/icons.png'), 27);
    add_submenu_page('edupress-courses', 'Meus cursos', 'Meus cursos', 'manage_options', 'edupress-courses');
    add_submenu_page('edupress-courses', 'Adicionar novo curso', 'Adicionar novo curso', 'manage_options', 'edupress-courses-new', array('ED_Courses', 'new_course'), 'new_course');
}
Пример #2
0
 protected function _getInfoModel()
 {
     $infoModel = new Model_Info();
     if ($infoModel->isMultilingual()) {
         $infoModel = instance(new Garp_I18n_ModelFactory())->getModel('Info');
     }
     return $infoModel;
 }
Пример #3
0
function check_session()
{
    // jika session habis, redirect ke logout
    $username = instance()->session->userdata("username");
    if (empty($username)) {
        redirect("login/logout", "refresh");
    }
    return true;
}
Пример #4
0
 public function results($table = NULL, $orderby = NULL, $order = NULL, $limit = 100, $offset = 0)
 {
     $ED =& instance();
     $ED->load_class('options');
     $orderby = $_GET['orderby'] ? $_GET['orderby'] : $orderby;
     $order = $_GET['order'] ? strtoupper($_GET['order']) : strtoupper($order);
     $offset = $_GET['paged'] ? $_GET['paged'] * $limit - $limit : $offset;
     return $this->db->get_results("SELECT * FROM " . $table . " ORDER BY " . $orderby . " " . $order . " LIMIT " . $limit . " OFFSET " . $offset);
 }
Пример #5
0
 public function paged($paged_args = array())
 {
     $ED =& instance();
     $num_pages = 15;
     $num_results = 1;
     $num_results_per_page = 10;
     $num_results_this_page = 1;
     $paged = $_GET['paged'] == 0 || $_GET['paged'] == NULL ? 1 : $_GET['paged'];
     $paged = $paged > $num_pages ? $num_pages : $paged;
     foreach ($paged_args as $k => $v) {
         eval("\$" . $k . " = \"" . $v . "\";");
     }
     $return = '<form id="paged-filter" method="get">';
     foreach ($_GET as $key => $value) {
         $return .= '<input name="' . $key . '" value="' . $value . '" type="hidden">';
     }
     $return .= '<div class="tablenav bottom">';
     $return .= '<div class="tablenav-pages">';
     $return .= '<span class="displaying-num">' . $num_results_this_page . ' itens</span>';
     $return .= '<span class="pagination-links">';
     $disabled = $paged == 1 ? ' disabled' : '';
     $return .= '<a class="first-page' . $disabled . '" title="Ir para a primeira página" href="' . get_url() . 'paged=1">«</a>';
     $prev = $paged - 1;
     $prev = $prev < 1 ? 1 : $prev;
     $disabled = $paged == 1 ? ' disabled' : '';
     $return .= '<a class="prev-page' . $disabled . '" title="Ir para a página anterior" href="' . get_url() . 'paged=' . $prev . '">‹</a>';
     $return .= '<span class="paging-input">';
     $return .= '<label for="current-page-selector" class="screen-reader-text">Selecionar Página</label>';
     $return .= '<input class="current-page" id="current-page-selector" title="Página atual" name="paged" value="' . $paged . '" size="1" type="text"> de ';
     $return .= '<span class="total-pages">' . $num_pages . '</span>';
     $return .= '</span>';
     $next = $paged + 1;
     $next = $next < $num_pages ? $next : $num_pages;
     $disabled = $paged == $num_pages ? ' disabled' : '';
     $return .= '<a class="next-page' . $disabled . '" title="Ir para a próxima página" href="' . get_url() . 'paged=' . $next . '">›</a>';
     $last = $num_pages;
     $disabled = $paged >= $last ? ' disabled' : '';
     $return .= '<a class="last-page' . $disabled . '" title="Ir para a última página" href="' . get_url() . 'paged=' . $last . '">»</a>';
     $return .= '</span>';
     $return .= '</div>';
     $return .= '<input name="mode" value="list" type="hidden">';
     $return .= '<div class="view-switch">';
     $_GET['mode'] = $_GET['mode'] == NULL ? 'list' : $_GET['mode'];
     $list_current = $_GET['mode'] == 'list' ? ' current' : '';
     $excerpt_current = $_GET['mode'] == 'excerpt' ? ' current' : '';
     $return .= '<a href="' . get_url() . 'mode=list" class="view-list' . $list_current . '" id="view-switch-list"><span class="screen-reader-text">Visualização em lista</span></a>';
     $return .= '<a href="' . get_url() . 'mode=excerpt" class="view-excerpt' . $excerpt_current . '" id="view-switch-excerpt"><span class="screen-reader-text">Visualização do resumo</span></a>';
     $return .= '</div>';
     $return .= '<br class="clear">';
     $return .= '</div>';
     $return .= '</form>';
     echo $return;
 }
Пример #6
0
 /**
  * Admin globals
  *
  * @since eduPress
  * @access private
  */
 private function setup_globals()
 {
     $ED = instance();
     $this->admin_dir = trailingslashit($edp->admin_dir);
     // Admin path
     $this->admin_url = trailingslashit($edp->admin_url);
     // Admin url
     $this->images_url = trailingslashit($this->admin_url . 'images');
     // Admin images URL
     $this->styles_url = trailingslashit($this->admin_url . 'styles');
     // Admin styles URL
     $this->css_url = trailingslashit($this->admin_url . 'css');
     // Admin css URL
     $this->js_url = trailingslashit($this->admin_url . 'js');
     // Admin js URL
 }
Пример #7
0
 public static function new_course()
 {
     $ED =& instance();
     $ED->load_class(array('class' => 'forms', 'name' => 'form'));
     $ED->form->header('Adicionar novo curso');
     $ED->form->open('post', array('class' => 'classe do form', 'id' => 'id-do-form'));
     $ED->form->hidden(array('casa' => 'janela'));
     $ED->form->text('Nome do curso:', 'name', NULL, 'id="coursename" class="regular-text" ');
     $ED->form->text(array('label' => 'Slug:', 'name' => 'slug', 'value' => 'curso-qgis-teste', 'class' => 'regular-text'));
     $ED->form->url('URL:', 'url', NULL, 'class="regular-text code" ');
     $ED->form->email('EMAIL:', 'url', NULL, 'class="regular-text ltr" ');
     $ED->form->password('Senha:', 'password', NULL);
     $ED->form->number('Tamanho:', 'number', NULL);
     $ED->form->textarea('Descrição:', 'textarea', NULL);
     $ED->form->checkbox('Aceitar:', 'textarea', NULL, NULL, NULL, 'Aceitar termos');
     $ED->form->radio('Selecione uma opção:', 'sleciona', array('opcao1' => 'Primeira opçaõ', 'opcao2' => 'Segunda opção'));
     $ED->form->select('Selecione uma segunda opção:', 'sleciona2', array('opcao1' => 'Primeira opçaõ', 'opcao2' => 'Segunda opção', 'opcao3' => 'Terceira opção'), 'opcao3');
     $ED->form->file('Arquivo:', 'file', NULL);
     $ED->form->close('submit', 'Enviar');
 }
Пример #8
0
function getInstance($name = null)
{
    // Only create the object if it doesn't exist.
    if (empty(self::$instance)) {
        if (class_exists($name) && is_subclass_of($name, 'JApplicationCli')) {
            self::$instance = new $name();
        } else {
            self::$instance = new JApplicationCli();
        }
    }
    return self::$instance;
}
Пример #9
0
 protected function _setCmsClosedMessage()
 {
     $config = Zend_Registry::get('config');
     if (!isset($config->cms->closed) || !$config->cms->closed) {
         return;
     }
     $this->view->isClosed = true;
     try {
         $snippetModel = new Model_Snippet();
         if ($snippetModel->isMultilingual()) {
             $snippetModel = instance(new Garp_I18n_ModelFactory())->getModel('Snippet');
         }
         $snippet = $snippetModel->fetchByIdentifier('cms closed message');
         $cmsClosedMessage = $snippet->html;
         if (isset($cmsClosedMessage[Garp_I18n::getCurrentLocale()])) {
             $cmsClosedMessage = $cmsClosedMessage[Garp_I18n::getCurrentLocale()];
         }
         $this->view->cmsClosedMessage = $cmsClosedMessage;
     } catch (Exception $e) {
         throw $e;
         $this->view->cmsClosedMessage = '<p>The CMS is closed.</p>';
     }
 }
Пример #10
0
 function __construct()
 {
     $this->err = instance();
 }
Пример #11
0
 /**
  * Save a new Zuora Object. If the Id is preset, update operation will happen.
  * @return  Object      A Zuora ZOQL query result
  */
 protected function save()
 {
     $this->setObjectProperties();
     if (!empty($this->Id)) {
         return instance()->update(array($this->object));
     }
     return instance()->create(array($this->object));
 }
Пример #12
0
 function tearDown()
 {
     // Removing the global loop object.
     instance(null);
 }
Пример #13
0
 public static function instance()
 {
     return instance(__CLASS__);
 }
Пример #14
0
 function __construct()
 {
     $this->obj = instance();
 }
Пример #15
0
 /**
  * Get related hasOne records and combine into a single response
  *
  * @param string $datatype
  * @param array $records
  * @param array $with
  * @return array The combined resultsets
  */
 protected function _combineRecords($datatype, array $records, $with)
 {
     $modelName = $this->_normalizeModelName($datatype);
     $rootModel = new $modelName();
     $schema = instance(new Garp_Content_Api_Rest_Schema('rest'))->getModelDetails($datatype);
     $hasOneRelations = array_filter($schema['fields'], propertyEquals('origin', 'relation'));
     $hasOneRelations = array_map(array_get('relationAlias'), $hasOneRelations);
     // Check validity of 'with'
     $unknowns = array_filter($with, callRight(not('in_array'), $hasOneRelations));
     if (count($unknowns)) {
         $err = sprintf(Garp_Content_Api_Rest_Schema::EXCEPTION_RELATION_NOT_FOUND, $datatype, current($unknowns));
         throw new Garp_Content_Api_Rest_Exception($err);
     }
     $self = $this;
     return array_reduce($with, function ($acc, $cur) use($rootModel, $records, $schema, $self) {
         // grab foreign key names from the relation
         $foreignKey = current(array_filter($schema['fields'], propertyEquals('relationAlias', $cur)));
         // Grab foreign key values
         $foreignKeyValues = array_map(array_get($foreignKey['name']), $records);
         // No values to filter on? Bail.
         if (!count(array_filter($foreignKeyValues))) {
             $acc[$cur] = array();
             return $acc;
         }
         $foreignKeyValues = array_values(array_unique($foreignKeyValues));
         // Construct options object for manager
         $options = array('options' => array('query' => array('id' => $foreignKeyValues)), 'datatype' => $foreignKey['model']);
         // fetch with options
         $acc[$cur] = array_get(current($self->_getIndex($options)), 'result');
         return $acc;
     }, array($datatype => $records));
 }
Пример #16
0
 protected function _scaleSync($filename, $id, $template)
 {
     return instance(new Garp_Image_Scaler())->scaleAndStore($filename, $id, $template, true);
 }
Пример #17
0
        }
    }
    /**
     * The main function responsible for returning the one true eduPress Instance
     * to functions everywhere.
     *
     * Use this function like you would a global variable, except without needing
     * to declare the global.
     *
     * Example: <?php $edup = edupress(); ?>
     *
     * @return The one true eduPress Instance
     */
    function instance()
    {
        return edupress::instance();
    }
    /**
     * Hook eduPress early onto the 'plugins_loaded' action.
     *
     * This gives all other plugins the chance to load before eduPress, to get their
     * actions, filters, and overrides setup without eduPress being in the way.
     */
    if (defined('EDUPRESS_LATE_LOAD')) {
        add_action('plugins_loaded', 'edupress', (int) EDUPRESS_LATE_LOAD);
        // "And now here's something we hope you'll really like!"
    } else {
        instance();
    }
}
// class_exists check
Пример #18
0
 public function __construct()
 {
     self::$obj = instance();
 }
Пример #19
0
 public function testShouldRejectClaimedToken()
 {
     if (!$this->_testsEnabled) {
         return;
     }
     $pwless = new Garp_Auth_Adapter_Passwordless();
     $response = $pwless->requestToken(array('email' => self::TEST_EMAIL));
     // manually claim token
     instance(new Model_AuthPasswordless())->update(array('claimed' => 1), 'id > 0');
     $userId = instance(new Model_User())->fetchRow()->id;
     $token = instance(new Model_AuthPasswordless())->fetchRow()->token;
     $response = $pwless->acceptToken($token, $userId);
     $this->assertFalse($response);
     $this->assertEquals(array(__('passwordless token claimed')), $pwless->getErrors());
 }
Пример #20
0
 protected function _extractContentTypeBindOptions($chapterType, $model)
 {
     if (is_string($chapterType)) {
         return array('modelClass' => 'Model_' . $chapterType);
     }
     $out = array();
     if (isset($chapterType['i18n']) && $chapterType['i18n']) {
         if (!isset($chapterType['model'])) {
             throw new Exception('Required key "model" not found');
         }
         if (Zend_Registry::isRegistered('CMS') && Zend_Registry::get('CMS')) {
             return array('modelClass' => 'Model_' . $chapterType['model']);
         }
         $out['modelClass'] = instance(new Garp_I18n_ModelFactory())->getModel($chapterType['model']);
         // Make sure the localised relation exists in the referenceMap
         $localiser = new Garp_Model_ReferenceMapLocalizer($model);
         $localiser->populate('Model_' . $chapterType['model']);
     }
     return $out;
 }
Пример #21
0
 protected function _getSnippet($identifier)
 {
     $snippetModel = new Model_Snippet();
     if ($snippetModel->isMultilingual()) {
         $snippetModel = instance(new Garp_I18n_ModelFactory())->getModel('Snippet');
     }
     return $snippetModel->fetchByIdentifier($identifier)->text;
 }
Пример #22
0
/**
 * Stops a running eventloop
 *
 * @return void
 */
function stop()
{
    instance()->stop();
}