Example #1
0
 public function home()
 {
     $title = MObject::get('preference', 'website_title');
     if (strlen($title->get_value()) > 0) {
         $this->set_page_title($title->get_value());
     }
 }
Example #2
0
 /**
  * 
  *
  * @return MView
  */
 public function __construct()
 {
     parent::__construct();
     $this->subviews = new MMutableArray();
     $this->superview = null;
     $this->contentType = S("text/plain");
 }
 /**
  * 
  * @return MApplicationNode
  */
 public function __construct(MString $name = null)
 {
     parent::__construct();
     $this->name = $name ? $name : S("");
     $this->parentNode = null;
     $this->childNodes = new MMutableArray();
 }
 /**
  * Constructs a new MPersistentStoreRequest instance. This method should be called
  * by all subclasses of MPersistentStoreRequest
  *
  * @see MPersistentStoreRequest::FetchRequestType
  * @see MPersistentStoreRequest::SaveRequestType
  * @see MPersistentStoreRequest::FaultRequestType
  *
  * @param int $requestType A constant defining the type of the request, possible
  * values are:
  * MPersistentStoreRequest::FetchRequestType
  * MPersistentStoreRequest::SaveRequestType
  * MPersistentStoreRequest::FaultRequestType
  *
  * @param MManagedObjectContext $context The context in which this Persistent Store
  * Request will be performed
  *
  * @return MPersistentStoreRequest The newly created instance of MPersistentStoreRequest
  */
 public function __construct($requestType, MManagedObjectContext $context)
 {
     MAssertTypes('int', $requestType);
     parent::__construct();
     $this->requestType = $requestType;
     $this->context = $context;
 }
 /**
  * Creates a new Persistent Store Coordinator instance
  *
  * @param MManagedObjectMode $mode The model to use for across the
  * different Persistent Stores
  *
  * @return MPersistentStoreCoordinator
  */
 public function __construct(MManagedObjectModel $model)
 {
     parent::__construct();
     $this->model = $model;
     $this->persistentStores = new MMutableSet();
     $this->managedObjectContext = null;
 }
Example #6
0
 public function category()
 {
     $this->category = MObject::get('category', $this->get_object());
     if ($this->category && $this->category->get_id()) {
         $this->set_page_title($this->category->get_title());
         $contents = $this->category->get_contents();
         //getting language
         $language = new M_Language();
         $lang = $language->getLanguage();
         $filtered_contents = array();
         foreach ($contents as $content) {
             if ($lang == $content->get_language()) {
                 $mod = $content->modified();
                 $time = strtotime($mod['when']);
                 $filtered_contents[$time] = $content;
             }
         }
         ksort($filtered_contents);
         $descending = array_reverse($filtered_contents);
         $this->view('default', array($descending, $this->category->get_title()));
     } else {
         header('Location: index.php?module=page404');
         exit(0);
     }
 }
 /**
  * Creates a new MApplicationControllerAcceptedMethod instance with the specified
  * method.
  *
  * @param MString $method A string containing the HTTP method this accepted method
  * represents
  *
  * @return MApplicationControllerAcceptedMethod The newly created acceted method
  * instance
  */
 public function __construct(MString $method)
 {
     parent::__construct();
     $this->method = $method;
     $this->contentTypes = new MMutableArray();
     $this->fields = new MMutableArray();
 }
Example #8
0
 public function __construct($options = array())
 {
     parent::__construct();
     if (array_key_exists('lineend', $options)) {
         $this->setLineEnd($options['lineend']);
     }
     if (array_key_exists('charset', $options)) {
         $this->setCharset($options['charset']);
     }
     if (array_key_exists('language', $options)) {
         $this->setLanguage($options['language']);
     }
     if (array_key_exists('direction', $options)) {
         $this->setDirection($options['direction']);
     }
     if (array_key_exists('tab', $options)) {
         $this->setTab($options['tab']);
     }
     if (array_key_exists('link', $options)) {
         $this->setLink($options['link']);
     }
     if (array_key_exists('base', $options)) {
         $this->setBase($options['base']);
     }
 }
Example #9
0
 /**
  * 
  *
  * @return MRange
  */
 public function __construct($location, $length)
 {
     MAssertTypes('int', $location, 'int', $length);
     parent::__construct();
     $this->location = $location;
     $this->length = $length;
 }
Example #10
0
function mwidget_content($id)
{
    $content = MObject::get('content', $id);
    $title_addon = $content->get_meta('title-addon');
    if ($content) {
        ?>
					<h2 class="featurette-heading"><?php 
        MPut::_html($content->get_title());
        ?>
							<?php 
        if ($title_addon) {
            ?>
 
								<br />
								<span class="text-muted"><?php 
            ' ' . MPut::_html($title_addon->get_value());
            ?>
</span>
							<?php 
        }
        ?>
					</h2>
					<p class="lead"><?php 
        MPut::_text($content->get_text());
        ?>
</p>
				<?php 
    }
}
 /**
  * Initializes a new instance of an MEntityDescriptionAttribute class
  *
  * @param MEntityDescription $entity The entity that this attribute belongs to
  * @param MString $name The attribute name
  *
  * @return MEntityDescriptionAttribute A new instance of the MEntityDescriptionAttribute class
  */
 public function __construct(MEntityDescription $entity, MString $name)
 {
     parent::__construct();
     $this->entity = $entity;
     $this->name = $name;
     $this->entity->addAttribute($this);
 }
Example #12
0
 static function get_profile()
 {
     $profile = MObject::get('user', MAuth::user_id());
     if ($profile->get_id()) {
         return $profile;
     }
     return null;
 }
 /**
  * Constructs a new Model by loading data from a model file
  *
  * @param MFile $file The file containing information about this model to be loaded
  * @param MString $version A String used to identify a specific version of the model
  * to use, if null is specified, the default version specified inside the model file
  * is used
  *
  * @return MManagedObjectModel The loaded Model instance
  */
 public function __construct(MFile $modelFile, MString $version = null)
 {
     parent::__construct();
     $this->modelFile = $modelFile;
     $this->version = $version;
     $this->entities = new MMutableArray();
     $this->parse();
 }
 /**
  * This method should be overriden by subclasses of this class to perform
  * extra initialization as necessary
  *
  * This method initializes a new instance of a subclass of MApplicationControllerAttribute
  * with the specified name, type and required parameters
  *
  * @param MString $name The name of this attribute
  * @param int $type A constant representing the type of this attribute
  * Possible values are:
  * 	StringType
  *  IntegerType
  *  FloatType
  *  BooleanType
  *  DateType
  *  BinaryType
  *  ArrayType
  *  DictionaryType
  * @param bool $required Wether or not this attribute is required
  */
 public function __construct(MString $name, $type, $required = true)
 {
     MAssertTypes('int', $type, 'bool', $required);
     parent::__construct();
     $this->name = $name;
     $this->type = $type;
     $this->required = $required;
 }
 static function facebook_login_link()
 {
     $appid = MObject::get('preference', 'facebook_app_id');
     $secret = MObject::get('preference', 'facebook_secret');
     $scope = array('scope' => 'user_events');
     $facebook = new Facebook(array('appId' => $appid->get_value(), 'secret' => $secret->get_value(), 'allowSignedRequest' => false));
     return $facebook->getLoginUrl($scope);
 }
Example #16
0
 /**
  * 
  *
  * @return MData
  */
 public function __construct($bytes)
 {
     MAssertTypes('string', $bytes);
     parent::__construct();
     if (!is_string($bytes)) {
         throw new MInvalidDataTypeException(S("string"), S(gettype($bytes)));
     }
     $this->bytes = $bytes;
 }
Example #17
0
 /**
  * Creates a new instance of the class specified using the specified parameters
  *
  * @example $mString = MObject::newInstanceOfClass(S("mango.system.MString"), A("my string"));
  * // $mString is a new instance of MString with the value of S("my string")
  *
  * @param MString $className The fully qualified class name you wish to create an intance of
  * @param MArray $params The list of arguments to pass to the class' constructor
  *
  * @return MObject|mixed A new instance of the class specified by $className initialized with the
  * parameters specified by $params
  */
 public static function newInstanceOfClassWithParameters(MString $className, MArray $params = null)
 {
     $reflectionClass = MObject::reflectionClass($className);
     if ($params != null) {
         return $reflectionClass->newInstanceArgs($params->toArray());
     } else {
         return $reflectionClass->newInstance();
     }
 }
Example #18
0
 static function remove_menu($page_id)
 {
     $id = MGet::int('menu_id');
     $menu = MObject::get('menu', $id);
     if ($menu) {
         $menu->remove_page($page_id);
         $menu->update(false);
     }
 }
Example #19
0
function mwidget_dropdownmenu($menu_item)
{
    $menu_item = strtolower($menu_item);
    switch ($menu_item) {
        case "associarsi":
            $menu_id = 5;
            break;
        case "chi siamo":
            $menu_id = 6;
            break;
        case "eventi":
            $menu_id = 7;
            break;
        case "attivita'":
            $menu_id = 8;
            break;
        default:
            $menu_id = null;
            break;
    }
    $menu = MObject::get('menu', $menu_id);
    if ($menu) {
        $pages = $menu->get_pages();
        ?>
				<ul style="margin:0;">
				<?php 
        if (sizeof($pages) > 0) {
            foreach ($pages as $page) {
                ?>
										<div style="position: relative; margin:6px; text-align:left;">
												<li style="white-space:nowrap;">
												<a href="<?php 
                MPut::_link($page->get_url());
                ?>
" title="<?php 
                MPut::_html_attr($page->get_title());
                ?>
" style="margin: 6px 0; font-size: 13px;">
														<?php 
                //MPut::_html( $page->get_title() );
                ?>
														<?php 
                __($page->get_title());
                ?>
												</a>
												</li>
										</div>
								<?php 
            }
        }
        ?>
				</ul>
				<?php 
    }
}
Example #20
0
 static function add_category()
 {
     $category = MObject::create('category');
     $category->set_title(MGet::string('category_title'));
     $category->add();
     if (0 == MMessaging::any_errors() + MMessaging::any_warnings()) {
         return $category;
     } else {
         return false;
     }
 }
Example #21
0
function mwidget_dividedmenu($menu_id, $class = null, $id = null)
{
    $menu = MObject::get('menu', $menu_id);
    if ($class) {
        $class = ' class="' . MPut::html_attr($class) . '"';
    } else {
        $class = '';
    }
    if ($id) {
        $id = ' id="' . MPut::html_attr($id) . '"';
    } else {
        $id = '';
    }
    if ($menu) {
        $pages = $menu->get_pages();
        if (sizeof($pages) > 0) {
            foreach ($pages as $page) {
                ?>
										<div<?php 
                echo $class . $id;
                ?>
 style="position: relative;">
												<a href="<?php 
                MPut::_link($page->get_url());
                ?>
" title="<?php 
                MPut::_html_attr($page->get_title());
                ?>
">
														<?php 
                //MPut::_html( $page->get_title() );
                ?>
														<?php 
                __($page->get_title());
                ?>
												</a>
											<div style="display:none;background-color:#000;min-width:100%;position:absolute; left: 0px; top: 20px;text-align: center;z-index: 9999;" >
												<?php 
                M_Template::widget('dropdownmenu', $page->get_title());
                ?>
											</div>
										</div>
										<div class="visible-xs col-xs-3"></div>
										<div class="visible-xs col-xs-6">
											<?php 
                M_Template::widget('dropdownmenu', $page->get_title());
                ?>
										</div>
										<div class="visible-xs col-xs-3"></div>
								<?php 
            }
        }
    }
}
Example #22
0
 public function modified()
 {
     $modified = array('when' => $this->modified, 'by' => $this->modifiedby);
     $user = MObject::get('user', $this->modifiedby);
     if ($user && $user->get_username()) {
         $modified['by_user'] = $user->get_username();
     } else {
         $modified['by_user'] = '******';
     }
     return $modified;
 }
Example #23
0
 static function add_menu()
 {
     $menu = MObject::create('menu');
     $menu->set_title(MGet::string('menu_title'));
     $menu->add();
     if (0 == MMessaging::any_errors() + MMessaging::any_warnings()) {
         return $menu;
     } else {
         return false;
     }
 }
Example #24
0
 private function route($env)
 {
     $request = mapi_request();
     switch ($env) {
         case 'manager':
             if (isset($request['module'])) {
                 $this->set_module(MGet::string('module'));
             }
             if (isset($request['task'])) {
                 $this->set_task(MGet::string('task'));
             }
             if (isset($request['object'])) {
                 $this->set_num_object_id(MGet::string('object'));
             }
             break;
         case 'frontend':
             $routing = 'default';
             $pref = MObject::get('preference', 'routing');
             if ($pref && is_object($pref) && 'sef' == $pref->get_value()) {
                 $routing = 'sef';
             }
             // sef routing here
             if (isset($request['module'])) {
                 $this->set_module(MGet::string('module'));
             }
             if (isset($request['task'])) {
                 $this->set_task(MGet::string('task'));
             }
             if (isset($request['object'])) {
                 $this->set_num_object_id(MGet::string('object'));
             }
             break;
     }
     MAuth::init();
     if ('manager' == $env) {
         if ('register' != $this->module) {
             if ('login' != $this->module && !MAuth::is_auth()) {
                 $this->reset_to('login');
             } elseif ('login' == $this->module && MAuth::is_auth() && !isset($_POST['do-logout'])) {
                 $this->reset_to('dashboard');
             }
         } else {
             if (MAuth::is_auth()) {
                 $this->reset_to('dashboard');
             }
         }
         if ('login' != $this->module && 'register' != $this->module) {
             //if ( ! MAuth::check_perm( self::$this->module, $this->task ) ) $this->reset_to( 'denied' );
         }
     }
 }
Example #25
0
 public function content()
 {
     $task = $this->get_task();
     if (!$task) {
         //getting language
         $language = new M_Language();
         $lang = $language->getLanguage();
         $this->content = MObject::get('content', $this->get_object());
         //print_r($this->content); die();
         if ($lang == $this->content->get_language()) {
             //var_dump($lang); die();//megfelel a nyelv, kiolvassuk.
             $this->content = MObject::get('content', $this->get_object());
         } else {
             //nem felel meg, megnezzuk van-e olyan nyelvu forditasa
             $this->content_id = $this->model('get_translation', array("content" => $this->get_object(), "lang" => strval($lang)));
             $this->content = MObject::get('content', intval($this->content_id));
         }
         if ($this->content) {
             global $content;
             $content = $this->content;
             if ($this->content->is_enabled() == FALSE) {
                 header('Location: index.php?module=page404');
                 exit(0);
             }
             global $coords;
             $coords['lat'] = $this->content->get_lat();
             $coords['lng'] = $this->content->get_lng();
             $this->set_page_title($this->content->get_title());
             $content_meta = $content->get_meta();
             if (sizeof($content_meta) > 0) {
                 foreach ($content_meta as $meta) {
                     switch ($meta->name) {
                         case 'description':
                         case 'keywords':
                         case 'author':
                         case 'robots':
                             $this->add_page_meta($meta->name, $meta->value);
                             break;
                     }
                 }
             }
             $this->model('add_hit', $content->get_id());
             $this->view('default', $content);
         } else {
             header('Location: index.php?module=page404');
             exit(0);
         }
     }
 }
Example #26
0
 public function register()
 {
     $reg_allowed = MObject::get('preference', 'registration');
     if ('yes' == $reg_allowed->get_value()) {
         if (isset($_POST['do-register']) && mapi_csrf_check(MGet::string('mapi_csrf'))) {
             $this->model('register');
         }
         if (isset($_GET['activate']) && 1 == $_GET['activate']) {
             $this->model('activate');
         }
         $this->view();
     } else {
         header('Location: ../index.php');
         exit(0);
     }
 }
 /**
  * 
  *
  * @return MViewController
  */
 public function __construct(MView $view = null)
 {
     parent::__construct();
     $this->view = $view;
     $this->applicationController = null;
     $this->responseCode = MHTTPResponse::RESPONSE_OK;
     $this->responseHeaders = new MMutableDictionary();
     $this->restricted = false;
     $this->realm = S("Restricted Area");
     $this->accessDeniedView = null;
     $this->invalidCredentialsView = null;
     $this->authenticatedUserName = null;
     $this->parameterValues = null;
     $this->fieldValues = null;
     $this->parentViewController = null;
     $this->childViewControllers = new MMutableArray();
 }
Example #28
0
 static function add_user()
 {
     $user = MObject::create('user');
     $user->set_group_id(MGet::int('user_group_id'));
     $user->set_username(MGet::string('user_username'));
     $user->set_email(MGet::string('user_email'));
     $user->set_name(MGet::string('user_name'));
     if (MGet::string('user_pass') != MGet::string('user_pass_repeat')) {
         return mapi_report_message('Passwords do not match');
     }
     $user->add(MGet::string('user_pass'));
     if (0 == MMessaging::any_errors() + MMessaging::any_warnings()) {
         return $user;
     } else {
         return false;
     }
 }
Example #29
0
 /**
  * 
  *
  * @return MDictionary
  */
 public function __construct($dictionary = array())
 {
     parent::__construct();
     $this->keys = new MMutableArray(A(array_keys($dictionary)));
     $this->values = new MMutableArray(A(array_values($dictionary)));
     $args = func_get_args();
     if (N(count($args))->isEven()) {
         for ($i = 0; $i < count($args); $i++) {
             $key = $args[$i];
             $object = $args[++$i];
             $this->keys->addObject($key);
             $this->values->addObject($object);
         }
     } else {
         throw new MException(S("Uneven number of keys and objects specified"));
     }
 }
Example #30
0
function mwidget_bottommenu($menu_id, $class = null, $id = null)
{
    $menu = MObject::get('menu', $menu_id);
    if ($class) {
        $class = ' class="' . MPut::html_attr($class) . '"';
    } else {
        $class = '';
    }
    if ($id) {
        $id = ' id="' . MPut::html_attr($id) . '"';
    } else {
        $id = '';
    }
    if ($menu) {
        $pages = $menu->get_pages();
        $size = sizeof($pages);
        if ($size > 0) {
            $i = 0;
            foreach ($pages as $page) {
                $i++;
                ?>
										<a href="<?php 
                MPut::_link($page->get_url());
                ?>
" title="<?php 
                MPut::_html_attr($page->get_title());
                ?>
">
												<?php 
                //MPut::_html( $page->get_title() );
                ?>
												<?php 
                __($page->get_title());
                ?>
										</a>
										<?php 
                if ($i != $size) {
                    echo '&nbsp;|&nbsp;';
                }
                ?>
								<?php 
            }
        }
    }
}