Example #1
0
 public function testMultisumWithIndexedArrays()
 {
     $arr1 = array(1, 2, 0, 4);
     $arr2 = array(3, 1, 3);
     $result = array(4, 3, 3, 4);
     $this->assertEqual(MArray::multisum($arr1, $arr2), $result);
 }
 /**
  * 
  *
  * @return MMutableArray
  */
 public function __construct(MArray $array = null)
 {
     if (!is_null($array)) {
         parent::__construct($array->array);
     } else {
         parent::__construct();
     }
 }
Example #3
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 #4
0
 protected function generateOptions()
 {
     $AuthOptions = PEAR::getStaticProperty('m_office', 'options');
     $userOpt = $AuthOptions['auth'];
     $opt = array('all' => PEAR::getStaticProperty('Module', 'global'));
     $options = array('caching' => MODE == 'developpement' ? false : true, 'cacheDir' => $opt['all']['cacheDir'] . '/config/' . ($userOpt ? User::getInstance('office')->getId() . '/' : ''), 'lifeTime' => null, 'fileNameProtection' => false, 'automaticSerialization' => true);
     $optcache = new Cache_Lite($options);
     if (!($moduleopt = $optcache->get($this->_modulename))) {
         if (@(include_once $this->_path . $this->_modulename . '.conf.php')) {
             if (!is_array($config)) {
                 $config = array();
             }
             $moduleopt = MArray::array_merge_recursive_unique($opt, $config);
         } else {
             $moduleopt = $opt;
         }
         $useropt = Mreg::get('authHelper')->getPrivilegesForModule(User::getInstance('office'), $this->_modulename);
         $moduleopt = MArray::array_merge_recursive_unique($moduleopt, $useropt);
         $optcache->save($moduleopt);
     }
     return $moduleopt;
 }
 /**
  *
  *
  * @return MViewController
  */
 public function viewControllerForPath(MArray $path)
 {
     $viewController = null;
     $name = S("");
     if ($path->count() > 0) {
         $name = $path->objectAtIndex(0);
     }
     $subpath = new MArray();
     if ($path->count() > 1) {
         $subpath = $path->subarrayFromIndex(1);
     }
     $node = $this->childNodeWithName($name);
     if ($node) {
         $viewController = $node->viewControllerForPath($subpath);
     }
     if ($viewController) {
         return $viewController;
     } else {
         return parent::viewControllerForPath($path);
     }
 }
Example #6
0
File: T.php Project: demental/m
 public function getStringsFromYML($file, &$lngtb)
 {
     $yaml = Spyc::YAMLLoad($file);
     $result = MArray::flatten_keys($yaml[$this->locale]);
     if (is_array($result)) {
         $lngtb = array_merge($lngtb, $result);
     }
 }
 /**
  * @internal
  *
  * @return MString
  */
 protected function createTableQuery(MString $tableName, MArray $fields, MString $primaryKey = null)
 {
     $tableQuery = new MMutableString();
     $tableQuery->appendLine(Sf("CREATE TABLE `%s` (", $tableName));
     $tableQuery->appendString($fields->componentsJoinedByString(S(",\n")));
     if (!empty($primaryKey)) {
         $tableQuery->appendFormat(",\nPRIMARY KEY (`%s`)", $primaryKey);
     }
     $tableQuery->appendLine(S("\n);"));
     $tableQuery->appendLine(S(""));
     return $tableQuery;
 }
Example #8
0
 /**
  *
  * description
  *
  * @return unknown_type
  */
 protected function generateOptions($opt, $group = NULL)
 {
     $opt = array('all' => $opt);
     $options = array('caching' => MODE == 'developpement' ? false : true, 'cacheDir' => $opt['all']['cacheDir'] . '/config/', 'lifeTime' => 72000, 'fileNameProtection' => false, 'automaticSerialization' => true);
     Log::info('preparing options');
     $optcache = new Cache_Lite($options);
     if (empty($group)) {
         $group = 'default';
     }
     if (!($moduleopt = $optcache->get(get_class($this), $group))) {
         Log::info('no cache for options, live generating');
         foreach ($this->_path as $path) {
             if (@(include $path . '/' . $this->_modulename . '.conf.php')) {
                 Log::info('loading module config file');
                 if (!is_array($config)) {
                     $config = array();
                 }
                 $moduleopt = MArray::array_merge_recursive_unique($opt, $config);
                 break;
             } else {
                 $moduleopt = $opt;
             }
             Log::info('no cache for options, live generating');
         }
         if (MODE != 'developpement') {
             $ret = $optcache->save($moduleopt);
             Log::info('group = ' . $group);
             if ($ret) {
                 Log::info('options saved');
             }
         }
     }
     Log::info('options prepared');
     return $moduleopt;
 }
Example #9
0
 /**
  * 
  *
  * @return MSet
  */
 public function __construct(MArray $array = null)
 {
     parent::__construct();
     $this->set = $array ? $array->toArray() : array();
 }